Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input())

sumx = 0
for i in range(N-2):
    if S[i] != S[i + 1]:
        sumx += 1

if S[-2] != S[-1]:
    sumx += 2
elif S[-2] == S[-1]:
    sumx += 1

print(sumx)


Fixed submission:
N = int(input())
S = list(input())

sumx = 0
mem = ""

for i in S:
    if i != mem:
        sumx += 1
        mem = i
    else:
        mem = i

print(sumx)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input())

newS = []
for i in range(N-2):
    if S[i] != S[i + 1]:
        newS.append(S[i])

if S[-2] != S[-1]:
    newS.append(S[-2])
    newS.append(S[-1])
elif S[-2] == S[-1]:
    newS.append(S[-2])
print(len(newS))


Fixed submission:
N = int(input())
S = list(input())

sumx = 0
mem = ""

for i in S:
    if i != mem:
        sumx += 1
        mem = i
    else:
        mem = i

print(sumx)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = []
for i in range(N):
    ans.append(A.index(i+1)+1)

print(*ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))

out = [0] * N

for i in range(N):
    out[A[i] - 1] = i + 1
print(*out)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = [-1] * N

for i in range(N):
    ans[A[i] - 1] = A.index(A[i])+1

print(*ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))

out = [0] * N

for i in range(N):
    out[A[i] - 1] = i + 1
print(*out)
Buggy python submission (verdict: Runtime Error):
ULURU

Fixed submission:
N = list(input())
N.insert(0, '')
even = N[2::2]
odd = N[1::2]
if ('R' in even or 'L' in odd):
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = []
for i in range(M):
    L, R = map(int, input().split())
    if i == 0:
        S = set(list(range(L, R + 1)))
    else:
        S = S & set(list(range(L, R + 1)))
        if len(S) == 0:
            break

# L = set(A[0])
# for i in range(1, M):
#     L = L & set(A[i])

print(len(S))


Fixed submission:
N, M = map(int, input().split())
A = []
for i in range(M):
    L, R = map(int, input().split())
    if i == 0:
        Lmax = L
        Rmin = R
    else:
        Lmax = max(L, Lmax)
        Rmin = min(R, Rmin)

# L = set(A[0])
# for i in range(1, M):
#     L = L & set(A[i])

if Rmin-Lmax < 0:
    print(0)
else:
    print(Rmin-Lmax+1)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = []
for i in range(M):
    L, R = map(int, input().split())
    if i == 0:
        S = set(list(range(L, R + 1)))
    else:
        S = S & set(list(range(L, R + 1)))

# L = set(A[0])
# for i in range(1, M):
#     L = L & set(A[i])

print(len(S))


Fixed submission:
N, M = map(int, input().split())
A = []
for i in range(M):
    L, R = map(int, input().split())
    if i == 0:
        Lmax = L
        Rmin = R
    else:
        Lmax = max(L, Lmax)
        Rmin = min(R, Rmin)

# L = set(A[0])
# for i in range(1, M):
#     L = L & set(A[i])

if Rmin-Lmax < 0:
    print(0)
else:
    print(Rmin-Lmax+1)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = []
for i in range(M):
    L, R = map(int, input().split())
    A.append(list(range(L, R + 1)))

L = set(A[0])
for i in range(1, M):
    L = L & set(A[i])

print(len(L))


Fixed submission:
N, M = map(int, input().split())
A = []
for i in range(M):
    L, R = map(int, input().split())
    if i == 0:
        Lmax = L
        Rmin = R
    else:
        Lmax = max(L, Lmax)
        Rmin = min(R, Rmin)

# L = set(A[0])
# for i in range(1, M):
#     L = L & set(A[i])

if Rmin-Lmax < 0:
    print(0)
else:
    print(Rmin-Lmax+1)
Buggy python submission (verdict: Runtime Error):
import math
A, B, K = map(int, input().split())

answer = []
ans = 1
max_ans = math.gcd(A, B)
while ans <= max_ans:
    if A % ans == 0 and B % ans == 0:
        answer.append(ans)
        ans += 1
    else:
        ans += 1
answer = sorted(answer, reverse=True)

print(answer[K-1])


Fixed submission:
import fractions
A, B, K = map(int, input().split())

answer = []
ans = 1
max_ans = fractions.gcd(A, B)
while ans <= max_ans:
    if A % ans == 0 and B % ans == 0:
        answer.append(ans)
        ans += 1
    else:
        ans += 1
answer = sorted(answer, reverse=True)

print(answer[K-1])
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
S = list(input())

if S[B] == '-':
    for i in range(8):
        if i == B:
            continue
        else:
            if S[i] == '-':
                print('No')
                break
    print('Yes')
else:
    print('No')


Fixed submission:
A, B = map(int, input().split())
S = input()

fwd = S[0:A]
bwd = S[A+1:]
flag = 0
if fwd.isdigit() == True:
    if S[A] == '-':
        if bwd.isdigit() == True:
            flag = 1
if flag == 1:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
S = list(input())

if S[B] == '-':
    for i in range(8):
        if i == B:
            continue
        else:
            if S[i] == '-':
                print('No')
                exit()
    print('Yes')
else:
    print('No')


Fixed submission:
A, B = map(int, input().split())
S = input()

fwd = S[0:A]
bwd = S[A+1:]
flag = 0
if fwd.isdigit() == True:
    if S[A] == '-':
        if bwd.isdigit() == True:
            flag = 1
if flag == 1:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
queue = [list(map(int, input().split())) for _ in range(N)]


max_N = 100100
prime = np.ones(max_N, dtype=int)
a = np.zeros(max_N, dtype=int)
b = np.zeros(max_N+1, dtype=int)

prime[0], prime[1] = 0, 0
for i in range(2, max_N):
    if i == 0:
        continue
    for j in range(i*2, max_N, i):
        prime[j] = 0

for i in range(1, max_N):
    if i % 2 == 0:
        continue
    if prime[i] == 1 and prime[int((i + 1) / 2)] == 1:
        a[i] = 1
for i in range(0, max_N):
    b[i + 1] = a[i] + b[i]

for i in queue:
    print(b[i[1]+1]-b[i[0]])


Fixed submission:
import numpy as np
N = int(input())
queue = [list(map(int, input().split())) for _ in range(N)]


max_N = 100100
prime = list(np.ones(max_N, dtype=int))
a = list(np.zeros(max_N, dtype=int))
b = list(np.zeros(max_N+1, dtype=int))

prime[0], prime[1] = 0, 0
for i in range(2, max_N):
    if i == 0:
        continue
    for j in range(i*2, max_N, i):
        prime[j] = 0

for i in range(1, max_N):
    if i % 2 == 0:
        continue
    if prime[i] == 1 and prime[int((i + 1) / 2)] == 1:
        a[i] = 1
for i in range(0, max_N):
    b[i + 1] = a[i] + b[i]

for i in queue:
    print(b[i[1]+1]-b[i[0]])
Buggy python submission (verdict: Runtime Error):
S = list(input())
S = sorted(S)
num = len(set(S))
newS = sorted(list(set(S)))

if num == 26:
    print('None')
else:
    for i in range(26):
        if newS[i] != chr(i+97):
            print(chr(i+97))
            break


Fixed submission:
S = input()
S = sorted(list(set(S)))

n = 97
for i in range(len(S)):
    if ord(S[i]) == n:
        n += 1
    else:
        break

if n == 123:
    print('None')
else:
    print(chr(n))
Buggy python submission (verdict: Runtime Error):
from sys import stdin
input = stdin.readline()

n = int(input())
a = [0]*4

for i in range(n):
    s = input().strip()
    if s == "AC":
        a[0] += 1
    elif s == "WA":
        a[1] += 1
    elif s == "TLE":
        a[2] += 1
    else:
        a[3] += 1
        
print("AC x "*a[0])
print("WA x "*a[1])
print("TLE x "*a[2])
print("RE x "*a[3])

Fixed submission:
n = int(input())
a = [0]*4

for i in range(n):
    s = input()
    if s == "AC":
        a[0] += 1
    elif s == "WA":
        a[1] += 1
    elif s == "TLE":
        a[2] += 1
    else:
        a[3] += 1
        
print("AC x",a[0])
print("WA x",a[1])
print("TLE x",a[2])
print("RE x",a[3])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

def smallestPrimeFactor(mxn): 
    spf = [i for i in range(1+mxn)]

    for i in range(4, 1+mxn, 2):
        spf[i] = 2

    for i in range(3, int(mxn**0.5)+1):
        if spf[i] == i:
            for j in range(i*i, mxn, i):
                if spf[j] == j:
                    spf[j] = i
                    
    return spf

n = int(input())
spf = smallestPrimeFactor(1+n)
ans = 0

for i in range(1, n+1):
    num = i
    d = defaultdict(int)
    d[1] = 0
    
    while i != 1:
        d[spf[i]] += 1
        i //= spf[i]
        
    prod = 1
    for k,v in d.items():
        prod *= (v+1)
    ans += prod*num
    
print(ans)

Fixed submission:
n = int(input())
s = 0

for i in range(1, n+1):
    y = n//i
    s += i*y*(y+1)//2
    
print(s)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
q = int(input())

bckt = [0]*(n+1)
for i in a:
    bckt[i] += 1
    
s = sum(a)

for i in range(q):
    b, c = map(int, input().split())
    q = bckt[b]
    bckt[c] += q
    bckt[b] -= q
    s += (c*q - b*q)
    print(s)
    

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
q = int(input())

bckt = [0]*(int(1e5)+1)
for i in a:
    bckt[i] += 1
    
s = sum(a)

for i in range(q):
    b, c = map(int, input().split())
    q = bckt[b]
    bckt[c] += q
    bckt[b] -= q
    s += (c*q - b*q)
    print(s)
Buggy python submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
v = list(map(int, input().split()))
t = sum(v)/(4*m)

ct = 0
for i in v:
    if v>t:
        ct += 1
        
if ct >= m:
    print("Yes")
else:
    print("No")

Fixed submission:
n, m = list(map(int, input().split()))
v = list(map(int, input().split()))
t = sum(v)/(4*m)

ct = 0
for i in v:
    if i>=t:
        ct += 1
        
if ct >= m:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()

dp = [[0]*(1+len(s)) for i in range(1+len(t))]

for i in range(1, 1+len(t)):
    for j in range(1, 1+len(s)):
        if s[j-1] == t[i-1]:
            dp[i][j] = 1+dp[i-1][j-1]
            st += s[j-1]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

i = len(t)
j = len(s)
st = ""

while dp[i][j] != 0:
    if s[j-1] == t[i-1]:
        st += s[j-1]
        i -= 1
        j -= 1
    else:
        if dp[i][j-1] > dp[i-1][j]:
            j -= 1
        else:
            i -= 1
            
print(st[::-1])

Fixed submission:
s = input()
t = input()

dp = [[0]*(1+len(s)) for i in range(1+len(t))]

for i in range(1, 1+len(t)):
    for j in range(1, 1+len(s)):
        if s[j-1] == t[i-1]:
            dp[i][j] = 1+dp[i-1][j-1]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

i = len(t)
j = len(s)
st = ""

while dp[i][j] != 0:
    if s[j-1] == t[i-1]:
        st += s[j-1]
        i -= 1
        j -= 1
    else:
        if dp[i][j-1] > dp[i-1][j]:
            j -= 1
        else:
            i -= 1
            
print(st[::-1])
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
    
n, m = map(int, input().split())
adj = defaultdict(list)
radj = defaultdict(list)

for i in range(m):
    s, e = map(int, input().split())
    adj[s].append(e)
    
dp = [-1]*(n+1)

def dfs(e):
    if dp[e] != -1:
        return dp[e]
    
    temp = 0
    for i in adj[e]:
        temp = max(temp, 1+dfs(i))
        
    dp[e] = temp
    return temp
    
    
for i in range(1, n+1):
    dfs(i)
    
print(max(dp))

Fixed submission:
import sys
from collections import defaultdict
    
sys.setrecursionlimit(10**9)
    
n, m = map(int, input().split())
adj = defaultdict(list)
radj = defaultdict(list)

for i in range(m):
    s, e = map(int, input().split())
    adj[s].append(e)
    
dp = [-1]*(n+1)

def dfs(e):
    if dp[e] != -1:
        return dp[e]
    
    temp = 0
    for i in adj[e]:
        temp = max(temp, 1+dfs(i))
        
    dp[e] = temp
    return temp
    
    
for i in range(1, n+1):
    dfs(i)
    
print(max(dp))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
    
n, m = map(int, input().split())
adj = defaultdict(list)
radj = defaultdict(list)

for i in range(m):
    s, e = map(int, input().split())
    adj[s].append(e)
    radj[e].append(s)
    
mp = [0]*(n+1)
v = [0]*(n+1)
    
for i in range(1, 1+n):
    if len(adj[i]) == 0:
        q = [i]
        while q:
            e = q.pop()
            for j in radj[e]:
                mp[j] = max(mp[j], 1+mp[e])
                q.append(j)

print(max(mp))

Fixed submission:
import sys
from collections import defaultdict
    
sys.setrecursionlimit(10**9)
    
n, m = map(int, input().split())
adj = defaultdict(list)
radj = defaultdict(list)

for i in range(m):
    s, e = map(int, input().split())
    adj[s].append(e)
    
dp = [-1]*(n+1)

def dfs(e):
    if dp[e] != -1:
        return dp[e]
    
    temp = 0
    for i in adj[e]:
        temp = max(temp, 1+dfs(i))
        
    dp[e] = temp
    return temp
    
    
for i in range(1, n+1):
    dfs(i)
    
print(max(dp))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
    
n, m = map(int, input().split())
mp = 0

adj = defaultdict(list)

for i in range(m):
    s, e = map(int, input().split())
    adj[s].append(e)
    
for i in range(1, 1+n):
    q = [[i, 0]]

    while q:
        e, l = q.pop()

        if len(adj[e]) == 0:
            mp = max(mp, l)
        else:
            for j in adj[e]:
                q.append([j, l+1])

print(mp)

Fixed submission:
import sys
from collections import defaultdict
    
sys.setrecursionlimit(10**9)
    
n, m = map(int, input().split())
adj = defaultdict(list)
radj = defaultdict(list)

for i in range(m):
    s, e = map(int, input().split())
    adj[s].append(e)
    
dp = [-1]*(n+1)

def dfs(e):
    if dp[e] != -1:
        return dp[e]
    
    temp = 0
    for i in adj[e]:
        temp = max(temp, 1+dfs(i))
        
    dp[e] = temp
    return temp
    
    
for i in range(1, n+1):
    dfs(i)
    
print(max(dp))
Buggy python submission (verdict: Runtime Error):
x = int(input())
a = int(input())
if x < a:
    print(0)
else:
    print(10)

Fixed submission:
x,a = map(int, input().split())
if x < a :
    print(0)
else:
    print(10)

Buggy python submission (verdict: Runtime Error):
x = int(input())
a = int(input())
if x < a :
    print(0)
else :
    print(10)

Fixed submission:
x,a = map(int, input().split())
if x < a :
    print(0)
else:
    print(10)

Buggy python submission (verdict: Runtime Error):
x = int(input())
a = int(input())
if x < a :
    print(0)
else :
    print(10)

Fixed submission:
x,a = map(int, input().split())
if x < a :
    print(0)
else:
    print(10)
Buggy python submission (verdict: Runtime Error):
S=str(input())
T=str(input())
sum=0

for i in range(len(S)):
    if S[i]!=T[i]:
        sum++

print(sum)

Fixed submission:
S=str(input())
T=str(input())
sum=0

for i in range(len(S)):
    if S[i]!=T[i]:
        sum+=1

print(sum)
Buggy python submission (verdict: Runtime Error):
a=int(input())

print('A' if(a.isupper) else 'a')

Fixed submission:
a=input()

print('A' if a.isupper() else 'a')
Buggy python submission (verdict: Runtime Error):
S = input()
if (S = 'ABC'):
  print('ARC')
elif (S = 'ARC'):
  print('ABC')


Fixed submission:
S = input()
if (S == 'ABC'):
  print('ARC')
elif (S == 'ARC'):
  print('ABC')

Buggy python submission (verdict: Runtime Error):
S = input()
if S = 'ABC':
  print('ARC')
elif S = 'ARC':
  print('ABC')

Fixed submission:
S = input()
if (S == 'ABC'):
  print('ARC')
elif (S == 'ARC'):
  print('ABC')
Buggy python submission (verdict: Runtime Error):
import math
print(int(input())*2*math.py)

Fixed submission:
import math
print(int(input())*math.pi*2)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = list(map(int, input().split()))
for i in range(M+1):
  N -= a[i]
print(N if N>0 else '-1')


Fixed submission:
N,M = map(int,input().split())
a = list(map(int, input().split()))
for i in range(M):
  N -= a[i]
print(N if N>=0 else '-1')

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = [int(input()) for i in range(M)]
for i in range(M):
  N = N - a[i]
print(N if N>0 else -1)


Fixed submission:
N,M = map(int,input().split())
a = list(map(int, input().split()))
for i in range(M):
  N -= a[i]
print(N if N>=0 else '-1')

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = [int(input()) for i in range(M)]
for i in range(M):
  N -= a[i]
print(N if N>0 else -1)

Fixed submission:
N,M = map(int,input().split())
a = list(map(int, input().split()))
for i in range(M):
  N -= a[i]
print(N if N>=0 else '-1')
Buggy python submission (verdict: Runtime Error):
N = input()
if 7 in N:
  print('Yes')
else:
  print('No')

Fixed submission:
N = input()
if ('7' in N):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
sum=0
for i in range( 1, N+1):
  if !(i%5==0) and !(i%3==0):
    sum+=i
print(sum)

Fixed submission:
N = int(input())
sum=0
for i in range(1,N+1):
  if ((i%3!=0)and(i%5!=0)):
    sum+=i
print(sum)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n[-1] == "3":
  print("bon")
elif n[-1] == ["0","1","6","8"]:
  print("pon")
else:
  print("hon")

Fixed submission:
n = input()
if n[-1] == "3":
  print("bon")
elif n[-1] in ["0","1","6","8"]:
  print("pon")
else:
  print("hon")
Buggy python submission (verdict: Runtime Error):
N,M = input().split()
result = int(N*(N-1)/2) + int(M*(M-1)/2)
print(result)

Fixed submission:
a,b = map(int, input().split())
 
c = a*(a-1)//2 + b*(b-1)//2
print(c)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())

ans = a*b % 2
if ans == 0:
  print(Even)
else:
  print(Odd)


Fixed submission:
a,b = map(int,input().split())

ans = a*b % 2
if ans == 0:
  print("Even")
else:
  print("Odd")
Buggy python submission (verdict: Time Limit Exceeded):
N = input()
A = list(map(int,input().split()))
count = 0
exist_odd = False

while (exist_odd == False):
  for x in A:
    x = int(x)
    if x % 2 != 0:
      exist_odd = True
      
  if exist_odd == True:
    break
  else:
    for x in A:
      x /= 2
      count += 1
print(count)
        

Fixed submission:
N = input()
A = list(map(int,input().split()))
count = 0
exist_odd = False

while (exist_odd == False):
  for x in A:
    if x % 2 != 0:
      exist_odd = True
      
  if exist_odd == True:
    break
  else:
    A = [x/2 for x in A]
  count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
hist = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0 }
for i in range(N):
  tc = input()
    hist[tc] += 1

for k in ['AC', 'WA', 'TLE', 'RE']:
  print(f'{k} x {hist[k]}', flush=True)



Fixed submission:
N = int(input())
hist = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0 }
for i in range(N):
  tc = input()
  hist[tc] += 1

for k in ['AC', 'WA', 'TLE', 'RE']:
  print(f'{k} x {hist[k]}', flush=True)
Buggy python submission (verdict: Runtime Error):
N, K = (int(i) for i in input().split())
p = [input().split()]

sp = sorted(p)
print(sum(sp[:K]))


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

sp = sorted(p)
print(sum(sp[:K]))
Buggy python submission (verdict: Time Limit Exceeded):
def combine(a, j):
    # combine by xor all elements of a except a[j]
    x = 0
    n = len(a)
    for i in range(n):
        if i != j:
            x ^= a[i]
    return x

def main():
    N = int(input())
    a = [int(i) for i in input().split()]

    print(' '.join(str(combine(a, j)) for j in range(N)))


main()


Fixed submission:
def main():
    N = int(input())
    a = [int(i) for i in input().split()]
    x = 0
    for i in range(N):
        x ^= a[i]

    x ^= a[0]
    xors = [x]
    for i in range(1, N):
        x ^= a[i-1]
        x ^= a[i]
        xors.append(x)

    print(' '.join(str(x) for x in xors))


main()
Buggy python submission (verdict: Runtime Error):
def main():
    na, nl = (int(i) for i in input().split())
    nc = (4*na - nl) / 2

    pos = nc == int(nc) and nc >= 0 and nc <= x

    if pos:
        print('Yes')
    else:
        print('No')
      
main()


Fixed submission:
def main():
    na, nl = (int(i) for i in input().split())
    nc = (4*na - nl) / 2

    pos = (nc == int(nc) and nc >= 0 and nc <= na)

    if pos:
        print('Yes')
    else:
        print('No')
      
main()

Buggy python submission (verdict: Runtime Error):
x, y = (int(i) for in in input().split())

pos = (4*x - y) // 2 >= 0

if pos:
  print('Yes')
else:
  print('No')
  

Fixed submission:
def main():
    na, nl = (int(i) for i in input().split())
    nc = (4*na - nl) / 2

    pos = (nc == int(nc) and nc >= 0 and nc <= na)

    if pos:
        print('Yes')
    else:
        print('No')
      
main()
Buggy python submission (verdict: Runtime Error):
def main():
    x, n = (int(i) for i in input().split())
    if n > 0:
        p = [int(i) for i in input().split()]
    else:
        p = []

    mask = [0] * 101 
    for pe in p:
        mask[pe] = 1

    b, e = x, x
    while True:
        if mask[b] == 0 or mask[e] == 0:
            break
        b -= 1
        e += 1

    if mask[b] == 0:
        print(b)
    else:
        print(e)



main()


Fixed submission:
def main():
    # x in [1, 100]
    # n in [0, 100]
    # p_i in [1, 100] 
    x, n = (int(i) for i in input().split())
    if n > 0:
        p = set(int(i) for i in input().split())
    else:
        p = set() 

    b, e = x, x
    while b in p and e in p:
        b -= 1
        e += 1

    if b not in p:
        print(b)
    else:
        print(e)


main()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ary = [int(i) for i in input().split()]

pr = 1
for i in range(n):
  pr *= ary[i]

if pr > 10**18:
  print('-1')
else:
  print(pr)

Fixed submission:
def main():
    n = int(input())
    ary = [int(i) for i in input().split()]
    ary = sorted(ary)

    from math import log2
    lt = log2(10**18)

    if ary[0] == 0:
        print(0)
        return
      
    if any(log2(ary[i]) > lt / (n-i) for i in range(n)):
        print('-1')

    else:
        prod = 1
        for i in range(n):
            prod *= ary[i]
        if prod > 10**18:
            print(-1)
        else:
            print(prod)

main()
Buggy python submission (verdict: Runtime Error):
from decimal import Decimal

def main():
    a, b = input().split()
    v = int((Decimal(a) * Decimal(b))
    print(v)

main()

Fixed submission:
def main():
    astr, bstr = input().split()
    a = int(astr)
    b = int(''.join(c for c in bstr if c != '.'))
    trunc = (a * b) // 100
    print(trunc)


main()
Buggy python submission (verdict: Runtime Error):
k = int(input())
a, b = (int(i) for i in input().split())

for i in range(a, b+1):
  if i % k == 0:
    print('OK')
    return

print('NG')

Fixed submission:
def main():
    k = int(input())
    a, b = (int(i) for i in input().split())

    for i in range(a, b+1):
        if i % k == 0:
          print('OK')
          return

    print('NG')


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

def main():
    x = int(input())
    y = 0
    p = Decimal(100)
    while p < x:
        p *= Decimal(1.01)
        p = math.floor(p) 
        y += 1

    print(y)

main()


Fixed submission:
from decimal import Decimal
import math

def main():
    x = Decimal(input())
    y = 0
    p = Decimal(100)
    gr = Decimal('1.01')
    while p < x:
        p *= gr 
        p = math.floor(p) 
        y += 1

    print(y)

main()