Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02623 (python)

Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ans = 0
    a_time = [0]
    b_time = [0]
    for i in range(1, len(a) + 1):
        a_time.append(a_time[i - 1] + a[i - 1])
    for i in range(1, len(b) + 1):
        b_time.append(b_time[i - 1] + b[i - 1])

    a_max = 0
    b_max = 0
    for i in range(len(a_time)):
        if a_time[i] > k:
            break
        else:
            a_max = i
    for i in range(len(b_time)):
        if b_time[i] > k:
            break
        else:
            b_max = i

    for i in range(len(b_time)):
        if a_time[a_max] + b_time[i] <= k:
            ans = max(ans, a_max + i)
        else:
            if a_max > 0:
                a_max -= 1
    for i in range(len(a_time)):
        if b_time[b_max] + a_time[i] <= k:
            ans = max(ans, b_max + i)
        else:
            if b_max > 0:
                b_max -= 1

    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ans = 0
    a_time = [0]
    b_time = [0]
    for i in range(1, len(a) + 1):
        a_time.append(a_time[i - 1] + a[i - 1])
    for i in range(1, len(b) + 1):
        b_time.append(b_time[i - 1] + b[i - 1])

    a_max = 0
    b_max = 0
    for i in range(len(a_time)):
        if a_time[i] > k:
            break
        else:
            a_max = i
    for i in range(len(b_time)):
        if b_time[i] > k:
            break
        else:
            b_max = i

    for i in range(len(b_time)):
        if a_time[a_max] + b_time[i] <= k:
            ans = max(ans, a_max + i)
        else:
            a_max -= 1
    for i in range(len(a_time)):
        if b_time[b_max] + a_time[i] <= k:
            ans = max(ans, b_max + i)
        else:
            b_max -= 1

    print(ans)

if __name__ == '__main__':
    main()
Problem p02897 (python)

Fixed submission:
import math
n=int(input())
ans=0.5 if n%2==0 else math.ceil(n/2)/n
print(ans)

Buggy submission (verdict: Runtime Error):
n=map(int,input().split())
print(0.5 if n%2==0 else ceil(n/2)/n)
Problem p02596 (python)

Fixed submission:
K = int(input())
ans = -1
if K%2 == 0:
    pass
elif K%5 == 0:
    pass
else:
    num = 7
    ans = 0
    while True:
        ans += 1
        if num % K == 0:
            break
        else:
            num = (num * 10 + 7)%K
print(ans)

Buggy submission (verdict: Runtime Error):
ans = -1
if K in [2,5]:
    pass
else:
    num = 7
    ans = 0
    while True:
        ans += 1
        if num % K == 0:
            break
        else:
            num = (num * 10 + 7)%K
print(ans)
Problem p02693 (python)

Fixed submission:
k=int(input())
a, b=map(int, input().split())
c = True
for i in range(a, b+1):
  if i%k ==0:
    print("OK")
    c = False
    break
if c:
  print("NG")

Buggy submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
ans = 0
for x in range(n+1):
 c = int(a*x/b)
 d = int(x/b)
 e = c - a*d
 ans = max(ans, e)
print(ans)

Buggy submission (verdict: Runtime Error):
k=int(input())
a, b=map(int, input().split())
c = True
for i in range(a, b+1):
  if i%k ==0:
    print(OK)
    c = False
    break
if c:
  print(NG)
Problem p02699 (python)

Fixed submission:
s,w = map(int, input().split())
if s <= w:
  print("unsafe")
else:
  print("safe")

Buggy submission (verdict: Runtime Error):
s,w = map(int, input().split())
if s =< w:
  print("unsafe")
else:
  print("safe")
Problem p03253 (python)

Fixed submission:
def factrize(x):
    f = {}
    if x == 1:
        return f
    tmp = x
    i = 2
    while i**2 <= tmp:
        cnt = 0
        while tmp % i == 0:
            cnt += 1
            tmp = tmp//i
        if cnt > 0:
            f[i] = cnt
        i += 1
    if tmp != 1 or f == {}:
        f[tmp] = 1
    return f


def comb(n, r, p):
    x = 1
    for i in range(1, r + 1):
        x *= (n - i + 1) * pow(i, p - 2, p) % p
    return x % p


p = 10**9+7
n, m = map(int, input().split())
A = list(factrize(m).values())
ans = 1
for a in A:
    ans = (ans*comb(a+n-1, a, p)) % p
print(ans)

Buggy submission (verdict: Runtime Error):
import math
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def cmb(n, r):
    if n < 0 or r < 0:
        return 0
    if r > n:
        return 0
 
    r = min(n-r, r)
    res = 1
    for i in range(r):
        res *= n - i
n, m = map(int, input().split())
b = [x[1] for x in factorization(m)]
ans = 1
for i in b:
  c = cmb(n+i-1, i)
  ans = ans * c
print(ans%(10**9+7))
Problem p03038 (python)

Fixed submission:
import sys
N, M = map(int, input().split())
A = list(map(int, input().split()))
card = [ list(map(int, i.rstrip().split())) for i in sys.stdin.readlines()]
card = sorted(card, key=lambda x:x[1], reverse=True)
A = sorted(A)
i = 0
for b, c in card:
  for _ in range(b):
    if i >= N:
      break
    elif A[i] >= c:
      break
    else:
      A[i] = c
      i += 1
print(sum(A))

Buggy submission (verdict: Runtime Error):
import sys
N, M = map(int, input().split())
A = list(map(int, input().split()))
card = [ list(map(int, i.rstrip().split())) for i in sys.stdin.readlines()]
card = sorted(card, key=lambda x:x[1], reverse=True)
A = sorted(A)
i = 0
for b, c in card:
  for _ in range(b):
    if A[i] >= c:
      break
    else:
      A[i] = c
      i += 1
print(sum(A))
Problem p02622 (python)

Fixed submission:
s=input()
t=input()
cnt=0
for i in range(len(s)):
    if s[i]!=t[i]:
        cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
cnt=0
for i in range(len(s)):
    if s[i]!=t[i]:
        cnt+=1
print(cnt)
Problem p02623 (python)

Fixed submission:
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

a=[0]
b=[0]
for i in range(n):
  a.append(a[i]+A[i])
for i in range(m):
  b.append(b[i]+B[i])
ans=0
j=m
for i in range(n+1):
  if a[i]>k:
    break
  while a[i]+b[j]>k:
    j-=1
  ans=max(ans,i+j)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
i=0
j=0
time=0
while time<k:
    if A[i]<=B[j]:
        time+=A[i]
        i+=1
    elif A[i]>B[j]:
        time+=B[j]
        j+=1
print(i+j-1)
Problem p02624 (python)

Fixed submission:
n=int(input())
ans=0
for i in range(1,n+1):
  y=n//i
  ans+=y*(y+1)*i//2
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=0
for i in range(n):
  y=n//i
  ans+=y*(y+1)*i//2
print(ans)
Problem p02676 (python)

Fixed submission:
K=int(input())
S=input()

n=len(S)

if n<=K:
    print(S)
else:
    for i in range(K):
        print(S[i],end="")
    print("...")

Buggy submission (verdict: Runtime Error):
K=int(input())
S=input()

n=len(S)

if n<=K:
    print(S)
else:
    for i in range(7):
        print(S[i],end="")
    print("...")
Problem p02847 (python)

Fixed submission:
S=input()
week=["SUN","MON","TUE","WED","THU","FRI","SAT"]
print(7-week.index(S))

Buggy submission (verdict: Runtime Error):
A,B,X=map(int,input().split())
N=0
while A*N+B*len(str(N))<X:
    N+=10000
    
N-=10000
while A*N+B*len(str(N))<X:
    N+=1000

N-=1000
while A*N+B*len(str(N))<X:
    N+=100

N-=100
while A*N+B*len(str(N))<X:
    N+=10

N=N-10
while A*N+B*len(str(N))<X:
    N+=1
print(N-1)
Problem p02897 (python)

Fixed submission:
import math
N=int(input())
if N%2==0:
    print((N/2)/N) 
elif N==1:
    print(N/N)
else:
    round_number=math.ceil(N/2)
    print(round_number/N)

Buggy submission (verdict: Runtime Error):
N=int(input())
if N%2==0:
    print((N/2)/N) 
else if N==1:
    print(1.0)
else:
    print(((N/2)+1)/N)
Problem p02659 (python)

Fixed submission:
import math
from decimal import Decimal

a, b = list(input().split())

num = math.floor(Decimal(a) * Decimal(b))
print(num)

Buggy submission (verdict: Runtime Error):
from functools import reduce
from operator import mul

n = int(input())
a_list = list(map(int, input().split()))

result = reduce(mul, a_list)

if result > 10 ** 18:
    print(-1)
else:
    print(result)
Problem p02729 (python)

Fixed submission:
import math

def comb(n, r):
	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

nums = list(map(int, input().split()))

if nums[0] <= 1 and nums[1] <= 1:
  print(0)
elif nums[1] <= 1:
  print(comb(nums[0], 2))
elif nums[0] <= 1:
  print(comb(nums[1], 2))
else:
  print(comb(nums[0], 2) + comb(nums[1], 2))

Buggy submission (verdict: Runtime Error):
import math
 
def comb(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())
a_list = list(map(int, input().split()))
a_list.append(n + 100)

for i in range(len(a_list) - 1):
  tmp_list = a_list[:]
  del tmp_list[i]
  tmp_list.sort()
  count = 0
  tmp_count = 0
  for j in range(1, len(tmp_list)):
    if tmp_list[j] == tmp_list[j - 1]:
      tmp_count += 1
    else:
      if tmp_count >= 1:
      	count += comb(tmp_count + 1, 2)
      tmp_count = 0
  print(count)
Problem p03127 (python)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

while len(A) > 1:
  min_num = min(A)
  min_index = A.index(min(A))
  for i in range(len(A)):
    if i != min_index:
      A[i] = A[i] % min_num

  while 0 in A:
    A.remove(0)

print(A[0])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]

while len(A) > 1:
  min_num = min(A)
  min_index = A.index(min(A))
  for i in range(len(A)):
    if i != min_index:
      A[i] = A[i] % min_num
      if(A[i] == 0):
        A.pop(i)


print(A[0])
Problem p02594 (python)

Fixed submission:
x = int(input())
if x >= 30:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x = input().split()
if x >= 30:
    print("Yes")
else:
    print("No")
Problem p02989 (python)

Fixed submission:
n = int(input())
d = list(map(int,input().split()))
d.sort()
print(d[(int(n/2))] - d[int(n/2)-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
d = list(map(int,input().split()))
d.sort()
if d[int(n/2)-1] == d[(int(n/2))+1]:
    print(0)
else:
    print(d[(int(n/2))] - d[int(n/2)-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
d = list(map(int,input().split()))
if d[int(n/2)-1] == d[(int(n/2))+1]:
    print(0)
else:
    print(d[(int(n/2))] - d[int(n/2)-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
d = list(map(int,input().split()))
if d[int(n/2)] == d[int(n/2)+1]:
    print(0)
else:
    print(d[int(n/2)+1] - d[int(n/2)])
Problem p03041 (python)

Fixed submission:
n, k = map(int,input().split())
s = list(input())
if s[k-1] == "A":
    s[k-1] = "a"
    print("".join(s))
elif s[k-1] == "B":
    s[k-1] = "b"
    print("".join(s))
else:
    s[k-1] = "c"
    print("".join(s))

Buggy submission (verdict: Runtime Error):
n, k = map(int,input().split())
s = list(input())
if s[k] == "A":
    s[k] = "a"
    print("".join(s))
elif s[k] == "B":
    s[k] = "b"
    print("".join(s))
else:
    s[k] = "c"
    print("".join(s))
Problem p02580 (python)

Fixed submission:
def main():
    h, w, m = map(int, input().split())
    bombs_h = [0] * h
    bombs_w = [0] * w
    B = []
    for n in range(m):
        h1, w1 = map(lambda x: int(x)-1, input().split())
        B.append((h1, w1))
        bombs_w[w1] += 1
        bombs_h[h1] += 1
    max_h = max(bombs_h)
    max_w = max(bombs_w)
    h_maxindex = [i for i, x in enumerate(bombs_h) if x == max_h]
    w_maxindex = [i for i, x in enumerate(bombs_w) if x == max_w]
    cnt = 0
    k = len(h_maxindex) * len(w_maxindex)
    for i, j in B:
        if bombs_h[i] == max_h and bombs_w[j] == max_w:
            cnt += 1
    ans = max_h + max_w - (cnt == k)
    print(ans)
    
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from collections import deque
import numpy as np


def main():
    h, w, m = map(int, input().split())
    base = np.zeros((h, w), dtype=int)
    B = []
    for n in range(m):
        h1, w1 = map(int, input().split())
        B.append((h1-1, w1-1))
        base[h1-1][w1-1] = 1
    hs, ws = [], []
    for n in range(h):
        hs.append(sum(base[n]))
    for n in range(w):
        ws.append(sum(base[:, n]))
    hs = np.array(hs)
    ws = np.array(ws)
    h_maxindex = [i for i, x in enumerate(hs) if x == max(hs)]
    w_maxindex = [i for i, x in enumerate(ws) if x == max(ws)]
    cnt = 0
    k = len(h_maxindex) * len(w_maxindex)
    for i, j in B:
        if hs[i] == max(hs) and ws[j] == max(ws):
            cnt += 1
    ans = max(hs) + max(ws) - (cnt == k)
    print(ans)
    
    
    
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from collections import deque
import numpy as np


def main():
    h, w, m = map(int, input().split())
    base = np.zeros((h, w), dtype=int)
    for n in range(m):
        h1, w1 = map(int, input().split())
        base[h1-1][w1-1] = 1
    hs, ws = [], []
    for n in range(h):
        hs.append(sum(base[n]))
    for n in range(w):
        ws.append(sum(base[:, n]))
    hs = np.array(hs)
    ws = np.array(ws)
    h_maxindex = [i for i, x in enumerate(hs) if x == max(hs)]
    w_maxindex = [i for i, x in enumerate(ws) if x == max(ws)]
    fla = 0
    for i in h_maxindex:
        for j in w_maxindex:
            if base[i][j] == 0:
                print(max(hs) + max(ws))
                fla = 1
                break
    if fla == 0:
        print(max(hs) + max(ws) - 1)

if __name__ == "__main__":
    main()
Problem p02699 (python)

Fixed submission:
S, W = map(int, input().split())
if W >= S:
    print("unsafe")
else:
    print("safe")

Buggy submission (verdict: Runtime Error):
S, W = map(int, input().split())
if W >= S:
    print("unsafe")
else:
    print("safe")S, W = map(int, input().split())
if W >= S:
    print("unsafe")
else:
    print("safe")
Problem p02578 (python)

Fixed submission:
a = int(input())
b = list(map(int,input().split()))
bmax = 0
ans = 0
for i in range(a):
    if i == 0:
        bmax = b[i]
    else:
        if bmax < b[i]:
            bmax = b[i]
        elif bmax > b[i]:
            ans += bmax - b[i]
print(str(ans))

Buggy submission (verdict: Runtime Error):
a = int(input())
b = list(map(int,input().split()))
bmax = 0
ans = 0
for i in range(a):
    if i == 0:
        bmax = a[i]
    else:
        if bmax < a[i]:
            bmax = a[i]
        elif bmax > a[i]:
            ans += bmax - a[i]
print(str(ans))
Problem p02729 (python)

Fixed submission:
from itertools import combinations

N,M = map(int,input().split())

a=["A" for i in range(0,N)]
b=["B" for i in range(0,M)]

tmp1=(len(list(combinations(a,2))))
tmp2=(len(list(combinations(b,2))))

print(tmp1+tmp2)

Buggy submission (verdict: Runtime Error):
import math

N,M = map(int,input().split())

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

print(combinations_count(N, 2)+combinations_count(M, 2))

Buggy submission (verdict: Runtime Error):
import math

N,M = map(int,input().split())

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

print(combinations_count(N, 2)+combinations_count(M, 2))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
N,M = map(int,input().split())

print(comb(N, 2,exact=True)+(comb(M, 2,exact=True)))
Problem p02623 (python)

Fixed submission:
N,M,K = map(int, input().split())
As = [int(n) for n in input().split()]
Bs = [int(n) for n in input().split()]

a_sum = [0]
b_sum = [0]

for i in range(len(As)):
    a_sum.append(a_sum[-1] + As[i])

for j in range(len(Bs)):
    b_sum.append(b_sum[-1] + Bs[j])

 
max_book_num = 0
j = M
for i in range(N+1):
    if a_sum[i] > K:
        continue

    while b_sum[j] + a_sum[i] > K:
        j -= 1
    
    max_book_num = max(max_book_num, i + j)

        
print(max_book_num)

Buggy submission (verdict: Runtime Error):
N,M,K = map(int, input().split())
As = [int(n) for n in input().split()]
Bs = [int(n) for n in input().split()]

a_sum = [0] * (len(As) + 1)
b_sum = [0] * (len(Bs) + 1)

for i in range(1, len(As)):
    a_sum[i] = a_sum[i-1] + As[i]

for j in range(1, len(Bs)):
    b_sum[i] = b_sum[i-1] + Bs[i]

max_book_num = 0
j = M
for i in range(N+1):
    if a_sum[i] > K:
        continue

    while b_sum[j] + a_sum[i] > K:
        j -= 1
    
    max_book_num = max(max_book_num, i + j)

        
print(max_book_num)
Problem p02682 (python)

Fixed submission:
# -*- coding: utf-8 -*-
a, b, c, k = map(int, input().split())
cnt = 0
if k <= a:
    cnt += k
elif (a < k <= a+b):
    cnt += a
elif (a+b < k < a+b+c):
    cnt += a - (k-(a+b))
else:
    cnt += a - c
print(cnt)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a, b, c, k = map(int, input().split())
L = [1]*a+[0]*b+[-1]*c
cnt = 0
for i in range(k):
    cnt += L[i]
print(cnt)
Problem p02699 (python)

Fixed submission:
s, w = map(int, input().split())
if s > w:
  print("safe")
else:
  print("unsafe")

Buggy submission (verdict: Runtime Error):
s, w = map(int, input().split())
if s > w:
  print("safe")
 else:
  print("unsafe")
Problem p02723 (python)

Fixed submission:
S = input()
if S[2] == S[3] and S[4] == S[5]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S = input()
if S[2] == S[3] and S[4] == S[5]:
  print(Yes)
else:
  print(No)
Problem p02777 (python)

Fixed submission:
# -*- coding: utf-8 -*-
s, t = input().split()
a, b = map(int, input().split())
u = input()
if u == s:
    a -= 1
if u == t:
    b -= 1
print(a, b)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
p = list(map(int, input().split()))
Exp = [0]*(N-K+1)
for i in range(N-K+1):
    x = 0
    for j in range(i, i+K):
        x += (sum(range(1, p[j]+1)))/p[j]
    Exp[i] = x
print(max(Exp))
Problem p03135 (python)

Fixed submission:
T, X = map(int, input().split())
print(T/X)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(input())
L = list(map(int, input().split()))
if max(L) > (sum(L)-max(L)):
    print("Yes")
else:
    print("No")
Problem p02707 (python)

Fixed submission:
import math
n=int(input())
arr=list(map(int,input().split()))
freq=[0]*(200020)
for i in range(len(arr)):
	freq[arr[i]]+=1
for i in range(1,n+1):
	print(freq[i])

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
arr=list(map(int,input().split()))
freq=[0]*(max(arr)+10)
for i in range(len(arr)):
	freq[arr[i]]+=1
for i in range(1,n+1):
	print(freq[i])
Problem p03250 (python)

Fixed submission:
l=list(map(int,input().split()))
l=sorted(l)
l=l[::-1]
s=str(l[0])
s+=str(l[1])
xx=int(s)
print(xx+l[-1])

Buggy submission (verdict: Runtime Error):
n,m,x,y=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a.sort(reverse=True)
b.sort()
# xx=a[0]
f=0
# if xx<x:
#     xx=x 
for i in range(x+1,y+1):
    if i<=b[0] and i>a[0]:
        #print(i)
        f=1 
        break 
if f==1:
    print("No War")
else:
    print("War")
Problem p02735 (python)

Fixed submission:
H, W = map(int, input().split())
MAX_VAL = 10**9
cost = [[MAX_VAL]*(W+1) for _ in range(H+1)]

field = ["#" * (W+1)]
for i in range(H):
    line = input()
    field.append("#" + line)

if field[1][1] == "#":
    cost[1][1] = 1
else:
    cost[1][1] = 0

for i in range(1, H+1):
    for j in range(1, W+1):
        if i * j == 1:
            continue

        if field[i][j] == ".":
            cost[i][j] = min(cost[i-1][j], cost[i][j-1])
        else:
            top_cost = cost[i-1][j]
            left_cost = cost[i][j-1]
            
            if field[i-1][j] == ".":
                top_cost += 1
            if field[i][j-1] == ".":
                left_cost += 1
            
            cost[i][j] = min(top_cost, left_cost)

print(cost[H][W])

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
MAX_VAL = 10**9
cost = [[MAX_VAL]*(W+1) for _ in range(H+1)]
field = ["#" * (H+1)]
for i in range(H):
    line = input()
    field.append("#" + line)

if field[1][1] == "#":
    cost[1][1] = 1
else:
    cost[1][1] = 0

for i in range(1, H+1):
    for j in range(1, W+1):
        if i * j == 1:
            continue

        if field[i][j] == ".":
            cost[i][j] = min(cost[i-1][j], cost[i][j-1])
        else:
            top_cost = cost[i-1][j]
            left_cost = cost[i][j-1]
            
            if field[i-1][j] == ".":
                top_cost += 1
            if field[i][j-1] == ".":
                left_cost += 1
            
            cost[i][j] = min(top_cost, left_cost)

print(cost[H][W])
Problem p02819 (python)

Fixed submission:
import math
import bisect

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

    primes = [i for i in range(x)]
    primes[1] = 0 

    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 [prime for prime in primes if prime != 0]

def is_prime(x):
    if x < 2: return False
    if x == 2 or x == 3 or x == 5: return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False

    
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True


if __name__ == '__main__':
    target = int(input())
    ps = primes(2 * 10**5)
    ans_idx = bisect.bisect_left(ps, target)
    print(ps[ans_idx])

Buggy submission (verdict: Runtime Error):
import math
import bisect

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

    primes = [i for i in range(x)]
    primes[1] = 0 

    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 [prime for prime in primes if prime != 0]

def is_prime(x):
    if x < 2: return False
    if x == 2 or x == 3 or x == 5: return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False

    
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True


if __name__ == '__main__':
    target = int(input())
    ps = primes(10**5+1)
    ans_idx = bisect.bisect_left(ps, target)
    print(ps[ans_idx])