Problem:
Prime Numbers A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. Write a program which reads a list of N integers and prints the number of prime numbers in the list. Input The first line contains an integer N , the number of elements in the list.  N numbers are given in the following lines. Output Print the number of prime numbers in the given list. Constraints 1 ≤ N ≤ 10000 2 ≤ an element of the list ≤ 10 8  Sample Input 1 5
2
3
4
5
6 Sample Output 1 3 Sample Input 2 11
7
8
9
10
11
12
13
14
15
16
17 Sample Output 2 4

Solution (Python):
def f(x):
    if x==2:
        return 1
    if x<2 or x%2==0:
        return 0
    i=3
    while i<=x**(1/2):
        if x%i==0:
            return 0
        i+=2
    return 1

n=int(input())
s=0
for i in range(n):
    x=int(input())
    s+=f(x)
print(s)

Solution (Python):
a=int(input())
b=[int(input()) for i in range(a)]

def isPrime(x):
    if x==2:
        return True
    if x<2 or x%2==0:
        return False
    i=3
    while i<=x**0.5:
        if x%i==0:
            return False
        i+=2
    return True
ans=0
for i in b:
    if isPrime(i):
        ans+=1
print(ans)

Solution (Python):
import sys

input = sys.stdin.readline


def is_prime_number(n):
    if n == 1:
        return False

    if n == 2:
        return True

    if n % 2 == 0:
        return False

    f = 3
    root_n = int(n ** 0.5) + 1
    while f <= root_n:
        if n % f == 0:
            return False
        f += 2

    return True


def main():
    n = int(input())
    ans = 0
    for _ in range(n):
        x = int(input())
        ans += is_prime_number(x)

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

import math
def prime(n):
    limit = math.sqrt(n)
    if n == 2: return 1
    if n < 2 or n % 2 == 0: return 0
    
    i = 3
    while i <= limit:
        if n % i == 0: return 0
        else:
            i += 2
    return 1
        
n = int(input())
res = 0
for _ in range(n):
    res += prime(int(input()))
print(res)

Solution (Python):
from collections import defaultdict

n = int(input())
A = [int(input()) for _ in range(n)]

prime_dict = defaultdict(lambda : True)
prime_dict[0],prime_dict[1] = False,False
finished = defaultdict(lambda : False)

ans = 0
for a in A:
    if not finished[a]:
        root_a = int(a**0.5)
        for i in range(2,root_a + 1):
            if a % i == 0:
                prime_dict[a] = False
                break
        finished[a] = True
    if prime_dict[a]:
        ans += 1

print(ans)

Solution (Python):
def get_primes(maxn):
    c = int(maxn**0.5)+1
    sieve = [True]*c
    sieve[0] = sieve[1] = False
    primes = []
    for p in range(2, c):
        if sieve[p]:
            primes.append(p)
            for i in range(2*p, c, p):
                sieve[i] = False
    return primes


def is_prime(n, primes):
    if n <= 1:
        return False
    c = int(n**0.5)+1
    for p in primes:
        if p > c:
            break
        if n != p and n % p == 0:
            return False
    return True


def solve():
    n, *A, = map(int, open(0).read().split())

    primes = get_primes(max(A))
    ans = 0
    for a in A:
        if is_prime(a, primes):
            ans += 1
    print(ans)


if __name__ == '__main__':
    solve()

Solution (Python):
import math
def p(x):
    if x==2:
        return True
    
    if x==1 or x%2==0:
        return False
    
    i=3
    while i <=math.sqrt(x):
        if x%i==0:
            return False
        i=i+2
    return True
    
c=0
n=int(input())
for i in range(n):
    x=int(input())
    if p(x)==True:
        c+=1
print(c)

Solution (Python):
import sys
input()
print(sum(2 in[x,pow(2,x,x)]for x in map(int,sys.stdin)))

Solution (Python):

from sys import stdin
import math

def is_prime_number(n):
  if n == 1:
    return False
  if n == 2:
    return True
  i = 2
  while i <= math.sqrt(n):
    if n % i == 0:
      return False
    i += 1
  else:
    return True

n = int(stdin.readline().rstrip())
cnt = 0

for i in range(n):
  v = int(stdin.readline().rstrip())
  if is_prime_number(v):
    cnt += 1
else:
  print(cnt)

Solution (Python):
n=int(input())
cnt=0
for i in range(n):
  x=int(input())
  s=0
  for j in range(2,(int(pow(x,0.5)//1)+1)): 
    if x%j==0:
      s=1
      break
  if s==0:
    cnt+=1
print(cnt)

Solution (Python):
from math import sqrt
n = int(input())
ans = 0
for i in range(n):
    x = int(input())
    ok = 1
    for z in range(2, int(sqrt(x))+1):
        if x % z == 0:
            ok = 0
            break;
    ans += ok
print(ans)

Solution (Python):
import random


def judge_miller(n, rep):
    if(n == 1):
        return False
    if(n == 2):
        return True
    if(n % 2 == 0):
        return False
    d = n - 1
    while(d & 1 == 0):
        d >>= 1
    for k in range(rep):
        cp_d = d
        a = random.randint(2, n - 1)
        may_prime = False
        x = pow(a, d, n)
        if(x == 1):
            may_prime = True
        while((not may_prime) and x != n - 1 and d != n - 1):
            if(x == n - 1):
                may_prime = True
            d <<= 1
            x = (x * x) % n
        if(x == n - 1):
            may_prime = True
        if(not may_prime):
            return False
        d = cp_d
    return True


n = int(input())
cnt = 0
for i in range(n):
    x = int(input())
    res = judge_miller(x, 15)
    if(res):
        cnt += 1
print(cnt)

Solution (Python):






import math

def is_prime(x):
    if x == 1:
        return False

    for j in range(2, int(math.sqrt(x))+1):
        if x % j == 0: return False

    return True

n = int(input())
print(sum([(1 if is_prime(int(input())) else 0) for _ in range(n)]))

Solution (Python):


"""Determines whether an input integer is prime, by trial division.

Verification: [ALDS1_1_C](https://onlinejudge.u-aizu.ac.jp/status/users/hamukichi/submissions/1/ALDS1_1_C/judge/4573080/Python3)
"""


def is_prime_trial_division(n):
    """Determing whether the given integer `n` is prime by trial division.

    """

    assert n > 0
    if n < 2:
        return False
    else:
        for i in range(2, n):
            if i * i > n:
                break
            elif n % i == 0:
                return False
        return True


def count_primes(ms):
    return sum(is_prime_trial_division(m) for m in ms)


def main():
    n = int(input())
    ms = [int(input()) for _ in range(n)]
    print(count_primes(ms))


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())

def isprime(n):
    if n == 2:
        return True
    if (n < 2) or (n % 2 == 0):
        return False
    
    i = 3
    while i <= n**0.5:
        if n % i == 0:
            return False
        i += 2
    
    return True

c = 0

for _ in range(N):
    if isprime(int(input())):
        c += 1

print(c)

Solution (Python):
def main():
    n = int(input())
    flag = True
    cnt = 0
    for _ in range(n):
        i = int(input())
        if i == 2:
            flag = True
        else:
            for j in range(2, int(-(-i**0.5//1))+1):
                if i%j == 0:
                    flag = False
                    break
        if flag:
            cnt += 1
        flag = True   
    print(cnt)

if __name__ == '__main__':
    main()

Solution (Python):
import math

def isprime(n):
    if n == 1: return False
    
    for k in range(2, int(math.floor(math.sqrt(n))) + 1):
        if n % k == 0:
            return False
    
    return True

n = int(input())
a = 0

for i in range(n):
    x = int(input())
    if isprime(x):
        a += 1
        
print(a)

Solution (Python):
def P(n):
    for i in range(2,n):
        if i*i>n:
            return True
        if n%i==0:
            return False
    return True

n=int(input())
count=0
for i in range(n):
    x = int(input())
    count+=P(x)
print(count)

Solution (Python):
def is_prime(n):
    t=True
    for i in range(2,int(n**0.5)+1):
        if(n%i)==0:
            t=False
            break
    return t

n=int(input())
ans=0
for i in range(n):
    ans+=is_prime(int(input()))
print(ans)

Solution (Python):
def is_prime(N):
    if N == 2:
        return True
    i = 2
    while i * i <= N:
        if N % i == 0:
            return False
        i += 1
    return True


def resolve():
    N = int(input())
    ans = 0
    for _ in range(N):
        ans += 1 if is_prime(int(input())) else 0
    print(ans)


resolve()

Solution (Python):
import math

def readinput():
    n=int(input())
    a=[]
    for i in range(n):
        a.append(int(input()))
    return n,a

def isPrime(n):
    if n==2:
        return True

    if n<=1 or n%2==0:
        return False

    m = int(math.sqrt(n))+1
    for i in range(3,m,2):
        if n % i == 0:
            return False
    return True

def getPrimes(n):
    '''n以下の素数のリストを返す'''
    p=[]
    for i in range(2,n+1):
        if isPrime(i):
            p.append(i)
    return p

def main(n,a):
    m=max(a)
    p=getPrimes(m)
    cnt=0
    for _ in a:
        if _ in p:
            cnt+=1
    return cnt

if __name__=='__main__':
    
    
    n=int(input())
    cnt=0
    for i in range(n):
        x = int(input())
        if isPrime(x):
            cnt+=1
    print(cnt)

Solution (Python):


import math

ans = 0
while True:
   try:
      n = int(input())
      if n == 2:
         ans += 1
         continue
      if n % 2 == 0:
         continue
      
      c = 0
      for i in range(2, math.floor(math.sqrt(n)) + 1):
         if n % i == 0:
            c += 1
      if c == 0:
         
         ans += 1

   except EOFError:
      break
   
print(ans)

Solution (Python):
import math
def Sosu(N) :
    for i in range(2, int(math.sqrt(N))+1) :
        if N % i == 0 :
            return 'F'
    return 'T'
    

n = int(input())
ans = 0
for j in range(n) :
    a = int(input())
    if Sosu(a) == 'T' :
        ans += 1

print(ans)

Solution (Python):
import math

n = int(input())
Numbers = [int(input()) for i in range(n)]

ans = 0
for i in Numbers:
    for j in range(2,int(math.sqrt(i))+1):
        if i%j==0:
            break
    else:
        ans += 1
print(ans)

Solution (Python):
count = 0
def prime(n):
    if n < 2:
        return 0
    elif n == 2:
        return 1
    elif n % 2 == 0:
        return 0

    for i in range(3,int(n**(1/2))+1,2):
        if n % i == 0:
            return 0
    return 1

n = int(input())
for i in range(n):
    a = int(input())
    count += prime(a)

print(count)

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect
import functools

def is_prime(n):
    if n == 1:
        return False
    if n == 2:
        return True
    for i in range(2,int(n**0.5)+1):
        if n%i != 0:
            continue
        else:
            return False
    return True

n = int(input())
A = [int(input()) for i in range(n)]
cnt = 0
for i in range(n):
    if is_prime(A[i]):
        cnt+=1
print(cnt)

Solution (Python):
import math

def isPrime(n):
  if n == 2:
    return True
  if n % 2 == 0:
    return False

  m = math.floor(math.sqrt(n)) + 1
  for p in range(3, m, 2):
      if n % p == 0:
        return False
  return True
  
count = 0
n = int(input())
for i in range(n):
    x = int(input())
    if isPrime(x):
        count +=1

print(count)

Solution (Python):
import math

def calc(n):
    global p
    q = 1
    lst = list(range(2, math.floor(math.sqrt(n))+1))

    for i in lst:
        if n%i ==0:
            q =0
            break

    if q==1:
        p = p+1

p =0
num = int(input())

for i in range(num):
    inputnum = int(input())
    if inputnum ==2:
        p =p+1
    else:
        calc(inputnum)

print(p)

Solution (Python):
primes = []
for i in range(2, 10 ** 4):
    for j in primes:
        if i % j == 0:
            break
    else:
        primes.append(i)

n = int(input())
cnt = 0
for i in range(n):
    p = int(input())
    if p in primes:
        cnt += 1
    elif p > 10 ** 4:
        for j in primes:
            if p % j == 0:
                break
        else:
            cnt += 1
    else:
        pass
print(cnt)

Solution (Python):
from math import sqrt
s = int(input())
ct = 0
for i in range(s):
    ok = 1
    x = int(input())
    for z in range(2, int(sqrt(x))+1):
        if x % z == 0:
            ok = 0
            break
    ct += ok
print(ct)

Solution (Python):
import math


def is_prime_v2(x: int) -> bool:
    if x == 2:
        return True

    if x <= 1 or x % 2 == 0:
        return False

    for i in range(3, int(math.sqrt(x)) + 1, 2):
        if x % i == 0:
            return False
    return True


def main():
    n: int = int(input())
    count: int = 0

    for _ in range(n):
        num: int = int(input())
        if is_prime_v2(num) == True:
            count += 1

    print(count)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    n = I()
    A = [I() for _ in range(n)]

    def is_prime(n):
        if n==0 or n==1: return False
        for i in range(2, int(n**0.5)+1):
            if n%i==0:
                return False
        return True

    print([is_prime(i) for i in A].count(True))

if __name__ == '__main__':
    resolve()

Solution (Python):
import math

def prime(x):
	for i in range(2,int(math.sqrt(x))+1):
		if x%i == 0:
			return 0
	return 1

n=int(input())
count=0
for i in range(n):
	x=int(input())
	if prime(x):
		count+=1
print(count)

Solution (Python):
import sys
input = sys.stdin.readline
def is_prime(n):
    if n == 1:
        return False
    for k in range(2, int(n**0.5) + 1):
        if n % k == 0:
            return False
    return True
n = int(input())
ans = 0
for _ in range(n):
    ans += int(is_prime(int(input())))
print(ans)

Solution (Python):
import math

def isPrime(x):
    if x==2:
        return True
    
    if x<2 or x%2==0: 
        return False
    
    i=3
    while  i<=math.sqrt(x):
        if x%i==0:
            return False
        i+=2
    return True
    
n=int(input())
count=0
for i in range(n):
    a=int(input())
    if isPrime(a):
        count+=1
print(count)

Solution (Python):
import math
def is_prime(N):
    if 1 >= N:
        return False
    for i in range(2,int(math.sqrt(N) + 1)):
        if N % i == 0:
            return False
    return True
  
answer = 0
N = int(input())
for i in range(N):
  a  = int(input())   
  if is_prime(a):
        answer += 1
print(answer)

Solution (Python):
import math
n = int(input())
input_nums = [int(input()) for _ in range(n)]

primes = []
for i in range(2, 10000):
    is_prime = True
    
    for p in primes:
        if i % p == 0:
            is_prime = False
    if is_prime:
        primes.append(i)


def check(n):
    for p in primes:
        if n <= p:
            return True
        if n % p == 0:
            return False
    return True


count = 0
for num in input_nums:
    if check(num):
        count += 1
print(count)

Solution (Python):
def is_prime(x):
    if x == 2:
        return True
    if x < 2 or x % 2 == 0:
        return False
    i = 3
    while i <= x ** (1 / 2):
        if x % i == 0:
            return False
        i += 2
    return True

N = int(input())
cnt = 0
for _ in range(N):
    x = int(input())
    if is_prime(x):
        cnt += 1

print(cnt)

Solution (Python):
import math as m

def is_prime(x):
    if x < 2:
        return False
    if x == 2 or x == 3 or x == 5:
        return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0:
        return False
    prime_number = 7
    difference = 4
    while prime_number <= m.sqrt(x):
        if x % prime_number == 0:
            return False
        prime_number += difference
        difference = 6 - difference
    return True
n = int(input())
a = [int(input()) for i in range(n)]
ans = 0
for i in a:
    ans += 1 if is_prime(i) else 0
print(ans)

Solution (Python):
def is_prime(x):
    if x == 2:
        return 1
    elif x % 2 == 0:
        return 0
    else:
        return pow(2, x - 1, x) == 1

import sys

def solve():
    file_input = sys.stdin
    N = file_input.readline()
    count = 0
    for n in map(int, file_input):
        count += is_prime(n)
    print(count)

solve()

Solution (Python):
def prime(x):
    if x == 2:
        return 1
    if x < 2 or x % 2 == 0:
        return 0
    i = 3
    while (i**2 <= x):
        if x%i == 0:
            return 0
        i+=2
    return 1
def Isprime(x):
    sum = 0
    for i in x:
        sum += prime(i)
    return sum
n = int(input())
x = [int(input()) for i in range(n)]
print(Isprime(x))

Solution (Python):

import math

def isPrime_number(a):
    for i in range(2, int(math.sqrt(a))+1):
        if a%i == 0:
            return False
    return True

n = int(input())
cnt = 0
for _ in range(n):
    if isPrime_number(int(input())):
            cnt += 1
print(cnt)

Solution (Python):
n = int(input())
count = 0
for _ in range(n):
    num = int(input())
    judge = True
    for p in range(2, int(num**0.5)+1):
        if num % p == 0:
            judge = False
            break
    if judge:
        count += 1
print(count)

Solution (Python):
n=int(input())
num = [int(input()) for _ in range(n)]
cnt=0
for i in num:
    if i==2:
        cnt+=1
    if i<2 or i%2==0:
        continue
    j=3
   
    while j*j<=i:
        if i%j==0:
            break
        j+=2
    else:
        cnt+=1

print(cnt)

Solution (Python):
N = int(input())
count = 0
for i in range(N):
    n = int(input())
    if (n != 2) * (n % 2 == 0):
        continue
    j = 3
    while j*j <= n:
        if n % j == 0:
            break
        j += 2
    if j*j > n:
        count += 1
print(count)

Solution (Python):
def isPrime(n):
    for i in range(2, n):
        if i * i > n:
            return 1
        if n % i == 0:
            return 0
    return 1

ans = 0
n = int(input())
for i in range(n):
    x = int(input())
    ans = ans + isPrime(x)

print(ans)

Solution (Python):
def isPrime(x):
    if x > 2 and x % 2 == 0:
        return False
    if x == 1:
        return True
    for a in range(3,round(x**(1/2))+1,2):
        if x % a == 0:
            return False
    return True

n = int(input())

prime = []
for a in range(n):
    prime.append(int(input()))

count = 0
for a in prime:
    if isPrime(a):
        count += 1

print(count)

Solution (Python):
import math

def is_prime(x):
    if x == 2:
        return True
    if x < 2 or x % 2 == 0:
        return False
    i = 3
    while i <= math.sqrt(x):
        if x % i == 0:
            return False
        i += 2
    return True

n = int(input())
ans = 0
for i in range(n):
    x = int(input())
    if is_prime(x):
        ans += 1
print(ans)

Solution (Python):
import math

def main():
  n = int(input())

  r = 0
  for _ in range(n):
    m = int(input())

    flag = True
    for i in range(int(math.sqrt(m)) - 1):
      if m % (i+2) == 0:
        flag = False
        break
      
    if flag:
      r += 1

  print(r)

if __name__ == '__main__':
  main()

Solution (Python):
import math

def is_prime(a):
  if a == 2:
    return 1

  if 2 > a or a % 2 == 0:
    return 0
  
  v = 3
  while v <= math.sqrt(a):
    if a % v == 0:
      return 0
    v += 2
  return 1
  
num = int(input())
count = 0
while num > 0:
  i = int(input())
  count += is_prime(i)
  num -= 1
print(count)

Solution (Python):
def pnj(a):
    i = 2
    while i*i <= a:
        if a%i == 0:
            return False
        i += 1
    return True

n = int(input())
i, c = 0, 0

while n > i:
    a = int(input())
    if pnj(a):
        c += 1
    i += 1

print(c)

Solution (Python):
def isPrime(n):
    for i in range(2, n):
        if i * i > n:
            return 1
        if n % i == 0:
            return 0
    return 1

ans = 0
n = int(input())
for i in range(n):
    x = int(input())
    ans = ans + isPrime(x)

print(ans)

Solution (Python):
import math

n = int(input())
cnt = 0
for i in range(0, n):
	j = int(input())
	if (1 <= j <= 3):
		continue
	if j % 2 == 0:
		cnt = cnt + 1
		continue
	k = int(math.sqrt(j))
	l = 3
	while l <= k:
		if j % l == 0:
			cnt = cnt + 1
			break
		l = l +1

print(n - cnt)

Solution (Python):
import math
def prime(n):
    for i in range(2, int(math.sqrt(n))+1):
        if  n % i == 0:
            return False
    return True
num_prime = []
k = 0
while True:
    try:
        n = input()
    except:
        break
    if prime(int(n)):
        if not int(n) in num_prime:
            k += 1
            num_prime.append(int(n))
print(k)

Solution (Python):
import math as m

def prime(n):
    if n <= 1:
        return False
    for i in range(2,int(m.sqrt(n)) + 1):
        if n % i == 0:
            return False
    return True
    
a = int(input())
x = []
for j in range(a):
    b = int(input())
    if prime(b):
        x.append(b)
print(len(x))

Solution (Python):
import math
def isPrime(x):
    if x <= 1:
        return False

    for i in range(2,int(math.sqrt(x))+1):
        if x % i == 0:
            return False

    return True
n = int(input())
ans = 0
for i in range(n):
    a = int(input())
    b = isPrime(a)
    if b:
        ans+=1
print(ans)

Solution (Python):
import math

n = int(input())
cnt = 0

def prime(a) :
    for i in range(2, int(math.sqrt(a)) + 1) :
        if a % i == 0 :
            return False
        
    return True

for i in range(n) :
    if prime(int(input())) :
        cnt += 1
        
print(cnt)

Solution (Python):
from math import sqrt


def is_prime(num):
    this_is_prime = True
    for i in range(2, int(sqrt(num))+1):
        if num % i == 0:
            this_is_prime = False

    return this_is_prime


n = int(input())

nums = [int(input()) for _ in range(n)]
count = 0
for num in nums:
    if is_prime(num):
        count += 1
print(count)

Solution (Python):
n=int(input())
a=[]
[a.append(int(input())) for x in range(n)]
cnt=0
for i in a:
    for j in range(2,int(i**0.5)+1):
        if i%j==0:
            cnt+=1
            break
print(n-cnt)

Solution (Python):
def isprime(x):
    if x == 2:
        return True

    if x < 2 or x % 2 == 0:
        return False

    i = 3
    while i <= x ** 0.5:
        if x % i == 0:
            return False
        i = i + 2

    return True

count = 0
n = int(input())
for i in range(n):
    x = int(input())
    if isprime(x):
        count += 1
print(count)

Solution (Python):

import sys
from math import sqrt
n = int(input())


def is_prime(x):
    if x == 1:
        return False
    if x % 2 == 0:
        if x == 2:
            return True
        else:
            return False
    for i in range(3, int(sqrt(x)) + 1):
        if x % i == 0:
            return False

    return True


ans = 0
for i in range(n):
    if is_prime(int(input())):
        ans += 1
print(ans)

Solution (Python):
import math
N = int(input())

num_list = []
num_list2 = []
for i in range(N):
    num_list.append(int(input()))
    
def isprime(x):
  if x == 2:
    return True

  if x < 2 or x % 2 == 0:
    return False

  i = 3
  while i <= math.sqrt(x):
    if x % i == 0:
      return False
    
    i = i + 2
  return True
  
for i in num_list:
    if not isprime(i):
        continue
    else:
        num_list2.append(i)
  
print(len(num_list2))

Solution (Python):
import math
countp = 0
a = int(input())
for j in range(a):
     n = int(input())
     if n > 1  :
         for i in range(2,math.floor(math.sqrt(n))+1 ): 
              if n % i == 0: 
                   break  
         else :
             countp += 1
            
print(countp)

Solution (Python):
import math

def isPrime(x):
    if x == 2:
        return True
    elif x < 2 or x % 2 == 0:
        return False
    else:
        for i in range(3, int(math.sqrt(x))+1, 2):
            if x % i == 0:
                return False
        return True

n = int(input())
ret = 0
for _ in range(n):
    x = int(input())
    if isPrime(x):
        ret += 1
print(ret)

Solution (Python):
n = int(input())
c = 0

def isPrime(x:int):
    if x < 2 or x == 9:
        return False
    if x == 2 or x == 3:
        return True
    if x%2 == 0:
        return False
    i = 2
    while True:
        i += 1
        if x%i == 0:
            return False
        if x <= i**2 :
            return True

for _ in range(n):
    if isPrime(int(input())):
        c += 1

print (c)

Solution (Python):
def primeNumber(a):
  if ( a == 2 or a == 3 or a == 5):
    return True
  elif a % 2 == 0:
    return False
  else:
    b = int(a ** 0.5 + 0.5)
    b = b + 1 if b % 2 == 0 else b

    for b in range(b,2,-2)	:
      if a % b == 0 :
        return False

    return True

cnt = 0
N = int(input())
for i in range(N):
  k = int(input())
  pn = primeNumber(k)
  if pn == True:
    cnt +=1
    
print(cnt)

Solution (Python):
N = int(input())
A = [int(input()) for _ in range(N)]

def is_prime(a):
    for i in range(2,int(a**0.5)+1):
        if a%i==0:
            return False
    return True

ans = 0
for i in A:
    if is_prime(i):
        ans += 1
print(ans)

Solution (Python):
def isprime(p):
    import math
    if p == 2:
        return True
    
    if p < 2 or p % 2 == 0:
        return False

    i = 3
    while i <= math.sqrt(p):
        if p % i == 0:
            return False
        i = i + 2

    return True

if __name__ == "__main__":
    num = int(input())
    p_cnt=0
    for i in range(num):
        p = int(input())
        if isprime(p):
            p_cnt += 1
    
    print(p_cnt)

Solution (Python):
import math

def is_prime(n):
    if n == 2:
        return True
    
    if n < 2 or n % 2 == 0:
        return False
    
    for i in range(3, int(math.sqrt(n))+1, 2):
        if n % i == 0:
            return False

    return True

n = int(input())
nums = [int(input()) for _ in range(n)]


result = 0
for num in nums:
    if is_prime(num):
        result += 1

    
print(result)

Solution (Python):
import math

def is_prime(N :int) -> bool:
    if N < 2:
        return False

    if N == 2:
        return True
    
    if N == 3:
        return True
    
    sqrt_n = int(math.sqrt(N)) + 1
    for i in range(2, sqrt_n):
        if N % i == 0:
            return False

    return True

if __name__ == "__main__":
    N = int(input())
    
    ans = 0
    for i in range(N):
        num = int(input())
        if is_prime(num):
            ans += 1

    print(ans)

Solution (Python):
def isPrimeNumber(x):
    for i in range(2, int(x ** 0.5) + 1):
        if x % i == 0:
            return False
    return True

count = 0
for n in range(int(input())):
    count += 1 if isPrimeNumber(int(input())) else 0
print(count)

Solution (Python):

import sys,bisect,math
sys.setrecursionlimit(15000)

N = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(N)]

def isPrime(n):
  if n == 2:
    return True
  for i in range(2,math.ceil(pow(n,0.5))+1):
    if n % i == 0:
      return False
  return True

print(sum(1 for e in A if isPrime(e)))

Solution (Python):
n=int(input())
a=[int(input()) for i in range(n)]




import random

def is_prime3(q, k=50):
    q = abs(q)
    
    if q == 2: return True
    if q < 2 or q & 1 == 0: return False

    
    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    
    for i in range (0,k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True

ans=0
for i in range(n):
    if is_prime3(a[i],50):
        ans+=1

print(ans)

Solution (Python):
n = int(input())
A = [int(input()) for _ in range(n)]


def is_prime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return n != 1 

cnt = 0
for v in A:
	if is_prime(v): cnt += 1

print(cnt)

Solution (Python):
def eratos():
    primes = []
    for i in range(2, 10**4):
        flag = True
        for p in primes:
            if i%p == 0:
                flag = False
        if flag:
            primes.append(i)
    return primes

def check(n, primes):
    for p in primes:
        if n <= p:
            return True
        if n%p == 0:
            return False
    return True

N = int(input())
primes = eratos()
ans = 0
for _ in range(N):
    n = int(input())
    if check(n, primes):
        ans += 1
print(ans)

Solution (Python):
import math
n = int(input())
cnt_prime = n

for i in range(n):
    m = int(input())
    for k in range(2, int(math.sqrt(m))+1):
        if m % k == 0 and m != k:
            cnt_prime -= 1
            break
        
print(str(cnt_prime))

Solution (Python):


import math

def is_prime(x):
    if x==2:
        return True

    if x<2 or x%2==0:
        return False

    i = 3
    while i<=math.sqrt(x):
        if x%i==0:
            return False
        i += 2

    return True


N = int(input())


ans = 0
for i in range(N):
    num = int(input())
    if is_prime(num):
        ans += 1


print(ans)

Solution (Python):
def sosu(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

n = int(input())
prime = [int(input()) for i in range(n)]
cnt = 0
for i in prime:
    if sosu(i):
        cnt += 1
print(cnt)

Solution (Python):
def isPrime(x):
    if x < 2:
        return False
    for i in range(2, int(x**0.5 + +1.5)):
        if x%i == 0 and i < x:
            return False
    return True

n = int(input())
cnt = 0
for _ in range(n):
    x = int(input())
    if isPrime(x):
        cnt += 1
print(cnt)

Solution (Python):
import math

def isPrime(x):
    if x == 2:
        return 1
    if x % 2 == 0:
        return 0
    for i in range(2,int(math.sqrt(x))+1):
        if x%i == 0:
            return 0
    return 1

n=int(input())
ans=0
for i in range(n):
	x=int(input())
	if isPrime(x):
		ans+=1
print(ans)

Solution (Python):
n = int(input())
cnt = 0
for i in range(n):
    num = int(input())
    judge = True
    if num == 2:
        pass
    elif num < 2 or num%2 == 0:
        judge = False
        pass
    else:
        j = 3
        while j <= num**0.5:
            if num%j == 0:
                judge = False
                break
            j += 2
    if judge == True:
        cnt += 1
print(cnt)

Solution (Python):
import math


def is_prime(n):
    for i in range(2, int(math.sqrt(n))+1):
        if n % i == 0:
            return False
    return True


n = int(input())
count = 0
for _ in range(n):
    m = int(input())
    if is_prime(m):
        count += 1
print(count)

Solution (Python):
import math
N = int(input())
count = 0
for _ in range(N):
    x = int(input())
    for i in range(2,int(math.sqrt(x)+1)):
        if x % i == 0:
            break
    else:
        count += 1
print(count)

Solution (Python):
def main():
    q = int(input())
    cnt = 0
    for _ in range(q):
        n = int(input())
        i = 2
        f = True
        while i*i <= n and f:
            if n % i == 0:
                f=False
            i += 1
        if f:
            cnt += 1
    print(cnt)

main()

Solution (Python):
import math
def is_prime(n):
    if n == 2: return True
    if n < 2 or n % 2 == 0: return False
    i = 3
    while i <= math.sqrt(n):
        if n % i == 0: return False
        i += 1
    return True

n = int(input())
ans = 0
for i in range(n):
    num = int(input())
    if is_prime(num): ans += 1
print(ans)