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



Sample input:
20


Sample output:
23

Submission status: Accepted

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

def get_prime(n):
    if n <= 1:
        return []
    prime = [2]
    limit = 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

plist = get_prime(200000)
ans = 0
for y in range(x, 200000):
    if y in plist:
        ans = y
        break
    else:
        pass

print(ans)

Submission status: Accepted

Solution code:
x = int(input())

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

print(m)

Submission status: Accepted

Solution code:
def is_prime(x):
    for i in range(2, x):
        if x%i == 0:
            return 1
    return 0

x = int(input())

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

Submission status: Accepted

Solution code:
import numpy as np
X = int(input())
A = np.array(range(X,X+100))
if X==2:
    print(X)
    exit()

A = np.array(range(3,10**5+4,2))
for i in range(3,int(np.sqrt(10**5+4))+1000,2):
    A = np.where((A%i == 0) & (A//i != 1), 1, A)

A = np.sort(A)
I = np.searchsorted(A,X, side="left")
print(A[I])

Submission status: Accepted

Solution code:
import math

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

x = int(input())

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    x=int(input())
    ans=x
    while True:
        flag=False
        for i in range(2,int(x**0.5)):
            if ans%i==0:
                flag=True
                break
        if flag:
            ans+=1
            continue
        else:
            break
    print(ans)
resolve()

Submission status: Accepted

Solution code:
sieve = [True] * (10**6 + 1)
for i in range(2, 10**3):
  if sieve[i]:
    for j in range(i**2, 10**6, i):
      sieve[j] = False
sieve[0] = sieve[1] = False
x = int(input())
ind = x
while True:
  if sieve[ind]:
    print(ind)
    break
  ind += 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
ans = X
while True:
  flag = False
  for i in range(2,int(X**0.5)):
    if ans%i==0:
      flag = True
      break
  if flag:
    ans += 1
    continue
  else:
    break
print(ans)

Submission status: Accepted

Solution code:
x = int(input())
num = 0
j = 1
while(j):
    ans = 1
    for i in range(2,1000):
        if (x+num)%i == 0 and x+num > i :
            ans = 0
            break
        elif x + num <= i:
            break
        else:
            pass
    if ans == 1:
        j = 0
    num +=1

print(x+num-1)

Submission status: Accepted

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

if x == 2:
    print(2)
    exit()
 
while True:
    f = True
    g = math.ceil(math.sqrt(x))
    for i in range(2,g+1):
        if x%i == 0:
            f = False
            break
    if f == True:
        print(x)
        exit()
    x += 1

Submission status: Accepted

Solution code:
import math

x = int(input())

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

while True:
    f = True
    g = math.ceil(math.sqrt(x))
    for i in range(2,g+1):
        if x%i == 0:
            f = False
            break
    if f == True:
        print(x)
        exit()
    x += 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())
ans=x-1
cnt=0
while cnt==0:
	cnt=1
	ans+=1
	for i in range(2,ans):
		if ans%i==0:
			cnt=0
			break
print(ans)

Submission status: Accepted

Solution code:
x=int(input())
ans=x-1
cnt=0
while cnt==0:
	cnt=1
	ans+=1
	for i in range(2,ans):
		if ans%i==0:
			cnt=0
print(ans)

Submission status: Accepted

Solution code:
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:
    print(X)
    break
  
  X += 1

Submission status: Accepted

Solution code:
X=int(input())

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

for i in range(1000):
    A=is_prime(X+i)
    if A==True:
        print(X+i)
        break

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

X = int(input())


for i in range(X, 10**100):
    if all(i%j != 0 for j in range(2, int(i**(1/2)+1))):
        print(i)
        exit()

Submission status: Accepted

Solution code:
def is_prime(n):
    if n == 1:
        return False
    else:
        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) == False:
    X += 1

print(X)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

N = 200000   # N is max number
prime = [True]*(N+1)
prime[0] = False
prime[1] = False

R = int(math.sqrt(N))

for i in range(2, R+1):
    if prime[i]:
        cnt = 2
        while i * cnt <= N:
            prime[i * cnt] = False
            cnt += 1

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

Submission status: Accepted

Solution code:
import math

x = int(input())

for num in range(x, 100003+1):
    cnt = 0
    # 素数を見つける割り算は半分でいい
    for i in range(2, int(math.sqrt(num))+1):
        if num % i == 0:
            cnt += 1
    if cnt == 0:
        print(num)
        break

Submission status: Accepted

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

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

while non_prm(X):
    X += 1

print(X)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
X = int(input())
if X == 2:
    print(2)
    exit()
while True:
    N = int(X**0.5)
    for i in range(1,N):
        if X % (i+1) == 0:
            break
        else:
          if i == N - 1:
            print(X)
            exit()
    X += 1

Submission status: Accepted

Solution code:
def prime(X):
    if X<2:
        return False
    if X==2:
        True
    for i in range(2,X):
        if X%i==0:
            return False
    return True
X=int(input())
p=False
while p==False:
    p=prime(X)
    X+=1
print(X-1)

Submission status: Accepted

Solution code:
import math
def solve():
   X = int(input())
   while True:
       for i in range(2, math.floor(math.sqrt(X))+1):
           if X%i == 0:
               break
       else:
           print(X)
           exit()
       X += 1



if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

X = ri()

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

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

Submission status: Accepted

Solution code:
X=int(input())

def prime(N):
  for i in range(2,N-1):
    if N%i==0:
      return -1
  
  return N

for x in range(X,10**10):
  if prime(x)==x:
    print(x)
    break

Submission status: Accepted

Solution code:
x = int(input())
count = x

while(1):
    check = 0
    for i in range(1,count+1):

        if count % i == 0:
            check += 1
    if check == 2:
        break
    count += 1
print(count)

Submission status: Accepted

Solution code:
import math
n = int(input())
div = math.floor(math.sqrt(n))
def sosu(n):
    if n <= 1:
        return False
    for i in range(2,div+1):
        if n%i==0:
            return False
    return True
while True:
    if sosu(n):
        print(n)
        break
    else:
        n+=1

Submission status: Accepted

Solution code:
X = int(input())

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 is_prime

arr =primes(10**5+100)

for i in range(X,10**5+100,1):
    if arr[i]:
        print(i)
        exit()

Submission status: Accepted

Solution code:
from math import sqrt
def judge(num):
    if num < 2:
        return False
    elif num == 2:
        return True
    elif num % 2 == 0:
        return False
    else:
        for i in range(3,int(sqrt(num))+1,2):
            if num % i == 0:
                return False
        return True
s = int(input()) 
while(1):
    if judge(s):
        print(s)
        break
    else:
        s += 1

Submission status: Accepted

Solution code:
X = int(input())

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]]

prime_list = primes(100100)

for i in prime_list:
    if X <= i:
        print(i)
        exit()

Submission status: Accepted

Solution code:
import math

X = int(input())

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

Submission status: Accepted

Solution code:
x = int(input())
if x == 2:
         print(x)
         exit()
for i in range(x,100004):
         for j in range(2,max(3,int(i**(1/2))+1)):
                  if i % j == 0:
                           break
         else:
                  print(i)
                  exit()

Submission status: Accepted

Solution code:
def abc149_c():

  def primes_list(n):
    # n以下の素数リスト
    # https://qiita.com/chun1182/items/ddf2b6cba932b2bb0d4e
    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 list(primes)

  # 制約範囲内とその次まで、すべて用意しておく
  all_primes = primes_list(10**5)
  all_primes.append(100003)
  all_primes.sort()

  # 小さい順にxと比較してx以上なら出力して終了
  x = int(input())
  for p in all_primes:
    if x <= p:
      print(p)
      return

abc149_c()

Submission status: Accepted

Solution code:
N = int(input())
n = 11**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)
print(min([i for i in primes if i >= N]))

Submission status: Accepted

Solution code:

x=int(input())
j=0

while j==0:
    ans=0
    if x%2==0 and x!=2:
        x+=1
        continue
    for i in range(2,x//2):
        if x%i==0:
            ans+=1
    if ans==0:
        j=x

    x+=1

print(j)

Submission status: Accepted

Solution code:
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
    else:
        X += 1

Submission status: Accepted

Solution code:

X = int(input())

flg = 1
ans = 0
for i in range(X, 10**100):
    flg = 1
    for j in range(2, i):
        if i % j == 0:
            flg = 0
            break
    if flg == 1:
        ans = i
        break

print(ans)

Submission status: Accepted

Solution code:
import math

N = int(input())

for j in range (N, 1000000):
    t = 0
    dest = int(math.sqrt(j))

    for i in range(2,dest+1):
        if j % i == 0:
            t = 1
            break

    if t == 0:
        print(j)
        break

Submission status: Accepted

Solution code:
X = int(input())


def calculate(x):
    if x == 2:
        return 2

    while not condition(x):
        x = x + 1

    return x

def condition(x):
    result = True
    for i in range(2,x):
        if x % i == 0:
            result = False
            break

    return result


result = calculate(X)

print(result)

Submission status: Accepted

Solution code:
from math import *
x = int(input())
if x == 2 or x == 3:
    print(x)
else:
    while True:
        done = True
        if x % 6 != 1 and x % 6 != 5:
            done = False
        else:
            upper = floor(sqrt(x))
            for i in range(2, upper+1):
                if x % i == 0:
                    done = False
                    break
        if done:
            print(x)
            break
        x += 1

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
#import math
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()

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# C

import sys
# 再起回数上限変更
# sys.setrecursionlimit(1000000)

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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

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

def readInts():
  return list(map(int,input().split()))
def main():
    # X 以上の素数のうち、最小のもの
    X = int(input())
    PrimeList = defaultdict(int)
    while True:
        # X を増やし続ける
        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()

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
X = int(input())

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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