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:
  flag = True
  for i in range(2,x//2+1):
    if x % i == 0:
      flag = False
  if flag:
    print(x)
    exit()
  x += 1

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

if x == 2:
    print(2)
    quit()
li = [2]
for i in range(3, 10**6, 2):
    for j in li:
        if i % j == 0:
            break
    else:
        if i >= x:
            print(i)
            quit()
        li.append(i)

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

result = 0

now = X

while result == 0:
    for i in range(2, now + 1):
        if i == now:
            result = i
        elif now % i == 0:
            break
    now += 1
print(result)

Solution (Python):

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



def main():
	N = int(input())
	while not prime(N):
		N+=1
	print(N)
main()

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

for i in range(x, 10**6):
  for k in range(2, i):
    if i % k != 0: 
      continue;
    else: 
      break;
  else:
    break;
  
print(i)

Solution (Python):



import sys



X = int(input())


def is_prime(n: int) -> bool:
    """
    素数判定
    >>> p = Mint()
    >>> p.is_prime(2)
    True
    >>> p.is_prime(43)
    True
    >>> p.is_prime(4)
    False
    """

    if n == 1:
        return False
    if n == 2:
        return True

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


def enumerate_prime(n: int) -> (list, dict, list):
    """
    n以下の素数を列挙する
    何で割るかを記録しておくことで、素因数分解が高速にできる
    >>> p = Mint()
    >>> p.enumerate_prime(11)
    ([2, 3, 5, 7, 11], {2: 0, 3: 1, 5: 2, 7: 3, 11: 4}, [0, 1, 2, 3, 2, 5, 3, 7, 2, 3, 5, 11])
    """

    lis_prime = [True] * (n + 1)
    lis_prime[0] = False
    lis_prime[1] = False

    primes = []
    div_prime = [i for i in range(n + 1)]
    primes_idx = {}

    cnt = 0
    for i in range(2, n + 1):
        if lis_prime[i]:
            primes.append(i)
            primes_idx[i] = cnt
            cnt += 1

            j = 2 * i
            while True:
                if j > n:
                    break
                lis_prime[j] = False
                div_prime[j] = i
                j += i

    return primes, primes_idx, div_prime


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

Solution (Python):
X=int(input())
Y=[i for i in range(100005)]
for j in range(2,333):
  k=100004 // j  
  for a in range(2,k+1):
    Y[a*j] = 0 
b=X
while True:
  if Y[b] != 0:
    print(b)
    break
  else:
    b += 1

Solution (Python):
from statistics import median


from itertools import combinations 
from collections import deque
from collections import defaultdict
import bisect










import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    
    X = int(input())
    PrimeList = defaultdict(int)
    while True:
        
        i = 2
        a = X
        flag = True
        while i * i <= a:
            if a % i == 0:
                X += 1
                
                flag = False
                break
            else:
                i += 1
        if flag:
            print(X)
            exit()

if __name__ == '__main__':
  main()

Solution (Python):
import math
import sys
def isprime(x):
    m = int(math.sqrt(x))
    if m%2 == 1: m += 2
    for i in range(3, m, 2):
        if x%i == 0: return False
    return True

x = int(input())
if x == 1 or x == 2:
    print(x)
    sys.exit()
if x%2 == 0: x += 1
while True:
    if isprime(x):
        print(x)
        break
    x += 2

Solution (Python):
n=int(input())
p=[i for i in range(3,n+1,2)]
p=[2]+p
prime=[2]
std=[True]*(n+1)
for i in p:
  if std[i]:
    if i%prime[-1]!=0:
      prime.append(i)
      for j in range(n//i+1):
        std[i*j]=False
  else:
    continue
if n in prime:
  print(n)
else:
  for i in range(n):
    t=n+i
    for j in prime:
      if t%j==0:
        break
    else:
      print(n+i)
      break

Solution (Python):
import math
X = int(input())
def isPrime(n):
  if n == 1:
    return False
  max = math.ceil(math.sqrt(n))
  for i in range(2,max):
    if n % i == 0:
      return False
  return True

while(True):
  if isPrime(X):
    print(X)
    quit()
  else:
    X = X+1

Solution (Python):
X = int(input())
for i in range(X, 100005):
  for j in range(2,i):
    if i%j == 0:
      break
  else:
    print(i)
    quit()

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 (1):
    if is_prime(x):
        print(x)
        exit()
    else:
        if x % 2 == 0:
            x += 1
        else:
            x += 2

Solution (Python):
def isPrime(n):
  if (n%2 == 0):
    return n == 2
  
  i = 3;
  while(i*i <= n):
    if (n%i == 0):
      return False
    i += 2
  
  return True



x = int(input())
while True:
  if (isPrime(x)):
    print(x)
    break
  x += 1

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

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

    while True:
        flag_prime = True
        x_ = int(x**0.5) + 1

        for i in range(2, x_):
            if x % i == 0:
                flag_prime = False
                break

        if flag_prime:
            break

        x += 1

    print(x)


if __name__ == "__main__":
    main()

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

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


if __name__ == "__main__":
    main()

Solution (Python):
def is_prime(x):
    if x<=1:
        return False
    for i in range(2,x):
        if x%i==0:
            return False
    return True

x=int(input())
p=False
while p==False:
    p=is_prime(x)
    x+=1
print(x-1)

Solution (Python):
X = int(input())
max_num = 100004
ans = 0
for i in range(X, max_num):
    cnt = 0
    for j in range(2, i+1):
        if i%j==0:
            cnt += 1
    if cnt == 1:
        ans = i
        break

print(ans)

Solution (Python):
import math
def main():
    X = int(input())
    for i in range(X, 2*10**5+1):
        if i % 2 == 0 and i != 2:
            continue
        is_prime = True
        for j in range(2, math.floor(math.sqrt(i))+1):
            if i % j == 0:
                is_prime = False
        if is_prime :
            print(i)
            break
if __name__ == "__main__":
    main()

Solution (Python):
from math import sqrt

def eratosthenes(n):
    if n <= 1:
        return []
    prime = [2]
    lim = int(sqrt(n))
    num = list(range(3, n, 2))

    while lim > num[0]:
        prime.append(num[0])
        num = [i for i in num if i % num[0] != 0]
    
    return prime + num

X = int(input())

for p in eratosthenes(10**5):
    if p >= X:
        print(p)
        break
    elif X > 99991:
        print(100003)
        break

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

if n==2: print(n)
else: 
  for i in range(n,999999,1):
    for j in range(2,i):
      
      if i%j==0: break
      elif j==i-1:
        print(i)
        exit(0)

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

Solution (Python):
X = int(input())
def primes():
    """
    素数のジェネレータ
    """
    d = {}
    q = 2
    while True:
        if q not in d:
            yield q
            d[q * q] = [q]
        else:
            for p in d[q]:
                d.setdefault(p + q, []).append(p)
            del d[q]
        q += 1

for p in primes():
    if p >= X:
        print(p)
        break

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

import math

while True:
  
    if n == 2:
      print(n)
      break

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
          flag = False
    
    if flag==False:
      n+=1
      flag = True
    else:
      print(n)
      break

Solution (Python):
X=int(input())
if X==2:
  pass
if X%2==0 and X!=2:
  X+=1
flag=0
while flag==0:
  if all(X%i!=0 for i in range(3,X-1,2)):
    flag=1
  else:
    X+=2
print(X)

Solution (Python):
import math
def get_prime(n):
    if n <= 1:
        return[]
    prime = [2]
    limit = int(math.sqrt(n))

    data = [i+1 for i in range(2,n,2)]
    while limit > data[0]:
        prime.append(data[0])
        data = [j for j in data if j% data[0] != 0]
    return prime + data
prime_num = get_prime(100003)

x = int(input())
for i in prime_num:
    if x <= i:
        print(i)
        exit()

Solution (Python):
X=int(input())
def is_prime(q,k=100):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    for i in range(3,k):
        x,y = q,i
        while y:
            x, y =  y, x % y
        if x != 1: continue
        if pow(i, q-1, q) != 1:
            return False
    return True
flag=False
while(flag==False):
    if is_prime(X):
        print(X)
        flag=True
        break
    X+=1

Solution (Python):
X=int(input())
def is_prime(q,k=100):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    for i in range(3,k):
        x,y = q,i
        while y:
            x, y =  y, x % y
        if x != 1: continue
        if pow(i, q-1, q) != 1:
            return False
    return True
flag=False
while(flag==False):
    if is_prime(X):
        print(X)
        flag=True
        break
    X+=1

Solution (Python):
X=int(input())
def is_prime(q,k=100):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    for i in range(3,k):
        x,y = q,i
        while y:
            x, y =  y, x % y
        if x != 1: continue
        if pow(i, q-1, q) != 1:
            return False
    return True
flag=False
while(flag==False):
    if is_prime(X):
        print(X)
        flag=True
        break
    X+=1

Solution (Python):
X=int(input())
def is_prime(q,k=100):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    for i in range(3,k):
        x,y = q,i
        while y:
            x, y =  y, x % y
        if x != 1: continue
        if pow(i, q-1, q) != 1:
            return False
    return True
flag=False
while(flag==False):
    if is_prime(X):
        print(X)
        flag=True
        break
    X+=1

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

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

def main(x):
  dx = 0
  while(True):
    if(isPrime(x+dx)):
      return x+dx
    dx+=1

result = main(X)
print(result)

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

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

def main(x):
  dx = 0
  while(True):
    if(isPrime(x+dx)):
      return x+dx
    dx+=1

result = main(X)
print(result)

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

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

for i in range(x, 1000000):
    if isPrime(i):
        print(i)
        break

Solution (Python):
X = int(input())
count = 0
flag = False
for i in range(X, 100004):
    for k in range(2,X):
        if i%k==0:
        	break
        else:
            count += 1
        if count == X-2:
            print(i)
            flag = True
            break
    if flag:
        break
if X == 2:
    print(2)

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

def is_prime(p):
    if p in [2, 3]:
        return True
    if p % 2 == 0:
        return False
    if p % 3 == 0:
        return False
    for i in range(5, int(p**(1/2)+1)):
        if p % i == 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 k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


for i in range(X, 10**7):
    if is_prime(i):
        print(i)
        break

Solution (Python):
from numpy import sqrt
x = int(input()) -1
isprime = False
while not isprime:
    x += 1
    d = int(sqrt(x))
    isprime = True
    for i in range(2,x-1):
        if (x%i == 0) and (x != i):
            isprime = False
            break
print(x)

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

for i in range(X, 100010):
    for j in range(2, i):
        if i % j == 0:
            break
    else:
        print(i)
        break

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

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

print(x)

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

X=int(input())

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

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

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

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

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

Solution (Python):
import math


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


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

Solution (Python):
a=int(input())-1
hantei=0
if a>1:
    while hantei==0:
        a+=1
        ct=1
        while 1:
            ct+=1
            if a%ct==0:
                break
            if ct>(a/2):
                hantei=1
                break
else:
    a=2
print(a)

Solution (Python):
from itertools import permutations as perm
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)


args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def is_prime(v):
    """素数"""
    if v <= 1:
        return False
    if v == 2:
        return True
    if v % 2 == 0:
        return False
    for x in range(3, ceil(v ** 0.5), 2):
        if v % x == 0:
            return False
    return True


def main():
    """エントリーポイント"""
    N = input(int)
    for x in range(N, 100003 + 1):
        if is_prime(x):
            print(x)
            break


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()

Solution (Python):
import math
X=int(input())
if X==2:
    print(2)
else:
    n=1
    while n==1:
        for j in range(2,int(math.sqrt(X))+1):
            if j==int(math.sqrt(X)) and X%j!=0:
                n=0
                print(X)
            elif X%j==0:
                X+=1
                break

Solution (Python):
from itertools import permutations as perm
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)


args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def is_prime(v):
    if v <= 1:
        return False
    for x in range(2, floor(v ** 0.5)):
        if v % x == 0:
            return False
    return True


def main():
    """エントリーポイント"""
    N = input(int)
    for x in range(N, 100003 + 1):
        if is_prime(x):
            print(x)
            break


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()

Solution (Python):
from itertools import permutations as perm
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)


args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    N = input(int)
    primes = [2]
    for x in range(3, 100000 + 100, 2):
        for p in primes:
            if x % p == 0:
                break
        else:
            primes.append(x)
    for p in primes:
        if N <= p:
            print(p)
            break


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()

Solution (Python):
from math import floor, sqrt

x = int(input())

if x == 2:
    print(x)
    exit()

if x % 2 == 0:
    x += 1

while True:
    stop = floor(sqrt(x)) + 1
    for i in range(3, stop, 2):
        if x % i == 0:
            x += 2
            break
    else:
        break
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

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

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

print(x)

Solution (Python):
from math import sqrt


def IsPrime(num):
    if num < 2:
        return True
    elif num == 2:
        return True
    elif num % 2 == 0:
        return False

    sqrtNum = sqrt(num)
    for i in range(3, int(sqrtNum) + 1, 2):
        if num % i == 0:
            return False

    return True


if __name__ == "__main__":
    x = int(input())

    for i in range(x, 10**5+4):
        if IsPrime(i):
            print(i)
            exit()

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

import math

serach_number = 100


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

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

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())
while is_prime(X) != True:
  X += 1

print(X)

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())
while is_prime(X) != True:
  X += 1

print(X)

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


j = True
s = []
while j == True:
    for p in range(2, X):
        if X % p == 0:
            s.append(False)
        else:
            s.append(True)

    if all(s) == True:
        print(X)
        exit()
    else:
        X += 1
        s = []

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())
for i in range(x, 2*x+1):
    flg = is_prime(i)
    if flg == True:
        ans = i 
        break
print(ans)

Solution (Python):
x=int(input())
A=10**6
pn=[2]
for L in range(3, A, 2):
    if x==2:
        print(2)
        exit()
    if all(L % L2 != 0 for L2 in pn):
        pn.append(L)
        if L>=x:
            k=L
            break
print(k)

Solution (Python):
import sys

X = int(input())

def prime(x):

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

while 1:
    if True==prime(X):
        print(X)
        sys.exit()
    X = X + 1

Solution (Python):
x = int(input())
max_x = 100003
f = [0 for _ in range(max_x+1)]
f[0] = -1
f[1] = -1
primes = []
for i in range(2, max_x+1):
    if f[i]:
        continue
    primes.append(i)
    f[i] = i
    for j in range(i*i, max_x+1, i):
        if f[j] == 0:
            f[j] = i

for p in primes:
    if x <= p:
        print(p)
        break

Solution (Python):
import math
import bisect
prime = [2]
max = 10 ** 5 + 7
limit = int(math.sqrt(max))
data = [i + 1 for i in range(2, max, 2)]

while limit > data[0]:
    prime.append(data[0])
    data = [j for j in data if j % data[0] != 0]
prime = prime + data

x = int(input())
ans = bisect.bisect_left(prime, x)
print(prime[ans])

Solution (Python):
def is_prime(k):
    import math
    if k % 2 == 0 and k != 2:
        return False
    for divisor in range(2, math.floor(math.sqrt(k))+1):
        if k % divisor == 0:
            return False
    return True
import sys
x = int(input())
while True:
    if is_prime(x):
        print(x)
        sys.exit()
    x+=1

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

Solution (Python):
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

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

max = 10**9

for i in range(x, max):
    if is_prime(i):
        print(i)
        break

Solution (Python):

import math

X = int(input())
  



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

for i in range(X,10**10):
    if is_prime(i):
        print(i)
        break

Solution (Python):
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n + 1):
        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())
l=primes(100010)
for i in range(len(l)):
  if l[i]>=x:
    print(l[i])
    exit()

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

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

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

if x == 2:
    print(2)
    exit()

flag = True
x -= 1
while flag:
    x += 1
    i = 2
    while flag:
        if x % i == 0:
            break
        elif i ** 2 >= x:
            flag = False
        else:
            i += 1
print(x)

Solution (Python):
import math

ip = int(input())

if ip == 2:
    print(2)
    exit()

primes = [2]
for i in range(3, 100001, 2):
    for p in primes:
        if i % p == 0:
            break
    else:
        primes.append(i)

primes.append(100003)
primes = primes[::-1]

for i in range(len(primes)):
    if primes[i] < ip:
        print(primes[i - 1])
        exit()

Solution (Python):

import sys
import math

def isPrime(n):
    if n == 2:
        return True
    if n % 2 == 0:
        return False

    
    m = math.floor(math.sqrt(n)) + 1
    for p in range(3, m, 2):
        if n % p == 0:
            return False
    return True

def solve(X: int):
    for i in range(X,10**16):
        if isPrime(i):
            print(i)
            exit()
    return



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):
n = int(input())
m = n
if n in [2,3]:
  print(n)
  exit()
while True:
  for i in range(2,int(m**0.5)+1):
    if m %i == 0:
      break
    elif i > int(m**0.5)-1:
      print(m)
      exit()
  m += 1

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

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

p = [0]*1000001
for i in range(2,n):
    if(p[i] == 0):
        for j in range(i,1000001,i):
            p[j] = 1

result = 0
for i in range(n,1000001):
    if(p[i] == 0):
        result = i
        break

print(result)

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

def factors(x):
  a = []
  for i in range(1, x + 1):
      if x % i == 0:
          a.append(i)
  return a

f = (factors(num))

if (len(f) != 2): 
  while (len(f) != 2): 
    num += 1
    f = factors(num)
  print (num)
else: 
  print (num)

Solution (Python):
X = int(input())
x = X
X *= 2
work = [True for i in range(X)]
for i in range(2, int(X**0.5)+1):
    if not work[i]:
        continue
    for j in range(i*2, len(work), i):
        work[j] = False
prime = []
for i in range(2, len(work)):
    if work[i] and i>=x:
        result = i
        break
print(result)

Solution (Python):
import sys
from bisect import bisect_left as bi_l

def sieve_of_eratosthenes(n=5 * 10 ** 6):
  sieve = [1] * (n + 1); sieve[0] = sieve[1] = 0
  for i in range(2, int(n ** 0.5) + 1):
    if not sieve[i]: continue
    for j in range(i * 2, n + 1, i): sieve[j] = 0
  prime_numbers = [i for i in range(2, n + 1) if sieve[i]]
  return sieve, prime_numbers

is_prime, prime_numbers = sieve_of_eratosthenes()

def prime_factorize(n):
  res = dict()
  if n < 2: return res
  border = int(n ** 0.5)
  for p in prime_numbers:
    if p > border: break
    while n % p == 0: res[p] = res.get(p, 0) + 1; n //= p
    if n == 1: return res
  res[n] = 1
  return res

def prime_factorize_factorial(n):
  res = dict()
  for i in range(2, n + 1):
    for p, c in prime_factorize(i).items(): res[p] = res.get(p, 0) + c
  return res

x = int(sys.stdin.readline().rstrip())

def main():
    i = bi_l(prime_numbers, x)
    print(prime_numbers[i])

if __name__ ==  '__main__':
    main()

Solution (Python):
import sys

import numpy as np
def sieve_of_eratosthenes(n=5 * 10 ** 7):
  sieve = np.ones(n + 1); sieve[:2] = 0
  for i in range(2, int(np.sqrt(n)) + 1):
    if sieve[i]: sieve[i*2::i] = 0
  return sieve, np.flatnonzero(sieve)

is_prime, prime_numbers = sieve_of_eratosthenes()

def prime_factorize(n):
  res = dict()
  if n < 2: return res
  border = int(n ** 0.5)
  for p in prime_numbers:
    if p > border: break
    while n % p == 0: res[p] = res.get(p, 0) + 1; n //= p
    if n == 1: return res
  res[n] = 1
  return res

def prime_factorize_factorial(n):
  res = dict()
  for i in range(2, n + 1):
    for p, c in prime_factorize(i).items(): res[p] = res.get(p, 0) + c
  return res

x = int(sys.stdin.readline().rstrip())

def main():
    i = np.searchsorted(prime_numbers, x, side='left')
    print(prime_numbers[i])

if __name__ ==  '__main__':
    main()

Solution (Python):
import sys

import numpy as np
def sieve_of_eratosthenes(n=10 ** 7):
  sieve = np.ones(n + 1); sieve[:2] = 0
  for i in range(2, int(np.sqrt(n)) + 1):
    if sieve[i]: sieve[i*2::i] = 0
  return sieve, np.flatnonzero(sieve)

is_prime, prime_numbers = sieve_of_eratosthenes()

def prime_factorize(n):
  res = dict()
  if n < 2: return res
  border = int(n ** 0.5)
  for p in prime_numbers:
    if p > border: break
    while n % p == 0: res[p] = res.get(p, 0) + 1; n //= p
    if n == 1: return res
  res[n] = 1
  return res

def prime_factorize_factorial(n):
  res = dict()
  for i in range(2, n + 1):
    for p, c in prime_factorize(i).items(): res[p] = res.get(p, 0) + c
  return res

x = int(sys.stdin.readline().rstrip())

def main():
    i = np.searchsorted(prime_numbers, x, side='left')
    print(prime_numbers[i])

if __name__ ==  '__main__':
    main()

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

while is_prime(n) is False:
    n+=1
print(n)

Solution (Python):
import math
x = int(input())
for i in range(x, 100004):
    flag = True
    for j in range(2, math.floor(math.sqrt(i)+1)):
        if i % j == 0:
            flag = False
            break
    if flag:
        print(i)
        exit(0)

Solution (Python):
import math

x = int(input())
a = 1

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