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())
while True:
    key=1
    for k in range(2, int(math.sqrt(x)) + 1):
        if x % k == 0:
            key=0
    if key==1:
        print(x)
        exit()
    else:
        x += 1
print(x)

Solution (Python):
import math

x = int(input())

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

while True:
    if is_prime(x):
        print(x)
        exit()
    x += 1

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

X = int(input())
i = X

while 1:
    if not is_prime(i):
        i += 1
    else:
        ans = i
        print(i)
        break

Solution (Python):
import itertools
import collections

class PrimeFactorize:
    def __init__(self, n):
        self.prime_factor_table = self.create_prime_factor_table(n)

    
    def create_prime_factor_table(self, n):
        self.table = [0] * (n + 1)
        
        for i in range(2, n + 1):
            if self.table[i] == 0:
                for j in range(i + i, n + 1, i):
                    self.table[j] = i
        return self.table

    def prime_factor(self, n):
        prime_count = collections.Counter()
        
        while self.prime_factor_table[n] != 0:
            prime_count[self.prime_factor_table[n]] += 1
            n //= self.prime_factor_table[n]
        prime_count[n] += 1
        return prime_count

N = int(input())
pf = PrimeFactorize(10**5+5)

for i in range(N,10**5+5):
    if pf.prime_factor_table[i]==0:
        print(i)
        break

Solution (Python):
import math

x = int(input())

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

while True:
    if is_prime(x):
        print(x)
        break
    x += 1

Solution (Python):

import math
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 True
    return False


while is_prime(x):
    x += 1

print(x)

Solution (Python):
import math
N = int(input())
prime = True
if N == 2:
  print(2)
  exit()
else:
  for k in range(N, 110000):
    prime = True
    max = math.ceil(math.sqrt(k))
    for i in range(2, max+1):
      if k % i == 0:
        prime = False
        break
    if prime == True:
      ans = k
      break
print(ans)

Solution (Python):
import math

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

  if X == 2: return 2
  if X == 3: return 3
  if X == 4 or X == 5: return 5
  if X == 6 or X == 7: return 7
  if X == 8: return 11

  while True:
    if X % 2 != 0:
      for i in range(3, int(math.sqrt(X))+1, 2):
        if X % i == 0: break
      else: return X
    X += 1

ans = main()
print(ans)

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

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

for i in range(10**7):
    if i < X:
        continue
    elif is_prime(i) is True:
        print(i)
        exit()

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

Solution (Python):
X = int(input())
MAX = 10**5+3
num = 2
primes = [0 for _ in range(MAX+1)]


for num in range(2, int(MAX**0.5)):
  if primes[num] == 1:
    continue
  for i in range(num*2, MAX+1, num):
    primes[i] = 1
for num in range(X, MAX+1):
  if primes[num] == 0:
    print(num)
    exit()

Solution (Python):
x = int(input())
if x == 2 or x == 3:
   print(x)
   exit()
while True:
      n = 0
      for i in range(2, int(-(-x**0.5//1))+1):
          if x % i == 0:
             break
          else:
              n = n + 1
      if n == int(-(-x**0.5//1))-1 :
          print(x)
          exit()
      else:
          x = x + 1

Solution (Python):
import math
x=int(input())
def is_prime(n):
    if n <= 1:
        return False
    for i in range(2, int(math.sqrt(n)) +1):
        if n % i == 0:
            return False
    return True
for i in range(x, 100003+1):
    if is_prime(i):
        print(i)
        exit()

Solution (Python):

N = 110000
p = [0]*N
x = int(input())

for i in range(2,N):
    if p[i]:
        continue
    if i>=x:
        print(i)
        break
    tmp = i
    while tmp<N:
        p[tmp] = 1
        tmp += i

Solution (Python):
from math import sqrt
n=int(input())
while 1:
    k=0
    for i in range(2,int(sqrt(n))+1):
        if(n%i==0):
            k=1
            break
    if(k==0):
            print(n)
            break
        
    n+=1

Solution (Python):
import sys
import itertools

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

    pred = lambda v: v * v <= x
    it = itertools.chain((2,), itertools.count(3, 2))
    return not any(not (x % i) for i in itertools.takewhile(pred, it))
        

def resolve(in_):
    X = int(next(in_))
    for i in itertools.count(X):
        if is_prime(i):
            return i


def main():
    answer = resolve(sys.stdin)
    print(answer)


if __name__ == '__main__':
    main()

Solution (Python):
x=int(input())
import math
def is_prime(n):
    if n<=1:
        return False
    for i in range(2,int(math.sqrt(n) + 1)):
        if n%i == 0:
            return False
    return True
for i in range(x,2*x+1):
        if is_prime(i):
                print(i)
                exit()

Solution (Python):
isprime = [True] * 100201

def seive(n): 
  isprime[0] = isprime[1] = False
  p = 2
  while (p*p <= n):
    if isprime[p]:
      for i in range(p*p, n+1, p):
        isprime[i] = False   
    p += 1
      
  prime = [j for j in range(n) if isprime[j]]
  return prime

		
def program():
  x = int(input())
  N = 100200
  prime = seive(N) 
    
  for i in range(len(prime)):
    if prime[i] >= x:
      return prime[i]
      break
		
print(program())

Solution (Python):

def prime(n):
    if n <=1:
        return False
    for i in range(2, n):
        if n%i == 0:
            return False
    return True
if __name__ == "__main__":
    n = int(input())
    while not prime(n):
        n+=1
    print(n)

Solution (Python):
X = int(input())
prime_under_X = []
for i in range(2, int(X ** 0.5) + 1):
    flg = True
    for j in range(len(prime_under_X)):
        if i % prime_under_X[j] == 0:
            flg = False
            break
    if flg:
        prime_under_X.append(i)

while True:
    flg = True
    for j in range(len(prime_under_X)):
        if X % prime_under_X[j] == 0:
            flg = False
            break
    if flg:
        print(X)
        break
    X = X + 1

Solution (Python):
X = int(input())
prime_under_X = []
for i in range(2, int(X ** 0.5) + 1):
    flg = True
    for j in range(len(prime_under_X)):
        if i % prime_under_X[j] == 0:
            flg = False
            break
    if flg:
        prime_under_X.append(i)

while True:
    flg = True
    for j in range(len(prime_under_X)):
        if X % prime_under_X[j] == 0:
            flg = False
            break
    if flg:
        print(X)
        break
    X = X + 1

Solution (Python):
x=int(input())
if x==2:
    print(2)
else:
    while True:
        cnt=0
        if x%2==0:
            x+=1
            continue
        for i in range(2,x):
            if x%i==0:
                cnt=1
                continue
        if cnt==1:
            x+=1
        else:
            print(x)
            break

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

def is_prime(x):
  if x <= 1:
    return False
  for i in range(2, x):
    if x % i == 0:
      return False
  return True
 
p = X
while not is_prime(p):
  p += 1
  
print(p)

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

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

Solution (Python):
import math

for n in range(int(input()),100003+1):
    fact = True
    if n % 2 == 0 and n != 2:
        continue

    for div in range(2,math.floor(math.sqrt(n))+1):
        if n % div == 0:
            fact = False
            break

    if fact:
        print(n)
        break

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

for i in range(x, x+100):
    cnt=0
    for j in range(2,int(math.sqrt(i))+1):
        if (i)%j==0:
            cnt+=1
            break
    if cnt==0:
        print(i)
        break

Solution (Python):
dp = [0 for i in range(1000000)]
N = int(input())
for i in range(2,1000):
  if i**2>N:
    break
  if dp[i]!=0:
    continue
  for j in range(i,1000000,i):
    dp[j] = 1
while dp[N]!=0:
  N += 1
print(N)

Solution (Python):
import sys
def I(): return int(sys.stdin.readline().rstrip())


X = I()

for i in range(X,1000000):
    for j in range(2,int(i**.5)+1):
        if i % j == 0:
            break
    else:
        print(i)
        break

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

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

while True:
    if is_prime(X):
        break
    X += 1

print(X)

Solution (Python):
import sys

X = int(sys.stdin.readline())
exists = set()
for i in range(2, X + 10**5 + 1):
    if i in exists:
        continue
    exists.add(i)
    if X <= i:
        
        print(i)
        sys.exit()

    for j in range(i+i, X + 10**5 + 1, i):
        exists.add(j)

Solution (Python):



def eratosthenes_sieve(n):
    is_prime = [True]*(n + 1)
    is_prime[0] = is_prime[1] = False
    for p in range(2, n + 1):
        if is_prime[p]:
            for q in range(2*p, n + 1, p):
                is_prime[q] = False
    return is_prime

MAX_N=(10**6)
Primes = eratosthenes_sieve(MAX_N)

x = int(input())
while True:
    if Primes[x]:
        print(x)
        exit()
    x += 1

Solution (Python):
import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

X = int(input())
primeNum = seachPrimeNum(100003)
i = 0
while True:
    if primeNum[i] >= X:
        ans = primeNum[i]
        break
    else:
        i += 1

print(ans)

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

X = int(input())

while True:
    result = prime(X)
    if result:
        break
    else:
        X += 1

print(X)

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


X = int(input())
while not prime_judge(X):
    X += 1
print(X)

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

era=[1]*(10**6+1)
era[0]=0
era[1]=0
k=2
while k<10**6+1:
  if era[k]==1:
    for i in range(2*k,10**6+1,k):
      era[i]=0
  if k==2:
    k+=1
  else:
    k+=2
for i in range(x,10**6+1):
  if era[i]==1:
    print(i)
    break

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

loop = True
i = -1

while loop:
    i += 1
    loop = False
    for j in range(2, int(pow(X+i, 1/2)+1)):
        if (X+i) % j == 0:
            loop = True
            break
print(X+i)

Solution (Python):

import bisect
X = int(input())
n = 10**5+3
sosu = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    sosu.difference_update(range(i*2, n+1, i))
sosu = list(sosu)
sosu.sort()
ind = bisect.bisect_right(sosu, X)
if sosu[ind-1] == X:
    print(X)
else:
    print(sosu[ind])

Solution (Python):


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


x = int(input())
i = x
while True:
    if is_prime(i):
        print(i)
        exit()
    i += 1

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

def main():
    x = int(input())
    while not isPrime(x):
        x += 1
    print(x)

if __name__ == "__main__":
    main()

Solution (Python):
P = [1 for _ in range(10**6)]
P[0]=0
P[1]=0
for i in range(2,10**3+1):
    for j in range(i*i,10**6,i):
        P[j]=0
X = int(input())
for i in range(X,10**6):
    if P[i]==1:
        print(i)
        break

Solution (Python):
isPrime=[1 for i in range(10**6+1)]
isPrime[0]=0;isPrime[1]=0
for i in range(2,10**6+1):
    if isPrime[i]==0:
        continue
    for j in range(2*i,10**6+1,i):
        isPrime[j]=0
X=int(input())
for i in range(X,10**6+1):
    if isPrime[i]==1:
        print(i)
        exit()

Solution (Python):
isPrime=[1 for i in range(10**6+1)]
isPrime[0]=0;isPrime[1]=0
for i in range(2,10**6+1):
    if isPrime[i]==0:
        continue
    for j in range(2*i,10**6+1,i):
        isPrime[j]=0
X=int(input())
for i in range(X,10**6+1):
    if isPrime[i]==1:
        print(i)
        exit()

Solution (Python):
n = 10**5 + 3
primes = set(range(3, n+1, 2))

for i in range(3, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes.add(2)
primes = list(primes)
primes.sort()

x = int(input())

primes = [y for y in primes if y >= x]

print(primes[0])

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  


X = I()

for i in range(X,1000000):
    for j in range(2,int(i**.5)+1):
        if i % j == 0:
            break
    else:
        print(i)
        break

Solution (Python):
from bisect import bisect_left, bisect_right

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


x = int(input())
ps = primes(10**6)
ind = bisect_left(ps, x)
val = ps[ind]
print(val)

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

def is_prime(n):
    if n == 2: return True
    if n < 2 or n%2 == 0: return False
    m = 3
    while m*m <= n:
        if n%m == 0: return False
        m += 2
    return True

while 1:
    if is_prime(X):
        print(X)
        exit()
    X += 1

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

import math

def check(n):
    if n == 1: return False

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

n = x
while check(n) == False:
    n += 1

print(n)

Solution (Python):
X = int(input())
for i in range(X, 9999999999999999):
    flag = 1
    for j in range(2, X//2 +1):
        if i % j == 0:
            flag = -1
            break
    if X == 2:
        print(2)
        break
    elif X == 3:
        print(3)
        break
    elif flag == 1:
        print(i)
        break

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

flug=0
while(flug == 0):
  flug2=1
  for i in range(2,round(math.sqrt(X))+1):
    if X%i==0:
      flug2=0
      
  if flug2==1:
    flug=1
    
  else:
    X+=1
    
print(X)

Solution (Python):

import sys
def input():
    return sys.stdin.readline()[:-1]


def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

def main():
    X = int(input())
    for i in range(X, 10**8):
        if is_prime(i):
            print(i)
            exit()

if __name__ == '__main__':
    main()

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

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

for i in range(X, 1000000):
    if isPrime(i) == True:
        print(i)
        exit()

Solution (Python):
import math

X = int(input())

for x in range(X, 2 * X + 1):
	for i in range(2, int(math.sqrt(x)) + 1):
		if x % i == 0:
			break
	else:
		print(x)
		break

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

def is_Prime(x):
  for i in range(2, x+1):
    if i * i + 1 > x:
      return True
    if x % i == 0:
      return False

for i in range(X, 2*X+1):
  if is_Prime(i):
    print(i)
    break

Solution (Python):
import math
X = int(input())
temp = int(math.sqrt(X))
while True:
  b = True
  for i in range(2, temp + 1):
    if X % i == 0:
      b = False
      break
  if b == True:
    print(X)
    exit()
  X += 1

Solution (Python):
a=int(input())
def judge(n):
    if n==2:
        return True
    else:
        for i in range(2,n):
            if n%i==0:
                break
            elif i*i>n:
                return True
while True:
    if judge(a)==True:
        print(a)
        break
    a+=1

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    X = int(readline())

    def enum_primes(n):
        flag_num = (n + 1) // 2
        prime_flag = [True] * flag_num

        for num in range(3, int(n ** 0.5) + 1, 2):
            idx = (num - 1) // 2 - 1
            if prime_flag[idx]:
                for j in range(idx + num, flag_num, num):
                    prime_flag[j] = False

        primes = [2]
        temp = [(i + 1) * 2 + 1 for i in range(flag_num) if prime_flag[i]]
        primes.extend(temp)

        return primes

    primes = enum_primes(10 ** 6)

    for prime in primes:
        if prime >= X:
            return print(prime)


if __name__ == '__main__':
    main()

Solution (Python):
X = int(input())
a = [-1] * 2 * X
a[0] = 0
a[1] = 1
for i in range(2, X):
    if a[i] == -1:
        for j in range(i, 2*X, i):
            a[j] = i
for ans in range(X, 2*X):
    if a[ans] == -1:
        break
print(ans)

Solution (Python):
X=int(input())
while True:
    for x in range(2,X):
        if X%x==0:
            break
    else:
        print(X)
        break
    X+=1

Solution (Python):
import math


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


'''
def find_prime(x):
    while True:
        if x == 2:
            return x
        else:
            for i in range(2, x+1):
                if x % i == 0:
                    if i == x:
                        return x
                    else:
                        break
                else:
                    continue
            x += 1
'''


def main():
    x = int(input())
    while True:
        if is_prime(x) == False:
            x += 1
        else:
            print(x)
            break


if __name__ == "__main__":
    main()

Solution (Python):
import sys
X = int(input())
while True:
    OK = True
    for i in range(2, X):
        if X % i == 0:
            X += 1
            OK = False
            break
    if OK:
        print(X)
        break

Solution (Python):
def find_prime(x):
    while True:
        if x == 2:
            return x
        else:
            for i in range(2, x+1):
                if x % i == 0:
                    if i == x:
                        return x
                    else:
                        break
                else:
                    continue
            x += 1


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

    x = find_prime(x)

    print(x)


if __name__ == "__main__":
    main()

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

while True:
    for i in range(2, int(math.sqrt(x)+1)):
        if x % i == 0:
            x += 1
            break
    else:
        break
print(x)

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

while True:
  for i in range (2, int(math.sqrt(x))+1):
    if x%i==0:
      x+=1
      break
  else:
    break
print(x)

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

for x in range(x,x*2):
    for i in range(2,x//2):
        if x%i==0:
            break
    else:
        print(x)
        sys.exit()

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

x = int(input())

while True:
    if is_prime(x):
        print(x)
        sys.exit(0)
    else:
        x += 1

Solution (Python):
X=int(input())
while True:  
  for i in range(2,X):
    if X%i==0:
      X+=1
      break
  else:
    print(X)
    break

Solution (Python):
x = int(input())
 
while True:
  flag =0
  for i in range(2,x//2):
    if x%i==0:
      flag =1
      break
  if flag ==0:
    print(x)
    exit()
  x = x+1

Solution (Python):
X=int(input())
x=0
for j in range(X,10**6):
    for i in range(j-1,0,-1):
        if i==1:
            print(j)
            x=1
        elif j%i==0:
            break
    if x==1:
        break

Solution (Python):
X=int(input())
x=0
for j in range(X,10**6):
    for i in range(j-1,0,-1):
        if i==1:
            print(j)
            x=1
        elif j%i==0:
            break
    if x==1:
        break

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


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

    while True:
        if is_prime(x):
            ans = x
            break
        x += 1

    print(ans)


if __name__ == "__main__":
    main()

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


def main():
    x = int(input())
    num = x

    while True:
        if is_prime(num):
            ans = num
            break
        num += 1

    print(ans)


if __name__ == "__main__":
    main()

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

while(True):
  if x < 2:
    x += 1
  elif x == 2:
    print(x)
    break
  else :
    isPrime = True
    for p in range(2,x):
      if x % p == 0:
        x += 1
        isPrime = False
        break
    if isPrime:
      print(x)
      break

Solution (Python):
import sys
sys.setrecursionlimit(10**7) 
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque, defaultdict


from collections import Counter

from itertools import accumulate,combinations,permutations,product

from heapq import heapify,heappop,heappush

from functools import reduce,lru_cache

from decimal import Decimal
from argparse import ArgumentParser

args=ArgumentParser()
args.add_argument('-loc', '--local', type=bool,default=False)
LOCAL=args.parse_args().local

def input(): 
    x=sys.stdin.readline(); 
    if x[-1]=="\n": 
        return x.rstrip() 
    return x
    
def printe(*x):_=print("
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): 
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    

    X = int(input())
    
    
    
    
    def hurui(n=200000):
        primes = set(range(2, n+1))
        for i in range(2, int(n**0.5+1)):
            primes.difference_update(range(i*2, n+1, i))
        
        return primes
    l=list(hurui())
    i=bisect_left(l,X)
    print(l[i])


if __name__ == "__main__":
    main()

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


def abc149c_next_prime():
    import bisect
    x = int(input())
    list = get_sieve_of_eratosthenes(100003)
    idx = bisect.bisect_left(list, x)
    print(list[idx])


abc149c_next_prime()

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

while True:
  flg = 0
  for i in range(2,math.ceil(y**0.5)):
    if y%i == 0:
      flg = 1
      break
  if flg == 0:
    print(y)
    break
  y += 1

Solution (Python):
import math
N = int(input())
lst = [True]*(N*2)
for i in range(2,int(math.sqrt(N*2))+1):
  for j in range(i+i,N*2,i):
    lst[j] = False
for i in range(N,len(lst)):
  if lst[i]:
    print(i)
    break

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

while True:
  flag = 0
  for i in range(2,X//2):
    if X % i == 0:
      flag = 1
      break
  if flag == 0:
    print(X)
    exit()
  X = X + 1

Solution (Python):
x = int(input())
ans = "No"
if x == 2:
    ans = "Yes"
while ans == "No":
    for i in range(2,max(x//2,3)):
        ans = "Yes"
        if x % i == 0:
            x += 1
            ans = "No"
            break
print(x)

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

for j in range(x,2*x):
  flag=1
  for i in range(2,int(math.sqrt(x))+1):
    if x%i==0:
      flag=0
  if flag==1:
    print(x)
    exit(0)
  x+=1

Solution (Python):
n=int(input())
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
while 1:
    if isprime(n):
       print(n)
       exit()
    else:
        n+=1

Solution (Python):
import sys
from collections import deque

import math

def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    exclude = set()
    prime = set()
    for i in range(2,int(math.sqrt(x))+1):
        if i in exclude:
            continue
        prime.add(i)
        j = i+i
        while j<=math.sqrt(x):
            exclude.add(j)
            j += i
    
    current = x
    while True:
        for rep in prime:
            if current%rep==0:
                break
        else:
            print(current)
            return
        current += 1
    return

if __name__=='__main__':
    x = I()
    solve()

Solution (Python):
import sys
from collections import deque

import math

def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    exclude = set()
    prime = set()
    for i in range(2,int(math.sqrt(x))+1):
        if i in exclude:
            continue
        prime.add(i)
        j = i
        while j<=math.sqrt(x):
            exclude.add(j)
            j += i
    current = x
    while True:
        for rep in prime:
            if current%rep==0:
                break
        else:
            print(current)
            return
        current += 1
    return

if __name__=='__main__':
    x = I()
    solve()

Solution (Python):
import sys
from collections import deque

import math

def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    exclude = set()
    prime = set()
    for i in range(2,int(math.sqrt(x))+1):
        if i in exclude:
            continue
        prime.add(i)
        j = i
        while j<=x+2*i:
            exclude.add(j)
            j += i
    current = x
    while True:
        for rep in prime:
            if current%rep==0:
                break
        else:
            print(current)
            return
        current += 1
    return

if __name__=='__main__':
    x = I()
    solve()

Solution (Python):
import math

def 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(n**0.5)+1,2):
        if n%i==0:
            return False
    
    return True

X=int(input())
while True:
    if prime(X):
        print(X)
        break
    else:
        X+=1

Solution (Python):
x = int(input())
if x == 2:
  print(2)
  exit()
  
for i in range(1000000):  
  for j in range(2, x+i):
    
    if (x+i) % j == 0:
      break   
         
    if j == x+i-1:
      print(x+i)
      exit()

Solution (Python):
x = int(input())
ans = x
while True:
  jud = 0
  if(ans <= 2):
    print(2)
    break
  if(ans%2==0):
    jud += 1
  i = 3
  while i < ans**(1/2):
    if(jud>0):
      break
    if(ans%i == 0):
      jud += 1
    i += 2
  if(jud==0):
    print(ans)
    break
  ans += 1

Solution (Python):
import bisect, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if is_prime[i]:
            for j in range(i*2, n+1, i):
                is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

def resolve():
    X = I()

    primes = sieve(X * 2)
    idx = bisect.bisect_left(primes, X)
    print(primes[idx])

if __name__ == '__main__':
    resolve()

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

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

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