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

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

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

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

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

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

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

    
    
    


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)

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

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

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

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

Solution (Python):
def check(n):
    if n == 1:
        return 0
    elif n == 2 or n == 3:
        return 1
    else:
        for i in range(2,int(n**(1/2))+1):
            if n % i == 0:
                return 0
        return 1
n = int(input())
s = [0 for i in range(n)]
count = 0
for i in range(n):
    s[i] = int(input())
    if check(s[i]) == 1:
        count += 1
print(count)

Solution (Python):

import math
import random
def miller_rabin_test(n, k=20):
    """n > 2????´???°???????????????"""
    if n == 2: return True
    li = []
    if n % 2 == 0:
        return False
    s = 0
    n1 = n - 1
    d = n1
    while d % 2 == 0:
        s += 1
        d //= 2
    for i in range(k):
        a = random.randint(1, n1)
        first = 1 != pow(a, d, n)
        li.clear()
        for r in range(0, s): 
            result = pow(a, pow(2,r)*d, n)
            li.append(result)
        if first and li.count(n1) == 0:
            return False 
    return True
counter = 0
for _ in range(int(input())):
	if miller_rabin_test(int(input())): counter += 1
print(counter)

Solution (Python):

def isPrime_naive(x):
    if x <= 1:
        return False
    for i in xrange(2, x):
        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*i <= x:
        if x % i == 0:
            return False
        i += 2
    return True

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