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):
x = int(input())

while True:
    for i in range(2,int(x**0.5)+1):
        if x%i==0:
            x = x + 1
            break
    else:
        print(x)
        exit()

Solution (Python):
X=int(input())
num=2
while num<X:
    if X%num==0:
        X+=1
        num=2
    else:
        num+=1
print(X)

Solution (Python):
import math

x = int(input())

max_num = int(math.sqrt(x * 2))
numlist = [True for i in range(x * 2 + 1)]

for i in range(2, max_num):
    if not numlist[i]:
        continue
    for j in range(i * 2, x * 2 + 1, i):
        numlist[j] = False

numlist[0:x] = [False for i in range(x)]

print(numlist.index(True))

Solution (Python):
X=int(input())
for x in range(X,2*X):
    for i in range(2,int(x**.5)+1):
        if x%i==0:
            break
    else:
        print(x)
        break

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):
x=int(input())
result=0
cnt=0

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

print(result)

Solution (Python):
X=int(input())
for x in range(X,2*X):
    flag=True
    for i in range(2,int(x**.5)+1):
        if x%i==0:
            flag=False
            break
    if flag:
        print(x)
        exit()

Solution (Python):
import math,sys

def hantei(x):
  for i in range(2, math.ceil(math.sqrt(x))):
    if x % i == 0:
      return False
    
  return True

x = int(input())

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

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

f=False
a=X
if X==2 or X==3:
    print(X)
    exit()
while f==False:
    for i in range(2,int(a**0.5)+1):
        if a%i==0:
            break
        if i==int(a**0.5):
            f=True
    a+=1
print(a-1)

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

f=False
a=X
if X==2:
    print("2")
    exit()
while f==False:
    for i in range(2,a+1):
        if a%i==0:
            break
        if i==a-1:
            f=True
    a+=1
print(a-1)

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

def isPrime(n):
    if n < 2:
        return False
    if n == 2:
        return True
    for i in range(2, n):
        if n % i == 0:
            return False

    return True

while isPrime(x) == False:
    x += 1
    
print(x)

Solution (Python):

import math
import sys

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


def solve(X: int):
    i = X
    while True:
        
        if is_prime(i):
            print(i)
            break
        else:
            i += 1


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  
    solve(X)

if __name__ == '__main__':
    main()

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

is_prime = False
a_tmp = a
while is_prime == False:
  cnt = 0
  for i in range(1, a_tmp+1):
    is_div = (a_tmp % i == 0)
    if is_div:
      cnt += 1
  if cnt == 2:
    is_prime = True
    print(a_tmp)
  else:
    a_tmp += 1

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(x,x*2+2):
    if is_prime(i):
        print(i)
        exit()

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

Solution (Python):
x = int(input())
while 1:
    if all(x%i!=0 for i in range(2, int(x**(1/2))+1)):
        print(x)
        break
    else:
        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

n = int(input())
ans = 0
while True:
    if is_prime(n):
       ans = n
       break
    else:
        n += 1

print(ans)

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

serach_number = 100004

def sieve_of_eratosthenes(target, x):
    dest = int(math.sqrt(target))
    target_list = list(range(2, target + 1))
    prime_list = []

    while True:
        num_min = min(target_list)
        if num_min >= dest:
            prime_list.extend(target_list)
            break
        prime_list.append(num_min)


        i = 0

        while True:
            if i >= len(target_list):
                break
            elif target_list[i] % num_min == 0:
                target_list.pop(i)
            i += 1
    while True:
        if (x in prime_list) == True:
            print(x)
            break
        else:
            x +=1


sieve_of_eratosthenes(serach_number, x)

Solution (Python):
import math

x = int(input())

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

while is_prime(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, x):
        if x%i == 0:
            return False
    return True

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

print(x)

Solution (Python):
def Is_prime(n):
    
    if n<=1:
        return False
    
    if n==2 or n==3:
        return True
    
    if n%2==0:
        return False
    
    sqrt_root = int(n**.5)
    
    for i in range(3,sqrt_root+1,2):
        if n%i==0:
            return False
    
    return True

N = int(input())
while True:
    if Is_prime(N):
        print(N)
        exit()
    N += 1

Solution (Python):
def is_prime(x: int) -> bool:
    """自然数nが素数であるかを判定する
    計算量: O(sqrt(N))
    """
    if x == 2:
        return True
    if x == 1 or x % 2 == 0:
        return False
    for k in range(3, int(x ** 0.5) + 1, 2):
        if x % k == 0:
            return False
    return True


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

Solution (Python):
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

X = int(input())
while True:
    if len(prime_factorize(X)) == 1:
        break
    X += 1
print(X)

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

while True:
    pf={}
    m=X
    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:pf[m]=1
    

    if (len(pf)==1) and (list(pf.values())[0]==1):
        break
    else:
        X +=1
        
print(m)

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

prime = [0] * (2 * X)

for i in range(2, 2 * X):
	if prime[i] == 0:
		for j in range(2, (2 * X) // i):
			prime[j * i] = 1
	else:
		continue

for i in range(X, 2 * X):
	if prime[i] == 0:
		print(i)
		break

Solution (Python):

import math

def isPrime(n):
	tmp=math.ceil(math.sqrt(n))
	if n==1:
		return False
	for i in range(2,tmp):
		if n%i==0:
			return False
	return True


x=int(input())
for i in range(x,100004):
	if isPrime(i):
		print(i)
		exit()

Solution (Python):
X=int(input())
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))
primes=list(primes)
for i in range(len(primes)-1):
    if X==2:
        print("2")
        break
    elif (primes[i]<X)and(X<=primes[i+1]):
        print(primes[i+1])
        break

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

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

while not is_prime(X):
    X += 1

print(X)

Solution (Python):
X = int(input())
while True:
    pf={}
    m=X
    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:pf[m]=1
    if (len(pf)==1)and(list(pf.values())[0]==1):
        break
    X += 1
print(X)

Solution (Python):
import math
x=int(input())
if x<4:
    print(x)
elif x<=5:
    print(5)
else:
    ans=0
    while ans==0:
        if x%2==0:
            x+=1
        if x%10==5:
            x+=2
        i_max=math.ceil(x**0.5)+1
        for i in range(2,i_max):
            if x%i==0:
                break
            elif i==i_max-1:
                ans=x
                break
        x+=2
    print(ans)

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

X=int(input())

while True:
    if(isPrime(X)):
        print(X)
        sys.exit()

    X+=1

Solution (Python):
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


x = ni()


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


for ans in range(x, 10**5 + 4):
    if is_prime(ans):
        print(ans)
        break

Solution (Python):
def sieve_of_eratosthenes(n):
    prime = list(range(n + 1))
    prime[0] = prime[1] = 0
    for i in range(2, n + 1):
        if i**2 > n:
            break
        if prime[i] > 0:
            for j in range(i**2, n + 1, i):
                prime[j] = 0
    return prime
    

x = int(input())
prime = sieve_of_eratosthenes(3 * 10**5)
for i in range(x, 3 * 10**5):
    if prime[i]:
        print(i)
        exit()

Solution (Python):
from math import sqrt
x=int(input())
def chk(n):
  for i in range(2,int(sqrt(n))):
    if n%i==0:
      return False
  return True
for i in range(x,x+500):
  if chk(i):
    print(i)
    break

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


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors


while 1:
    if len(make_divisors(X)) == 2:
        break
    X += 1

print(X)

Solution (Python):
x = int(input())
def is_prime(n):
    for i in range(2,int(n**0.5)+1):
        if n%i != 0:
            continue
        else:
            return False
    return True
while  True:
    if is_prime(x) == True:
        break
    else:
        x +=1
print(x)

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

Solution (Python):


def main():
    x = int(input())
    primes = sieve(300000)
    for p in primes:
        if x <= p:
            print(p)
            return
    raise ValueError


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

if __name__ == "__main__":
    main()

Solution (Python):


def main():
    x = int(input())
    primes = furui(300000)
    for p in primes:
        if x <= p:
            print(p)
            return
    raise ValueError


def furui(nmax):
    assert nmax > 2
    p = 2
    primes = list(range(2, nmax + 1))
    while True:
        if p ** 2 > nmax:
            break
        primes_next = []
        for x in primes:
            if x <= p or x % p != 0:
                primes_next.append(x)
        primes = primes_next
        p = primes[primes.index(p) + 1]
    return primes

if __name__ == "__main__":
    main()

Solution (Python):


def main():
    x = int(input())
    primes = furui(300000)
    for p in primes:
        if x <= p:
            print(p)
            return
    raise ValueError

def furui(nmax):
    assert nmax > 2
    p = 2
    primes = list(range(2, nmax + 1))
    while True:
        if p ** 2 > nmax:
            break
        primes_next = []
        for x in primes:
            if x <= p or x % p != 0:
                primes_next.append(x)
        primes = primes_next
        p = primes[primes.index(p) + 1]
    return primes

if __name__ == "__main__":
    main()

Solution (Python):
def main() :
    X = int(input())
    testing_number = X
    while(True) :
        is_prime = True
        while(True) :
            for i in range(2,testing_number) :
                if (testing_number % i == 0) :
                    is_prime = False
                    testing_number += 1
                    break
            break

        if(is_prime) :
            break

    print(testing_number)

main()

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

def hans(n):
    a=0
    for i in range(2,n):
        if n%i==0:
            a=a+1
    
    if a==0:
        return 1
    else:
        return 0

def maxs(n):
    for i in range(n,):
        if hans(n)==1:
            return n
        else:
            n=n+1
            continue

print(maxs(x))

Solution (Python):
from math import sqrt

x = int(input())

MAX_VAL = 10**(5+1)
prime = [1] * (MAX_VAL+1)
prime[0] = prime[1] = 0
for i in range(2, int(sqrt(MAX_VAL))+1):
    if prime[i]:
        for k in range(2*i, MAX_VAL+1, i):
            prime[k] = 0

cnt = x
while True:
    if prime[cnt]:
        print(cnt)
        break
    cnt += 1

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
def inputS(): return input().rstrip().decode()
readlines = sys.stdin.buffer.readlines  

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

X = int(input())

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

Solution (Python):










import math
import statistics
import string


def intinput():
    return int(input())

def listintinput():
    return list(map(int, input().split()))

def splitintinput():
    return map(int, input().split())

def factorialsurplus(x, y, z):  
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)

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

x = intinput()

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

Solution (Python):
n = int(input())
import math
def get_primenumber(number):
    prime_list = []
    search_list = list(range(2,number+1))
    while True:
      if search_list[0] > math.sqrt(number):
        prime_list.extend(search_list)
        break
      else:
        head_num = search_list[0]
        prime_list.append(head_num)
        search_list.pop(0)
        search_list = [num for num in search_list if num % head_num != 0]
    return prime_list
p_l = get_primenumber(10**5+1000)


for prime in p_l:
    if prime >= n:
        print(prime)
        exit()

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

Solution (Python):
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]


def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

sosuu = [None] * 200005

for i in range(2, len(sosuu)):
    if sosuu[i] is None:
        
        sosuu[i] = True
        for j in range(i*2, len(sosuu), i):
            sosuu[j] = False

x = int(input())

while sosuu[x] != True:
    
    x += 1

print(x)

Solution (Python):
x=int(input())
l=[2]
for i in range(3,round((2*x)**0.5)):
  for j in range(len(l)):
    if i%l[j]==0:
      break
    if j==len(l)-1:
      l.append(i)
def pri(x,l):
  for i in range(len(l)):
    if x%l[i]==0 and x>l[i]:
      return 0
    if i==len(l)-1:
      return 1

while pri(x,l)==0:
  x+=1
print(x)

Solution (Python):
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    x = int(readline())
    for i in range(x, 10 ** 10 + 1):
        is_prime = True
        for j in range(2, int(i ** 0.5 + 1)):
            if i % j == 0:
                is_prime = False
                break
        if is_prime:
            print(i)
            exit()


if __name__ == '__main__':
    solve()

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

a = 10 ** 6
b = int(math.sqrt(a)+1)
p = [True]*(a+1)
p[0] = False
p[1] = False

for i in range(4, a+1, 2):
  p[i] = False
  
for i in range(3, b+1, 2):
  if p[i]:
    for j in range(i+i, a+1, i):
      p[j] = False

for i in range(x, a+1):
  if p[i]:
    print(i)
    break

Solution (Python):
x = int(input())
while True:
    isAns = True
    for d in range(2, int(x ** 0.5) + 2):
        if d == x:
            continue
        if x % d == 0:
            isAns = False
            break
    if isAns:
        print(x)
        break
    x += 1

Solution (Python):
def is_prime(x):
  if x <= 1: return false
  i=2
  while i*i <= x:
    if not x%i: return False
    i+=1
  return True
 
X=int(input())
while not is_prime(X):
  X+=1
print(X)

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

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

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

def is_prime(n):
  if n ==2:
    return 2
  for i in range(2,n):
    if n % i ==0:
      return False
    elif i**2 > n:
      return True

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

Solution (Python):
import math

def main(x):
    if x == 2:
        return 2
    res = x
    while(1):
        if isSosuu(res):
            return res
        res += 1

def isSosuu(val):
    div = math.ceil(math.sqrt(val))
    for i in range(2,div+1):
        if val%i == 0:
            return False
    return True

x = int(input())
print(main(x))

Solution (Python):
import math
def main(X):
    if X <= 3:
        return X
    SosuuFlg = False
    while SosuuFlg == False:
        max_search = int(math.sqrt(X)+1) if math.sqrt(X) % 1 == 0 else math.ceil(math.sqrt(X))
        for i in range(2, max_search):
            if X % i == 0:
                break
        else:
            SosuuFlg = True
            return X
        X += 1
        
X = int(input())
print(main(X))

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

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

while(1):
    if x==1:
        x+=1
        continue
    elif x==2:
        print(x)
        break
    if is_prime(x):
        print(x)
        break
    x+=1

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

def is_prime(x):
    ma = math.ceil(math.sqrt(x))
    for i in range(2,ma):
        if x%i==0:
            return False
    else:
        return True

while(1):
    if x==1:
        x+=1
        continue
    if is_prime(x):
        print(x)
        break
    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())

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

Solution (Python):
import math

num = int(input())
step = []
sqrt_num = int(math.sqrt(num))
count=0

while True:
  for i in range(2,sqrt_num+2):
    if num == 2:
      count=1
      break
      
    if num%i == 0:
      count = 0
      break
      
    count=1
    
  if count == 1:
    break
    
  num = num+1
  sqrt_num = int(math.sqrt(num))

print(num)

Solution (Python):
import math

X = int(input())

flag = 1
while True:
  i = 2
  flag = 1
  while i * i <=  X:
    if X % i == 0:
      flag = 0
      break
    i += 1
  
  if flag == 1:
    print(X)
    break
    
  X += 1

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

ans = 0

for _ in range(10**5):
    if x == 2:
        print(x)
        break
    for i in range(2, int(x**0.5) + 1):
        if (x % i) == 0:
            break
        elif i == int(x**0.5): 
            ans = x
        else:
            pass

    if ans != 0:
        print(ans)
        break
    else:
        x += 1

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

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

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

Solution (Python):
import math
def prime(n):
    for i in range(3, int(math.sqrt(n)), 2):
        if n % i == 0:
            return False
    return True
x = int(input())
if x <= 2:
    print(2)
else:
    if x % 2 != 0:
        y = x
    else:
        y = x + 1
    f = prime(y)
    while f == False:
        y += 2
        f = prime(y)
    print(y)