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 ≤ 108

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



Sample input:
5
2
3
4
5
6


Sample output:
3

Submission status: Accepted

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

num = int(input())
result = 0
for _ in range(num):
    target = int(input())
    result += isPrime(target)

print(result)

Submission status: Accepted

Solution code:
def is_prime(p):
    for i in range(2, int(p**(1/2))+ 1):
        if p % i == 0:
            return False
    
    return True


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

print(count)

Submission status: Accepted

Solution code:
import math

N = int(input())
A = []
prim = 0
for i in range(N):
    x = int(input())
    A.append(x)

for j in range(len(A)):
    num = 0

    if A[j] == 2:
        prim += 1
    else:
        for k in range(2, int(math.sqrt(A[j]))+1):
            if A[j] == 1:
                pass
            elif A[j]%k == 0:
                break
        else:
            prim += 1
print(prim)

Submission status: Accepted

Solution code:
N = int(input())
not_prime = 0
 
for loop in range(N):
    num = int(input())
 
    if num%2 == 0:
        if num != 2:
            not_prime += 1
    else:
        for i in range(3,num,2):
            if i*i > num:
                break
            if num%i == 0:
                not_prime += 1
                break
 
print("%d"%(N-not_prime))

Submission status: Accepted

Solution code:
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

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

Submission status: Accepted

Solution code:
count = int(input())
primeCount = 0
for i in range(count):
    num = int(input())
    beki = num**(1/2)
    if beki%1 == 0:
        chkmax = beki//1
    else:
        chkmax = beki//1 + 1
    chkmax = int(chkmax)

    flag = True
    for i in range(2,chkmax+1):
        if num%i == 0:
            flag = False
            break

    if flag or num == 2:
        primeCount += 1

print(primeCount)

Submission status: Accepted

Solution code:
#! python3
# primeNumber.py - 素数を判定するアルゴリズム

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

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

Submission status: Accepted

Solution code:
def isPrime(x):
    if x <= 1:
        return 0
    for i in range(2, int(x**0.5) + 1):
        if x % i == 0:
            return 0
    return 1

n = int(input())
sum = 0

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

Submission status: Accepted

Solution code:
from math import sqrt
#from math import floor
def is_prime(n):
	if n<4:
		return True
	else:
		s = int(sqrt(n))
		for i in range(2, s+1):
			if not n%i:
				return False
		return True
n = int(input())
count = 0
for i in range(n):
    if is_prime(int(input())):
        count += 1
print(count)

Submission status: Accepted

Solution code:
n = int(input())
mlist = []
plist = [2]
for i in range(3,10000):
    count = 0
    for k in plist:
        if (i%k != 0):
            count += 1
        else:
            break
    if (count == len(plist)):
        plist.append(i)
def check(m):
    for p in plist:
        if (m <= p):
            return True
        if m%p == 0:
            return False     ##한번이라도 False가 return되면 False가 되기에 prime인지 아닌지 check가능
    return True

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

Submission status: Accepted

Solution code:
#prime number
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**0.5+1),2):
        if x % i == 0:
            return False
        
    return True

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

Submission status: Accepted

Solution code:
n = int(input())
total = 0
for i in range(n) :
    x = int(input())
    a = 1
    b = True
    if x == 1 :
        b = False
    while a**2 < x and x != 2 :
        a += 1
        if x%a == 0 :
            b = False
            break  
    if b :
        total += 1
print (total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
import math
def isPrime(n):
    if n == 1:
        return False
    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
            

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

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(N):
    n = int(input())
    if n==2:ans+=1
    elif n%2==0:continue
    for j in range(3,n+1,2):
        if j**2 > n:
            ans+=1
            break
        if n%j==0:break
print(ans)

Submission status: Accepted

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

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

for k in range(n):
    x=int(input())
    if is_prime(x):
        count+=1
print(count)

Submission status: Accepted

Solution code:
def isPrime(num):
    '''int -> boolean
    return True/False of Is num a prime number 
    '''
    if num == 2:
        return True
    elif num <= 1 or num %2 == 0:
        return False
    import math
    maxp = int(math.sqrt(num))
    for p in range(3, maxp + 1):
        if num % p == 0:
            return False
    return True
n = int(input())
cnt = 0
for i in range(n):
    num = int(input())
    if isPrime(num) == True:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
def isPrime(num):
        if num <= 1:
                return False
        elif num == 2 or num == 3:
                return True
        if num % 2 == 0 or num % 3 == 0:
                return False
        if not(num % 6 == 1) and not(num % 6 == 5):
                return False
        i = 5
        while i * i <= num:
                if num % i == 0 or num % (i + 2) == 0:
                        return False
                i += 6
        return True

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

print(count)

Submission status: Accepted

Solution code:
import sys, math
input = sys.stdin.readline

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())
IN = set([int(input()) for _ in range(N)])

cnt = 0

for x in IN:
    if is_prime(x):
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import math

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

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

print(len([n for n in nums if is_prime(n)]))

Submission status: Accepted

Solution code:
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())
nums = list(set([int(input()) for _ in range(n)]))
print(len([num for num in nums if is_prime(num)]))

Submission status: Accepted

Solution code:
import math

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

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

    i = 3
    while i <= math.sqrt(x) :
        if x % i == 0 :
            return 0
        i += 2
    else :
        return 1
        
ans=0
N=int(input())
for k in range(N):
    x=int(input())
    ans = ans + isprime(x)
print(ans)

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
#素数を判定するプログラム
import math

n = int(input())
count = 0

for loop in range(n):
    a = int(input())
    flag = True
    if a == 1:
        flag = False
    elif a == 2:
        flag = True
    else:
        if a % 2 == 0:
            flag = False
        for j in range(3, int(math.sqrt(a))+1, 2):
            if a % j == 0:
                flag = False
    if flag:
        count += 1

print(count)

Submission status: Accepted

Solution code:
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

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

print(count)

Submission status: Accepted

Solution code:
def prime(n):
    if n==1:return 0
    for i in range(2,int(n**0.5)+1):
        if n%i==0:
            return 0
    return 1

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

Submission status: Accepted

Solution code:
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

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

Submission status: Accepted

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
nNum = [int(stdin.readline().rstrip()) for i in range(n)]

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

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

    return True

print(len([True for x in nNum if isPrime(x)]))

Submission status: Accepted

Solution code:
import math
input_num = int(input())
input_list = [int(input()) for i in range(input_num)]
input_list.sort()

max = input_list[len(input_list)-1]
sqrt_max = int(math.sqrt(max))
nums = [i + 2 for i in range(sqrt_max - 1)]
for num in input_list:
    if num > sqrt_max:
        nums.append(num)

prime_nums = []
while True:
    first_num = nums[0]
    if first_num > math.sqrt(max):
        break
    prime_nums.append(first_num)
    deleted = 0
    for i in range(len(nums)):
        index = i - deleted
        if nums[index] % first_num == 0:
            del nums[index]
            deleted += 1

prime_nums.extend(nums)

prime_count = 0
for num in input_list:
    if num in prime_nums:
        prime_count += 1

print(prime_count)

Submission status: Accepted

Solution code:
def isPrime(num):
    if num == 2 or num == 3:
        return True
    elif num % 2 == 0:
        return False

    p = 3
    sqrt_num = int(num ** 0.5)
    while True:
        if num % p == 0:
            return False

        if sqrt_num >= p:
            p += 2
        else:
            return True


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

print(len(list(filter(lambda x: isPrime(x), input_num))))

Submission status: Accepted

Solution code:
from math import sqrt
def isPrime(number):
    divisor = 3
    if number == 2:
        return True
    if number % 2 == 0:
        return False
    while divisor <= sqrt(number):
        if number % divisor == 0:
            return False
        divisor += 2
    return True

def main():
    N = eval(input())
    count = 0
    for i in range(0, N):
        number = eval(input())
        if (isPrime(number)):
            count += 1
    print(count)

main()

Submission status: Accepted

Solution code:
import math
n = int(input())
cnt = 0
for _ in range(n):
    x = int(input())
    if x == 2: cnt += 1
    if x < 2 or x%2 == 0: continue
    i = 3
    while i <= math.sqrt(x):
        if x%i == 0: break
        i += 2
    if not i <= math.sqrt(x): cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))
count=0
for i in range(len(A)):
    if A[i]<2:
        continue
    elif A[i]==2:
        count += 1
        continue
    if A[i]%2==0:
        continue
    elif A[i]>=3:
        j=3
        flag=0
        while j<=A[i]/j:
            if A[i]%j==0:
                flag=1
                break
            j += 2
        if flag==0:
            count += 1
print(count)

Submission status: Accepted

Solution code:
import math

n = int(input())
a = [int(input()) for i in range(n)]
n = 0
for x in a:
    if x == 2:
        n += 1
        continue
    if x < 2 or x % 2 == 0:
        continue
    i = 3
    while i <= math.sqrt(x):
        if x % i == 0:
            n -= 1
            break
        i = i + 2
    n += 1
print(n)

Submission status: Accepted

Solution code:
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

if __name__ == "__main__":
    n = int(input())
    a = []
    for l in range(0,n,1):
        a.append(int(input()))
    cnt = 0
    for x in a:
        if isPrime(x):
            cnt += 1
    print(cnt)

Submission status: Accepted

Solution code:
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
cnt=0

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

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())

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

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

print(ans)

Submission status: Accepted

Solution code:
import math

primes = [2, 3, 5, 7]

def is_prime(n):
    n_sqrt = math.sqrt(n)
    if n_sqrt.is_integer():
        return False
    n_sqrt = int(n_sqrt+1)

    if n in primes:
        return True
    if any(n % i == 0 for i in primes):
        return False
    if n > 10 and any(n % i == 0 for i in range(2, n_sqrt)):
        return False
    return True

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

print(len(list(filter(is_prime, a))))

Submission status: Accepted

Solution code:
import math

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


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

main()

Submission status: Accepted

Solution code:
n = int(input())
count = 0
j = 2

for i in range(n):
    tmp = int(input())
    limit = tmp ** 0.5
    r = round(limit)


    if r > 2:
        for j in range(2, r+1):
            if tmp%j == 0:
                count += 1
                break
    else:
        if tmp == 4:
            count += 1
        if tmp == 6:
            count += 1

print(n-count)

Submission status: Accepted

Solution code:
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

n = int(input())
count = 0

for i in range(0, n):
    b = int(input())

    if isprime(b):
        count += 1

print(count)

Submission status: Accepted

Solution code:
import math

def fun(n):
    if n%2==0 and n!=2:return False
    for i in range(3,round(math.sqrt(n))+1,2):
        if n%i==0:return False
    else: return True

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

Submission status: Accepted

Solution code:
import math


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


def main():
    num = int(input())
    count_prime = 0
    for i in range(num):
        if is_prime(int(input())):
            count_prime += 1
    print(count_prime)
    return

main()

Submission status: Accepted

Solution code:
import math
n=int(input())

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

c=0
for i in range(n):
    m=int(input())
    if is_prime(m) is True:
        c+=1
    
print(c)

Submission status: Accepted

Solution code:
from math import sqrt

n = int(input())

count = 0

def isPrime(num):
    if num == 2:
        return True
    if num % 2 == 0:
        return False
    i = 3
    while i <= sqrt(num):
        if num % i == 0:
            return False
        i += 1
    return True

for i in range(0, n):
    num = int(input())

    if isPrime(num):
        count += 1

print(count)

Submission status: Accepted

Solution code:
# Prime Numbers
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_C&lang=jp

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

cnt = 0
n = int(input())
while ( n > 0):
    n = n -1
    s = int(input())
    if ( isPrime(s) == True ):
        cnt += 1
print (cnt)

Submission status: Accepted

Solution code:
import math
n=int(input())
nums=[int(input()) for i in range(n)]

count=0
for num in nums:
    flag=0
    # check 2
    if num == 2:
        count+=1
        continue

    #skip
    if num%2==0:
        continue
    
    for p in range(3, int(math.sqrt(num))+1, 2):
        if num%p==0:
            flag=1
            break
        
    if flag==0:
        count+=1
        
print(count)

Submission status: Accepted

Solution code:
import math


def is_prime(num):
    if num == 2:
        return True
    elif num % 2 == 0:
        return False

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


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


if __name__ == "__main__":
    """
    1 <= n <= 10000
    x <= 10^8
    """
    solve()

Submission status: Accepted

Solution code:
def is_prime(n):
    n = abs(n)
    if n == 2:
        return True
    if n < 2 or n % 2 == 0:
        return False
    return pow(2, n - 1, n) == 1

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

Submission status: Accepted

Solution code:
import math

n = int(input())

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

ans = 0

for l in nlist:
    if l == 1:
        continue
    flag = 1
    for i in range(2, int(math.sqrt(l)) + 1):
        if l % i == 0:
            flag = 0
            break
    if flag:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
from enum import Enum
import sys
import math
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
 
N = int(input())
 
ans = 0
 
for loop in range(N):
    num = int(input())
 
    if num == 1:
        ans += 1
    if num <= 3:
        continue
    elif num%2 == 0:
        ans += 1
    else:
        tmp_num = 3
        while True:
            if tmp_num*tmp_num > num:
                break
            if num%tmp_num == 0:
                ans += 1
                break
            tmp_num += 2
 
print("%d"%(N-ans))

Submission status: Accepted

Solution code:
def judge_prime(n):
    if n == 1:
        return False
    else:
        cnt = 2
        while cnt ** 2 <= n:
            if n % cnt == 0:
                return  False
            else:
                cnt += 1
        return  True

cnt_prime = 0

N = int(input())
for i in range(N):
    judge_num = int(input())
    if judge_prime(judge_num):
        cnt_prime += 1
        
print(cnt_prime)

Submission status: Accepted

Solution code:
def isprime(x):
    if x == 2:
        return True
    elif (x < 2) | (x%2 == 0):
        return False
    for i in range(3, int(x**0.5)+1, 2):
        if x%i == 0:
            return False
    return True


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

Submission status: Accepted

Solution code:
import math
num=int(input())
n=[]
for i in range(num):
    b=int(input())
    if b==2 or b%2!=0:
        n.append(b)
count=0
for i in n:
    a=0
    for j in range(1,int(math.sqrt(i))+1):
        if i%j==0:
            a+=1
            if a>1:
                break
    if a==1:
        count+=1
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
pn_L = [2, 3, 5] 
for i in range(7, 10000):
    for j in range(2, i):
        if i % j == 0:
            break
    else:
        pn_L.append(i)

pn = 0
for i in range(N):
    n = int(input())
    if n <= 10000:
        if n in pn_L:
            pn += 1
    else:
        sqn = round(n**0.5)
        L = [p for p in pn_L if p <= sqn]
        for j in L:
            if n % j == 0:
                break
        else:
            pn += 1
print(pn)

Submission status: Accepted

Solution code:
n=int(input())
count=0
for i in range(0,n):
    x=int(input())
    if(x==2 or x==3):
        count+=1
    elif(x%2!=0):
        d=3
        while(1):
            if(x%d!=0):
                d+=2
            else:
                break
            if(x < d*d):
                count+=1
                break
print(count)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
import math

def isPrime(x):
    if x == 2:
        return 1
    elif x < 2 or x % 2 == 0:
        return 0
    i = 3
    while i <= math.sqrt(x):
        if x % i == 0:
            return 0
        i += 2
    return 1

arr = []
cnt = 0
            
n = int(input())
for i in range(n):
    x = int(input())
    arr.append(x)

for i in arr:
    cnt += isPrime(i)
    
print(cnt)

Submission status: Accepted

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

print(sum([isPrimeNum(int(input())) for _ in range(int(input()))]))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
def isprime(a,kore):
    for i in range(0,len(kore)):
        if a>kore[i] and a%kore[i]==0:
            return 0
    return 1
#main
n=int(input())
cnt=0
primes=[0,]*10001
primes[2]=1
kore=[]
for i in range(2,10001):
    for j in range(i,10001,i):
        if j==i and primes[j]!=-1:
            primes[j]=1
            kore.append(j)
        else:
            primes[j]=-1
for i in range(0,n):
    a=int(input())
    cnt+=isprime(a,kore)
print(str(cnt))

Submission status: Accepted

Solution code:
n =  int(input())
index=0
count=0
while index<n:
    number = int(input())
    stock =[]
    devideN = 1
    while devideN <= number:
        if len(stock)>2:
            break
        elif devideN==10000:
            stock.append(devideN)
            break
        elif number%devideN==0:
            if devideN!=1 and devideN!=number:
                break
            else:
                stock.append(devideN)
        else:
            pass
        devideN+=1
    if len(stock) == 2:
        count+=1
    index+=1
print(count)

Submission status: Accepted

Solution code:
import math
def isprime(x):
    if x == 2:
        return True

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


if __name__ == "__main__":
    n = int(input())
    ans = 0
    for i in range(n):
        if isprime(int(input())):
            ans += 1

    print(ans)

Submission status: Accepted

Solution code:
import math

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

def main():
    N = int(input())
    ans = 0

    for i in range(N):
        k = int(input())

        if is_prime(k):
            ans += 1

    print(ans)

main()

Submission status: Accepted

Solution code:
from math import sqrt
N = int(input())
Numbers = []
for _ in range(N):
    Numbers.append(int(input()))
count = 0
for Num in Numbers:
    flag = True
    for j in range(2, int(sqrt(Num) + 1)):
        if Num % j == 0:
            flag = False
            break
    if flag:
        count += 1
print(count)

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
from math import sqrt


def main():
    list1 = []
    for _ in range(int(input())):
        list1.append(int(input()))
    prime_number = [2]
    for i in range(3, int(sqrt(max(list1)))+1, 2):
        prime = True
        for j in prime_number[:]:
            if i % j == 0:
                prime = False
                break
        if prime:
            prime_number.append(i)
    for i in list1[:]:
        if i == 2:
            continue
        else:
            for j in prime_number:
                if i % j == 0:
                    list1.remove(i)
                    break
                elif j**2 >= i:
                    break
    print(len(list1))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
cnt=0
n=int(input())
for i in range(n):
    s=int(input())
    for j in range(2,int(s**0.5)+2):
        if s%j==0:
            break
    if j>=int(s**0.5)+1:
        cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
import math as m

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

N = int(input())

number_of_prime = 0

for _ in range(N):
    if is_prime(int(input())):
        number_of_prime += 1

print(number_of_prime)

Submission status: Accepted

Solution code:
def isprime(x):
    import math
    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())
cnt = 0
for i in range(n):
    j = isprime(int(input()))
    if j == True:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
def is_primt(x):
    if x == 2:
        return True

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

    for i in range(3, int(x**0.5)+1, 2):
        if x % i == 0:
            return False

    return True


N = int(input())
cnt = 0
for _ in range(N):
    i = int(input())
    cnt += is_primt(i)
print(cnt)

Submission status: Accepted

Solution code:
from math import sqrt

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

    if x % 2 == 0:
        return 0

    i = 3
    while i <= int(x/i):
        if x % i == 0:
            return 0
        i += 2

    return 1

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

    count = 0

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

    print(count)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math


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

    elif x % 2 == 0:
        return False

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

    # 3から始まる
    # 偶数は2以外は判定に用いないので一つずつ飛ばすために3,5,7と
    # i += 2となる。


n, cnt = int(input()), 0
num = [int(input()) for i in range(n)]
for i in num:
    if isprime(i) == True:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import math
def isprime(x):
    if x == 2:
        return 1
    
    if x < 2 or x % 2 == 0:
        return 0
    
    i = 3
    while i <= math.sqrt(x):
        if x % i == 0:
            return 0
        i = i + 2
    return 1
    
n = int(input())
cnt = 0
for i in range(n):
    cnt += isprime(int(input()))
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

Solution code:
def prime(n):
  p = 2
  while p * p <= n:
    if n % p == 0:
      return 0
    p += 1
  return 1

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

Submission status: Accepted

Solution code:
f=lambda x: 1 if x == 2 or x == 3 or (x>3 and x&1==1 and pow(2, x-1, x)==1) else 0
print(sum(f(int(input())) for _ in range(int(input()))))