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=int(input())
num=10**5
ori_plist=[2]
i=3
while i<num:
    plist=ori_plist
    for j in range(len(plist)):
        if i%plist[j]==0:
            i+=1
            break
        else:
            plist.append(i)
            i+=1
            ori_plist=plist
            break
if plist.count(X)==1:
    print(X)
    exit()
else:
    plist.append(X)
    ans=sorted(plist)
    a=ans.index(X)
print(ans[a+1])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from sympy import sieve

x = int(input())
boolean = True
while boolean:
    if x in sieve:
        print(x)
        break
    x += 1

Submission status: Runtime Error

Solution code:
a = [int(i) for i in input().split()]


for I in range(a[2]):
    if a[0] and a[1] == 0:
        print(0,0)
        break
    elif a[0]+a[1] < a[2]:
        print(0,0)
        break
    elif a[0]>=1:
        a[0] = a[0]-1
        if I == a[2]:
            print(a[0],a[1])
    elif a[0] < 1 and a[1]>=1:
        a[1] = a[1]-1
        if I == a[2]:
            print(a[0],a[1])

Submission status: Runtime Error

Solution code:
a = [int(i) for i in input().split()]


for I in range(a[2]):
    if a[0] and a[1] == 0:
        print(0,0)
        break
    elif a[0]+a[1] < a[2]:
        print(0,0)
        break
    elif a[0]>=1:
        a[0] = a[0]-1
        if I == a[2]-1:
            print(a[0],a[1])
    elif a[0] < 1 and a[1]>=1:
        a[1] = a[1]-1
        if I == a[2]-1:
            print(a[0],a[1])

Submission status: Runtime Error

Solution code:
so=[]
def sosu(a):
    global so
    x=2
    while True:
        if all( x% elem != 0 for elem in so)==True:
            so.append(x)
            if x>=a:
                print(str(x))
                break
        x+=1

sosu(a)

Submission status: Runtime Error

Solution code:
X=int(input())
if x==2:
  print(2)
else:
  for i in range(X,10**6):
    for j in range(2,i):
      if i%j==0:
        break
      if j==i-1:
        print(i)
        exit()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
x = int(input())
def prime(n):
  for j in range(2, int(n**(0.5))+1):
    if n%j == 0:
      return False
  return True
for i in range(x, 10**(5) + 1):
  if prime(i):
    ans = i
    break
print(ans)

Submission status: Runtime Error

Solution code:
import sys
sys.path.append('../../')
from librarys import prime_factorization

x = int(input())

while(True):
    p = prime_factorization.factorization(x)
    if len(p)==1:
        break
    else:
        x += 1

print(x)

Submission status: Runtime Error

Solution code:
X = int(input()) 

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

print(X)

Submission status: Runtime Error

Solution code:
X = input()

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

print(X)

Submission status: Runtime Error

Solution code:
スコード 

Copy
Copy
import math
def prime(n):
    for i in range(2, int(math.sqrt(n))):
        if n % i == 0: return False
    return True
 
X = int(input())
 
for i in range(X, 10**8):
    if prime(i):
        print(i)
        exit(0)
 
print('No prime number in this range')

Submission status: Runtime Error

Solution code:
def miller_rabin(n, k=-1):
    import random
    if n == 2:
        return True
    if n == 1 or n & 1 == 0:
        return False
    if k < 1:
        k = min(n - 1, 100)
    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1
    for a in random.sample(range(n), k):
        t = d
        y = pow(a, t, n)
        while t != n - 1 and y != 1 and y != n - 1:
            y = (y * y) % n
            t <<= 1
        if y != n - 1 and t & 1 == 0:
            return False
    return True
def main():
  x=int(input())
  for i in range(n+1,1000000):
    if miller_rabin(i):
      print(i)
      return
main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

    return

resolve()

Submission status: Runtime Error

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

    return
  
  
resolve()

Submission status: Runtime Error

Solution code:
limit = 100000
def resolve()
	N = int(input())
  	for k in range(N, limit+1):
        if k % 2 == 0 and k != 2:
            continue
        for divisor in range(2, math.floor(math.sqrt(k))+1):
            if k % divisor == 0:
              	print(k)
                break
resolve()

Submission status: Runtime Error

Solution code:
def isPrime(n):
    if (n > 2 and n % 2 == 0) return False
    i = 3
    while (i <= mySqrt(n)):
        if (n % i == 0):
            return False
        i += 2;
    return n > 1
 
 
n = int(input())
while !isPrime(n):
  	n += 1
print(n)

Submission status: Runtime Error

Solution code:
def isPrime(n):
    if (n > 2 and n % 2 == 0) return False
    i = 3
    while (i <= mySqrt(n)):
        if (n % i == 0):
            return false
        i += 2;
    return n > 1


n = int(input())
while !isPrime(n):
  n += 1
print(n)

Submission status: Runtime Error

Solution code:
from fractions import gcd

a, b = map(int,input().split())

def lcm(x, y):
    return (x*y)//gcd(x,y)
    
tmp = lcm(a, b)
print(tmp)

Submission status: Runtime Error

Solution code:
X=int(input())
ps=[]
x=2
while x=<X:
  f=True
  for p in ps:
    if x%p==0:
      f=False
      break
  if f:ps.append(x)
  x+=1
print(x)

Submission status: Runtime Error

Solution code:
X = int(input())

def check(num):
    max_div = int(num**0.5)
    for div in range(2, max_div+1):
        if num % div == 0:
            return False
    else:
        return True

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

Submission status: Runtime Error

Solution code:
a

Submission status: Runtime Error

Solution code:
n=int(input())

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

for i in range(i,i+30):
  if is_prime(i):
    print(i)

Submission status: Runtime Error

Solution code:
x = int(input())
if x == 2:
    print(2)
    sys.exit()
elif x%2 == 0:
    x += 1

def get_prime(n):
    p = [2]
    for i in range(3, n, 2):
        if all(i%j!=0 for j in p):
            p.append(i)
    return p

p = get_prime(x)

while True:
    for prime in p:
        if x%prime == 0:
            break
    else:
        print(x)
        break
    x += 2

Submission status: Runtime Error

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

for i in range(10^5):
  while x % n != 0 or n =< x/2:
      n += 1
  if n =< x/2:
    x += 1
    
  else:
    print(x)
    break

Submission status: Runtime Error

Solution code:


import math
x_sq = math.sqrt(x)
x_sq_it = int(x_sq)

pnlist = [2]

countn = 0
for i in range(3,x_sq_it+1):
    for j in range(len(pnlist)):
        if i % pnlist[j] == 0:
            break
        else:
            countn += 1
    if countn == len(pnlist):
        pnlist.append(i)
        countn = 0
# print(pnlist)

countn = 0
for i in range(x,10**5):
    for j in range(len(pnlist)):
        if i % pnlist[j] == 0:
            break
        else:
            countn += 1
    if countn == len(pnlist):
        print(i)
        exit()
    else:
        countn = 0

Submission status: Runtime Error

Solution code:
import sys
import math
import itertools

rl = sys.stdin.readline
x = int(rl())
while True:
    if x % 2:
      for i in range(3, 7//2, 2):
        if x % i == 0
        break
      else:
        print(x)
        break
    x += 1

Submission status: Runtime Error

Solution code:
import sys
import math
import itertools
import numpy
import sympy

rl = sys.stdin.readline
x = int(rl())
while True:
    if sympy.isprime(x):
        print(x)
        break
    x += 1

Submission status: Runtime Error

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

half = int(X/2)
i = X
while i >=X:
    for j in range(2,int(i/2)):
        if math.gcd(i,j) == 1:
            pass

        else:
            i += 1
            continue

    print(i)
    exit()

Submission status: Runtime Error

Solution code:
from sympy import nextprime
import sympy
import isprime

X = int(input())

if isprime(X) = "True":
    print(X)

else:
    p = sympy.nextprime(X, 1)
    print(p)

Submission status: Runtime Error

Solution code:
from sympy import nextprime

X = int(input())
p = sympy.nextprime(X, 1)

print(p)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
from goto import goto, label

X = int(input())
max = 10 ** 5

for i in range(X,max):
    sqt = math.sqrt(i)
    for j in range(1, math.ceil(sqt)):
        cal = i % j
        if cal == 0:
            print(i)
            goto .END
label .END

Submission status: Runtime Error

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

while flag==0:
    if sosuu(n):
        flag=1
    n+=1
print(n)

Submission status: Runtime Error

Solution code:
def is_prime(n, k=100):
    n = abs(n)
    if n == 2:
        return True
    if n < 2 or n&1 == 0:
        return False
    for i in xrange(3, k):
        x, y = n, i
        while y:
            x, y = y, x%y
        if x != 1:
            continue
        if pow(2, n-1, n) != 1:
            return False
    return True


X = int(input())

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

Submission status: Runtime Error

Solution code:
from sympy import isprime
X=int(input())

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

Submission status: Runtime Error

Solution code:
import sympy as sym
a=int(input())
b=[]
while len(b)<2:
  for i in sym.primerange(a,10**5):
    b.append(i)
print(b[0])

Submission status: Runtime Error

Solution code:
for num in range(x,10**6):
    ok = True
    for i in range(2,num):
        if num % i == 0:
            ok = False
    if ok:
        print(num)
        break

Submission status: Runtime Error

Solution code:
from sympy import isprime
x=int(input())
for i in range(x,2**64):
    if isprime(i)==True:
        print(i)
        break

Submission status: Runtime Error

Solution code:
from sympy import nextprime

# input
X = int(input())

print(nextprime(X))

Submission status: Runtime Error

Solution code:
x=int(input())
def hantei(n):
    for i in range(2,n):
        if n%i==0:
            return 0
    return 1

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

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

Submission status: Runtime Error

Solution code:
import math
import sys
sys.setrecursionlimit(100000)

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

def findPrime(x):
  if is_Prime(x):
    return x
  else:
    return findPrime(x+1)

print(findPrime(X))

Submission status: Runtime Error

Solution code:
def isprime(n):
  if n<10:
    return n in (2,3,5,7)
  for i in range(int(2,sqrt(n)+1)):
    if n%i==0:
      return False
  return True

x = int(input())
for d in range(x,x+300):
  if isprime(d):
    print(d)
    break

Submission status: Runtime Error

Solution code:
import sympy
n=int(input())
if sympy.isprime(n)==True:
    print(n)
else:
    print(sympy.nextprime(n))

Submission status: Runtime Error

Solution code:
import math
X=int(input())
if X==2:
  print('2')
  exit()
else:
  l=list()
  x=math.sqrt(X)
  key=math.ceil(x)
  if X<=50000:
    for i in range(X,2*X):
      l.append(i)
  else:
    for i in range(X,100000):
      l.append(i)
    
for n in range(2,key+1):
  for x in l:
    if x%n==0:
      l.remove(x)
print(l[0])

Submission status: Runtime Error

Solution code:
import math
X=int(input())
if X==2:
  print('2')
  exit()
else:
  l=list()
  x=math.sqrt(X)
  key=math.ceil(x)
  if X<=50000:
    for i in range(X,key**2):
      l.append(i)
  else:
    for i in range(X,key**2):
      l.append(i)
    
for n in range(2,key):
  for x in l:
    if x%n==0:
      l.remove(x)
print(l[0])

Submission status: Runtime Error

Solution code:
X=int(input())
l=list()
if X<=50000:
  for i in range(X,2*X):
    l.append(i)
else:
  for i in range(X,100000):
    l.append(i)
    
for n in range(2,317):
  for x in l:
    if x%n==0:
      l.remove(x)
print(l[0])

Submission status: Runtime Error

Solution code:
x=int(input())
slist=[]
for i in range(2,10**5):
  l=list(range(2,i):
  if all(i%ll!=0 for ll in l):
    slist.append(i)
slist.append(2)
while x>0:
  if all(x%ss!=0 for ss in slist):
    print(x)
    exit()
  x+=1

Submission status: Runtime Error

Solution code:
def primelist(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 [i for i in range(n + 1) if is_prime[i]]
  
x = int(input())

list = primelist(x*10)
print(min([i for i in list if i>x])

Submission status: Runtime Error

Solution code:
import math
def is_sosu(n):
  for i in range(2, math.sqrt(n)//1+1):
    if n % i == 0:
      return False
  return True

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

Submission status: Runtime Error

Solution code:
from sympy import nextprime
from sympy import isprime
x=int(input())
if isprime(x)==1:
    print(x)
else:
    print(nextprime(x))

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:
            break
    else:
        print(x)
        exit()
    x += 1

Submission status: Runtime Error

Solution code:
x, y, z = map(int, input().split())

def takahashi(A, B, K):
  if A <= K <= A + B:
    print(0, B - (K - A))
  elif K < A:
    print(A - K, B)
  else:
    print(0, 0)
    
takahashi(x, y, z)

Submission status: Runtime Error

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

import fractions
import copy
import bisect
import math
import numpy as np
import itertools
from itertools import combinations_with_replacement
#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


j=0
k=0
n=3
r=1
a=[0]
#n=int(input())
#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桁ごとにリストに値を入れているかんじ
#intを取ると文字列分解に使える
'''
入力
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)


'''
import itertools
from itertools import combinations_with_replacement

combinationについて
以下の違いを意識しよう
combinations() p, r 長さrのタプル列、ソートされた順で重複なし

combinations_with_replacement() p, r 長さrのタプル列、ソートされた順で重複あり


使用例 　　　　　　　　　　　                  出力　　
combinations('ABCD', 2)　　　　　　　　　　　　AB AC AD BC BD CD

combinations_with_replacement('ABCD', 2)　　 AA AB AC AD BB BC BD CC CD DD
'''



'''
#集計
#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の全体が探索対象です。
'''

'''素数判定の関数  ''''
def is_prime(n):
    if n == 1: return False

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




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

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

def main():


    j=0
    k=0
    #n=int(input())
    #r=int(input())


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

    #s=input()
    #a=[int(i) for i in s]#int取るとstrでも行ける
    #print(a)
    '''
    入力
    1234
    出力
    [1, 2, 3, 4]
    '''



if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

x=0
for i in range(n):
    if a[i]!=0:
        x+=1
a=sum(a)

print(a//x if a%x==0 else a//x+1)

Submission status: Runtime Error

Solution code:
import fractions

def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)

a,b=map(int,input().split())
print(lcm(a,b))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if x == 2:
    print(2)
    exit()
 
while 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: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in range(x + 1, 10**5 + 1):
  for k in range(2, i):
    if i % k != 0: #割り切れない
      continue;
    else: #割り切れた
      break;
  else:
    break;
  
print(i)

Submission status: Runtime Error

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

for i in range(x + 1, 10**5 + 1):
  for k in range(1, i):
    if i % k != 0: #割り切れない
      continue;
    else: #割り切れた
      break;
  else:
    continue;
  break;
  
print(i)

Submission status: Runtime Error

Solution code:
X = int(input())
max_num = 100005
ans = 0
for i in range(X, max_num):
    if prime_check(i):
        print(i)
        break

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

    return True

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
x = int(input())
while True:
    i = 2
    while i*i <= x:
        prime = 0
        if x % i != 0:
            i+= 1
        else:
            prime = 1
            break
    if prime == 1:
        x += 1
    else:
        print(x)
        break

Submission status: Runtime Error

Solution code:
x = int(input())
while True:
    i = 2
    while i*i <= x:
        prime = 0
        if x % i != 0:
            i+= 1
        else:
            x+= 1
            prime = 1
            break
    if prime == 0:
        print(x)
        break

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
x=int(input())
A=10**5
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)

Submission status: Runtime Error

Solution code:

import math

X = int(input())
  
#素数判定
#Nが素数か True/False で返す
#O(√N)
def is_prime(N):
    if N == 1:
        return False
    for i in range(2,N+1):
        #調べるのはNの1/2乗まででよい
        if i * i > N:
            break
        #割り切れたら素数じゃない
        if N % i == 0:
            return False
    
    return True

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

Submission status: Runtime Error

Solution code:
X = int(input())
P = make_primes_list(100005)

def make_primes_list(n):
    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)
    return primes

for x in range(X,100005):
    if x in P:
        print(x)
        break

Submission status: Runtime Error

Solution code:
import math

X = int(input())

def era(n):
    O = [i + 2 for i in range(n-1)]
    P = []
    for i in range(int(math.sqrt(n))):
        P.append(O[0])
        O = [o for o in O if o % P[-1] != 0]
    for o in O:
        P.append(o)
    return P

print(max(P))
for i in range(len(P)):
    if X <= P[i]:
        print(P[i])
        break

Submission status: Runtime Error

Solution code:
from sympy import sieve
x = int(input())
s = [i for i in sieve.primerange(2,100004) if i >= x]
print(s[0])

Submission status: Runtime Error

Solution code:
a = int(input())
while True:
  b = []
  for i in range(1, int(a ** 0.5) + 1):
    if a % i == 0:
      b.append(i)
      if i != X // i:
        b.append(a // i)
  if b == [1, a]:
    print(X)
    exit()
  else:
    a += 1

Submission status: Runtime Error

Solution code:
import bisect
x = int(input())
def eratosthenes(limit):
    A = [i for i in range(2,limit+1)]
    P = []
    time = 0
    while True:
        prime = min(A)
        
        if prime > limit**0.5:
            break
        P.append(prime)
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
    for a in A:
        P.append(a)
    return P
L = eratosthenes(100000)
y = bisect.bisect_left(L,x)
print(L[y])

Submission status: Runtime Error

Solution code:
=int(input())

for i in range(X,X*2):
    ok=0
    for j in range(2,i):
        if i%j == 0:
            ok += 1
    if ok == 0:
        print(i)
        break

Submission status: Runtime Error

Solution code:
x = int(input())

is_prime = [True] * (10**5+1)   #全部Trueに
is_prime[0] = False
is_prime[1] = False

for i in range(2,int(10**2.5)+1):  
    if is_prime[i]:
        for j in range(i * 2, 10**5 + 1, i):
            is_prime[j] = False

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

Submission status: Runtime Error

Solution code:
x = int(input())

def prime(n):
  a = int(n**(1/2))
  for i in range(2,a+1):
    if n%i==0: return False
  return true

while (1):
  if prime(x)==False: x += 1
  else: break
  x += 1
print(x)

Submission status: Runtime Error

Solution code:
def Sieve_of_Eratosthenes(N):
    if N<2:
        prime = [False for i in range(N+1)]
        return prime
 
    prime = [True for i in range(N+1)]
    prime[0] = False
    prime[1] = False
 
    for i in range(2, int(N**0.5)+1):
        if prime[i]:
            for j in range(i*2, N+1, i):
                prime[j] = False
 
    return prime

prime=Sieve_of_Eratosthenes(10**5)
x=int(input())
while prime[x]==False:
    x+=1
print(x)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
def check_prime(m):
  prime_flag = 1
  counter = 1
  while counter **2 <= m:
    if not m%counter:
      prime_flag = 0
      break
  return prima_flag


n = int(input())

for i in range(n, 10**6):
  if check_prime(i):
    print(i)
    break

Submission status: Runtime Error

Solution code:
n = int(input())

import math
def prime(n):
  a = math.ceil(sqrt(n))
  for i in range(2,a):
    if n%i==0: return 1
  return 0

while (1):
  n += 1
  if prime(n)==1: 
    print(n)
    exit()

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    for (int i=n; 1; i++)
    {
        for (int j=2; 1; j++)
        {
            if (i%j==0)
                break;
            if (j<n)
            {
                cout << i << endl;
                return 0;
            }
        }
    }
}

Submission status: Runtime Error

Solution code:
import sympy as sp
n = int(input())
print(n if sp.isprime(n) else sp.nextprime(n, 0))

Submission status: Runtime Error

Solution code:
n.k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(input())
for i in range(n-k):
    if t[k+i] == t[i]:
        t[k+i] = 0
xs = t.count('r')*p+ t.count('s')*r+t.count('p')*s
print(x)

Submission status: Runtime Error

Solution code:
x = int(input())

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

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

Submission status: Runtime Error

Solution code:
n = int(input())

flag = 0

while flag==0:
#check if n is prime or not
	tst = 2
	while n % tst != 0:
    	tst = tst + 1
    if tst==n: 
		flag=1
	else:
		n=n+1
print(n)

Submission status: Runtime Error

Solution code:
import sympy
x=int(input())
ans=sympy.nextprime(x)
print(ans)