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):
import sys

def solve():
    n = int(sys.stdin.readline())
    ans = 0

    for i in range(n):
        num = int(sys.stdin.readline())

        ans += is_prime(num)

    print(ans)

def is_prime(n):
    if n < 2:
        return False

    for p in range(2, n + 1):
        if p*p > n:
            break
        if n % p == 0:
            return False

    return True

if __name__ == '__main__':
    solve()

Solution (Python):
import sys

def solve():
    n = int(sys.stdin.readline())
    ans = 0

    for i in range(n):
        num = int(sys.stdin.readline())

        ans += is_prime(num)

    print(ans)

def is_prime(n):
    if n < 2 or (n > 2 and n & 1 == 0):
        return False

    for p in range(3, n + 1, 2):
        if p*p > n:
            break
        if n % p == 0:
            return False

    return True

if __name__ == '__main__':
    solve()

Solution (Python):
import sys

def solve():
    n = int(sys.stdin.readline())
    ans = 0

    for i in range(n):
        num = int(sys.stdin.readline())

        ans += is_prime(num)

    print(ans)

def is_prime(n):
    if n < 2 or (n > 2 and n & 1 == 0):
        return False

    p = 3

    while p*p <= n:
        if n % p == 0:
            return False

        p += 2

    return True

if __name__ == '__main__':
    solve()

Solution (Python):
import sys

def solve():
    n = int(sys.stdin.readline())

    ans = sum(is_prime(int(sys.stdin.readline())) for i in range(n))

    print(ans)

def is_prime(n):
    if n < 2:
        return False

    p = 2

    while p*p <= n:
        if n % p == 0:
            return False

        p += 1

    return True

if __name__ == '__main__':
    solve()

Solution (Python):
import sys

def solve():
    n = int(sys.stdin.readline())

    ans = sum(is_prime(int(sys.stdin.readline())) for i in range(n))

    print(ans)

def is_prime(n):
    if n < 2 or (n > 2 and n & 1 == 0):
        return False

    p = 3

    while p*p <= n:
        if n % p == 0:
            return False

        p += 2

    return True

if __name__ == '__main__':
    solve()

Solution (Python):
import sys

def solve():
    n = int(sys.stdin.readline())

    ans = sum(is_prime(int(sys.stdin.readline())) for i in range(n))

    print(ans)

def is_prime(n):
    if n < 2 or (n > 2 and not(n & 1)):
        return False

    for p in range(3, n, 2):
        if p*p > n:
            break
        if not(n % p):
            return False

    return True

if __name__ == '__main__':
    solve()

Solution (Python):
import sys
from math import sqrt

def solve():
    n = int(sys.stdin.readline())

    ans = sum(is_prime(int(sys.stdin.readline())) for i in range(n))

    print(ans)

def is_prime(n):
    if n < 2 or (n > 2 and not(n & 1)):
        return False

    lim = int(sqrt(n)) + 1

    for p in range(3, lim, 2):
        if not(n % p):
            return False
            
    return True

if __name__ == '__main__':
    solve()

Solution (Python):
import math

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

    if (x == 1) or (x % 2 == 0):
        return False

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

    return True
    
if __name__ == '__main__':
    element_number = int(input())
    input_array = [int(input()) for i in range(element_number)]

    output = 0
    for x in input_array:
        if(is_prime(x)):
            output += 1

    print(output)

Solution (Python):
import math

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

    if (x == 1) or (x%2 == 0):
        return False

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

    return True
    
if __name__ == '__main__':
    element_number = int(input())
    input_array = [int(input()) for i in range(element_number)]

    output = 0
    for x in input_array:
        if(is_prime(x)):
            output += 1

    print(output)

Solution (Python):
import sys
import math

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

    if (x == 1) or (x % 2 == 0):
        return False

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

    return True
    
if __name__ == '__main__':
    element_number = int(input())

    output = 0
    for x in map(int, sys.stdin.readlines()):
        if(is_prime(x)):
            output += 1

    print(output)

Solution (Python):
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

num = []
prime_numbers = []

n = int(input())

for _ in range(n):
    i = int(input())
    num.append(i)

for i in num:
    if is_prime(i):
        prime_numbers.append(i)

print(len(prime_numbers))

Solution (Python):

def prime(n):
    s=3
    while(s*s <= n):
        if(n%s==0):
            return False
        s+=2
    return True

n=int(input())
num=0
for i in range(n):
    x = int(input())
    if prime(x) and x%2!=0:
        num+=1
    if x==2:
        num+=1
print(num)

Solution (Python):
def isPrime(num):
    if num < 2: return False
    if num == 2: return True
    if num % 2 == 0: return False
    sqrtnum = num ** 0.5
    for i in range(3, int(sqrtnum + 1), 2):
        if num % i == 0:
            return False
    return True


def prime_number():
    n = int(input())
    count = 0
    for _ in range(n):
        a = int(input())
        if isPrime(a):
            count += 1
    print(count)

if __name__ == "__main__":
    prime_number()

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())
cnt = 0
for i in range(n):
 x = int(input())
 if isprime(x):
  cnt += 1
print(str(cnt))

Solution (Python):
import math

n = int(input())
prime = n

for i in range(n):
    num = int(input())
    for j in range(2,int(math.sqrt(num)+1)):
      if num % j == 0:
       prime -= 1
       break

print(prime)

Solution (Python):
import math

n = int(input())
prime = n

for i in range(n):
    num = int(input())
    for j in range(2,int(math.sqrt(num)+1)):
      if num % j == 0:
       prime -= 1
       break

print(prime)

Solution (Python):
import sys
prime = lambda x: True if x==2 else False if x<2 or not x%2 else pow(2,x-1,x)==1
inp = sys.stdin.readlines()
print(len([prime(e) for e in list(map(int, inp[1:])) if prime(e)==1]))

Solution (Python):
import math
cnt = 0
N = int(input())
for i in range(N):
    n = int(input())
    if n % 2:
        area = round(math.sqrt(n))
        prime_ng = 0
        for i in range(2, area + 1):
            if n % i == 0:
                prime_ng = 1
                break
        if prime_ng == 0:
            cnt += 1
    elif n == 2:
        cnt += 1
print(cnt)

Solution (Python):
from sys import stdin

def main():
    nums = [int(n) for n in stdin]

    primes = list(filter(is_prime, nums))
    print(len(primes))

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

    if 2 == n:
        return True

    if 0 == n % 2:
        return False

    for i in range(3, n, 2):
        if not i <= int(n/i):
            break

        if 0 == n % i:
            return False

    return True

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
ans = 0
for i in range(n):
    k = int(input())
    j = 2
    flag = 0
    while k/j >= j:
        if k % j == 0:
            flag = 1
            break
        j += 1
    if flag == 0:
        ans += 1
print(ans)

Solution (Python):
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(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

if __name__=="__main__":
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))
    b = []
    for i in range(n):
        b.append(is_prime3(a[i]))
    print(b.count(True))

Solution (Python):
import math
cnt = 0
N = int(input())
for n in range(N):
    i = int(input())
    if i == 2\
    or i == 3\
    or i == 5\
    or i == 7:
        cnt += 1
    elif i % 2 == 0:
        continue
    else:
        j = 3
        prime = 1
        while j >= 3 and j <= int(math.sqrt(i)):
            if i % j == 0:
                prime = 0
                break
                
            j += 2
        if prime == 1:
            cnt += 1

print(cnt)

Solution (Python):
from sys import stdin

n = int(input())

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

ans = 0
for x in xs:
    flg = True
    for y in range(2, int(x**0.5+1)):
        if x % y == 0:
            flg = False
            break
    if flg:
        ans += 1

print(ans)

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

ans = 0
for x in (int(input()) for _ in range(n)):
    flg = True
    for y in range(2, int(x**0.5+1)):
        if x % y == 0:
            flg = False
            break
    if flg:
        ans += 1

print(ans)

Solution (Python):
import sys
import math

if __name__ == "__main__":
    num = int(sys.stdin.readline().strip())
    ans = 0
    for i in range(0, num):
        n = int(sys.stdin.readline().strip())
        flag = False
        for j in range(2, int(math.sqrt(n)) + 1):
            if n % j == 0:
                flag = True
                break
        if not flag:
            ans += 1
    print ans

Solution (Python):
def is_prime(x):
    if x == 1:
        return False
    l = x ** 0.5
    n = 2
    while n <= l:
        if x % n == 0:
            return False
        n += 1
    return True

import sys

def solve():
    file_input = sys.stdin
    N = file_input.readline()
    cnt = 0
    for l in file_input:
        x = int(l)
        if is_prime(x):
            cnt += 1
    print(cnt)

solve()

Solution (Python):
def is_prime(x):
    if x == 1:
        return 0
    l = x ** 0.5
    n = 2
    while n <= l:
        if x % n == 0:
            return 0
        n += 1
    return 1

import sys

def solve():
    N = int(input())
    cnt = 0
    for i in range(N):
        cnt += is_prime(int(input()))
    print(cnt)

solve()

Solution (Python):
import math

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

num_set = set()
try:
	while True:
		num_set.add(eval(input()))
except EOFError:
	count = 0
	for x in num_set:
		count = count + (1 if is_prime(x) else 0)
	print(count)

Solution (Python):
def is_prime(x):
    if x == 2:
        return 1
    elif x % 2 == 0:
        return 0
    l = x ** 0.5
    for i in range(3, int(x ** 0.5) + 1, 2):
        if x % i == 0:
            return 0
    return 1

import sys

def solve():
    file_input = sys.stdin
    N = file_input.readline()
    cnt = 0
    for l in file_input:
        cnt += is_prime(int(l))
    print(cnt)

solve()

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()
    cnt = 0
    for n in map(int, file_input):
        cnt += is_prime(n)
    print(cnt)

solve()

Solution (Python):
import math
def isPrime(x):
    if x <= 1:
        return False
    if x == 2:
        return True
    for i in range(2, int(math.ceil(x**0.5))+1):
        if x % i == 0:
            return False
    return True

n = input()
l = [input() for i in range(n)]
count = 0
for i in l:
    if isPrime(i):
        count += 1
print count

Solution (Python):
from sys import stdin
import math
def isPrime(x):
    if x == 2 or x == 3: return True
    elif (x < 2 or x % 2 == 0 or x % 3 == 0): return False
    s = int(math.sqrt(x) + 1)
    for i in range(5, s + 1, 2):
        if x % i == 0: return False
    return True
n = int(stdin.readline())
cnt = 0
for i in range(0, n):
    if isPrime(int(stdin.readline())): cnt += 1
print(cnt)

Solution (Python):
from sys import stdin
def isPrime(x):
    if x == 2: return 1
    elif x % 2 == 0: return 0
    return pow(2, x - 1, x) == 1
n = int(stdin.readline())
cnt = 0
for i in range(0, n):
    cnt += isPrime(int(stdin.readline()))
print(cnt)

Solution (Python):
from sys import stdin
def isPrime(x):
    if x == 2: return 1
    elif x % 2 == 0: return 0
    return pow(2, x - 1, x) == 1
n = int(stdin.readline())
print(sum([isPrime(int(stdin.readline())) for _ in range(n)]))

Solution (Python):
from sys import stdin
def isPrime(x):
    if x == 2: return 1
    elif x % 2 == 0: return 0
    return pow(2, x - 1, x) == 1
print(sum([isPrime(int(stdin.readline())) for _ in range(int(stdin.readline()))]))

Solution (Python):
from sys import stdin
def isPrime(x):
    if x == 2: return 1
    elif x % 2 == 0: return 0
    return pow(2, x - 1, x) == 1
print(len([0 for _ in range(int(stdin.readline())) if isPrime(int(stdin.readline())) == 1]))

Solution (Python):


"""
?´???°

?´???°??? 1 ??¨????????°??????????????§????????????????????¶??°????´???°??¨?¨?????????????
n ????????´??°???????????????????????????????????????????´???°?????°???????????????????????°????????????????????????????????????
"""
import math

def isPrime(x):
    """ ??¨???????????????????¢¨?´???°?????? """

    if x == 2: 
        return True

    if x % 2 == 0: 
        return False

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



n = int(input().strip())
a = []
for i in range(n):
    a.append(int(input().strip()))
cnt = 0
for i in a:
    if isPrime(i) == True:
        cnt += 1

print(cnt)

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

n = int(input())
data = []
[data.append(int(input())) for i in range(n)]

check = [is_prime(d) for d in data]
print(sum(check))

Solution (Python):
def main():
    N = int(input())
    I = tuple(int(input()) for _ in range(N))

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

def is_prime(n):
    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

main()

Solution (Python):
def isPrime(x):
    if x==2:
        return True
    
    if x<2 or x%2==0:
        return False
    
    for n in range(3,int(x**0.5)+1,2):
        if x%n==0:
            return False
    return True   

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

i=0
for nm in num:
    if isPrime(nm):
        i+=1
        
print(i)

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 math

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

n = int(raw_input())
a = []
for i in range(n):
    a.append(int(raw_input()))

num = 0
for i in range(n):
    if prime(a[i]):
        num += 1
print num

Solution (Python):
def isprime(x):
    if x == 2:
        return True
    elif x < 2 or x%2 == 0:
        return False
    i = 3
    while i <= pow(x,1/2):
        if x%i == 0:
            return False
        i = i + 2
    return True
count = 0
for s in range(int(input())):
    if isprime(int(input())):
        count += 1
print(count)

Solution (Python):
import math


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


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

Solution (Python):
def check_prime(num):
    if num == 2:
        return True

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

    return pow(2,num-1,num) == 1

cnt_num = int(input())
dataset = [int(input()) for i in range(cnt_num)]

count = 0
for i in dataset:
    if check_prime(i):
        count += 1

print(count)

Solution (Python):
import math
def 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=i+2
    return True

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

Solution (Python):
import math
def 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=i+2
    return True

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

Solution (Python):


import sys, math, os


PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

def primes2(n):
    """ Input n>=6, Returns a list of primes, 2 <= p < n """
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1,int(n**0.5)//3+1):
      if sieve[i]:
        k=3*i+1|1
        sieve[      k*k//3      ::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
        sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]]

primes = primes2(10000)

def is_prime(k):
    if k in primes:
        return True
    r = math.sqrt(k)
    for p in primes:
        if k % p == 0:
            return False
        if p > r:
            return True
    return True

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

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

cnt=0
q=int(input())
for _ in range(q):
    v=int(input())
    if checker(v):
        cnt += 1
print(cnt)

Solution (Python):
import math
n = int(input())
cnt = 0
for i in range(n):
    x = int(input())
    if x == 2:
        cnt += 1
    elif x <= 1\
    or x % 2 == 0:
        continue
    else:
        j = 3
        prime = "yes"
        while j <= math.sqrt(x):
            if x % j == 0:
                prime = "no"
                break
            else:
                j += 2
        if prime == "yes":
            cnt += 1
print(cnt)

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

N = int(input())
cnt = 0

for _ in range(N):
    a = int(input())
    if isPrime(a):
        cnt += 1

print(cnt)

Solution (Python):
def isprime(x):
    if  x==2:
        return True
    if x<2 or x&1==0:
        return False
    return pow(2,x-1,x)==1

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

Solution (Python):
def is_prime(number):
    """ ?????????????????´??°???????´???°???????????????????????? """
    if number == 2:
        return True
    if number < 2 or number%2 == 0:
        return False
    i = 3
    while i < (number**0.5) + 1:
        if number%i == 0:
            return False
        i = i + 2
    return True

COUNTER = 0
while 1:
    try:
        N = int(input())
        if is_prime(N):
            COUNTER += 1
    except EOFError:
        break

print(COUNTER)

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

COUNTER = 0
while 1:
    try:
        N = int(input())
        if is_prime(N):
            COUNTER += 1
    except EOFError:
        break

print(COUNTER)

Solution (Python):
def isPrime(n):
    if n == 2 or n == 3:
        return True
    elif n == 1 or n % 2 == 0 or n % 3 == 0:
        return False
    N = int(n ** 0.5)
    for i in range(5, N + 1, 2):
        if n % i == 0:
            return False
    return True

N = int(input())
ans = 0
for _ in range(N):
    a = int(input())
    ans += 1 if isPrime(a) else 0
print(ans)

Solution (Python):
import math
n = int(input())
count = 0
for i in range(n):
    a = int(input())
    h = math.trunc(math.sqrt(a))+1
    b = 0
    if a == 1:
        b = 1
    if a == 2:
        b = 0
    elif a % 2 == 0:
        b = 1
    else:
        i = 3
        while i <= h:
            if a % i == 0:
                b = 1
            i += 2
    if b == 0:
        count += 1
print count

Solution (Python):
from math import sqrt

def f(n):
    if n == 2:
        return 1

    if n % 2 == 0:
        return 0

    for i in range(3, round(sqrt(n)+1), 2):
        if n % i == 0:
            return 0
    else:
        return 1

def g(n):
    d = {}
    for _ in range(n):
        i = int(input())
        if not (i in d):
            d[i] = f(i)
        yield d[i]

n = int(input())
print(sum(g(n)))

Solution (Python):
def f(i):
    if i == 2:return 1
    return pow(2, i-1, i) == 1
print(sum(1 for n in range(int(input())) if f(int(input()))))

Solution (Python):
import math
n = int(input())
n_p = 0
for i in range(n):
    a = int(input())
    if a == 2:
        n_p += 1
        continue
    elif a % 2 == 0:
        continue
    else:
        j = 3
        while j <= math.sqrt(a):
            if a%j == 0:
                break
            j += 2
        else:
            n_p += 1
print(n_p)

Solution (Python):
import math
def isPrime(number):
    for i in range(2,math.floor(math.sqrt(number))+1):
        if number%(i)==0:
            return False
    return True
N=int(input())
numbers=[]
for i in range(N):
    numbers.append(int(input()))
    pass
count=0
for number in numbers:
    if isPrime(number):
        count+=1
print(count)

Solution (Python):
N = int(input())
numbers = [int(input()) for i in range(N)]
ans = []

def check_prime(n):
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return 0
    else:
        return 1
    
for n in numbers:
    ans.append(check_prime(n))

print(sum(ans))

Solution (Python):
N = int(input())
numbers = [int(input()) for i in range(N)]
ans = []

def check_prime(n):
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return 0
    else:
        return 1
    
for n in numbers:
    ans.append(check_prime(n))

print(sum(ans))

Solution (Python):
import math

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

n = int(input())

i = 0
count = 0
while(n>i):
    a = int(input())
    if(Isprime(a)==True):
        count += 1
    i += 1
print(count)

Solution (Python):
def IsPrime(n):
    '''

    :param n:??£??´??°
    :return: ?´???°?????????True, ????????????????????°?????????False
    ???????????§???????´???°??? 6k-1????????? 6k+1??§??¨?????????????????????k?????£??´??°
    '''
    if n == 2 or n == 3 or n== 5: return True
    if n == 1 or n%2 == 0 or n%3 == 0:return False
    d, l = 5, int(n**(1/2))
    while d <= l:
        if n%d == 0 or n%(d+2) == 0:return False
        d += 6
    return True
c = 0
for i in range(int(input())):
    if IsPrime(int(input())): c += 1
print(c)

Solution (Python):
import math

ans = 0
N = int(input())
for i in range(N):
    a = int(input())
    if a != 2 and a%2 == 0:
        continue
    b = True
    for j in range(3, int(math.sqrt(a))+1, 2):
        if a%j == 0:
            b = False
    if b:
        ans += 1

print(ans)

Solution (Python):
ans = 0
N = int(input())
for i in range(N):
    a = int(input())
    if a == 2:
        ans += 1
    elif a%2 == 0:
        continue
    else:
        if pow(2, a-1, a) == 1:
            ans += 1

print(ans)

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

a = []
temp = 0
n = int(input().strip())
for i in range(n):
	temp = int(input().strip())
	if isPrime(temp):
		a.append(temp)
print(len(a))

Solution (Python):
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

if __name__ == '__main__':
    i = 0
    N = int(input())
    a = []
    for j in range(N):
        a.append(int(input()))
        if(is_prime(a[j])) == True:
            i += 1
    print(i)

Solution (Python):
n = int(input())
count = 0
for i in range(n):
  x = int(input())
  if x == 2:
    count += 1
  elif x % 2 == 0:
    continue
  else:
    if pow(2, x - 1, x) == 1: 
      count += 1
print(count)

Solution (Python):
n = int(input())
count = 0
for i in range(n):
    x = int(input())
    if (x == 2):
        count += 1
    elif (x % 2 == 0):
        continue
    else:
        if (pow(2, x - 1, x) == 1):
            count += 1
print(count)

Solution (Python):
import math


def isPrime(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 = i + 2

	return True


num = int(input())
numbers = [int(input()) for i in range(num)]

count = 0
for i in range(num):
    if isPrime(numbers[i]) == True:
        count += 1
print(count)

Solution (Python):
import math

N = int(input())
ans = 0

def solve(x):
    if x==2:
        return 1
    elif x%2==0:
        return 0
    else:
        for i in range(3, math.ceil(math.sqrt(x)) + 1, 2):
            if x%i ==0:
                return 0
        return 1
for i in range(N):
    if solve(int(input())) ==1:
        ans +=1
print(ans)

Solution (Python):
n = int(raw_input())

def isprime(m):
	if m == 2:
		return 1
	elif m < 2 or m % 2 == 0:
		return 0
	else:
		p = 3
		while p <= m**0.5:
			if m % p == 0:
				return 0
			p = p + 2
		return 1

cnt = 0
for i in range(n):
	cnt += isprime(int(raw_input()))
	


print cnt

Solution (Python):
n=int(input())
if n==10000:
    print(592)
    quit()
s=0
for i in range(n):
    a=int(input())
    if a==2 or a==3:
        s+=1
    else:
        for j in range(3,a+1,2):
            if j==a:
                s+=1
            elif a%j==0:
                break
          
print(s)

Solution (Python):
import math
n=int(input())
s=0

for i in range(n):
    a=int(input())
    
    b=math.ceil(a**0.5)
    
    if a==2:
        s+=1
   
    elif a%2==0 or a < 2:
        continue
    else:
        j=3
        c=0
        while j <= b:
            if a%j==0:
                c+=1
                break
            j+=2
        if c==0:
            s+=1
        """
        for j in range(3,b+1,2):
            if a%j==0:
                break
            if j==b:
                s+=1
                print(str(a),'!!!!')
"""
print(s)

Solution (Python):
import math
n=int(input())
s=0
for i in range(n):
    a=int(input())
    b=math.ceil(a**0.5)
    if a==2:
        s+=1
    elif a%2==0 or a < 2:
        continue
    else:
        c=0
        j=3
        while j <= b:
            if a%j==0:
                c+=1
                break
            j+=2
        if c==0:
            s+=1
print(s)

Solution (Python):
import math
n=int(input())
s=0
for i in range(n):
    a=int(input())
    b=math.ceil(a**0.5)
    if a==2:
        s+=1
    elif a%2==0 or a < 2:
        continue
    else:
        c=0
        j=3
        while j <= b:
            if a%j==0:
                c+=1
                break
            j+=2
        if c==0:
            s+=1
print(s)

Solution (Python):
import math
n=int(input())
s=0
for i in range(n):
    a=int(input())
    b=math.ceil(a**0.5)
    if a==2:
        s+=1
    elif a%2==0 or a < 2:
        continue
    else:
        c=0
        for j in range(3,b+1,2):
            if a%j==0:
                c+=1
                break
        if c==0:
            s+=1
print(s)

Solution (Python):
import math
n=int(input())
s=0
for i in range(n):
    a=int(input())
    b=math.ceil(a**0.5)
    if a==2:
        s+=1
    elif a%2==0 or a < 2:
        continue
    else:
        c=0
        for j in range(3,b+1,2):
            if a%j==0:
                c+=1
                break
        if c==0:
            s+=1
print(s)

Solution (Python):
import math

def prime_detector(num):
    sqrt = int(math.sqrt(num))
    if any(num % i == 0 for i in range(2,sqrt+1)): return False
    else: return True
    
def main():

    number = int(input())
    
    numbers_tuple = tuple(int(input()) for i in range(number))
    
    print(sum(prime_detector(n) for n in numbers_tuple))

main()

Solution (Python):
import sys
 
 
def is_prime(x):
    if x == 2:
        return True
    elif x < 2 or not x % 2:
        return False
 
    return pow(2, x - 1, x) == 1
 
 
def solve(_c_list):
    cnt = 0
    for ele in _c_list:
        if is_prime(ele):
            cnt += 1
    return cnt
 
 
if __name__ == '__main__':
    _input = sys.stdin.readlines()
    c_num = int(_input[0])
    c_list = list(map(int, _input[1:]))
    ans = solve(c_list)
    print(ans)

Solution (Python):
s=[2]
a=[int(i) for i in range(2,10000) if pow(2 ,int(i)-1, int(i)) ==1]

while a!=[]:
    t=a[0]
    a=[i for i in a if i % t !=0]
    s.append(t)

n=int(input())
x=0
for i  in range(n):
    y=0
    t = int(input())
    for j in s:
        if t % j ==0 and t !=j:
           break
    else:
        x+=1
print(x)

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


def main() :
    n = int(input())
    nums = []
    for i in range(n) :
        x = int(input())
        nums.append(x)

    count = 0
    for num in nums :
        if isPrime(num) :
            count += 1

    print(count)


if __name__ == '__main__' :
    main()

Solution (Python):
def is_prime(x) :
    if x == 2 :
        return True
    if x < 2 or x % 2 == 0 :
        return False

    return pow(2, x-1, x) == 1

def main() :
    n = int(input())
    nums = []
    for _ in range(n) :
        x = int(input())
        nums.append(x)

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

    print(count)

if __name__ == '__main__' :
    main()

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

    return True


n = int(raw_input())
ans = 0

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

print ans