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 sys
input=sys.stdin.readline
import math
x=int(input())
i=x
while True:
  flag="ok"
  for j in range(2,i):
    if i % j == 0:
      flag="ng"
      break
  if flag=="ok":
    print(i)
    break
  i+=1

  # int(math.sqrt(i)) + 1)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
import math
x=int(input())
i=x
while True:
  flag="ok"
  for j in range(2,int(math.sqrt(i)) + 1):
    if i % j == 0:
      flag="ng"
      break
  if flag=="ok":
    print(i)
    break
  i+=1

Submission status: Accepted

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

ceil_num = math.ceil(math.sqrt(x))


def is_prime(n):
    if n <= 1:
        return False
    else:
        pass
    for i in range(2, ceil_num):
        if n % i == 0:
            return False
    else:
        return True

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

Submission status: Accepted

Solution code:
def resolve():

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

        return True

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


resolve()

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

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

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

print(x)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

X = int(input())

import numpy as np

def make_prime(U):
    """素数判定（エラトステネスの篩）"""
    is_prime = np.zeros(U, np.bool)
    is_prime[2] = 1
    is_prime[3::2] = 1  # 3以上の奇数を一旦すべて素数としてマーク
    M = int(U**.5) + 1
    for p in range(3, M, 2):  # 倍数のふるい落とし
        if is_prime[p]:
            is_prime[p*p::p+p] = 0  # 奇数*奇数+奇数は偶数になり無駄なのでstepをp+pにして回避
    return is_prime, is_prime.nonzero()[0]

LIM = 10 ** 7
is_prime, primes = make_prime(LIM)
ans = list(filter(lambda x: x >= X, primes))[0]
print(ans)

Submission status: Accepted

Solution code:
import math
X=int(input())
ans = X
def prime(n):
    if n == 1: return False
    for i in range(2,int(math.sqrt(n))+1):
        if n%i == 0: return False
    return True

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

Submission status: Accepted

Solution code:
import math

X = int(input())

cnt = 0

# 素数判定関数 素数:True, 素数じゃない:False
def prime(x):
  for i in range(2, math.floor(math.sqrt(x)) + 1):
    if x % i == 0:
      return False
  return True
      

for j in range(1000000000):
  if prime(X) == True:
    print(X)
    break
  else:
    X += 1

Submission status: Accepted

Solution code:
# C - Next Prime
x = int(input())
while True:

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

Submission status: Accepted

Solution code:
# C - Next Prime

X = int(input())

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

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

print(X)

Submission status: Accepted

Solution code:
X = int(input())

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

Submission status: Accepted

Solution code:
x=int(input())
keep=0
haha=0
while keep==0:
  check=0
  attack=x+haha
  for i in range(2,x):
    if attack%i==0:
      check=1
      break
  if check==0:
    keep=1
  haha+=1
print(attack)

Submission status: Accepted

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

x = int(input())

while not is_prime(x):
  x += 1

print(x)

Submission status: Accepted

Solution code:
import numpy as np

n = 1000003
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 = np.array(list(primes))

x = int(input())

print(primes[np.where(primes>=x)][0])

Submission status: Accepted

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

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

if x == 2:
    print(2)
    exit()
if x % 2 == 0:
    x += 1

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

Submission status: Accepted

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


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


while not is_prime(X):
    X += 1

print(X)

Submission status: Accepted

Solution code:
x = int(input())

for i in range(x,1000001):
    ok = True
    for j in range(2,x):
        if i%j == 0:
            ok = False
            continue
    if ok:
        print(i)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def primenum(n):
  if n==2:
    return True
  elif n<2 or n%2==0:
    return False
  else:
    for i in range(3,int(n**0.5)+1,2):
      if n%i==0:
        return False
    return True

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

Submission status: Accepted

Solution code:
x = int(input())

def is_prime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return n != 1 # 1のときは例外


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ===========================素数判定 1:2以上の素数　,0：倍数    
def isPrime(x):
    if x < 2:
        return 0
    elif x == 2:
        return 1
    if x%2 == 0:
        return 0
    ir=int(x**(0.5))+1
    for i  in range(3,ir,2) :
        if x%i == 0:
            return 0
    return 1

x=int(input())

for i in range(x,10**5+4,1):
    if isPrime(i):
        print(i)
        break

Submission status: Accepted

Solution code:
x = int(input())

while(True):
    flag = True
    for i in range(2, x):
        if x % i == 0:
            flag = False
            break

    if flag:
        print(x)
        break

    x += 1

Submission status: Accepted

Solution code:

def main():
    n = int(input())
    flg = False

    while not flg:
        if is_prime(n):
            print(n)
            exit()
        else:
            n += 1

def is_prime(num):
    if num == 2:
        return True
    if num % 2 == 0:
        return False
    for i in range(3, num // 2 + 1, 2):
        if num % i == 0:
            return False

    return True

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
X =int(input())
Sqx = int(math.sqrt(X))
A=0
while A==0:
    for i in range(0,1000):
        if A != 0:
            break
        P = X
        P += i
        for j in range(2,Sqx+10):
            if P % j == 0:
                if P == j:
                    A = P
                    break
                else:
                    break
            elif j == Sqx:
                A = P
                break
print(A)

Submission status: Accepted

Solution code:
import math
x = int(input())
for k in range(x, 2 * x):
    factor = 0
    if k % 2 == 0 and k != 2:
        continue
    for divisor in range(2, math.floor(math.sqrt(k)) + 1):
        if k % divisor == 0:
            factor += 1
    if factor == 0:
        print(k)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def is_prime(x):
    if x <= 1:
        return False
    elif x == 2:
        return True
    else:
        n = 2
        while n**2 <= x:
            if x % n == 0:
                return False
            n += 1
        return True


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def get_primes(x):
    if x < 2:
        return list()
    primes = [2]
    n = 3
    while n <= x:
        is_prime = True
        for p in primes:
            if n % p == 0:
                is_prime = False
                break
            if p**2 > n:
                break
        if is_prime:
            primes.append(n)
        n += 2
    return primes


def main():
    X = int(input())
    if X <= 1:
        print(2)
        exit(0)
    primes = get_primes(X)
    while True:
        is_prime = True
        for p in primes:
            if X % p == 0 and X > p:
                is_prime = False
                break
        if is_prime:
            break
        X += 1
    print(X)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def prime(n):
    i = 2
    while i * i <= n:
        if n % i == 0:
            return 0
        i += 1
    return 1

x = int(input())
while not prime(x):
    x += 1
    # print(x)
print(x)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import itertools#これは色々使える組み込み関数みたいなやつ
import fractions
import copy
import bisect
import numpy as np
#import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
from operator import itemgetter
from sys import stdin
#input = sys.stdin.readline#こっちの方が入力が早いが使える時に使っていこう
from operator import mul
from functools import reduce
from collections import Counter
#from collections import deque

#input = stdin.readline

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

    for k in range(2, int(np.sqrt(n)) + 1):
        #sqrt(n)+1以上は考えて約数はないので却下
        if n % k == 0:
            return False
            #割り切れたらFalse
    return True

N=3
M=3
i=0
j=0
k=0
n=3
r=1
a=[0]*5
b=[]
X=int(input())#素数判定はやばい
for i in range(5000):
    if is_prime(X+i):
        print(X+i)
        sys.exit()



#r=int(input())
#print(M)
#A=int(input())
#B=int(input())
#print(N)
"1行1つの整数を入力を取得し、整数と取得する"


#number_list=list(map(int, input().split(" ")))#数字の時
#print(number_list)
"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#メモ
for i in number_list:#こっちの方がrage使うより早いらしい
    print(number_list[i-1])#

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''
#array=[input().split()for i in range(N)]
#print(type(array[0][0]))
#print(array)
"正方行列にstr型の値を入力"
'''

#brray=[list(map(int, input().split(" ")))for i in range(N)]
#print(type(brray[0][0]))
#print(brray)
'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"
#以下に別解を記載
#N, M = [int(i) for i in input().split()]
'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''




#s=input()
#a=[int(i) for i in s]
#print(a[0])
#print([a])
#単数値．桁ごとに分割したい．入力と出力は以下の通り
#イメージとして1桁ごとにリストに値を入れているかんじ

'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()#str style 何個でもいけることが多い
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''


#a= stdin.readline().rstrip()
#print(a.upper())
"aという変数に入っているものを大文字にして出力"


#a,b=map(int, input().split())  #int style 複数数値入力　「A B」みたいなスペース空いた入力のとき

#なんかうまく入力されるけど
#a=[[int(i) for i in 1.strip()]for 1 in sys.stdin]
#a = [[int(c) for c in l.strip()] for l in sys.stdin]]
#print(a)
#複数行の数値を入力して正方行列を作成


##############################################################################################
##############################################################################################
#under this line explains example calculation

'''
コンビネーションの組み合わせの中身を出力する形式
for i in itertools.combinations(brray, 2)
combinationsをpermutationsにすれば順列になる
今回なら(abc133B)
入力
1 2
5 5
-2 8
出力
[[1, 2], [5, 5], [-2, 8]]
もちろん一次元リストでも使えるし
何よりiもリストのように使えるので便利
'''

#nCr combination
'''
def cmb(n,r):
    #When n < r , this function isn't valid
    r= min(n-r,r)
    #print(n,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n-r, -1))
    #flochart mul(n,n-1)=x
    #next     mul(x,n-2)........(n-r+1,n-r)
    #mul read a,b and returns a*b

    under = reduce(mul, range(1, r+1))
    #print(over, under)
    #reduce is applied mul(1,2)=2
    #next   mul(2,3)=6
    #next   mul(6,4)=4.........last(r!,r+1)=r+1!

    return over // under
    #// is integer divide
    #calc example 5C2
    #over=5*4*3
    #under=3*2*1
a = cmb(n, r)
#print(a)
'''

'''
#集計
#example
#a=[2,2,2,3,4,3,1,2,1,3,1,2,1,2,2,1,2,1]
#a=Counter(a)
for i in a.most_common(n):print(i)
#most_common()メソッドは、出現回数が多い要素順にCounterオブジェクトを並び替えます。
#引数にint型の数字nを設定した場合は、出現回数が高い上位ｎ個の要素を返します。
#何も設定しなければ、コンテナ型にあるすべての要素を出現回数の順番に並び替えたタプル型オブジェクトを返します。
#out put
#(2, 8)
 #(1, 6)
#(3, 3)
#(4, 1)
'''


#二部探索(binary search)
#A = [1, 2, 3, 3, 3, 4, 4, 6, 6, 6, 6]
#print(A)
#index = bisect.bisect_left(A, 5) # 7 最も左(前)の挿入箇所が返ってきている
#A.insert(index, 5)
#print(index)
#print(A)
'''
bisect.bisect_left(a, x, lo=0, h=len(a))
引数
a: ソート済みリスト
x: 挿入したい値
lo: 探索範囲の下限
hi: 探索範囲の上限
(lo, hiはスライスと同様の指定方法)
bisect_leftはソートされたリストaに対して順序を保ったままxを挿入できる箇所を探索します。leftが示す通り、aにすでにxが存在している場合は、挿入箇所は既存のxよりも左側になります。また、lo, hiを指定することで探索範囲を絞り込むことも可能です。デフォルトはaの全体が探索対象です。
'''





########################################################################
########################################################################
#b2=a[:]  #1次元のときはコピーはこれで良い
#print(b2)

#a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
#b3=copy.deepcopy(a)  #2次元配列はこうコピーする
#print(b3)

Submission status: Accepted

Solution code:
import math as m

X = int(input())

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline

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

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

    while True:
        if is_prime(N):
            print(N)
            return
        N += 1



if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())

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

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

Submission status: Accepted

Solution code:
from math import sqrt

x = int(input())
ans = 0

def is_prime(num):
    if num == 0 or num == 1:
        return False
    else:
        this_is_prime = True
        for i in range(2, int(sqrt(num)) + 1):
            if num % i == 0:
                this_is_prime = False
        return this_is_prime

for num in range(x, 10**6):
    if is_prime(num):
        ans = num
        break

print(ans)

Submission status: Accepted

Solution code:
import random

def is_prime(q,k=50):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n = int(input())

i = n
while(not is_prime(i)):i += 1
print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    frui = [True] * (10 ** 5 + 4)

    for i in range(2, 10 ** 5 + 4):
        tmp = i
        if frui[tmp]:
            for j in range(2*tmp, 10 ** 5 + 4, tmp):
                frui[j] = False
    
    x = int(input())


    ans = 0
    for i in range(x, 10 ** 5 + 4):
        if frui[i]:
            ans = i
            break
    print(ans)

Submission status: Accepted

Solution code:
import math
X = int(input())
def isprime(n):
    max_n = math.floor(math.sqrt(n))
    for i in range(2, max_n+1):
        if n % i != 0:
            continue
        else:
            return False
    else:
        return True
while(not(isprime(X))):
    X = X+1
print(X)

Submission status: Accepted

Solution code:
X=int(input())

for i in range(X):
    count=0
    for j in range(X+i-2):
        if (X+i)%(j+2)==0:
            count+=1
    if count==0:
        print(X+i)
        exit(0)

Submission status: Accepted

Solution code:
x = int(input())
def prime_checker(i): #素数かどうか判定
    import sys
    if i == 1:
        return
    else:
        for j in range(2,(int(i**0.5))+1):
            if i % j == 0:
                return
        else:
            print(x)
            sys.exit()
while True:
    prime_checker(x)
    x += 1

Submission status: Accepted

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

def is_prime(n):
  if n==2:
    return True
  for p in range(2, n):
    if n % p == 0:
      return False
  return True

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

Submission status: Accepted

Solution code:
import math

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

def solve():
    X = int(input())
    while 1:
        if isPrime(X):
            return X
        X += 1

print(solve())

Submission status: Accepted

Solution code:
import math
ans=int(input().strip('\n'))
if ans!=2:
    flag=True
    while flag:
        for i in range(2,math.ceil(math.sqrt(ans))+1):
            if ans%i==0:
                flag=False
                break
        if flag:
            break
        else:
            flag=True
            ans+=1
print(ans)

Submission status: Accepted

Solution code:
def myFunc(N):
  sosu = True
  for i in range(2,N):
    sosu = sosu and N%i!=0
  return sosu

i = int(input())
while True:
  if myFunc(i): break
  i = i + 1

print(i)

Submission status: Accepted

Solution code:
from bisect import bisect_left

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

l = primes(100000)
l.append(100003)
print(l[bisect_left(l, int(input()))])

Submission status: Accepted

Solution code:

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


def main():
    X = int(input())
    for x in range(X, 2*X):
        if is_prime(x):
            print(x)
            break


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

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


def main():
    X = int(input())
    primes = get_sieve_of_eratosthenes(X*2)
    for p in primes:
        if X <= p:
            print(p)
            break


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import random


def main():
    X = int(input())
    for i in range(X, 10 ** 6):
        if is_prime(i) == True:
            print(i)
            break


def is_prime(n):
    if n == 1:
        return False
    if n == 2:
        return True
    if n == 561:
        return False
    if n == 1729:
        return False
    for _ in range(100):
        a = random.randint(2, n - 1)
        if gcd(n, a) != 1:
            return False
        if pow(a, n - 1, n) != 1:
            return False
    return True


def gcd(a, b):
    while b > 0:
        a, b = b, a % b
    return a


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math
X = int(input())
while any(X % i == 0 for i in range(2, int(math.sqrt(X)+1))):
  X += 1
print(X)

Submission status: Accepted

Solution code:
import math
X = int(input())
X -= 1
Flag = True

if X == 1:
  print(2)
  Flag = False

while Flag:
  X += 1
  r = 1
  for i in range(math.ceil(math.sqrt(X)) - 1):
    r += 1
    if X % r == 0:
      break
    if r == math.ceil(math.sqrt(X)):
      print(X)
      Flag = False

Submission status: Accepted

Solution code:
import math

def aa(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 aa(x)== False:
    x +=1
    
print(x)

Submission status: Accepted

Solution code:
N = int(input())
import math
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
def prime(q):
    a = int(math.sqrt(q))
    for i in range(2,a+1):
        if q % i == 0:
            return False
    return True
while True:
    if prime(N):
        print(N)
        exit()
    N += 1

Submission status: Accepted

Solution code:
import math
n = int(input())
while 1 > 0:
    if n == 2 or n ==3:
        break
    k = 0
    l = 0
    r = int(math.sqrt(n) // 1)
    for i in range(2, r + 1):
        if n % i == 0:
            k = 1
        if i == r:
            if k == 0:
                l = 1
    if l == 1:
        break
    else:
        n += 1

print(n)

Submission status: Accepted

Solution code:
def prime(n):
    for i in range(2,n):
        if n%i==0:
            return False
    return True

X=int(input())

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

Submission status: Accepted

Solution code:
X = int(input())
done = False
num = X - 1

while not done:
    num += 1
    if num > 1:
        for i in range(2, num):
            if (num % i) == 0:
                break
        else:
            done = True

print(num)

Submission status: Accepted

Solution code:
x = int(input())
isPrime = False


def isP(num):
    for i in range(2, num):
        if num % i == 0:
            return False
    return True


isPrime = isP(x)

if isPrime:
    print(x)
else:
    while isPrime == False:
        x += 1
        isPrime = isP(x)
    print(x)

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
import math
n = int(input())
for i in range(n, 2**n):
  cnt = 0
  for j in range(2, n):
    if i%j==0:
      cnt += 1
  if cnt ==0:
    print(i)
    break;

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=int(input())

sosu=[]

i=2
import math

while 1:
    sqrt_i =int(math.sqrt(i))

    flag=0
    for item in sosu:
        if item>sqrt_i:
            break
        if i%item==0:
            flag=1
            break

    if flag==0:
        sosu.append(i)
        if i>=x:
            print(i)
            exit()
    i+=1

Submission status: Accepted

Solution code:
X = int(input())

p = X
while True:
    for j in range(2, int(p ** 0.5) + 1):
        if p % j == 0: break
    else:
        break
    p += 1

print(p)

Submission status: Accepted

Solution code:
X = int(input())

n = 2 * X
is_prime = [False] * 2 + [True] * (n - 1)

for i in range(2, int(n ** 0.5) + 1): # 素数候補
    if not is_prime[i]: continue
    for j in range(2 * i, n + 1, i):
        is_prime[j] = False

for i in range(X, n):
    if is_prime[i]:
        print(i)
        break

Submission status: Accepted

Solution code:
x = int(input())
def han(n):
    p = 1
    for i in range(2,int(n**0.5)+1):
        if n%i == 0:
            p = p*0
        else:
            continue
    return p
for j in range(x,x+10000):
    if han(j) == 1:
        print(j)
        break

Submission status: Accepted

Solution code:
def prime(n):
    for i in range(2,n):
        if n%i==0:
            return False
    return True

n=int(input())

i=0
while True:
    if prime(n+i):
        print(n+i)
        exit()
    else:
        i+=1

Submission status: Accepted

Solution code:
def prime(n):
    for i in range(2,n):
        if n%i==0:
            False
            return
    return True

n=int(input())

i=0
while True:
    if prime(n+i):
        print(n+i)
        exit()
    else:
        i+=1

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
x = int(input())

# x までの素数を探す
prim_numbers = [2]
for divided in range(3, x, 2):
    for prim in prim_numbers:
        if divided % prim == 0:
            continue
        else:
            prim_numbers.append(divided)
            break


def is_prim(q):
    for divider in prim_numbers:
        if q % divider == 0:
            return False
    return True


# 2 なら終わり
if x == 2:
    print(x)
    exit()
# 偶数なら、奇数だけ調べるようにする
if x % 2 == 0:
    x += 1
while True:
    if is_prim(x):
        print(x)
        exit()
    else:
        x += 2
        continue

Submission status: Accepted

Solution code:
X=int(input())


while True:

    flg = 0
    for i in range(1,X+1):
        if X%i==0:
            if i!=1 and  i!=X:
                flg=1
    
    if flg == 0:
        break

    X+=1

print(X)

Submission status: Accepted

Solution code:
X = int(input())
isPrime = [True] * (X * 2)
isPrime[0] = False
isPrime[1] = False

for i in range(2,X):
  for j in range(i,X*2,i):
    isPrime[j] = False
  
ans = None
for i in range(X,X*2):
  if isPrime[i]:
    ans = i
    break
    
print(ans)

Submission status: Accepted

Solution code:
X = int(input())

def is_prime(x): #素数判定
    flag = True
    for i in range(2, x):
        if x % i == 0:
            return False
    return True

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

Submission status: Accepted

Solution code:
x = int(input())
ans = 0

for i in range(x,10**5+4):
    if ans != 0:
        break
    
    for j in range(2,i):
        if i % j == 0:
            break
        elif j == i-1:
            ans = i

if x == 2:
    ans = 2

print(ans)

Submission status: Accepted

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

for i in range(n,10**6):
  count = 0
  for j in range(2, int(math.sqrt(i))):
    if(i % j == 0 and i != j):
      count = 1
      break
  if(count == 0):
    print(i)
    break

Submission status: Accepted

Solution code:
X = int(input())

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

Submission status: Accepted

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

import math

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

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

Submission status: Accepted

Solution code:
x = int(input())
ans = 2

p = [2]
i = 1
Flag = True
while i**2 < 100001:
    i += 2
    for j in p:
        if i%j == 0:
            break
        elif j == p[-1]:
            p.append(i)
for i in range(100000):
    if x+i in p:
        ans = x+i
        break
    elif x+i > p[-1]:
        for j in p:
            if (x+i)%j == 0:
                break
            elif j == p[-1]:
                ans = x+i
                break
        if ans == x+i:
            break

print(ans)