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 math

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

    return True

N = int(input())
ans = 0
for i 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())
prime_count = 0

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

print(prime_count)

Solution (Python):
import math
N=int(input())
from sys import stdin
num_list=[3,5,7]

count=0
for i in range(N):
    flag=1
    cmd = int(stdin.readline().strip())

    if cmd==2 or cmd==3 or cmd==5 or cmd==7:
        count+=1
        continue
    if (cmd) % 2 == 0:
        continue
    else:
        for i in range(3,int(math.sqrt(cmd)+1),2):
            if cmd % i == 0:flag=0
        if flag==1:
            count+=1

print(count)

Solution (Python):
from math import floor

count = 0
n = int(input())

for _ in range(n):
    x = int(input())
    if x == 2 or x == 3:
        count += 1
    for i in range(2, floor(x**(1/2)) + 1):
        if x % i == 0:
            break
        if i == floor(x**(1/2)) and x % i != 0:
            count += 1
            
print(count)

Solution (Python):
from math import sqrt

def is_prime(a):
    if a<2:return 0
    if a==2:return 1
    if a%2 == 0:return 0
    i = 3
    while i<=sqrt(a):
        if a%i==0:return 0
        i+=2
    return 1

def main():
    n = int(input())
    res = 0
    for _ in range(n):
        a = int(input())
        if is_prime(a):res+=1
    print(res)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = [int(input()) for _ in range(n)]
ans = 0

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

for i in range(n):
    if isPrime(a[i]):
        ans += 1
    
print(ans)

Solution (Python):
import math
def is_prime(n):
  if n==2:
    return True
  elif n%2==0 or n<=1:
    return False
  else:
    for i in range(3,int(math.sqrt(n))+1,2):
      if n%i==0:
        return False
    return True
num=int(input())
ans=0
for _ in range(num):
  n=int(input())
  
  ans += is_prime(n)
print(ans)

Solution (Python):
import math

N = int(input())


def is_prime(x):
    
    if x == 2:
       
        return True
    if x > 2 and x % 2 == 0:
        return False
    i = 3
    while i <= math.sqrt(x):
        if x % i == 0:
            return False
        i = i+ 2
    
    return True
    
  
ans =0
for i in range(N):
    n =int(input())
    is_prime(n)
    if is_prime(n):
        ans += 1

print(ans)

Solution (Python):
def isprime(p):
    if p <= 1:
        return False
    if p == 2:
        return True
    if p % 2 == 0:
        return False
    lim = int(p**0.5)+1
    for q in range(3, lim, 2):
        if p % q == 0:
            return False
    return True

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

ans = sum(isprime(a) for a in A)
print(ans)

Solution (Python):
import math
def prime(v):
  if v == 2: return 1
  if v > 2 and v % 2 == 0: return 0

  for i in range(int(math.sqrt(v)), 2, -1):
    if v % i == 0: return 0
  return 1

N = int(raw_input())
n = []
count = 0
for i in range(N):
  count += prime(int(raw_input()))
print count

Solution (Python):
import math

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

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

print(cnt)

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


if __name__ == "__main__":
    n = int(input())
    ans = 0
    for _ in range(n):
        num = int(input())
        ans += is_prime(num)
    print(ans)

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

print(count)

Solution (Python):
n = int(input())
ans = 0
for _ in range(n):
    x = int(input())
    for i in range(2, int(x ** (1 / 2) + 1)):
        if x % i == 0:
            break
    else:
        ans += 1

print(ans)

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

def prime(m):
    for t in range(2,int(m**(1/2))+1):
        if m % t == 0:
            return False
    return True

for i in range(n):
    k = int(input())
    if k != 2 and k % 2 == 0:
        continue
    
    if prime(k):
        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 is_prime(num):
  if 2 < num and num % 2 == 0:
    return False

  n = num ** (1 / 2)

  cnt = 2

  while cnt <= n:
    if num % cnt == 0:
      return False
    cnt += 1
  
  return True

prime_num_cnt = 0

for i in range(int(input())):
  if is_prime(int(input())):
    prime_num_cnt += 1

print(prime_num_cnt)

Solution (Python):

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

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

Solution (Python):
import math

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

	x = int(math.sqrt(n))
	sw = True
	i = 3
	while i <= x:
		if n % i == 0:
			sw = False
			break
		i += 1
	return sw

cnt = 0
while 1:
	try:
		n = int(input())
		sw = chk(n)
		if sw == True:
			cnt += 1
	except:
		break
print(cnt)

Solution (Python):
from math import sqrt

li = []
N = int(input())
for _ in range(N):
    li.append(int(input()))


li = set(li)

count = 0
for v in li:
    if v == 2:
        count += 1
    elif v % 2 == 0:
        continue
    else:
        ubd = int(sqrt(v))
        flag = 1
        for i in range(3, ubd+1):
            if v % i == 0:
                flag = 0
                break
        count += flag

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 is_prime(n):
    if n < 2:
        return False
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    x = 3
    while x * x <= n:
        if n % x == 0:
            return False
        x += 2
    return True


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

Solution (Python):
import math
N=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
    
ans=0

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

Solution (Python):
import sys
import math
input = sys.stdin.readline














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

if __name__ == "__main__":
    res = 0
    for i in range(n):
        if is_prime(int(input())):
            res += 1
    print(res)

Solution (Python):
def is_prime(x: int) -> bool:
    """自然数nが素数であるかを判定する
    計算量: O(sqrt(N))
    """
    if x == 2:
        return True
    if x == 1 or x % 2 == 0:
        return False
    for k in range(3, int(x ** 0.5) + 1, 2):
        if x % k == 0:
            return False
    return True


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

ans = 0
for num in a:
    if is_prime(num):
        ans += 1
print(ans)

Solution (Python):
import math
n = int(input())
s = 0
for i in range(n):
    j = int(input())
    flg = False
    for p in range(2, int(math.sqrt(j)) + 1):
        if j % p == 0:
            flg = True
            break
    if flg == False:s += 1
print(s)

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

    return True


N = int(input())
count = 0

for i in range(N):
    a = int(input())
    if isPrime(a):
        count += 1

print(count)

Solution (Python):
n = int(input())
count = 0
for i in range(n):
    x = int(input())
    tf = True
    
    if x == 2:
        tf = True
    elif x < 2 or x % 2 == 0:
        tf = False
    else:
        j = 3
        while j <= (x)**(1/2):
            if x % j == 0:
                tf = False
                break
            j += 2
            tf == True
    
    if tf == True:
        count += 1
print(count)

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

cnt = 0

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 = i + 2
  return True
 
for i in range(n):
        if isprime(a[i]):
            cnt += 1
            
print(cnt)

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

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

res_list = [i for i in num_list if prime_chk(i)]
print(len(res_list))

Solution (Python):
import math

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

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

print(prime_count)

Solution (Python):
import math

def get_input():
    return int(input())

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

  if x < 2 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

n = get_input()
results = 0
for _ in range(n):
    a = get_input()
    if isprime(a):
        results += 1

print(results)

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

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

print(len([i for i in a if isPrime(i)]))

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

for i in range(n):
    m = int(input())
    if m == 2 or m == 3:
        c +=1
    else:
        T = 1
        for k in range(2,math.ceil(math.sqrt(m))+1):
            if m % k == 0:
                T = 0
                break
        if T == 1:
            c +=1
print(c)

Solution (Python):
_, *A = map(int, open(0).read().split())

ret = 0
for a in A:
    if a == 2:
        ret += 1
    else:
        if a % 2 == 0:
            continue
        else:
            flag = True
            for i in range(3, int(a**0.5)+2, 2):
                if a % i == 0:
                    flag = False
                    break
            if flag:
                ret += 1
                
print(ret)

Solution (Python):
import math

n = int(input())

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

answer = 0
for i in range(n):
    count = 0
    dest = int(math.sqrt(nums[i])) + 1

    prime = True
    for j in range(2, dest):
        if nums[i] % j == 0:
            prime = False
            break

    if (nums[i] != 1) and prime:
        answer += 1

print(answer)

Solution (Python):
n=int(input())
count=0
for i in range(n):
    a=int(input())
    flag=0
    if a==2:
        count+=1
        continue
    elif a<2 or a%2==0:
        continue
    for i in range(2,int(a**0.5)+1):
        if a%i==0:
            flag=1
            break
    if flag==0:
        count+=1
print(count)

Solution (Python):
import math

count = 0

def calculate(y):
    i = 3
    if y==2:
        return y
    elif y<2 or y%2==0:
        return False
    while i<= math.sqrt(y):
        if y % i == 0:
            return False
        i += 2
    return y

x = int(input())
y = [int(input()) for _ in range(x)] 

for l in y:
    if calculate(l)!=False:
        count += 1
print(count)

Solution (Python):



def is_Prime(x): 
   if x == 2: 
      return x
   if x < 2 or x % 2 == 0: 
      return False
   for i in range(3, x, 2): 
      if i * i > x: 
         break
      if x % i == 0: 
         return False
   return x

N = int(input())
num_list = [int(input()) for _ in range(N)] 
count = 0
for i in num_list: 
   prime = is_Prime(i)
   if prime != False: 
      count+=1
print(count)

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

ans = 0

for i in ints:
    if i == 2:
        ans += 1
        continue

    if i < 2 or i % 2 == 0:
        continue
    
    j = 3
    flag = True
    while j <= math.sqrt(i):
        if i % j == 0:
            flag = False
            break
        j += 1
    if flag: ans += 1

print(ans)

Solution (Python):
import time
import random
import sys
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math

inf = 10**9


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

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

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

    return True


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

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

    print(count)


if __name__ == '__main__':
    main()

Solution (Python):
import math

def is_prime(num):
    m = int(math.sqrt(num))

    for i in range(2, m + 1):

        if num == 2:
            return True

        elif num % i == 0:
            return False
    
    return True

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

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

    print(count)

main()

Solution (Python):

def isprime(x):
    if x <= 2:
        return True
    elif x % 2 == 0:
        return False
    else:
        i = 3
        while i <= int(x**0.5)+1:
            if x % i == 0:
                return False
            i += 2
        return True


input_number = int(input())
result_data = list()
for i in range(input_number):
    result_data.append(isprime(int(input())))


print(sum(result_data))

Solution (Python):






import math


def isPrimes(n: int) -> bool:
    if n == 2:
        return True

    if n % 2 == 0:
        return False

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

    return True


def main():
    number_of_numbers = int(input())
    number_of_primes = 0

    for i in range(0, number_of_numbers):
        n = int(input())
        if isPrimes(n):
            number_of_primes += 1

    print(number_of_primes)



if __name__ == "__main__":
    main()

Solution (Python):
import math

def prime_number(num):
    if num == 1:
        return False

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

    return True

count = 0
n = int(input().rstrip())
for i in range(n):
    num = int(input().rstrip())
    judge = prime_number(num)
    if judge == True:
        count += 1

print(count)

Solution (Python):
import math

def is_prime(n):
    if n <= 1:
        return False
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    for i in range(3, math.ceil(math.sqrt(n))+1, 2):
        if n % i == 0:
            return False
    return True
    
n = int(input())
ans = 0
for _ in range(n):
    x = int(input())
    if is_prime(x):
        ans += 1
print(ans)

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

Solution (Python):


import math

def is_prime(n):
    if n <= 3:
        return True
    
    if n % 2 == 0:
        return False 

    limit = int(math.sqrt(n)) + 1
    limit = limit if limit < n//2 else n//2 + 1

    for i in range(3,limit,2):
        if n % i == 0:
            return False
        
    
    return True

n = int(input())

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

print(ans)

Solution (Python):
import math


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


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

print(ans)

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


K = int(input())
count = 0
for i in range(K):
    n = int(input())
    if is_prime(n):
        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 += 1

    return True


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

print(result)

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


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


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

Solution (Python):

def prime_or_not(x):
    
    if x == 2:
        return True
        
    if x < 2 or x % 2 == 0:
        return False

    i = 3
    while i <= pow(x, 0.5):
        if x % i == 0:
            return False
        i = i + 2

    return True

n = int(input())

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

Solution (Python):
"""
素数を求める
素数以外の数 = 合成数
「合成数 x は p ≤ _√xを満たす素因子 p をもつ」
"""


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


def main():
    cnt = 0
    N = int(input())
    for n in range(N):
        x = int(input())
        if is_prime(x):
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

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

N = int(input())
count = 0

for i in range(N):
    a = int(input())
    if is_prime(a):
        count += 1

print(count)

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


ans = 0
while True:
    try:
        n = int(input())
        if is_prime(n):
            ans += 1
    except EOFError:
        break

print(ans)

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


n = int(input())
ret = []
for i in range(n):
    x = int(input())
    if is_prime(x):
        ret.append(x)
print(len(ret))

Solution (Python):
def main():

	number = int(input())
	count = 0
	for i in range(number):
		tmp = int(input())
		if isPrime(tmp):
			count +=1

	print(count)

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


if __name__ == '__main__':
	main()

Solution (Python):

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

    return True

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

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

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

print(ans)

Solution (Python):
import math

def isPrime(x):
	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())


def improved_is_prime(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


cnt = 0

for _ in range(n):
    if improved_is_prime(int(input())):
        cnt += 1

print(cnt)

Solution (Python):
import math
N=int(input())
a=[]
c=0
"""
def isPrime( x ):
    if x <= 1:
        return False

    for i in range(2,x-1):
        if x % i == 0:
            return False

    return True
"""

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 range(N):
    n=int(input())
    a.append(n)
    
for i in range(N):
    if(isPrime(a[i])==True):
        c=c+1

print(c)

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


n = int(input())
nums = [int(input()) for _ in range(n)]
ans = sum([1 for i in nums if is_prime(i)])
print(ans)

Solution (Python):
import math

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


ans = 0
for _ in range(int(input())):
    ans += is_prime(int(input()))
else:
    print(ans)

Solution (Python):
import math

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


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

Solution (Python):
import math

def get_primes(num):
    
    lim = math.sqrt(num)
    prime = []
    data = [i+1 for i in range(1, num)]
    
    while True:
        
        if data[0] >= lim:
            return prime + data
        
        prime.append(data[0])
        data = [i for i in data if i % data[0] != 0]

def is_prime(num, prime_arr):
    for i in prime_arr:
        if num <= i:
            return True
        if num % i == 0:
            return False
    return True

prime_arr = get_primes(10000)

N = int(input())

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

print(prime_count)

Solution (Python):
from collections import Counter

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

N = int(input())
nums = [int(input()) for i in range(N)]
Nums = Counter(nums)
c = 0
for a in Nums.keys():
    if prime(a):
        c += Nums[a]
print(c)

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 += 2
    return True

if __name__=='__main__':
    N = int(input())
    count = 0
    for _ in range(N):
        if isPrime(int(input())):
            count += 1
    print(count)

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

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

Solution (Python):


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


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

print(cnt)

Solution (Python):
import math
def isPrime(z):
    if z == 1:
        return False
    if z == 2:
        return True
    for i in range(2, int(z**(1/2))+1):
        if z % i == 0:
            return False
    return True


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

Solution (Python):
import sys
input=sys.stdin.readline
n=int(input())
cnt=n
for i in range(n):
	a=int(input())
	if a==1:
		cnt-=1
		continue
	for j in range(2,min(int(a**0.5)+2,a)):
		if a%j==0:
			cnt-=1
			break
print(cnt)

Solution (Python):
A, *N,  = [int(s.split()[0]) for s in open(0)]
cnt = 0
for n in N:
    p = round(n**0.5)
    for i in range(2, p + 1):
        if n % i == 0:
            break
    else:
        cnt += 1
print(cnt)

Solution (Python):
import math

def is_prime(n):
    if n == 1: return False
    
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    
    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 sys
import math
input = sys.stdin.readline


def main():
    sc = Scan()
    n = sc.intarr()[0]
    array = sc.intarr_ver(n)
    count = 0
    for i in array:
        count += natural_num(i)
    print(count)


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


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def intarr_ver(self, n):
        return [int(input()) for _ in range(n)]

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


def display(array):
    for a in range(len(array)):
        if len(array) - a != 1:
            print(array[a], end=' ')
        else:
            print(array[a])


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


main()

Solution (Python):
import math

n = input()
b = int(n) - 1

num = []
maxnum = 0

nnc = int(0)

for j in range(int(n)):
	inpn = int(input())
	if inpn < 2 or inpn % 2 == 0:
		if inpn != 2:
			continue
		else:
			nnc += 1
			continue
	num.append(inpn)
	if maxnum < inpn:
		maxnum = inpn



rx = math.sqrt(maxnum)
rx += 2



for i in range(3, int(rx),2):
	for j in reversed(num):
		if math.sqrt(j) < i:
			nnc += 1
			num.remove(j)
		elif j%i == 0:
			num.remove(j)

nnc += len(num)

print(nnc)

Solution (Python):
def cnt_primenumber(arr):
    cnt = 0
    for i in range(len(arr)):
        if arr[i] == 1:
            continue
        flag = 1
        for j in range(2,int(arr[i]**0.5)+1):
            if arr[i] % j == 0:
                flag = 0
                break
        if flag:
            cnt += 1
    return cnt

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

print(cnt_primenumber(ls))

Solution (Python):
def p(n):
    import math
    a = math.floor(n**(1/2))
    if n == 2:
        return n
    elif n == 1:
        return 1
    elif n%2 == 0:
        return 1
    else:
        for i in range(3,a+1):
            if n%i == 0:
               return 1
    return n
N = int(input())           
c = 0
for i in range(N):
    n = int(input())
    if p(n) != 1:
        c += 1
print(c)

Solution (Python):




from math import sqrt


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



N = int(input())
ans = 0
for _ in range(N):
    x = int(input())
    ans += is_prime(x)

print(ans)

Solution (Python):
def main():
    A = set()
    n_prime = 0
    while True:
        try:
            x = int(input())
            A.add(x)
        except:
            break

    for x in A:
        n_prime += is_prime(x)

    print(n_prime)


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

main()

Solution (Python):
import math


def is_prime(n):
    if n == 2:
        return 1
    if n == 1 or n % 2 == 0:
        return 0

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


def main():
    num_el = int(input())
    nums = [int(input()) for i in range(num_el)]
    are_primes = [is_prime(num) for num in nums]
    print(sum(are_primes))


if __name__ == "__main__":
    main()

Solution (Python):
import math

n = int(input())
prime_count = 0
for _ in range(n):
    num = int(input())
    num_sqrt = math.floor(math.sqrt(num))
    is_prime = True
    for d in range(2, num_sqrt+1):
        if num % d == 0:
            is_prime = False
            break
    if is_prime:
        prime_count += 1
print(prime_count)