Prime Team

There are n players standing in a line. Each of the players is assigned a unique jersey number. You …

Click here to read the complete problem statement.


If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

def test(n):
for i in range(2,n):
if n%i==0:
return False
return True
x=int(input())
m=list(map(int,input().split()[:x]))
km=[]
mk=[]
for k in range(len(m)):
if test(m[k]) is True and m[k]!=1 and m[k]!=0:
km.append(m[k])
else:
mk.append(m[k])
if len(mk)==len(km):
print(len(km))
elif len(mk)>len(km):
print(len(km))

What is the problem in my code

#include
#include
using namespace std;
int arr[100000];
bool is_prime(int n)
{
if(n == 1)
return false;

for(int i=2;i<n;i++)
{
    if(n%i == 0)
        return false;


}
return true;

}
int main()
{
int primes = 0;
int len;
cin >> len;
for(int i=1;i<=len;i++)
{
cin >> arr[i];
if(is_prime(arr[i]) == true){
primes += 1;

   }

}

int left = len - primes;
if(primes > left)
{
while(primes!= left)
{
primes --;
}

}
else if(primes < left)
{
while(left != primes)
{
left --;

   }

}

cout << primes << endl;

return 0;

}

What is the problem with this code ?? WA at 3rd test case , please help me
@touhidurrr @hjr265 @mdvirus @bokaif , anyone bhaiya please have a look!

def isprime(n):
if n in [2,3,5,7]:return True
if n in [0,1] or n < 0: return False
for x in range(2,int(n**0.5)+1):
if n%x == 0: return False
return True
num = int(input())
everyone = map(int, input().split())
leaders = list(filter(isprime, everyone))
non_leaders_num = num - len(leaders)
print(min(non_leaders_num, len(leaders)))

Why does it says Wrong Answer at 3rd Case? Can anyone kindly tell about that?