Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

n,m = map(int,input().split())
a = list(map(int,input().split()))
heapq.heapify(a)

for i in range(m):
    b,c = map(int,input().split())
    for j in range(b):
        d = heapq.heappop(a)
        if d >= c:
            heapq.heappush(a, d)
            break
        else:
            heapq.heappush(a, c)
        
print(sum(a))

Fixed submission:
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
aa = [-1] * (2*n)
bc = []

for i in range(m):
    b,c = map(int,input().split())
    bc.append((c,b))
bc.sort(reverse = True)

i = 0
for j in range(m):
    if i >= n:
        break
    for k in range(bc[j][1]):
        aa[i] = bc[j][0]
        i += 1

j = 0
for i in range(n):
    if a[i] < aa[j]:
        a[i] = aa[j]
        j += 1
        
print(sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
import heapq

n,m = map(int,input().split())
a = list(map(int,input().split()))
heapq.heapify(a)

for i in range(m):
    b,c = map(int,input().split())
    for j in range(b):
        d = heapq.heappop(a)
        d = max(d , c)
        heapq.heappush(a, d)
        
print(sum(a))

Fixed submission:
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
aa = [-1] * (2*n)
bc = []

for i in range(m):
    b,c = map(int,input().split())
    bc.append((c,b))
bc.sort(reverse = True)

i = 0
for j in range(m):
    if i >= n:
        break
    for k in range(bc[j][1]):
        aa[i] = bc[j][0]
        i += 1

j = 0
for i in range(n):
    if a[i] < aa[j]:
        a[i] = aa[j]
        j += 1
        
print(sum(a))
Buggy python submission (verdict: Runtime Error):
n = int(input())
b = list(map(int,input().split()))
p = []

for i in range(n):
    nn = len(b)
    for j in range(nn-1,-1,-1):
        if b[j] == j+1:
            b = b[:j]+b[j+1:]
            p.append(c[j])
            break
            
if b == []:
    for i in range(n-1,-1,-1):
        print(p[i])
else:
    print(-1)

Fixed submission:
n = int(input())
b = list(map(int,input().split()))
p = []

for i in range(n):
    nn = len(b)
    for j in range(nn-1,-1,-1):
        if b[j] == j+1:
            p.append(b[j])
            b = b[:j]+b[j+1:]
            break
            
if b == []:
    for i in range(n-1,-1,-1):
        print(p[i])
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import itertools as it
MOD = 10 ** 9 + 7
n = int(input())
s = input()

b = Counter(s)
c = list(b)

ans = 0
for i in range(1,len(b)+1):
    d = list(it.combinations(c,i))
    for j in d:
        a = 1
        for k in j:
            a = a*b[k]
            
        ans = (ans+a) %MOD
            
print(ans)

Fixed submission:
from collections import Counter
import itertools as it
MOD = 10 ** 9 + 7
n = int(input())
s = input()

b = Counter(s)
c = list(b)

ans = 1
for i in b:
    ans = ans * (b[i]+1) % MOD
    
print((ans + MOD - 1) % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

maxn = 100000

n , m = map(int, input().split())

par = [0] * n
rank = [0] * n

#初期化
for i in range(n):
    par[i] = i
    rank[i] = 0

#判定(一番上野根を求める)
def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
    
#結合
def unite(x , y):
    rx = find(x)
    ry = find(y)
    
    if rx == ry:
        return
    
    if rank[rx] < rank[ry]:
        par[rx] = ry
    elif rank[rx] > rank[ry]:
        par[ry] = rx
    else:
        par[ry] = x
        rank[rx] += 1

a = [0] * m
b = [0] * m
for i in range(m):
    a[i],b[i] = map(int,input().split())
    a[i] -= 1
    b[i] -= 1
    
nn = [0]*(maxn+1)
for i in range(maxn+1):
    nn[i] = i * (i-1) // 2
    
dis = [0]*m
for i in range(m-1,-1,-1):
    ans = n*(n-1) // 2
    l = [find(j) for j in range(n)]
    ll = Counter(l)
    values, counts = zip(*ll.most_common())
    for j in counts:
        ans -= nn[j]
    dis[i] = ans
    unite(a[i],b[i])
    
for i in range(m):
    print(dis[i])

Fixed submission:
maxn = 100000

n , m = map(int, input().split())

par = [0] * n
rank = [0] * n
siz = [1] * n

#初期化
for i in range(n):
    par[i] = i
    rank[i] = 0

#判定(一番上野根を求める)
def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
    
#結合
def unite(x , y):
    rx = find(x)
    ry = find(y)
    
    if rx == ry:
        return
    
    if rank[rx] < rank[ry]:
        par[rx] = ry
        siz[ry] += siz[rx]
        siz[rx] = 0
    elif rank[rx] > rank[ry]:
        par[ry] = rx
        siz[rx] += siz[ry]
        siz[ry] = 0
    else:
        par[ry] = x
        siz[rx] += siz[ry]
        siz[ry] = 0
        rank[rx] += 1

a = [0] * m
b = [0] * m
for i in range(m):
    a[i],b[i] = map(int,input().split())
    a[i] -= 1
    b[i] -= 1
    
nn = [0]*(maxn+1)
for i in range(maxn+1):
    nn[i] = i * (i-1) // 2
    
dis = [0]*m
ans = n*(n-1) // 2
dis[m-1] = ans
for i in range(m-1,0,-1):
    if find(a[i]) == find(b[i]):
        dis[i-1] = ans
    else:
        ans -= (siz[find(a[i])] * siz[find(b[i])])
        dis[i-1] = ans
        
    unite(a[i],b[i])
    
for i in range(m):
    print(dis[i])
Buggy python submission (verdict: Time Limit Exceeded):
inf = 1145141919810364364
start = 10**15
import heapq

def di(s,fl):
    d = [inf] * n
    used = [1] * n
    d[s] = 0
    used[s] = 0
    lis = []
    
    for q in edge[fl][s]:
        heapq.heappush(lis,q)
        
    while lis:
        minedge = heapq.heappop(lis)
        
        if used[minedge[1]] == 0:
            continue

        v = minedge[1]
        d[v] = minedge[0]
        used[v] = 0

        for q in edge[fl][v]:
            if used[q[1]] == 1:
                heapq.heappush(lis,[q[0]+d[v],q[1]])
    return d

n,m,s,t = map(int,input().split())
#0は円、1はスヌーク
edge = [[[] for i in range(n)] for _ in range(2)]

for i in range(m):
    u,v,a,b = map(int,input().split())
    edge[0][u-1].append([a,v-1])
    edge[0][v-1].append([a,u-1])
    edge[1][u-1].append([b,v-1])
    edge[1][v-1].append([b,u-1])
    
a = di(s-1,0)
b = di(t-1,1)
k = start - a[n-1] - b[n-1]
ans = [0] * n

for i in range(n):
    k = max(k , start - (a[n-1-i] + b[n-1-i]))
    ans[n-1-i] = k
    
for i in range(n):
    print(ans[i])

Fixed submission:
inf = 1145141919810364364
start = 10**15
import heapq

def di(s,fl):
    d = [inf] * n
    used = [1] * n
    d[s] = 0
    used[s] = 0
    lis = []
    
    for a,b in edge[fl][s]:
        heapq.heappush(lis,a*(10**6)+b)
        
    while lis:
        minedge = heapq.heappop(lis)
        
        if used[minedge%(10**6)] == 0:
            continue

        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = 0

        for q in edge[fl][v]:
            if used[q[1]] == 1:
                heapq.heappush(lis,(q[0]+d[v])*(10**6)+q[1])
    return d

n,m,s,t = map(int,input().split())
#0は円、1はスヌーク
edge = [[[] for i in range(n)] for _ in range(2)]

for i in range(m):
    u,v,a,b = map(int,input().split())
    edge[0][u-1].append([a,v-1])
    edge[0][v-1].append([a,u-1])
    edge[1][u-1].append([b,v-1])
    edge[1][v-1].append([b,u-1])
    
a = di(s-1,0)
b = di(t-1,1)
k = start - a[n-1] - b[n-1]
ans = [0] * n

for i in range(n):
    k = max(k , start - (a[n-1-i] + b[n-1-i]))
    ans[n-1-i] = k
    
for i in range(n):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())
n = len(s)
a = set([])

for i in range(n):
    for j in range(i+1,n+1):
        a.add(s[i:j])
        
b = list(a)
b.sort()
print(b[k-1])

Fixed submission:
from collections import Counter
s = input()
k = int(input())
n = len(s)
bb = Counter(s)
b = list(bb)
b.sort()
a = set([])

for l in range(k):
    for i in range(n):
        if s[i] == b[l]:
            for j in range(5):
                if i + j > n:
                    break
                a.add(s[i:i+1+j])
    if len(a) >= k:
        break
        
b = list(a)
b.sort()
print(b[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
q = []
import sys
from collections import Counter
import itertools

for _ in range(n):
    s = input()
    a = s[0]
    
    if a =='M' or a =='A' or a =='R' or a =='C' or a =='H':
        q.append(a)
        
b = Counter(q)
m = 0

if len(b) < 3:
    print(0)
    sys.exit()
else:
    p = list(itertools.combinations(q,3))

ans = 0
for i in p:
    if len(Counter(i)) == 3:
        ans += 1
        
print(ans)

Fixed submission:
n = int(input())
q = []
z = ['M','A','R','C','H']
import sys
from collections import Counter
import itertools

for _ in range(n):
    s = input()
    a = s[0]
    
    if a =='M' or a =='A' or a =='R' or a =='C' or a =='H':
        q.append(a)
        
b = Counter(q)
c = list(b.keys())
m = 0

if len(b) < 3:
    print(0)
    sys.exit()
else:
    p = list(itertools.combinations(c,3))

ans = 0
for f,g,h in p:
    ans += (b[f]*b[g]*b[h])
        
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
import sys

def ato(x):
    if x == "Male":
        return 0
    elif x == "Female":
        return 1
    else:
        return -1
    
print(0)
s0 = ato(input())
if s0 == -1:
    sys.exit()
    
print(n-1)
s1 = ato(input())
if s1 == -1:
    sys.exit()
    
left = 0
right = n-1
center = (left+right) // 2
while right - left >= 1:
    center = (left+right) // 2
    
    print(center)
    s2 = ato(input())
    if s2 == -1:
        break
    
    if (center - left)%2 != abs(s2 - s0):
        right = center - 1
        s1 = s2
    else:
        left = center + 1
        s0 = s2

Fixed submission:
n = int(input())
import sys

def ato(x):
    if x == "Male":
        return 0
    elif x == "Female":
        return 1
    else:
        return -1
    
print(0)
s0 = ato(input())
if s0 == -1:
    sys.exit()
    
print(n-1)
s1 = ato(input())
if s1 == -1:
    sys.exit()
    
left = 0
right = n-1
center = (left+right) // 2
while True:
    center = (left+right) // 2
    
    print(center)
    s2 = ato(input())
    if s2 == -1:
        break
    
    if (center - left)%2 == abs(s2 - s0):
        left = center
        s0 = s2
    else:
        right = center
        s1 = s2

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
import sys

def ato(x):
    if x == "Male":
        return 0
    elif x == "Female":
        return 1
    else:
        return -1
    
print(0)
s0 = ato(input())
if s0 == -1:
    sys.exit()
    
print(n-1)
s1 = ato(input())
if s1 == -1:
    sys.exit()
    
left = 0
right = n-1
center = (left+right) // 2
while right - left >= 1:
    center = (left+right) // 2
    
    print(center)
    s2 = ato(input())
    if s2 == -1:
        break
    
    if (center - left)%2 != s2 - s0:
        right = center - 1
        s1 = s2
    else:
        left = center + 1
        s0 = s2

Fixed submission:
n = int(input())
import sys

def ato(x):
    if x == "Male":
        return 0
    elif x == "Female":
        return 1
    else:
        return -1
    
print(0)
s0 = ato(input())
if s0 == -1:
    sys.exit()
    
print(n-1)
s1 = ato(input())
if s1 == -1:
    sys.exit()
    
left = 0
right = n-1
center = (left+right) // 2
while True:
    center = (left+right) // 2
    
    print(center)
    s2 = ato(input())
    if s2 == -1:
        break
    
    if (center - left)%2 == abs(s2 - s0):
        left = center
        s0 = s2
    else:
        right = center
        s1 = s2
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ab = [0] * (max(a) + 1)
bc = [0] * (max(b) + 1)

def isok(na , index , key):
    if na[index] >= key:
        return True
    else:
        return False
    
def bs(nar,key):
    left = -1
    right = len(nar)
    
    while (right - left) > 1:
        mid = left + (right - left) // 2
        
        if isok(nar , mid , key):
            right = mid
        else:
            left = mid
            
    return right

ans = 0
for i in b:
    q = bs(a,i)
    r = bs(c,i+1)
    
    ans += q*(n-r)
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()

def isok(na , index , key):
    if na[index] >= key:
        return True
    else:
        return False
    
def bs(nar,key):
    left = -1
    right = len(nar)
    
    while (right - left) > 1:
        mid = left + (right - left) // 2
        
        if isok(nar , mid , key):
            right = mid
        else:
            left = mid
            
    return right

ans = 0
for i in b:
    q = bs(a,i)
    r = bs(c,i+1)
    
    ans += q*(n-r)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
b.append(0)
c.append(0)
a.sort()
b.sort()
c.sort()

def isok(na , index , key):
    if na[index] >= key:
        return True
    else:
        return False
    
def bs(nar,key):
    left = -1
    right = len(nar)
    
    while (right - left) > 1:
        mid = left + (right - left) // 2
        
        if isok(nar , mid , key):
            right = mid
        else:
            left = mid
            
    return right

ans = 0
for i in a:
    q = bs(b,i+1)
    d = b[q:]
    
    for j in d:
        r = bs(c,j+1)
        f = c[r:]
        ans += len(f)
        
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()

def isok(na , index , key):
    if na[index] >= key:
        return True
    else:
        return False
    
def bs(nar,key):
    left = -1
    right = len(nar)
    
    while (right - left) > 1:
        mid = left + (right - left) // 2
        
        if isok(nar , mid , key):
            right = mid
        else:
            left = mid
            
    return right

ans = 0
for i in b:
    q = bs(a,i)
    r = bs(c,i+1)
    
    ans += q*(n-r)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
s = s + "0"
s2 = input()
MOD = 10**9 + 7

al = []
for i in range(n):
    if s[i] != s[i+1]:
        al.append(a0)
        a0 = 1
    else:
        a0 += 1

if al[0] == 1:
    ans = 3
else:
    ans = 6

for i in range(len(al)-1):
    if al[i] == 1:
        ans = ans * 2 % MOD
    else:
        if al[i+1] == 2:
            ans = ans * 3 % MOD
            
print(ans)

Fixed submission:
n = int(input())
s = input()
s = s + "0"
s2 = input()
MOD = 10**9 + 7

al = []
a0 = 1
for i in range(n):
    if s[i] != s[i+1]:
        al.append(a0)
        a0 = 1
    else:
        a0 += 1

if al[0] == 1:
    ans = 3
else:
    ans = 6

for i in range(len(al)-1):
    if al[i] == 1:
        ans = ans * 2 % MOD
    else:
        if al[i+1] == 2:
            ans = ans * 3 % MOD
            
print(ans)
Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

n = int(input())
t = [0]*n
for i in range(n):
    t[i] = int(input())
    
ans = t[0]
    
for i in range(1,n):
    ans = int(ans * t[i] / gcd(ans , t[i]))
    
print(ans)

Fixed submission:
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

n = int(input())
t = [0]*n
for i in range(n):
    t[i] = int(input())
    
ans = t[0]
    
for i in range(1,n):
    ans = ans * t[i] // gcd(ans , t[i])
    
print(ans)

Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

n = int(input())
t = [0]*n
for i in range(n):
    t[i] = int(input())
    
ans = t[0]
    
for i in range(n-1):
    ans = int(ans * t[i+1] / gcd(ans , t[i+1]))
    
print(int(ans))

Fixed submission:
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

n = int(input())
t = [0]*n
for i in range(n):
    t[i] = int(input())
    
ans = t[0]
    
for i in range(1,n):
    ans = ans * t[i] // gcd(ans , t[i])
    
print(ans)
Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

n = int(input())
t = [0]*n
for i in range(n):
    t[i] = int(input())
    
ans = t[0]
    
for i in range(1,n):
    ans = ans * t[i] // gcd(ans , t[i])
    
print(ans)

Fixed submission:
dic = dict()
n , k = map(int,input().split())

for _ in range(n):
    a , b = map(int,input().split())
    dic.setdefault(a , 0)
    dic[a] += b
    
sdic = sorted(dic.items(), key = lambda x : x[0])

for i in range(n):
    k -= sdic[i][1]
    
    if k <= 0:
        print(sdic[i][0])
        break
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
from collections import Counter

s = []
for _ in range(n):
    a,b = map(int,input().split())
    s.append(a)
    s.append(b)
    
c = Counter(s)
d = list(c.values())

ans = "YES"
for i in d:
    if i % 2 == 1:
        ans = "NO"
        break
        
print(ans)

Fixed submission:
n,m = map(int,input().split())
from collections import Counter

s = []
for _ in range(m):
    a,b = map(int,input().split())
    s.append(a)
    s.append(b)
    
c = Counter(s)
d = list(c.values())

ans = "YES"
for i in d:
    if i % 2 == 1:
        ans = "NO"
        break
        
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a = a + [0]

a.sort(reverse = True)

b = 1
ichi = 0
r = []
for i in range(n):
    if a[i] != a[i+1]:
        if b != 1:
            r.append(b)
        else:
            ichi += 1
        b = 1
    else:
        b += 1

for i in range(len(r)-1):
    if r[i] % 2 == 0:
        r[i] = 1
        r[i+1] -= 1
    else:
        r[i] = 1
        
if r[-1] % 2 == 0:
    print(ichi + len(r) - 1)
else:
    print(ichi + len(r))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a = a + [0]

a.sort(reverse = True)

b = 1
ichi = 0
r = []
for i in range(n):
    if a[i] != a[i+1]:
        if b != 1:
            r.append(b)
        else:
            ichi += 1
        b = 1
    else:
        b += 1

for i in range(len(r)-1):
    if r[i] % 2 == 0:
        r[i] = 1
        r[i+1] -= 1
    else:
        r[i] = 1
        
if r != []:
    if r[-1] % 2 == 0:
        print(ichi + len(r) - 1)
    else:
        print(ichi + len(r))
        
else:
    print(ichi)
Buggy python submission (verdict: Time Limit Exceeded):
x = input()

while True:
    n = len(x)
    fl = 0
    for i in range(n-1):
        if x[i] == "S" and x[i+1] == "T":
            x = x[:i] + x[i+2:]
            fl = 1
            break
            
    if fl == 0:
        break
        
print(len(x))

Fixed submission:
from collections import deque
x = input()
n = len(x)
st = deque()

for i in range(n):
    if x[i] == "S":
        st.append("S")
    else:
        if st == deque([]):
            st.append("T")
        else:
            a = st.pop()
            if a == "T":
                st.append("T")
                st.append("T")
            else:
                continue
                
print(len(st))
Buggy python submission (verdict: Runtime Error):
a, b, c, d = [int(x) for x in input().split(" ")]
print(max([a*c a*d, b*c, b*d]))

Fixed submission:
a, b, c, d = [int(x) for x in input().split(" ")]
print(max([a*c, a*d, b*c, b*d]))

Buggy python submission (verdict: Runtime Error):
a, b, c, d = [int(x) for x in input().split(" ")]
print(max(a*c a*d, b*c, b*d))

Fixed submission:
a, b, c, d = [int(x) for x in input().split(" ")]
print(max([a*c, a*d, b*c, b*d]))

Buggy python submission (verdict: Runtime Error):
a, b, c, d = [int(x) for x input().split(" ")]
print(max(a*c a*d, b*c, b*d))


Fixed submission:
a, b, c, d = [int(x) for x in input().split(" ")]
print(max([a*c, a*d, b*c, b*d]))
Buggy python submission (verdict: Runtime Error):
import math
 
def main():
  N = int(input())
  
  print(search(N))
 
def search(x):
  
  ints = list(range(2,x))
  
  # 順に確認する
  for i in ints:
    if x%i==0:
      seartch(x+1)
  	elif x < i**2:
      break
    
  return x

Fixed submission:
print("".join(input().split(" ")[::-1]))

Buggy python submission (verdict: Runtime Error):
import math
 
def main():
  N = int(input())
  
  if N==2:
    print(2)
  else:
    print(search(N))
 
# xは奇数を前提
def search(x):
  
  # 2は確認不要
  ints = list(range(3,x))
  
  # 順に確認する
  for i in ints:
    
    
    if x%i==0:
      seartch(x+2)
  	elif x < i**2:
      break
    
  return x

main()

Fixed submission:
print("".join(input().split(" ")[::-1]))
Buggy python submission (verdict: Runtime Error):
import math
 
def main():
  N = int(input())
  
  print(search(N))
 
def search(x):
  
  ints = list(range(2,x))
  
  # 順に確認する
  for i in ints:
    if x%i==0:
      return search(x+1)
  	elif x < i**2:
      break
    
  return x

Fixed submission:
def main():
  N = int(input())
  
  print(search(N))
 
def search(x):
  
  ints = list(range(2,x))
  
  # 順に確認する
  for i in ints:
    if x%i==0:
      return search(x+1)
    elif x < i**2:
      break
    
  return x

main()

Buggy python submission (verdict: Runtime Error):
import math
 
def main():
  N = int(input())
  
  print(search(N))
 
def search(x):
  
  ints = list(range(2,x))
  
  # 順に確認する
  for i in ints:
    if x%i==0:
      return seartch(x+1)
  	elif x < i**2:
      break
    
  return x

Fixed submission:
def main():
  N = int(input())
  
  print(search(N))
 
def search(x):
  
  ints = list(range(2,x))
  
  # 順に確認する
  for i in ints:
    if x%i==0:
      return search(x+1)
    elif x < i**2:
      break
    
  return x

main()

Buggy python submission (verdict: Runtime Error):
import math
 
def main():
  N = int(input())
  
  print(search(N))
 
def search(x):
  
  ints = list(range(2,x))
  
  # 順に確認する
  for i in ints:
    if x%i==0:
      seartch(x+1)
  	elif x < i**2:
      break
    
  return x

Fixed submission:
def main():
  N = int(input())
  
  print(search(N))
 
def search(x):
  
  ints = list(range(2,x))
  
  # 順に確認する
  for i in ints:
    if x%i==0:
      return search(x+1)
    elif x < i**2:
      break
    
  return x

main()

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

def main():
  N = int(input())
  
  if N==2:
    print(2)
  else:
    print(search(N))

# xは奇数を前提
def search(x):
  
  # 2は確認不要
  ints = list(range(3,x))
  
  # 順に確認する
  for i in ints:
    
    
    if x%i==0:
      seartch(x+2)
  	elif x < i**2:
      break
    
  return x
    

Fixed submission:
def main():
  N = int(input())
  
  print(search(N))
 
def search(x):
  
  ints = list(range(2,x))
  
  # 順に確認する
  for i in ints:
    if x%i==0:
      return search(x+1)
    elif x < i**2:
      break
    
  return x

main()