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: Runtime Error

Solution code:
from operator import itemgetter

def eratosthenes(n):
    table = [True] * (n + 1)
    table[0] = table[1] = True
    for i in range(2, int(round(pow(n, 0.5)))):
        if not table[i]:
            continue
        for j in range(i + i, n, i):
            table[j] = False
    return table

if __name__ == "__main__":
    N = int(input())
    f = itemgetter(*[int(input()) for _ in range(N)])
    print(sum(f(eratosthenes(100000))))

Submission status: Runtime Error

Solution code:
def isPrime(num):
    if num == 2: return 1
    if num < 2 or num&1 == 0: return 0
    if pow(2, num-1, num) == 1: return 1

n = input()
s = 0
for i in xrange(n):
    s += isPrime(input())

print s

Submission status: Runtime Error

Solution code:
def composite(d,n,s):
    for a in (2,3,5,7):
        maybe_prime = False
        if pow(a,d,n) == 1:
            maybe_prime = True
            continue
        for i in range(s):
            if pow(a, 2**i * d, n) == n-1:
                maybe_prime = True
                break
        return not probably_prime
    return False

def is_prime(n):
    if n==2:
        return True
    elif n%2==0:
        return False
    else:
        d,s = n-1, 0
        while not d%2:
            d,s = d>>1,s+1
        return not composite(d,n,s)
r = []
n = int(input())
for i in range(n):
  n = int(input())
  if is_prime(n):
      if n not in r:
          r.append(n)

print(len(r))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

import numpy as np


def is_prime(number):
    # exclude even number
    if number == 2:
        return True
    elif number < 2 or number % 2 == 0:
        return False
    else:
        i = 3
        while i <= np.sqrt(number):
            if number % i == 0:
                return False
            i += 2
        return True


if __name__ == '__main__':
    N = input()
    numbers = [input() for i in xrange(N)]
    count = 0
    for i in xrange(len(numbers)):
        if is_prime(numbers[i]):
            count += 1
    print count

Submission status: Runtime Error

Solution code:
import sys
import math


prime_numbers = [2, 3, 5, 7]

def prime_numbers_under(num):
  global prime_numbers

  if max(prime_numbers) > num:
    return list(filter(lambda x: x <= num, prime_numbers))

  primes = prime_numbers_under(num - 1)

  for i in primes:
    if num % i == 0:
      break
  else:
    primes.append(num)

  prime_numbers = primes
  return prime_numbers

def main():
  amount = 0

  length = int(input())
  for _ in range(0, length):
    i = int(input())
    check_max = math.floor(math.sqrt(i))
    for j in prime_numbers_under(check_max):
      if i % j == 0:
        break
    else:
      amount += 1

  print(amount)
  return 0


if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
def is_prime(n):
  if n in [2, 3, 5, 7]:
    return True
  elif 0 in [n%2, n%3, n%5, n%7]:
    return False
  else:
    check_max = math.floor(math.sqrl(n))
    for i in range(2, check_max):
      if n % i == 0:
        return False
    else:
      return True

def main():
  primes = []
  length = int(input())
  for _ in range(0, length):
    n = int(input())
    if is_prime(n):
      primes.append(n)

  print(len(primes))
  return 0


if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
mport math
import numpy as np
n = int(input())
A = [int(input()) for x in range(n)]
A_max = max(A)

#A_max?????§????´???°??¨???????????????
p_table = list(np.arange(2,A_max+1))
p_table
for p in p_table:
    j=2
    while 0 < j*p-2 < len(p_table):
            p_table[j*p-2] = 0
            j += 1
p_table = [x for x in p_table if x != 0]

count = 0
for a in A:
    if a in p_table:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
n = int(input())
A = [int(input()) for x in range(n)]
A_max = max(A)

#A_max?????§????´???°??¨???????????????
p_table = list(np.arange(2,A_max+1))
p_table
for p in p_table:
    j=2
    while 0 < j*p-2 < len(p_table):
            p_table[j*p-2] = 0
            j += 1
p_table = [x for x in p_table if x != 0]

count = 0
for a in A:
    if a in p_table:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
n = int(input())
A = [int(input()) for x in range(n)]
A_max = max(A)

p_table = list(np.arange(2,A_max+1))
p_table
for p in p_table:
    j=2
    while 0 < j*p-2 < len(p_table):
            p_table[j*p-2] = 0
            j += 1
p_table = [x for x in p_table if x != 0]

count = 0
for a in A:
    if a in p_table:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
n = int(input())
A = [int(input()) for x in range(n)]
A_max = max(A)

p_table = list(np.arange(2,A_max+1))
p_table
for p in p_table:
    j=2
    while 0 < j*p-2 < len(p_table):
            p_table[j*p-2] = 0
            j += 1
p_table = [x for x in p_table if x != 0]

count = 0
for a in A:
    if a in p_table:
        count += 1

print("aho")

Submission status: Runtime Error

Solution code:
for i in range(0, N):
    j = A[i] - 2
    if j == 0 or j == 1:
        counter += 1
    else:
        while j > 1:
            if A[i] % j == 0:
                break
            else:
                j -= 1
        else:
            counter += 1

Submission status: Runtime Error

Solution code:
import math
n = input()
c = 0

for i in range(n):
    x = input()
    if x == 1:
        x = 0
    for j in range(2,math.floor(math.sqrt(x))+ 1):
        if x % j == 0:
            x = 0
            break
        if x != 0:
            c += 1	
print(c)

Submission status: Runtime Error

Solution code:
import math
n = input()
c = 0

for i in range(n):
    x = input()
    if x == 1:
        x = 0
    for j in range(2,math.floor(math.sqrt(x))+ 1):
        if x % j == 0:
            x = 0
            break
    if x != 0:
        c += 1	
print(c)

Submission status: Runtime Error

Solution code:
import math
n = input()
c = 0

for i in range(n):
    x = input()
    if x == 1:
        x = 0
    for j in range(2,math.floor(math.sqrt(float(x)))+ 1):
        if x % j == 0:
            x = 0
            break
    if x != 0:
        c += 1	
print(c)

Submission status: Runtime Error

Solution code:
from math import sqrt
def isprime(farm, prime):
	
	first = min(farm)
	prime.append(first)
	maxfarm = max(farm)
	dellst = range(first, maxfarm+1, first)
	farm = set(farm - set(dellst))
	if len(farm) > 0 and sqrt(maxfarm) > first:
		return isprime(farm, prime)
	else:
		return prime.extend(farm)

n = int(input())
inlst = []
for i in range(n):
	inlst.append(int(input()))
	
farm = set(range(2, max(inlst)+1, 1))
prime = [1]

if len(farm) > 0:
	isprime(farm, prime)
	
out = list(set(inlst) & set(prime))
print(len(out))

Submission status: Runtime Error

Solution code:
from math import sqrt
def isprime(farm, prime):
	
	first = min(farm)
	prime.append(first)
	maxfarm = max(farm)
	dellst = range(first, maxfarm+1, first)
	farm = set(farm - set(dellst))
	if len(farm) > 0 and sqrt(maxfarm) > first:
		return isprime(farm, prime)
	else:
		return prime.extend(farm)

n = int(input())
inlst = []
for i in range(n):
	inlst.append(int(input()))
	
farm = set(range(3, max(inlst)+1, 2))
prime = [1,2]

if len(farm) > 0:
	isprime(farm, prime)
	
out = list(set(inlst) & set(prime))
print(len(out))

Submission status: Runtime Error

Solution code:
from math import sqrt
def isprime(inlst, i, sq):
	inlst = list(filter(lambda x: x % i is not 0 or x is i, inlst))
	if sq >= i:
		return isprime(inlst, i +2, sq)
	else:
		return inlst

n = int(input())
inlst = []
twonum = 0
for i in range(n):
	inlst.append(int(input()))
	if inlst[i] == 2:
			twonum += 1
	
inlst = list(filter(lambda x: x % 2 is not 0, inlst))
i = 3
maxin = max(inlst)
if len(inlst) > 0:
	inlst = isprime(inlst, i, int(sqrt(maxin)) + 1)
print(len(inlst) + twonum)

Submission status: Runtime Error

Solution code:
from math import sqrt
def isprime(inlst, i, sq):
	inlst = list(filter(lambda x: x % i is not 0 or x is i, inlst))
	if sq >= i:
		return isprime(inlst, i +2, sq)
	else:
		return inlst

n = int(input())
inlst = []
twonum = 0
for i in range(n):
	inlst.append(int(input()))
	
inlst = list(filter(lambda x: x % 2 is not 0 or x is 2, inlst))
i = 3
maxin = max(inlst)
if len(inlst) > 0:
	inlst = isprime(inlst, i, int(sqrt(maxin)) + 1)
print(len(inlst))

Submission status: Runtime Error

Solution code:
from math import sqrt
def isprime(inlst, i, sq):
    inlst = [x for x in inlst if x%i > 0 or x == i]
    if sq >= i:
        return isprime(inlst, i +2, sq)
    else:
        return inlst
 
n = int(input())
inlst = []
for i in range(n):
    inlst.append(int(input()))
inlst = [x for x in inlst if x%2 > 0 or x == 2]
i = 3
maxin = max(inlst)
if len(inlst) > 0:
    inlst = isprime(inlst, i, int(sqrt(maxin)) + 1)
print(len(inlst))

Submission status: Runtime Error

Solution code:
def isPrimeNum(x):
	# for speed up
	if x == 2:
		return True
	if x % 2 == 0:
		return False

	# check by only odd number 
	i = 3
	while i < x:
		if x % i == 0 or x % (x - i - 2) == 0:
			return False
		i += 2
		
	return True

# input
n = int(raw_input())

if n < 1 or n > 10000:
	exit()

count = 0

for i in range(0, n):
	e = int(raw_input())
	if e < 2 or e > 1000000000:
		exit()
	if isPrimeNum(e):
		count += 1

print count

Submission status: Runtime Error

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

def devisor(n):
    if n == 2:
        return 1
    else:
        if n < 2 or n % 2 == 0:
            return 0
        elif pow(2,n-1,n) == 1:
            return 1

for i in range(n):
    x = int(input())
    c += devisor(x)

print(c)

Submission status: Runtime Error

Solution code:
import math
num_max = 1000000
isPrimeNum = [True for i in range(0,num_max)]

isPrimeNum[0] == False
isPrimeNum[1] == False

for i in range(2, int(math.sqrt(num_max))):
    if isPrimeNum[i] == True:
        for j in range (i**2, num_max, i):
            isPrimeNum[j] = False
        


num_len = int(input())
cnt = 0

for i in range(num_len):
    num = int(input())
    if isPrimeNum[num]==True:
        cnt = cnt + 1

print(str(cnt))

Submission status: Runtime Error

Solution code:
import math
num_max = 100000
isPrimeNum = [True for i in range(0,num_max)]

isPrimeNum[0] == False
isPrimeNum[1] == False

for i in range(2, int(math.sqrt(num_max))):
    if isPrimeNum[i] == True:
        for j in range (i**2, num_max, i):
            isPrimeNum[j] = False
        


num_len = int(input())
cnt = 0

for i in range(num_len):
    num = int(input())
    if isPrimeNum[num]==True:
        cnt = cnt + 1

print(str(cnt))

Submission status: Runtime Error

Solution code:
import math
num_max = 1000
isPrimeNum = [True for i in range(0,num_max)]

isPrimeNum[0] == False
isPrimeNum[1] == False

for i in range(2, int(math.sqrt(num_max))):
    if isPrimeNum[i] == True:
        for j in range (i**2, num_max, i):
            isPrimeNum[j] = False
        


num_len = int(input())
cnt = 0

for i in range(num_len):
    num = int(input())
    if isPrimeNum[num]==True:
        cnt = cnt + 1

print(str(cnt))

Submission status: Runtime Error

Solution code:
import math
num_max = 100000
isPrimeNum = [True for i in range(0,num_max+1)]

isPrimeNum[0] == False
isPrimeNum[1] == False

for i in range(2, int(math.sqrt(num_max))):
    if isPrimeNum[i] == True:
        for j in range (i**2, num_max, i):
            isPrimeNum[j] = False
        


num_len = int(input())
cnt = 0

for i in range(num_len):
    num = int(input())
    if isPrimeNum[num]==True:
        cnt = cnt + 1

print(str(cnt))

Submission status: Runtime Error

Solution code:
import math
num_max = 10000000
isPrimeNum = [True for i in range(0,num_max+1)]

isPrimeNum[0] == False
isPrimeNum[1] == False

for i in range(2, int(math.sqrt(num_max))+1):
    if isPrimeNum[i] == True:
        for j in range (i**2, num_max, i):
            isPrimeNum[j] = False
        


num_len = int(input())
cnt = 0
for i in range(num_len):
    num = int(input())
    if isPrimeNum[num]==True:
        cnt = cnt + 1

print(str(cnt))

Submission status: Runtime Error

Solution code:
import math
n=input()
A=0
def is_prime(m):
 for i in range(2, int(math.sqrt(m))+1):
  if m%i==0:
   return False
  return True
for i in range(n):
 k=input()
 if is_prime(k):
 A+=1
print A

Submission status: Runtime Error

Solution code:
import math

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

num_prime = []
k = 0
while True:
    n = input()
    if n == '\x04':
        break
    if prime(int(n)):
        if not int(n) in num_prime:
            k += 1
            num_prime.append(int(n))

print(k)

Submission status: Runtime Error

Solution code:
import math

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

num_prime = []
k = 0
while True:
    try:
        n = input()
    except:
        break
    if prime(int(n)):
        if not int(n) in num_prime:
            k += 1
            num_prime.append(int(n))

print(k)

Submission status: Runtime Error

Solution code:
import math

p = [2]
    
def isprime(x):
    if x == 2:
        return True
    if x == 3:
        return True
    if max(p) < x**0.5:
        for j in range(max(p), math.floor(x**0.5) + 1):
            if all([j % k != 0 for k in p]):
                p.append(j)
    i = 0
    while i <= len(p)-1:
        if x%p[i] == 0:
            return False
        if p[i] > x**0.5:
            break;
        i += 1
    return True


n = int(input())
res = 0
for i in range(n):
    k = int(input())
    if isprime(k):
        res += 1
print(res, p)

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

Submission status: Runtime Error

Solution code:
import sys
import math

def isprime(n):
    ans = 1
    for i in range(2, n):
        x = i
        y = n % i
        if math.gcd(x, y) != 1:
            ans = 0
            break
    return ans


n = int(input())
p = 0
for i in map(int, sys.stdin.readlines()):
    p += isprime(i)

print(p)

Submission status: Runtime Error

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

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

    for i in range(3, sqrt(x), 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)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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
            else:
        if prime_ng == 0:
            cnt += 1
    elif n == 2:
        cnt += 1
print(cnt)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = list(map(int,input().split()))
print(int(n[0]/n[1]), n[0]%n[1], "{:f}".format(n[0]/n[1]))

Submission status: Runtime Error

Solution code:
def division(x,y):
    if y == 0:
        return x
    return  division(y, x%y)

def checker(x):
    for i in range(2,x//2+1):
        v = division(x,i)
        if v > 1 :
            return False
        else:
            return True

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

Submission status: Runtime Error

Solution code:
def checker(x):
    if x < 2 or x%2==0:
        return False
    for i in range(2,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)

Submission status: Runtime Error

Solution code:
def checker(x):
    if x < 2 or x % 2 == 0 :
        return False
    for i in range(2,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)

Submission status: Runtime Error

Solution code:
from math import ceil, sqrt

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

    if n % 2 == 0:
        return 0

    for i in range(3, ceil(sqrt(n)), 2):
        if pred(n, i):
            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)))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

def hurui(a):
    ret = [True for i in range(a+1)]
    for i in range(2, int(math.sqrt(a))+2):
        for j in range(i*2, a+1, i):
            ret[j] = False

    return ret

n = int(input())
l = hurui(10000)
ans = 0
for i in range(n):
    a = int(input())
    if l[a]:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
import math

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 math.pow(2, a-1, a) == 1:
            ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
count = 0
for i in range(n):
    x = int(input())
    if (x % i == 0):
        break
    else:
        count += 1
print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
count = 0
for i in range(n):
  x = int(input())
  for j in range(x):
    if x == 2:
      count += 1
    elif x % 2 == 0:
      continue
    else:
      if x % j != 0:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
n = int(input())
count = 0
for i in range(n):
    x = int(input())
    if (x == 2):
        count += 1
    else:
        while (j * j <= x):
            if (x % j == 0):
                break
            else:
                count += 1
print(count)

Submission status: Runtime Error

Solution code:
n = int(input())
count = 0
for i in range(n):
    x = int(input())
    if (x == 2):
        count += 1
    else:
        while (j * j <= x):
            if (x % j == 0):
                break
            else:
                count += 1
            j = j + 1
print(count)

Submission status: Runtime Error

Solution code:
n = int(input())
count = 0
for i in range(n):
    x = int(input())
    if (x < 2):
        break
    if (x == 2):
        count += 1
    else:
        while (j * j <= x):
            if (x % j == 0):
                break
            else:
                count += 1
            j = j + 1
print(count)

Submission status: Runtime Error

Solution code:
n = int(input())
count = 0
for i in range(n):
    x = int(input())
    if (x < 2):
        break
    if (x == 2):
        count += 1
    else:
        while (j * j <= x):
            if (x % j == 0):
                break
            else:
                count += 1
            j = j + 2
print(count)

Submission status: Runtime Error

Solution code:
n = int(input())
count = 0
for i in range(n):
    x = int(input())
    if (x < 2):
        break
    if (x == 2):
        count += 1
    else:
        while (j * j <= x):
            if (x % j == 0):
                break
            else:
                count += 1
            j += 2
print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

def isprime(number):
    if number == 2 or 2 ** (number -1) % number == 1:
        return 1 
    else:
        return 0
def countPrime(number,count):
    if isprime(number)== 1:
        count +=1
    return count
        
n = int(input())
c = 0
for i in range(n):
    c = countPrime(i,c)
print (c)

Submission status: Runtime Error

Solution code:
import sys


def isprime(n):
    '''check if integer n is a prime'''

    # make sure n is a positive integer
    n = abs(int(n))

    # 0 and 1 are not primes
    if n < 2:
        return False

    # 2 is the only even prime number
    if n == 2: 
        return True    

    # all other even numbers are not primes
    if not n & 1: 
        return False

    # range starts with 3 and only needs to go up 
    # the square root of n for all odd numbers
    for x in range(3, int(n**0.5) + 1, 2):
        if n % x == 0:
            return False

    return True


max = sys.stdin.readline()
answer = []

for x in [0..max-1]:
    n = sys.stdin.readline()
    if isprime(n):
        answer.append(n)

for x in answer:
    print(x + " ")

Submission status: Runtime Error

Solution code:
import sys


def isprime(n):
    '''check if integer n is a prime'''

    # make sure n is a positive integer
    n = abs(int(n))

    # 0 and 1 are not primes
    if n < 2:
        return False

    # 2 is the only even prime number
    if n == 2: 
        return True    

    # all other even numbers are not primes
    if not n & 1: 
        return False

    # range starts with 3 and only needs to go up 
    # the square root of n for all odd numbers
    for x in range(3, int(n**0.5) + 1, 2):
        if n % x == 0:
            return False

    return True


max = sys.stdin.readline()
answer = []

for x in [0..max-1]:
    n = sys.stdin.readline()
    if isprime(n):
        answer.append(n)

print(' '.join(answer))

Submission status: Runtime Error

Solution code:
import sys


def isprime(n):
    '''check if integer n is a prime'''

    # make sure n is a positive integer
    n = abs(int(n))

    # 0 and 1 are not primes
    if n < 2:
        return False

    # 2 is the only even prime number
    if n == 2: 
        return True    

    # all other even numbers are not primes
    if not n & 1: 
        return False

    # range starts with 3 and only needs to go up 
    # the square root of n for all odd numbers
    for x in range(3, int(n**0.5) + 1, 2):
        if n % x == 0:
            return False

    return True


max = sys.stdin.readline()
answer = []

for x in range(max):
    n = sys.stdin.readline()
    if isprime(n):
        answer.append(n)

print(' '.join(answer))

Submission status: Runtime Error

Solution code:
import sys


def isprime(n):
    '''check if integer n is a prime'''

    # make sure n is a positive integer
    n = abs(int(n))

    # 0 and 1 are not primes
    if n < 2:
        return False

    # 2 is the only even prime number
    if n == 2: 
        return True    

    # all other even numbers are not primes
    if not n & 1: 
        return False

    # range starts with 3 and only needs to go up 
    # the square root of n for all odd numbers
    for x in range(3, int(n**0.5) + 1, 2):
        if n % x == 0:
            return False

    return True


max = sys.stdin.readline()
answer = []

for x in range(max):
    n = sys.stdin.readline()
    if isprime(int(n)):
        answer.append(n)

print(' '.join(answer))

Submission status: Runtime Error

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

t = 0
for i in range(int(input())):
    if inPrime(int(input())):
        t += 1
print(t)

Submission status: Runtime Error

Solution code:
def p(n):
 for i in range(2,x//2):
  if x%i==0:return 0
 return 1
n=int(input())
print(sum([p(int(input()))for _ in range(n)]))

Submission status: Runtime Error

Solution code:
import math
N = int(input())
A = [int(input()) for i in range(N)]
c=0
for i in range(N):
    x=abs(A[i])
    if x==2:c+=1
    if x<2 or x&1==0:continue
    if pow(1,x-1,x)==1 c+=1

print(c)

Submission status: Runtime Error

Solution code:
def is_prime(x):
    if x==2:
        return 1
    elif x&1==0:
        return 0
    else:
        return pow(2,x-1,x)==1
N = int(input())
for i in range(N):
    n=int(input())
    c+=is_prime(n)
print(c)

Submission status: Runtime Error

Solution code:
def is_prime(x):
    if x==2:
        return 1
    elif x&1==0:
        return 0
    elif pow(2,x-1,x)==1:
        return 1
    else:
        return 0
N = int(input())
for i in range(N):
    n=int(input())
    c+=is_prime(n)
print(c)

Submission status: Runtime Error

Solution code:
import sys

def is_prime(x,y):
    if(y >= x-1):
        return 1
    elif(x % y == 0):
        return 0
    return 1 and is_prime(x,y+2)

a = ""
l = []
count = 0
for input in sys.stdin:
    a += input
l = sorted(set(a.split()))
for input in l:
    if(int(input) > 2 and int(input) % 2 != 0 and is_prime(int(input),3)):
        count += 1
    elif(int(input) == 2):
        count += 1
print count

Submission status: Runtime Error

Solution code:
import sys

count = 0

inarr = 10001 * [False]

for line in sys.stdin:
    n = int(line)
    inarr[n] = True

if inarr[2]:
    count += 1


for n in range(3, 10001):
    if not inarr[n]:
        continue

    jdg = True
    for i in range(2, n):
        if n % i == 0:
            jdg = False
            break
    if jdg:
        count += 1
        
print(count)

Submission status: Runtime Error

Solution code:
n = input()
cnt = 0
for i in range(0, n):
	x =  input() 
	if (x > 1) :
		for j in range(2, x):
			if (x%j == 0):
				break
			if (j== x-1):
				cnt = cnt + 1
	
	if (x == 2):
		cnt = cnt + 1

print(cnt)

Submission status: Runtime Error

Solution code:
for _ in[0]*int(input()):
 x=int(input())
 if 2 in[x,pow(2,x,x)]:c+=1
print(c)

Submission status: Runtime Error

Solution code:
import math
import sys

def is_prime(x):
    if x==1: return 0
    if x==2: return 1
    n = 3
    while n <= math.sqrt(x):
        if x % n == 0:
            return 1
        n += 2
    return 1

count = 0
for line in sys.stdin:
    x = int(raw_input())
    count += is_prime(x)
print count
~

Submission status: Runtime Error

Solution code:
n=int(input())
nums=[]
for i in range(n):
    nums.append(int(input()))
count=0
for i in range(n):
    for j in range(2,int(sqrt(nums[i])+1)):
        if nums[i]%j==0:
            break
    count+=1
print(count)

Submission status: Runtime Error

Solution code:
isprime :: Int -> Bool
isprime 1 = False
isprime 2 = True
isprime n = not $ or (map ((0==).(mod n)) [2..ceil])
    where ceil = ceiling (sqrt (fromIntegral n))

getNLines :: Int -> IO [String]
getNLines n = do
    ans <- sequence $ take n (repeat getLine)
    return ans

main = do
    n <- getLine >>= return . read
    numbers <- getNLines n
    let integers = map read numbers
    print $ foldl (\acc x -> if isprime x then acc+1 else acc) 0 integers

Submission status: Runtime Error

Solution code:
import sys
input()
print(len(1 for x in map(int,sys.stdin)if 2 in[x,pow(2,x,x)]))

Submission status: Runtime Error

Solution code:
def main2():
    n = 6
    alist = [2, 3, 4, 5, 6, 7]
    print(alist)

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

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

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

    print(sum([is_prime(n) for n in alist]))

main2()

Submission status: Runtime Error

Solution code:
def main2():
    alist = []
    for _ in range(int(input())):
        alist.append(int(input()))

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

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

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

    print(sum([is_prime(n) for n in alist]))

main2()

Submission status: Runtime Error

Solution code:
import math


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

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

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

    return True


n = int(input())
numbers = [int(input()) for i in n]


count = 0
for i in range(n):
    if is_prime(numbers[i]) is True:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
ef is_prime(n):
  t = 2
  while n > t:
    if n % t == 0: return 0
    t += 1
  return 1

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

Submission status: Runtime Error

Solution code:
count = 0
n = int(input())
def ifprime(num):
  for i in range(2,num ** 0.5 + 1):
    if num % i:
      continue
    else:
      return False
  return True
for _ in range(n):
  a = int(input())
  if ifprime(a):
    count += 1
print(count)