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: Runtime Error

Solution code:
x = input()

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

Submission status: Runtime Error

Solution code:
import sys
from collections import deque


   
def resolve():
    
    input = sys.stdin.readline
    N,K=map(int,input().rstrip().split())
    R,S,P=map(int,input().rstrip().split())
    T=list(input().rstrip())

    ans=0
    flag=[0 for _ in range(N)]
    for i in range(N):
        if T[i]==T[i-K] and i>=K and flag[i-K]==True: #足さない条件、K個前が既に制約で足せなくなっていた時は、今回は足せるようになるのでflag管理
            continue
        if T[i]=="r":
            ans+=P
        if T[i]=="s":
            ans+=R
        if T[i]=="p":
            ans+=S
        flag[i]=True
    print(ans)

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """5 2
8 7 6
rsrpr"""
        output = """27"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """7 1
100 10 1
ssssppr"""
        output = """211"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """30 5
325 234 123
rspsspspsrpspsppprpsprpssprpsr"""
        output = """4996"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Submission status: Runtime Error

Solution code:
from sympy import nextprime
N = int(input())
print(nextprime(N))

Submission status: Runtime Error

Solution code:
def is_prime(x):
    n = math.floor(math.sqrt(x))
    for i in range(2,n+1):
        if x % i == 0:
            return False
    return True            
a = int(input())
while not(is_prime(a)):
    a += 1    
print(a)

Submission status: Runtime Error

Solution code:
a,b,n = list(map(int, input().split()))

if a+b<=n:
  a=0
  b=0
else:
  if n>a:
    b-=(n-a)
    a=0
    if b<0:
      b=0
  else:
    a=n-a

print("%d %d" %(a,b))

Submission status: Runtime Error

Solution code:
import math
t=0
X=int(input())
while True:
  t=0
  for i in range(2,math.ceil((X)**(1/2))+1):
    if X%i==0:
      break
    else:
      t+=1
  if t=math.ceil((X)**(1/2))-1:
    break
  X+=1
print(X)

Submission status: Runtime Error

Solution code:
# coding: utf-8

num = int(input())
from sympy import sieve
prime_list = [i for i in sieve.primerange(2,num + 1)]
from sympy import nextprime
if num in prime_list:
    print(nextprime(num - 1))
else:
    print(nextprime(num))

Submission status: Runtime Error

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

N =int(input())
p=N
while cnt <10**7:
    if is_prime(p):
        p +=1
    else:
        print(p)
        break

Submission status: Runtime Error

Solution code:
N =int(input())
p=N
while cnt <10**7:
    if is_prime(p):
        p +=1
    else:
        print(p)
        break

Submission status: Runtime Error

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

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


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

Submission status: Runtime Error

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

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

    return True
  
  
x = int(input())

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

Submission status: Runtime Error

Solution code:
x = int(input())
flag = 1

while True:
    if x == 2:
        break
    for i in range(3, x):
    #print("i is " + str(i))
    if x % i == 0:
        flag = 0
        break
    if flag == 1:
        break
    else:
        flag=1
        x += 1
print(x)

Submission status: Runtime Error

Solution code:
n = int(input())
def f(x):
  for k in range(2, int(sqrt(x)) + 1):
    if x % k != 0:
      continue
      return False
    return True
i = n
while 1:
  if f(i):
    print(i)
    break
  i += 1

Submission status: Runtime Error

Solution code:
n = int(input())
def f(x):
  for k in range(2, int(sqrt(x)) + 1):
    if x % k != 0:
      continue
      return False
    return True
  i = n
while 1:
  if f(i):
    print(i)
    break
  i += 1

Submission status: Runtime Error

Solution code:
n = int(input())
def f(x):
    for k in range(2, int(sqrt(x)) + 1):
        if x % k == 0:
            continue
        return False
    return True
i = n
while 1:
    if f(i):
        print(i)
        break
    i += 1

Submission status: Runtime Error

Solution code:
x = int(input())

d = 2

while d < 1+x//2:
  if x%d == 0:
    x += 1
    d = 2
  else:
    if d == 1+x//2:
      ans = x
      break
    else:
      d += 1
print(ans)

Submission status: Runtime Error

Solution code:
from sympy import nextprime
x = int(input())
if x==2:
	print(2)
elif x==3:
	print(3)
else:
	print(nextprime(x))

Submission status: Runtime Error

Solution code:
x = int(input())

d = 2

while d < 1+x//2:
  if x%d == 0:
    x += 1
    d = 1
  else:
    if d == 1+x//2:
      ans = x
      break
    else:
      d += 1
print(ans)

Submission status: Runtime Error

Solution code:
import math
x=int(input())
primemode = True
while primemode:
  sos = True
  for n in range(math.floor(math.sqrt(x))):
    if n+1 != 1:
      if x\(n+1) == 0:
        sos = False
  if sos:
    primemode = False
  x = x+1
print(x)

Submission status: Runtime Error

Solution code:
from sympy import sieve


def main():
    number = int(input())
    isPrime = False
    while not isPrime:
        isPrime = (number in sieve) == True
        if not isPrime:
            number += 1
    print(number)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:

def is_prime(x: int)->None:
    # 解説見た
    if x <= 1:
        return True
    i: int = 2
    while i * i <= x:
        if x % i == 0:
            return True
        i += 1
    return False


def main()->None:
    X: int = int(input())
    p: int = X
    while is_prime(p):
        p += 1
    print(p)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def is_prime(num):
  for i in range(num):
    if num % i == 0:
      return False
  return True

x = int(input())

for i in range(x, 10000+4):
  if is_prime(i):
    print(i)
    break

Submission status: Runtime Error

Solution code:
x = int(input())
num = 11000
arr = list(range(2,num))
arr = set(arr)
primes = {2}

prime = min(arr)
while prime < num-500:
    primes.add(prime)
    nonprime = {prime * i for i in range(1,num//prime + 2)}
    arr = arr.difference(nonprime)
    prime = min(arr)

sol = {i for i in primes if i >= x}

print(min(sol))

Submission status: Runtime Error

Solution code:
def prm(x):
  if x == 1 or x == 4:
    return False
  for i in range(1,int(x**0.5+1)):
    if x%i == 0:
      return False
  return True
for i in range(X,X**2):
  if prm(i):
    print(i)
    break

Submission status: Runtime Error

Solution code:
def prm(x):
  if x == 1 or x == 4:
    return False
  for i in range(1,int(i**0.5+1)):
    if x%i == 0:
      return False
  return True
for i in range(X,X**2):
  if prm(i):
    print(i)
    break

Submission status: Runtime Error

Solution code:
while True:
    i = 2
    ok = True
    while i * i <= x:
        if x % i == 0:
            ok = False
            break
        i += 1
    if ok:
        print(x)
        break
    x += 1

Submission status: Runtime Error

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

Submission status: Runtime Error

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

x = int(input())
min_sosu = x


for i in range(x, 100000):
    for j in range(2, 100000):
        if i%j == 0 and j < x:
            break
        if i%j == 0 and j >= x and i == j:
            min_sosu = i
            print(min_sosu)
            exit(1)

if min_sosu == x:
    print(min_sosu)

Submission status: Runtime Error

Solution code:

X=int(input())
if X==2:
  print(X)
else:
  for i in range(2,X**(1/2)):
    if X%i==0:
      X+=1
  print(X)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
X = int(input())

is_prime_num_list = [True] * 100000
is_prime_num_list[0] = False
is_prime_num_list[1] = False

for i in range(2, X + 1):
    if is_prime_num_list[i] == True:

        # iの倍数番目をFalseにする
        for j in range(2 * i, 100000, i):
            is_prime_num_list[j] = False


prime_num_list = [i for i, j in enumerate(is_prime_num_list) if i >= X and j == True]

print(min(prime_num_list))


'''
if is_prime_num_list[X] == True:
    print(X)
    exit()
'''

'''
while True:
    X += 1
    is_target = True
    for i in prime_num_list:
        if X % i == 0:
            is_target = False
            break

    if is_target:
        print(X)
        exit()
'''

Submission status: Runtime Error

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

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1) >> 1
    while d & 1 == 0:
        d >>= 1

    #判定をk回繰り返す
    for i in xrange(k):
        a = random.randint(1, q-1)
        t = d
        y = pow(a, t, q)
        #[0,s-1]の範囲すべてをチェック
        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

X = int(input())

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

Submission status: Runtime Error

Solution code:
import math

# 0以上整数x「未満」の素数をリストに格納して返す
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return np.array([prime for prime in primes if prime != 0])


num = int(input())
prime_ls = primes(10**5)

if num == 10**5:
    print(100003)
    
elif num.in(prime_ls):
    print(num)

else:
    check_ar = prime_ls - num
    ind = check_ar[np.where(check_ar > 0)][0] + num
    
    print(ind)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
X=int(input())
for i in range(2,X+2):
  if(X%i==0):
    X+=1
    continue
  else:
    if(i<X):
      continue
    else if(i<=X):
      print(X)

Submission status: Runtime Error

Solution code:
a = int(input())

def mark(s, x):
    for i in range(x + x, len(s), x):
        s[i] = False

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

s = sieve(a * 2)
print(s[0])

Submission status: Runtime Error

Solution code:

def get_primenumber(N):
    #素数リスト
    prime_list = [2]
    #3からNまでの数字を一つずつ取り出す
    for num in range(3,N+1,2):
      #取り出した数字が素数リストの要素で割れなければ素数リストに追加する
      if all( num % prime != 0 for prime in prime_list):
        prime_list.append(num)

    return prime_list

def main():
    prime = []
    ans = []
    number = int(input())
    prime = get_primenumber(50000)
    for i in range(number):
        if number <= prime[i]:
            ans.append(prime[i])
    print(min(ans))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
x = int(input())
num = 11000
arr = list(range(2,num))
arr = set(arr)
primes = {2}

prime = min(arr)
while prime < num-500:
    primes.add(prime)
    nonprime = {prime * i for i in range(1,num//prime + 2)}
    arr = arr.difference(nonprime)
    prime = min(arr)

arr = {i for i in primes if i > x }
print(min(arr))

Submission status: Runtime Error

Solution code:

def get_primenumber(N):
    #素数リスト
    prime_list = [2]
    #3からNまでの数字を一つずつ取り出す
    for num in range(3,N+1,2):
      #取り出した数字が素数リストの要素で割れなければ素数リストに追加する
      if all( num % prime != 0 for prime in prime_list):
        prime_list.append(num)

    return prime_list

def main():
    prime = []
    ans = []
    number = int(input())
    prime = get_primenumber(50000)
    for i in range(number):
        if number < prime[i]:
            ans.append(prime[i])
            
    print(min(ans))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from sympy import nextprime
x = int(input())
if x==2:
	print(int(2))
elif x==3:
	print(int(3))
else:
	print(nextprime(x))

Submission status: Runtime Error

Solution code:

def get_primenumber(N):
    #素数リスト
    prime_list = [2]
    #3からNまでの数字を一つずつ取り出す
    for num in range(3,N+1,2):
      #取り出した数字が素数リストの要素で割れなければ素数リストに追加する
      if all( num % prime != 0 for prime in prime_list):
        prime_list.append(num)

    return prime_list

def main():
    prime = []
    ans = []
    number = int(input())
    prime = get_primenumber(50000)
    print(prime)
    for i in range(number):
        if number < prime[i]:
            ans.append(prime[i])
            
    print(min(ans))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from sympy import nextprime
import math
x=int(input())
for k in range(2, int(math.sqrt(x)) + 1):
    if x % k == 0:
        print(nextprime(x))
        exit()
print(x)

Submission status: Runtime Error

Solution code:
import math


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


def inputInt():
    return int(input())


def main():
    X = inputInt()
    ans = 0
    if X == 2:
        return 2

    for x in range(X, X*X/2):
        for mod in range(2, X):
            if x % mod == 0:
                break
        else:
            ans = x
            break

    return ans


if __name__ == "__main__":
    print(main())

Submission status: Runtime Error

Solution code:
a=int(input())
if a==2:
  print(a)
else:
  sosuu=1
  a=a-1
  while sosuu==1:
    a+=1
    b=2
    while a!=b:
      sosuu=0
      if a%b==0:
        sosuu=1//割り切れた
        break
      else:
        b+=1
  print(a)

Submission status: Runtime Error

Solution code:
from sympy import nextprime
x=int(input())
import math
if x < 2:
    print(nextprime(x))
else:
    if x == 2:
        print(x)
    else:
        if x % 2 == 0:
            print(nextprime(x))
        else:
            m = math.floor(x / 2) + 1
            for p in range(3, m, 2):
                if x % p == 0:
                    print(nextprime(x))
            print(x)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(20000)
x = int(input())

def mody(x,n):
	if n == 1:
		return 1
	if x%n == 0:
		return x
	else:
		return mody(x,n-1)

for i in range(0,10**5-x):
	n = mody(x+i,x+i-1)
	if n == 1:
		ans = x+i
		break
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from sympy import nextprime
x = int(input())
if x==2:
	print(int(2))
elif x ==3:
	print(int(3))
else:
	print(int(nextprime(x)))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**5)
x = int(input())

def mody(x,n):
	if n == 1:
		return 1
	if x%n == 0:
		return x
	else:
		return mody(x,n-1)

for i in range(0,10**5-x):
	n = mody(x+i,x+i-1)
	if n == 1:
		ans = x+i
		break
print(ans)

Submission status: Runtime Error

Solution code:
def check_prime(num):
  for i in range(2,num):
    if (x % i == 0):
      return False
      break
  else: 
    return True
 
if _name_ == "_main_":
  x = int(input())
  flag = True
  
  while flag: 
    if (check_prime(x)):
      print(x)
      flag = False
    else: 
      x = x + 1

Submission status: Runtime Error

Solution code:
import java.util.Scanner;

public class AtCoderTest {
    static boolean is_prime(int n)
    {

        if (n <= 1) return false;
        if (n <= 3) return true;


        if (n % 2 == 0 || n % 3 == 0) return false;

        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;

        return true;
    }
    static int nextPrime(int N)
    {
        if (N <= 1 || N == 2)
            return 2;

        int prime = N;
        boolean found = false;

        while (!found)
        {
            prime++;

            if (is_prime(prime))
                found = true;
        }

        return prime;
    }

    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if (is_prime(N)){
            System.out.println(N);
        }
        else{
                System.out.println(nextPrime(N));
        }
    }
}

Submission status: Runtime Error

Solution code:
Source Code 

Copy
Copy
X=int(input())
for i in range(2,X):
  if(X%i==0):
    X+=1
    break
  else :
  	print(X)

Submission status: Runtime Error

Solution code:

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

Submission status: Runtime Error

Solution code:
from sympy import nextprime
X = int(input().strip())
print(nextprime(X-1, 1))

Submission status: Runtime Error

Solution code:
from sympy import nextprime

x = int(input())
print(nextprime(x-1))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
x = int(input())
n = 10 ** 5
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes = list(primes)
import bisect
b = bisect.bisect_right(primes, x)
if x == primes[b - 1]:
    print(x)
else:
    print(primes[b])

Submission status: Runtime Error

Solution code:
# coding: utf-8
from sympy import isprime
from sympy import nextprime


def main():
    
    input_ = int(input())
    
    if isprime(input_):
        print(input_)
    else:
        print(nextprime(input_))

    return 0
    

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n = int(input()) 

if(is_prime(n)):
    print(n)
else:
    while(is_prime(n) == False):
        n = n + 1
        is_prime(n)
    print(n)

Submission status: Runtime Error

Solution code:
import math
import random

def is_prime3(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 xrange(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


a = int(input())
while True:
 if is_prime3(a) == 1:
  break
 a = a + 1

print(a)

Submission status: Runtime Error

Solution code:
n = int(input()) 

if(is_prime(n)):
    print(n)
else:
    while(is_prime(n) == False):
        n = n + 1;
        is_prime(n)
    print(n)

Submission status: Runtime Error

Solution code:
import math
import random

def is_prime3(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in xrange(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        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


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

print(a)

Submission status: Runtime Error

Solution code:
li = []

def is_prime(n):
        return False
    for m in li:
        if m * m > n: 
            return True
        if n % m == 0:
            return False
    return True

n = int(input())
for i in range(2, n):
  if is_prime(i):
    li.append(i)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from bisect import bisect_left
INFTY = 10**5
P = [1 for _ in range(INFTY)]
P[0]=0
P[1]=0
for i in range(2,int(INFTY**0.5)+1):
    for j in range(i*i,INFTY,i):
        P[j] = 0
Q = []
for i in range(INFTY):
    if P[i]==1:
        Q.append(i)
X = int(input())
ind = bisect_left(Q,X)
print(Q[ind])

Submission status: Runtime Error

Solution code:
// A school method based C++ program to check if a 
// number is prime 
#include <bits/stdc++.h> 
using namespace std; 

bool isPrime(int n) 
{ 
	// Corner case 
	if (n <= 1) return false; 

	// Check from 2 to n-1 
	for (int i=2; i<n; i++) 
		if (n%i == 0) 
			return false; 

	return true; 
} 

// Driver Program to test above function 
int main() 
{ 
	long int n,i;
	cin>>n;
	for(i=n;;i++)
	{
		if(isPrime(i))
		{
			cout<<i<<endl;
			break;
		}
	}
	return 0; 
}

Submission status: Runtime Error

Solution code:
def check(num):
  if num >1:
    for i in range (2,num):
      if(num % i) == 0:
        return False
      break
      else:
        return True
      else:
        return False
      a= int(input())
      
      for i in range(a,100500):
        if check(i):
          print(i)
          break

Submission status: Runtime Error

Solution code:
from bisect import bisect_right
INFTY = 10**5
P = [1 for _ in range(INFTY)]
P[0]=0
P[1]=0
for i in range(2,int(INFTY**0.5)+1):
    for j in range(i*i,INFTY,i):
        P[j] = 0
Q = []
for i in range(INFTY):
    if P[i]==1:
        Q.append(i)
X = int(input())
ind = bisect_right(Q,X)
print(Q[ind])

Submission status: Runtime Error

Solution code:

def check(num):
  if num >1:
    for i in range (2,num):
      if(num % i) == 0:
        return False;
      break
      else:
        return True
      else:
        return False
      a= int(input())
     
      for i in range(a,100500):
        if check(i):
          print(i)
          break

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def isPrime(x):
  i = 2
  while i*i <= x:
    if x % i == 0:
      return True
  return False

X = int(input())
ans = X
while not isPrime(x):
  ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import math
X=int(input())
if X=2:
  print(X)
else:
  for i in range(math.sqrt(X)-1):
    if X%(2+i)==0:
      X+=1
    else:
      print(X)

Submission status: Runtime Error

Solution code:
import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

prime = seachPrimeNum(10**5)
X = int(input())
left = 0
right = len(prime) - 1

while right - left > 2 :
    mid = (left + right) // 2
    if prime[mid] == X:
        ans = X
        break
    elif right - left == 1:
        ans = prime[right]
        break
    elif prime[mid] > X:
        right = mid - 1
    else:
        left = mid + 1

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())

if n != 2:
    if n % 2 == 0:
        n += 1
    while not is_prime(n):
        n += 2
    print(n)
else:
    print(n)

def is_prime(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 xrange(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

Submission status: Runtime Error

Solution code:
n = int(input())

if n % 2 == 0:
    n += 1
while not is_prime(n):
    n += 2
print(n)

def is_prime(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 xrange(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

Submission status: Runtime Error

Solution code:
# coding: utf-8

def is_prime2(q,k=100):
  q = abs(q)
  if q == 2: return True
  if q < 2 or q&1 == 0: return False
  for i in xrange(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

X = int(input())

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

Submission status: Runtime Error

Solution code:
import math
i=int(input())
j=math.sqrt(i)
k=0
m=i
while k==0:
  for l in range(2,i-1):
    if m%l!=0:
      break
    if l=i-1:
      k=1
      break
  m+=1
m=m-1
print(str(m))

Submission status: Runtime Error

Solution code:
A = int(input())
i = 0
S = 0
B = int(math.sqrt(A))
while i == 0:
    S = 0
    B = int(math.sqrt(A))
    for n in range(2,B + 1):
        if A % n == 0:
            A += 1
            S = 1
            break
    if S == 0:
        print(A)
        exit()

Submission status: Runtime Error

Solution code:
from sympy import nextprime

X=int(input())
print(nextprime(X))