Problem:
 Score: 300 points    Problem Statement  Find the minimum prime number greater than or equal to X .      Notes  A prime number is an integer greater than 1 that cannot be evenly divided by any positive integer except 1 and itself.  For example, 2 , 3 , and 5 are prime numbers, while 4 and 6 are not.      Constraints   2 \le X \le 10^5  All values in input are integers.         Input  Input is given from Standard Input in the following format:  X       Output  Print the minimum prime number greater than or equal to X .        Sample Input 1 20      Sample Output 1 23  The minimum prime number greater than or equal to 20 is 23 .       Sample Input 2 2      Sample Output 2 2  X itself can be a prime number.       Sample Input 3 99992      Sample Output 3 100003

Solution (Python):
import math

x = int(input())

def Eratos(n):
    P,L = [],[True for _ in range(n+1)]
    for i in range(2,int(math.sqrt(n))+1):
        if L[i]:
            for j in range(2,n//i+1):
                L[i*j] = False
    for i in range(2,n+1):
        if L[i]:
            P.append(i)
    return P

def b_search(A,key,left,right):
    mid = (left+right)//2
    if key <= A[0]:
        return A[0]
    elif key > A[len(A)-1]:
        return 10**9
    else:
        if A[mid] < key and key <= A[mid+1]:
            return A[mid+1]
        elif key > A[mid]:
            return b_search(A,key,mid,right)
        else:
            return b_search(A,key,left,mid)

P = Eratos(10**6)
ans = b_search(P,x,0,len(P))
print(ans)

Solution (Python):

x = int(input())

ans = x
while True:
    flag = True
    for i in range(2, x):
        if ans % i == 0:
            ans += 1
            flag = False
    if flag:
        print(ans)
        break

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

x = int(input())

i = x
while(i > 0):
    if is_prime(i):
        print(i)
        i = -1
    else:
        i+=1

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

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

    return True
  
n = int(input())
while not is_prime(n):
  n += 1
print(n)

Solution (Python):
from math import sqrt


def prime_check(a):
    for i in range(int(sqrt(a))):
        if a % (i + 2) == 0:
            return False
    return True


x = int(input())

if x != 2:
    while not(prime_check(x)):
        x += 1

print(x)

Solution (Python):
def isPrime(n):
  if n < 2:
    return False
  if n == 2:
    return True
  for p in range(2, n):
      if n % p == 0:
        return False
  return True
def main():
    X = int(input())
    while True:
        if isPrime(X) == True:
            print(X)
            break
        X += 1
main()

Solution (Python):
x = int(input())
def primechecker(n):
    if n != 2:
        for i in range(2,n):
            if n % i == 0:
                return False
                break
        return True
    else:
        return True

while primechecker(x) == False:
    x += 1

print(x)

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

i = X
while not is_prime(i):
    i += 1
print(i)

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

def is_prime(n):
  factors = []
  f = 2
  while f**2 <= n:
    if n % f == 0:
      n //= f
      factors.append(f)
    else:
      f += 1
  if len(factors) == 0:
    return True
  else:
    return False

ans = 0
i = X
while True:
  if is_prime(i):
    ans = i
    break
  else:
    i += 1
print(ans)

Solution (Python):
x=int(input())
for i in range(x,10**6):
    for j in range(2,i):
        if i%j==0:
            break 
    else:
         print(i)
         break

Solution (Python):
import math
x=int(input())

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

i=x
while prime(i)==False:
    i+=1
print(i)

Solution (Python):
import math

x = int(input())


def is_prime(n):
    if n < 2:
        return False
    if n % 2 == 0 and n > 2:
        return False
    return all(n % i for i in range(3, int(math.sqrt(n)) + 1, 2))


for n in range(100005):
    if n >= x and is_prime(n):
        print(n)
        break

Solution (Python):
x = int(input())
for i in range(x, 10**6):
    for n in range(2, i):
        if i % n == 0:
            break

    else:
         print(i)
         break

Solution (Python):

def is_prime_miller_rabin(n: int) -> bool:
    """Miller–Rabin primality test in O(k log^3 n).
    https://twitter.com/kiri8128/status/1241033090773860353
    https://www.wikiwand.com/en/Miller%E2%80%93Rabinprimalitytest
    """
    
    if n < 2:
        return False
    elif n in {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67}:
        return True
    elif (
        n % 2 == 0
        or n % 3 == 0
        or n % 5 == 0
        or n % 7 == 0
        or n % 11 == 0
        or n % 13 == 0
        or n % 17 == 0
        or n % 19 == 0
        or n % 23 == 0
        or n % 29 == 0
        or n % 31 == 0
        or n % 37 == 0
        or n % 41 == 0
        or n % 43 == 0
        or n % 47 == 0
        or n % 53 == 0
        or n % 59 == 0
        or n % 61 == 0
        or n % 67 == 0
    ):
        return False

    
    if n < 2047:
        witnesses = [2]
    elif n < 1373653:
        witnesses = [2, 3]
    elif n < 9080191:
        witnesses = [31, 73]
    elif n < 25326001:
        witnesses = [2, 3, 5]
    elif n < 3215031751:
        witnesses = [2, 3, 5, 7]
    elif n < 4759123141:
        witnesses = [2, 7, 61]
    elif n < 1122004669633:
        witnesses = [2, 13, 23, 1662803]
    elif n < 2152302898747:
        witnesses = [2, 3, 5, 7, 11]
    elif n < 3474749660383:
        witnesses = [2, 3, 5, 7, 11, 13]
    elif n < 341550071728321:
        witnesses = [2, 3, 5, 7, 11, 13, 17]
    elif n < 3825123056546413051:
        witnesses = [2, 3, 5, 7, 11, 13, 17, 19, 23]
    elif n < 318665857834031151167461:
        witnesses = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]
    else:  
        witnesses = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41]

    d = n - 1
    d = d // (d & -d)

    for a in witnesses:
        y = pow(a, d, n)
        if y == 1:
            continue
        t = d
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1:
                return False
            t <<= 1
    return True


def main():
    N = int(input())
    if N != 2 and N % 2 == 0:
        N += 1
    while not is_prime_miller_rabin(N):
        N += 2
    print(N)


if __name__ == "__main__":
    main()

Solution (Python):


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

    i = 2
    while i*i <= n:
        if n%i == 0: return False
        i += 1
    return True


def solve():
    X = int(input())

    
    x = X
    while not is_prime(x):
        x += 1
    print(x)


if __name__ == "__main__":
    solve()

Solution (Python):
x = int(input())
for i in range(x, 2*x):
  n = 0
  for j in range(2, i+1):
    if i % j == 0:
      n += 1
  if n == 1:
    print(i)
    quit()

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

def is_prime(x):
    if (x==0 or x==1):
        return False
    for n in range(2,x-1):
        if (x % n) == 0:
            return False
    else:
        return True
    
while True:
    if is_prime(tmp):
        print(tmp)
        break
    else:
        tmp += 1

Solution (Python):



def get_prime(x):
    for i in range(2, x+1):
        amari = x%i
        
        if amari == 0:
            if i == x:
                return x
            else:
                return -1
        else:
            continue
    
    return x

X  = int(input())

flag = True
num = 0
answer = 0
while flag:
    v = X+num 
    if get_prime(v) > 0:
        flag = False
    num += 1

print(v)

Solution (Python):
X = int(input())
if X == 2:
    print(X)
    exit(0)
while 1:
    for i in range(2, X):
        if X % i == 0:
            break
        elif i == X - 1 and X % i != 0:
            print(X)
            exit(0)
    X += 1

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

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

result = n
while(not is_prime(result)):
    result += 1

print(result)

Solution (Python):
from bisect import bisect_left

def get_primes(n):
    if not isinstance(n, int):
        raise TypeError('n is int-type.')
    if n < 2:
        raise ValueError('n is more than 2')
    
    from math import sqrt 
    def _sieve_of_eratosthenes(n):
        primes = []
        limit = sqrt(n)
        data = [i + 1 for i in range(1, n)]
        while True:
            p = data[0]
            if limit <= p:
                return primes + data
            primes.append(p)
            data = [e for e in data if e % p != 0]
    return _sieve_of_eratosthenes(n)

primes = get_primes(10**5 + 3)
print(primes[bisect_left(primes, int(input()))])

Solution (Python):
from bisect import bisect_left, bisect_right

def get_primes(n):
    if not isinstance(n, int):
        raise TypeError('n is int-type.')
    if n < 2:
        raise ValueError('n is more than 2')
    
    from math import sqrt 
    def _sieve_of_eratosthenes(n):
        primes = []
        limit = sqrt(n)
        data = [i + 1 for i in range(1, n)]
        while True:
            p = data[0]
            if limit <= p:
                return primes + data
            primes.append(p)
            data = [e for e in data if e % p != 0]
    return _sieve_of_eratosthenes(n)

primes = get_primes(10**5 + 3)
print(primes[bisect_left(primes, int(input()))])

Solution (Python):
def is_prime(num):
    if num == 1:
        raise ValueError("error!")
    d = 2
    while d * d <= num:
        if num % d == 0:
            return False
        d += 1
    return True

n = int(input())
for i in range(n, n+1000):
    if is_prime(i):
        print(i)
        exit()

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

n = int(input())
for i in range(n, n+1000):
    if is_prime(i):
        print(i)
        exit()