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 sys
input = sys.stdin.buffer.readline


from collections import defaultdict


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

L = [1 for i in range(100010)]
L[0] = 0
L[1] = 0
plist = []
for i in range(100010):
	if L[i] == 1:
		plist.append(i)
		c = 2
		while True:
			if i * c <= 100009:
				L[i * c] = 0
				c += 1
			else:
				break


def main():
	X = int(input())
	for i in plist:
		if X <= i:
			print(i)
			break

if __name__ == '__main__':
	main()

Solution (Python):
def sosuu(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        j = i + i
        while j <= n:
            is_prime[j] = False
            j += i
    return [p for p in range(n+1) if is_prime[p]]

primes = sosuu(300000)
import bisect
x = int(input())

print(primes[bisect.bisect_left(primes, x)])

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

def prime(x,number):
    return x % number 


if X == 2:
    print(2)
elif X == 3:
    print(3)

else:
    
    for number in range(2, X+1):
        if prime(X,number) == 0 and number != X:
            break
        elif prime(X,number) == 0 and number == X:
            print(X)
            quit()

    
    flag = True
    while flag:
        X = X + 1
        for number in range(2, X+1):
            if prime(X,number) == 0 and number != X:
                break
            elif prime(X,number) == 0 and number == X:
                flag = False
                print(X)

Solution (Python):
def nextprime(x):
    for i in range(2, x):
        if x % i == 0:
            return nextprime(x+1)
    return x


x = int(input())

if x == 2:
    print("2")
else:
    print(nextprime(x))

Solution (Python):
def nextprime(x):
    if pow(2, x-1, x) != 1:
        return nextprime(x+1)
    for i in range(2, x):
        if x % i == 0:
            return nextprime(x+1)
    return x


x = int(input())

if x == 2:
    print("2")
else:
    print(nextprime(x))

Solution (Python):
import numpy as np
from bisect import bisect_left


def primes():
    p = []
    c = np.ones(10**5 + 10)
    c[0] = c[1] = 0
    for i, f in enumerate(c):
        if f:
            p.append(i)
            c[2 * i:10**5 + 10:i] = 0
    return p


def solve(string):
    x = int(string)
    ps = primes()
    return str(ps[bisect_left(ps, x)])


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Solution (Python):

def is_prime(n: int) -> bool:
    """
    Evaluate whether a number is prime or not.

    Args:
        n: a number to evaluate

    Returns: whether n is prime or not
    """
    if n == 2:
        return True
    if n == 1 or n % 2 == 0:
        return False
    for i in range(3, int(n ** 0.5) + 1, 2):
        if n % i == 0:
            return False
    return True


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


if __name__ == "__main__":
    main()

Solution (Python):
X = int(raw_input())
con = 0
for i in range(X,X+100):
  
  for j in range (2,i):
    if i%j==0:
      con = con + 1
  if con == 0:
    print i
    break
  else:
    con = 0
    continue

Solution (Python):
import math

x = int(input())

def is_prime(n: int) -> bool:
    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):
        break
    x += 1
print(x)

Solution (Python):
import math

def isPrime(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 True:
    if isPrime(i):
        break
    i+=1
print(i)

Solution (Python):
import sys
input = sys.stdin.readline

def isPrime(x):
	ans = 0
	if x==1:
		ans = 1
	else:
		for i in range(2,x):
			if x%i==0:
				ans = 1
				break;
	return ans

x = int(input())

while 1:
	if isPrime(x)==0:
		break
	if x%10==1 or x%10==3 or x%10==7:
		x += 2
	else:
		x += 1

print(x)

Solution (Python):
import math

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

  return True

x = int(input())
while is_prime(x) is False:
  x += 1

print(x)

Solution (Python):
import sys


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


if __name__ == '__main__':
    solve()

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

Solution (Python):
def prime_flags(n):
    is_prime = [True] * (n + 1)
    is_prime[0:2] = [False, False]
    i = 2
    while i * i <= n:
        if is_prime[i]:
            for j in range(i * i, n+1, i):
                is_prime[j] = False
        i += 1
    return is_prime

n = int(input())
primes = prime_flags(1000000)
for i in range(n, 1000000):
    if primes[i]:
        print(i)
        exit()

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

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

Solution (Python):
x = input()

def is_sosu(num):
  st = 2
  while True:
    if num % st == 0:
      break
    st += 1
  if st == num:
    print(num)
    return
  is_sosu(num+1)

is_sosu(int(x))

Solution (Python):
x = int(input())
def check(x):
    i = 2
    while i*i<=x:
        if x%i==0:
            return False
        i+=1
    return True

while not check(x):
    x+=1
print(x)

Solution (Python):
x = int(input())
def check(x):
    i = 2
    while i*i<=x:
        if x%i==0:
            return False
        i+=1
    return True

while not check(x):
    x+=1
print(x)

Solution (Python):
from math import floor

tmp = int(input())
while True:
    for i in range(2, floor(tmp ** (1 / 2))):
        if tmp % i == 0:
            tmp += 1
            break
    else:
        print(tmp)
        break

Solution (Python):
from math import sqrt

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

x = int(input())
while next_prime(x):
      x = x + 1

print(x)

Solution (Python):
def prime(x):
  p = {}
  cnt = 2
  Flag = True
  while Flag:
    last = math.ceil(x ** 0.5) 
    if cnt > last:
      break
    for i in range(cnt, last + 1):
      if x % i == 0:
        x //= i
        p[i] = 1
        cnt = i + 2
        while x % i == 0:
          x //= i
          p[i] += 1
        cnt = i + 1
        break
      if i == last:
        Flag = False
  if x != 1:
    p[x] = 1
  if len(p) == 1:
    for i in p:
      if p[i] == 1:
        return True
      else:
        return False
  else:
    return False

X = int(input())
import math

ans = X
while True:
  if prime(ans):
    print(ans)
    break
  ans += 1

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

while 1:
	ok = 1
	for i in range(2, X):
		if X % i == 0:
			ok = 0
			break

	if ok:
		print(X)
		exit()
	X += 1

Solution (Python):
import math
x = int(input())
i = 0
flag = True
while flag:
  for k in range(2, int(math.sqrt(x+i)) + 1):
    if (x+i) % k == 0:
      i += 1
      break
  else:
      flag = False

print(x+i)

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

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

is_prime = False
while(not is_prime):
  is_prime = prime_checker(X)
  X += 1

X = X - 1
print(X)

Solution (Python):
MAX_X = 10 ** 5
buffer = 10 ** 3
prime_flags = [1 for _ in range(MAX_X + buffer)]

for i in range(2, MAX_X + buffer):
  num = i
  if prime_flags[num] == 0:
    continue
  while num + i < len(prime_flags):
    num += i
    prime_flags[num] = 0

X = int(input().strip())
for i, flag in enumerate(prime_flags[X:]):
  if flag == 1:
    print(X + i)
    break

Solution (Python):
a = int(input())
for i in range(a,10**7):
  result=[x for x in range(1,i+1) if i%x==0]
  if len(result)==2:
    print(i)
    break

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

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

r = X

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

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

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

ans=X
f=True

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

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

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

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

Solution (Python):
A = int(input())
if A == 2:
    print(2)
    exit()
sosu = [2] 
sosu_2 = [4] 
sosu_2_index = 1
for num in range(3, 100010, 2):
    if  num > sosu_2[sosu_2_index-1]:
        sosu_2_index += 1
    flag =  True
    for i in range(1,sosu_2_index):
        if num % sosu[i] == 0:
            flag = False
            break
    if flag:
        sosu.append(num)
        if num >= A:
            print(num)
            exit()
        sosu_2.append(num**2)

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

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

Solution (Python):
def com(_x):
    _flg = 1
    mx  = int(_x**0.5)
    for i in range(2, mx+1):
        if _x % i == 0:
            _flg = 0
            break
    return _flg


x = int(input())
flg = 0
while flg == 0:
    
    flg = com(x)
    if flg == 0:
        x+=1
print(x)

Solution (Python):
def com(_x):
    _flg = 1
    mx  = int(_x**0.5)
    for i in range(2, mx+1):
        if _x % i == 0:
            _flg = 0
            break
    return _flg


x = int(input())
flg = 0
while flg == 0:
    
    flg = com(x)
    if flg == 0:
        x+=1
print(x)

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


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


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

Solution (Python):
def com(_x):
    _flg = 1
    mx  = int(_x**0.5)
    for i in range(2, mx+1):
        if _x % i == 0:
            _flg = 0
            break
    return _flg


def main():
    x = int(input())
    flg = 0
    while flg == 0:
        
        flg = com(x)
        if flg == 0:
            x+=1
    print(x)



if __name__ == "__main__":
    main()

Solution (Python):
def com(_x):
    _flg = 1
    mx  = int(_x**0.5)
    for i in range(2, mx+1):
        if _x % i == 0:
            _flg = 0
            break
    return _flg


def main():
    x = int(input())
    flg = 0
    while flg == 0:
        
        flg = com(x)
        if flg == 0:
            x+=1
    print(x)



if __name__ == "__main__":
    main()

Solution (Python):
import math
def is_prime(n):
    if n==2:
        return True
    if n%2==0:
        return False
    for i in range(3,int(math.sqrt(n))+1,2):
        if n%i==0:
            return False
    return True
if __name__=="__main__":
    x=input()
    x=int(x)
    res=x
    while True:
        if is_prime(res):
            print(res)
            break
        res+=1

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


stop = 10**5 + 4





for i in range(start, stop, 1):
    for j in range(2, round(i**0.5)+1, 1):
        if i % j == 0:
            break
    else:
        print(i)
        break

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

def isPrime(x):
	for i in range(2,int(x**0.5)+2):
		if i==x:
			return 1
		if x%i==0:
			return 0
	return 1

for i in range(x,x+1234567890):
	if isPrime(i):
		print(i)
		exit()

Solution (Python):
import sys
x = input()
x = int(x)
pn = []
k = x
while True:
    cnt = 0
    for j in range(int(x/2)):
        j += 1
        if cnt >= 2:
            break
        if k % j == 0:
            cnt += 1
    if cnt < 2:
        ans = k
        break
    k += 1
print(ans)

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

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

Solution (Python):
import math

prims = list()

prims.append(2)

base = int(input())

def _is_prim(n):
  global prims
  for p in prims:
    if n == p:
      return True
    elif n % p == 0:
      return False
  
  return True


rt = int(math.sqrt(base))
for n in range(rt):
  if n < 2:
    continue
  elif n % 2 == 0:
    continue
  elif _is_prim(n):
    prims.append(n)


while not _is_prim(base):
  base += 1

print(base)

Solution (Python):
import numpy as np

X = int(input())

def get_primes(n):
    numbers = set(range(n, 1, -1))
    primes = []
    while numbers:
        p = numbers.pop()
        primes.append(p)
        numbers.difference_update(set(range(p*2, n+1, p)))
    return primes

primes = sorted(get_primes(110000))

print(primes[list(np.array(primes) >= X).index(True)])

Solution (Python):
import sys
import math

sys.setrecursionlimit(10**5)

def is_prime_num(num):
    for i in range(2, int(math.sqrt(num))):
        if num % i == 0:
            return False
    return True

x = int(input())
target = x
do = True
while do:
    if is_prime_num(target):
        print(target)
        do = False
    target += 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

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

Solution (Python):
x = int(input())
N = 1000000
def solve():
    primes = [False] * N
    for i in range(2, N):
        if primes[i]:
            continue
        for j in range(i*i, N, i):
            primes[j] = True

        if i >= x:
            print(i)
            return

solve()

Solution (Python):
import numpy as np
a = np.array([2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367])
candidate = int(input())


while True:
  if ((candidate / a[a<candidate]) % 1 == 0).any():
    candidate += 1
  else:
    break
print(candidate)

Solution (Python):

import math

number_to_check = int(input())

def if_prime(number):
    for i in range(2, int(math.sqrt(number) + 1)):
        if number%i == 0:
            return 0
    
    return 1

def check_next_prime(X):
    while(True):
        if if_prime(X):
            break 
        else:
            X += 1
            continue
    print(X)


check_next_prime(number_to_check)

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

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

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

memo = [None]*(2*X)

for i,v in enumerate(memo):
    if i < 2:
        continue
    if v is None:
        memo[i] = True
        for j in range(i*2, 2*X, i):
            memo[j] = False

print(next(i+X for i,v in enumerate(memo[X:]) if v))

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

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

Solution (Python):
import numpy as np

def check_prime(t):
    for p in range(2, int(np.sqrt(t))+1):
        if(t % p == 0):
            return False
    return True

X = int(input())

ans = X
while(True):
    if(check_prime(ans)):
        break
    ans += 1
print(ans)

Solution (Python):
import math
import bisect
x = int(input())
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 

    
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]
N = primes(1000004)
z = bisect.bisect_left(N, x)
print(N[z])

Solution (Python):
def is_prime(num):
    for i in range(2, num):
        if num % i == 0:
            return False

    return True

def main():
    x = int(input())
    while True:
        if is_prime(x):
            print(x)
            break

        x += 1

if __name__ == "__main__":
    main()

Solution (Python):
import math


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

def next_prime(x):
    i = x
    while True:
        if is_prime(i):
            return i
        i += 1

x = int(input())
print(next_prime(x))

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)
    exit()
  x += 1

Solution (Python):
n =10**5+4
p = [False] * 2 + [True] * (n-2)
for i in range(2,n):
    if p[i]:
        for j in range(i*2,n,i):
            p[j] = False
x=int(input())
while p[x]==False:
    x+=1
print(x)

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

for i in range(a,10**6):
  isprime=True
  for j in range(2,i):
    if i%j==0:
      isprime=False
      break
  if isprime==True:
    print(i)
    exit()

Solution (Python):
MAX_PRIME = 10**6
is_prime = [1] * MAX_PRIME
primes = []
is_prime[0] = 0
is_prime[1] = 0
for i in range(MAX_PRIME):
    if is_prime[i]:
        primes.append(i)
        for j in range(2, ((MAX_PRIME-1)//i) + 1):
            is_prime[i*j] = 0

x = int(input())
while not is_prime[x]:
    x += 1
print(x)

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

i = X

while i < 1000000:
    if isPrime(i):
        print(i)
        break
    else:
        i = i + 1

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


import sys
input = sys.stdin.readline().rstrip
X = int(input())

if X%2 == 0:
    if X == 2:
        print(2)
    else:
        X += 1
        for num in range(X, 10**6, 2):
            if is_prime(num):
                print(num)
                break
else:
    for num in range(X, 10**6, 2):
        if is_prime(num):
            print(num)
            break

Solution (Python):
def main():
  N = int(input())
  
  print(search(N))
 
def search(x):
  
  ints = list(range(2,x))
  
  
  for i in ints:
    if x%i==0:
      return search(x+1)
    elif x < i**2:
      break
    
  return x

main()

Solution (Python):
def seive(num,n):
    li=[True]*(n+1)
    x=2
    li[0]=False
    li[1]=False
    while x*x<n:
        if li[x]:
            for i in range(x*x,len(li),x):
                
                li[i]=False
                
        x+=1
        
        
    for i in range(num,len(li)):
        if li[i]:
            return i
num=int(input())
print(seive(num,1000000))

Solution (Python):
x = int(input())
prime = []
for i in range(2,2*x):
    prime_check = 0
    for j in prime:
        if i % j == 0:
            prime_check = 1
            break
    if prime_check == 0:
        if i >= x:
            ans = i
            break
        else:
            prime.append(i)
print(ans)

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]
x=int(input())
while 1:
    flag=0
    for i in range(2,int(x**(1/2))):
        if x%i==0:
            flag=1
            break
    if flag==0:
        break
    x+=1
print(x)

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)
        exit()
    X += 1

Solution (Python):
import math

def is_prime(x):
  if x <= 1:
    return False
  max_judge = math.sqrt(x)
  count = 2
  while(count < max_judge):
    if x % count == 0:
      return False
    count+=1
  return True
 
x = int(input())
 
judge_prime = False

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

print(x)

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


"""
for i in range(X, 2 * 10 ** 7):
    if is_prime(i):
        print(i)
        exit()
"""

while 1:
    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())
for i in range(X, 2 * 10 ** 7):
    if is_prime(i):
        print(i)
        exit()

Solution (Python):
from itertools import takewhile, count

def is_prime(x):
    if x == 1:
        return False
    for z in takewhile(lambda y: (y * y) <= x, count(2)):
        if (x % z) == 0:
            return False
    return True

def solve(x):
    while not is_prime(x):
        x += 1
    return x

print(solve(int(input())))

Solution (Python):
from math import sqrt

x = int(input())
if x == 2:
  print(2)
else:
  if x % 2 == 0:
    x += 1
  while True:
    flag = True
    for mod in range(3, int(sqrt(x))+1, 2):
      if x % mod == 0:
        flag = False
        break
    if flag:
      print(x)
      break
    else:
      x += 2

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

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

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

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

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

Solution (Python):

import sys
import math

input = list(map(float, input().split()))

q = int(input[0])

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(q):
    print(q)
    sys.exit()
  q = q + 1

Solution (Python):
import math

x = int(input())

while True:
    flag = True
    for i in range(2, int(math.sqrt(x))):
        if x % i == 0:
            flag = False

    if flag:
        print(x)
        exit()
    else:
        x += 1

Solution (Python):
def prime(x):
    flag = True
    n = 1
    while(n**2 <=x):
        n += 1
        q,r = divmod(x,n)
        if r==0:
            flag = False
            break
    return flag

def find(x):
    c = x
    while(prime(c)==False):
        c +=2
    return c


x = int(input())
if x==2:
    print(x)
elif x%2==0:
    print(find(x+1))
else:
    print(find(x))

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

n=2*10**5
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

for i in range(x,n):
  if is_prime[i]:
    print(i)
    break
  else:
    continue

Solution (Python):
m = int(input())
if m <= 2 :
  print('2')
else:
  n = 2*10**5
  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 primes[i] < m and m <= primes[i+1]:
      print(primes[i+1])

Solution (Python):
m = int(input())
if m <= 2 :
  print('2')
else:
  n = 10**6
  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 primes[i] < m and m <= primes[i+1]:
      print(primes[i+1])

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

for i in range(x, 150000):
    isPrime = True
    for j in range(2, x):
        if i%j == 0:
            isPrime = False
            break
    if isPrime == True:
        print(i)
        exit()

Solution (Python):
X = int(input())
if X == 2:
  print(2)
  exit()

num = 3
ps = [2]
while 1:
  flag = True
  for p in ps:
    if num%p == 0:
      flag = False
      break
  if flag:
    ps.append(num)
    if num>=X:
      print(num)
      exit()
  num += 2

Solution (Python):



class Prime(object):
    '''Represents a snippet for prime numbers.
    '''

    def __init__(self, number):
        self.number = number
        self._values = []

    def is_included(self) -> bool:
        '''Determine whether it is a prime number.
        Args:
            number: Int of number (greater than 0).
        Returns:
            True if the input number was prime.
            False if the input number was not prime.
        See:
            https://qiita.com/srtk86/items/874639e361917e5016d4
            https://docs.python.org/ja/3/library/2to3.html?highlight=isinstance
        '''

        from math import sqrt

        if (self.number <= 1) or (isinstance(self.number, float)):
            return False

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

        return True

    def generate(self) -> list:
        '''Generate a list of prime numbers using sieve of Eratosthenes.
        Returns:
            A list of prime numbers that is eqaul to or less than the input
            number.
        Landau notation: O(n log log n)
        See:
            https://beta.atcoder.jp/contests/abc110/submissions/3254947
        '''

        if self._values:
            return self._values

        is_met = [True for _ in range(self.number + 1)]
        is_met[0] = False
        is_met[1] = False

        for i in range(2, self.number + 1):
            if is_met[i]:
                self._values.append(i)

                for j in range(2 * i, self.number + 1, i):
                    is_met[j] = False
        return self._values


def main():
    x = int(input())
    ps = Prime(2 * 10 ** 5)

    for pi in ps.generate():
        if pi >= x:
            print(pi)
            exit()


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np


def is_prime(a):
	if a==1:
		return False
	for k in range(2, int(np.sqrt(a)) +1):
		if a % k == 0:
			return False
	return True
def main():
	a = int(input())
	while True:
		if a==2:
			print(a)
			exit()
		else:
			if is_prime(a):
				print(a)
				exit()
			else :
				a +=1
if __name__ == "__main__":
	main()

Solution (Python):
import numpy as np
a=int(input())
if a==2:
    print(2)
else:
    b = int(np.sqrt(a))
    strage = list(range(b))
    tf = False
    while tf == False:
        for n in strage:
            m = n + 2
            if a % m == 0:
                a = a + 1
                tf = False
                break
            else:
                tf = True
    print(a)

Solution (Python):
X = int(input())-1
result = False

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

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

while result == False:
  result = True
  for i in range(2,-(-X//2)+1):
    if X % i == 0:
      result = False
      break
    else:
      result = True
  if not result:
    X += 1
print(X)

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

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

Solution (Python):
def func(x):
    end = x**0.5
    i = 2
    while(i < end):
        if x%i == 0:
            return False
        i += 1
    return True

n = int(input())
for x in range(n,2*n):
    if func(x):
        print(x)
        break

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())
for i in range(x, 2*x):
    if is_prime(i):
        print(i)
        break

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())
for i in range(x, 2*x):
    if is_prime(i):
        print(i)
        break

Solution (Python):
def factorize(n):
    fct=[]
    b,e=2,0
    while b*b<=n:
        while n%b==0:
            n=n//b
            e=e+1
        if e>0:
            fct.append((b,e))
        b,e=b+1,0
    if n>1:
        fct.append((n,1))
    return fct
n=int(input())
while True:
    l=factorize(n)
    if len(l)==1 and l[0][1]==1:
        print(n)
        exit()
    else:
        n+=1

Solution (Python):
X=int(input())
testX=int(X**(1/2))+2
primeset=set()
for i in range(2,testX):
    num=0
    for p in primeset:
        if i%p != 0:
            pass
        else:
            num=1
            break
    if num==0:
        primeset.add(i)
num=0
if X in primeset:
    print(X)
    num=1
while num == 0:
    num=1
    for p in primeset:
        if X%p != 0:
            pass
        else:
            X+=1
            num=0
            break
    if num == 1:
        print(X)

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