Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n = int(input())
num = list(map(int, input().split()))
ans = 0
flg = 0
for i in range(n):
    if num[i] == 0:
        flg = 1;
        break
    
for i in range(n):
    if i == 0:
        ans = num[0]
    else:
        ans*=num[i]
    
    if ans > 10 ** 18 and flg ==0:
        print(-1)
        break
    

if ans <= 10 ** 18:
    print(ans)

Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
num = list(map(int, input().split()))
ans = 0
flg = 0
for i in range(n):
    if num[i] == 0:
        flg = 1;
        break
    
for i in range(n):
    if flg == 1:
        print(0)
        break
    elif i == 0:
        ans = num[0]
    else:
        ans*=num[i]
    
    if ans > 10 ** 18 and flg ==0:
        print(-1)
        break
    

if ans <= 10 ** 18 and flg == 0:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n = int(input())
num = list(map(int, input().split()))
ans = 0
for i in range(n):
    if i == 0:
        ans = num[0]
    else:
        ans*=num[i]

if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)

Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
num = list(map(int, input().split()))
ans = 0
flg = 0
for i in range(n):
    if num[i] == 0:
        flg = 1;
        break
    
for i in range(n):
    if flg == 1:
        print(0)
        break
    elif i == 0:
        ans = num[0]
    else:
        ans*=num[i]
    
    if ans > 10 ** 18 and flg ==0:
        print(-1)
        break
    

if ans <= 10 ** 18 and flg == 0:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
B=[]
C=[]
for i in range(Q):
  b,c=map(int,input().split())
  B.append(b)
  C.append(c)

for i in range(Q):
  ans = 0
  for j in range(len(A)):
    if A[j] == B[i]:
      A[j]=C[i]
      ans += A[j]
    else:
      ans += A[j] 
  print(ans)

Fixed submission:
import collections
n=int(input())
arr=list(map(int,input().split()))
cnt=collections.defaultdict(int)
for val in arr:#あらかじめ各Aiの個数を数えておく
  cnt[val]+=1
sums=sum(arr) #あらかじめAiの総和を求めておく
q=int(input())
for _ in range(q):
  b,c=map(int,input().split())
  diff=(c-b)*(cnt[b])
  sums+=diff
  print(sums)
  cnt[c]+=cnt[b]#CiがBiに変更されたので、Biの数をCiの数に加える
  cnt[b]=0 #Biの数はゼロになる。
Buggy python submission (verdict: Runtime Error):
X=int(input())
if 360%K==0:
  K=360//X
  print(K)
elif 360%K!=0:
  K=2*360//(180-X)
  print(K)

Fixed submission:
X=int(input())
if 360%X==0:
  K=360//X
  print(K)
elif 360%X!=0:
  i=1
  while True:
    if (X*i)%360==0:
      break
    i+=1
  print(i)
Buggy python submission (verdict: Runtime Error):
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())
if A < B and V <= W:
  print("NO")
elif B < A and W <= V:
  print("NO")
else:
  if A+V*i >= 0:
    if A+V*i >= B+W*i:
      print("YES")
    else:
      print("NO")
  elif A+V*i < 0:
    if abs(A+V*i) <= abs(B+W*i):
      print("YES")
    else:
      print("NO")

Fixed submission:
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

dist = abs(B-A)
r_vel = V - W

if r_vel * T >=dist:
  print("YES")
 
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())
flag = False
if A < B and V <= W:
  print("NO")
elif B < A and W <= V:
  print("NO")
else:
  if A+V*i > 0:
    if A+V*i >= B+W*i:
      print("YES")
    else:
      print("NO")
  elif A+V*i < 0:
    if abs(A+V*i) <= abs(B+W*i):
      print("YES")
    else:
      print("NO")

Fixed submission:
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

dist = abs(B-A)
r_vel = V - W

if r_vel * T >=dist:
  print("YES")
 
else:
  print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = 1
for i in A:
  ans *= i
if ans > 10**18:
  print("-1")
else:
  print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = 1
A.sort()
for i in A:
  ans *= i
  if i == 0:
    print(0)
    break
  if ans > 10**18:
    print("-1")
    break
if ans <= 10**18 and ans !=0:
  print(ans)
Buggy python submission (verdict: Runtime Error):
A,B,C,K = map(int,input().split())
res = 0
if A>=K:
  res= 1*A
else:
  for b in range(K-A,B+1):
    c = K-A-b
    ans = 1*A + 0*b + (-1)*c
    res = max(res,ans)
print(res)

Fixed submission:
S = input()
T = input()
flag = False
for i in "abcdefghijklmnopqrstuvwxyz":
  if T==S+i:
    print("Yes")
    flag = True
    break
if flag == False:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
for i in range(N):
  A.append(int(input()))

#num = [0]*(N+1)
#for i in range(N):
#num[i+1] = num[i] + A[i]

for j in range(N):
  result = A[:j]+A[j+1:]
  print(max(result))

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

left=[0]*(N+1)
right=[0]*(N+1)
for i in range(N):
  left[i+1]=max(left[i],A[i])
  right[N-1-i]=max(right[N-i],A[N-i-1])

ans=0
for i in range(N):
  ans=max(left[i],right[i+1])
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce
N = int(input())
A = list(map(int,input().split()))
#累積GCD
left = [0]
right = [0]
for i in range(N):
  left.append(fractions.gcd(left[i],A[i]))
  right.insert(0,fractions.gcd(right[0],A[N-1-i]))

ans = 0
for i in range(N):
  ans = max(ans,fractions.gcd(left[i],right[i + 1]))
print(ans)

Fixed submission:
import fractions
from functools import reduce
N = int(input())
A = list(map(int,input().split()))
#累積GCD
left = [0]*(N+1)
right = [0]*(N+1)
for i in range(N):
  left[i+1] = (fractions.gcd(left[i],A[i]))
  right[N-i-1] = (fractions.gcd(right[N-i],A[N-1-i]))

ans = 0
for i in range(N):
  ans = max(ans,fractions.gcd(left[i],right[i + 1]))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce
N = int(input())
A = list(map(int,input().split()))
result = [0]*N
tmp = 0
for i in range(N):
  tmp = A.pop(i)
  result[i] = reduce(fractions.gcd, A)
  A.insert(i,tmp)

print(max(result))

Fixed submission:
import fractions
from functools import reduce
N = int(input())
A = list(map(int,input().split()))
#累積GCD
left = [0]*(N+1)
right = [0]*(N+1)
for i in range(N):
  left[i+1] = (fractions.gcd(left[i],A[i]))
  right[N-i-1] = (fractions.gcd(right[N-i],A[N-1-i]))

ans = 0
for i in range(N):
  ans = max(ans,fractions.gcd(left[i],right[i + 1]))
print(ans)

Buggy python submission (verdict: Runtime Error):
import functools
import math
N = int(input())
A = list(map(int,input().split()))
result = [0]*N
tmp = 0
for i in range(N):
  tmp = A.pop(i)
  result[i] = functools.reduce(math.gcd, A)
  A.insert(i,tmp)

print(max(result))

Fixed submission:
import fractions
from functools import reduce
N = int(input())
A = list(map(int,input().split()))
#累積GCD
left = [0]*(N+1)
right = [0]*(N+1)
for i in range(N):
  left[i+1] = (fractions.gcd(left[i],A[i]))
  right[N-i-1] = (fractions.gcd(right[N-i],A[N-1-i]))

ans = 0
for i in range(N):
  ans = max(ans,fractions.gcd(left[i],right[i + 1]))
print(ans)

Buggy python submission (verdict: Runtime Error):
import functools
import math
N = int(input())
A = list(map(int,input().split()))
result = [0]*N
tmp = 0
for i in range(N):
  tmp = A.pop(i)
  result[i] = functools.reduce(math.gcd, A)
  A.insert(i,tmp)

print(max(result))

Fixed submission:
import fractions
from functools import reduce
N = int(input())
A = list(map(int,input().split()))
#累積GCD
left = [0]*(N+1)
right = [0]*(N+1)
for i in range(N):
  left[i+1] = (fractions.gcd(left[i],A[i]))
  right[N-i-1] = (fractions.gcd(right[N-i],A[N-1-i]))

ans = 0
for i in range(N):
  ans = max(ans,fractions.gcd(left[i],right[i + 1]))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,a = map(int,input().split())
x = list(map(int,input().split()))

#dp[j][k][s] = (x0...xj からk枚選んでxiの合計をsにするような選び方の総数)
dp = [[[0]*(a*n+1) for k in range(n+1) ] for j in range(n)]

dp[0][0][0] = 1
if x[0]<= a*n:
    dp[0][1][x[0]] = 1
    
for j in range(n-1):
    for k in range(n+1):
        for s in range(a*n+1):
            if k == 0 and s == 0:
                dp[j+1][k][s] = 1
            elif k>j+2:
                dp[j+1][k][s]=0
            elif s>=x[j+1] and k>= 1:
                dp[j+1][k][s]=dp[j][k][s] + dp[j][k-1][s-x[j+1]]
            else:
                dp[j+1][k][s]=dp[j][k][s]

res = 0
for i in range(1,n+1):
    res += dp[n-1][i][a*i]

print(res)

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

#dp[j][k][s] = (x0...xj からk枚選んでxiの合計をsにするような選び方の総数)
dp = [[[0]*(a*n+1) for k in range(n+1) ] for j in range(n)]

dp[0][0][0] = 1
if x[0]<= a*n:
    dp[0][1][x[0]] = 1
    
for j in range(n-1):
    for k in range(n+1):
        for s in range(a*n+1):
            if k == 0 and s == 0:
                dp[j+1][k][s] = 1
            elif k>j+2:
                dp[j+1][k][s]=0
            elif s>=x[j+1] and k>= 1:
                dp[j+1][k][s]=dp[j][k][s] + dp[j][k-1][s-x[j+1]]
            else:
                dp[j+1][k][s]=dp[j][k][s]

res = 0
for i in range(1,n+1):
    res += dp[n-1][i][a*i]

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

arr = input().split()
a = int(arr[0])
b = int(arr[1])
x = int(arr[2])
if b*a*a >= x:
    ans1 = 90-math.atan(a*a*a/(2.0*(b*a*a-x)))/math.acos(-1)*180
else:
    ans1 =0
ans2 = math.atan(a*b*b/2/x)/math.acos(-1)*180

if ans1 <= 45.0:
    print (ans1)
else:
    print (ans2)

Fixed submission:
import math 

arr = input().split()
a = int(arr[0])
b = int(arr[1])
x = int(arr[2])
if b*a*a > x:
    ans1 = 90-math.atan(a*a*a/(2.0*(b*a*a-x)))/math.acos(-1)*180
else:
    ans1 = 0.0
ans2 = math.atan(a*b*b/2/x)/math.acos(-1)*180

if a*a*b/2 <= x:
    print (ans1)
else:
    print (ans2)

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

arr = input().split()
a = int(arr[0])
b = int(arr[1])
x = int(arr[2])
ans1 = 90-math.atan(a*a*a/(2.0*(b*a*a-x)))/math.acos(-1)*180
ans2 = math.atan(a*b*b/2/x)/math.acos(-1)*180

if ans1 <= 45.0:
    print (ans1)
else:
    print (ans2)

Fixed submission:
import math 

arr = input().split()
a = int(arr[0])
b = int(arr[1])
x = int(arr[2])
if b*a*a > x:
    ans1 = 90-math.atan(a*a*a/(2.0*(b*a*a-x)))/math.acos(-1)*180
else:
    ans1 = 0.0
ans2 = math.atan(a*b*b/2/x)/math.acos(-1)*180

if a*a*b/2 <= x:
    print (ans1)
else:
    print (ans2)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math

sys.setrecursionlimit(10**7)

n, s = map(int, input().split())
a = list(map(int, input().split()))
dp = [[0 for __ in range(n+1)] for _ in range(s+1)]
dp[0][0] = 1
index = [(0, 0)]
for i in range(n):
    _index = []
    for j, k in index:
        if j+a[i] <= s:
            dp[j+a[i]][k+1] += 1
            _index.append((j+a[i], k+1))
    index = index + _index

ans = 0
for i in range(n+1):
    if dp[s][i] != 0:
        ans += dp[s][i]*2**(n-i)
        ans %= 998244353
print(ans)

Fixed submission:
import sys
import math

sys.setrecursionlimit(10**7)

n, s = map(int, input().split())
a = list(map(int, input().split()))
dp = [0 for _ in range(s+1)]
dp[0] = 1
for i in range(n):
    _dp = [0 for _ in range(s+1)]
    for j in range(s+1):
        if j+a[i] <= s:
            _dp[j+a[i]] += dp[j]
            _dp[j+a[i]] %= 998244353
        _dp[j] += 2*dp[j]
        _dp[j] %= 998244353
    dp = _dp
print(dp[s])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

n, m, k = map(int, input().split())
f = [[] for _ in range(n)]
b = [[] for _ in range(n)]
for _ in range(m):
    a, _b = map(int, input().split())
    f[a-1].append(_b-1)
    f[_b-1].append(a-1)
for _ in range(k):
    a, _b = map(int, input().split())
    b[a-1].append(_b-1)
    b[_b-1].append(a-1)

for i in range(n):
    ans = 0
    checked = [False]*n
    checked[i] = True
    def search(node):
        global ans, checked
        if node != i and node not in f[i] and node not in b[i]:
            ans += 1
        for _node in f[node]:
            if not checked[_node]:
                checked[_node] = True
                search(_node)
        return
    search(i)
    print(ans, end=" " if i != n-1 else "\n")

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#初期化
#根なら-size,子なら親の頂点

n, m, k = map(int, input().split())
par = [-1]*n
f = [set() for _ in range(n)]
b = [set() for _ in range(n)]
for _ in range(m):
    a, _b = map(int, input().split())
    f[a-1].add(_b-1)
    f[_b-1].add(a-1)
    unite(a-1, _b-1)
for _ in range(k):
    a, _b = map(int, input().split())
    b[a-1].add(_b-1)
    b[_b-1].add(a-1)

for i in range(n):
    ans = size(i)-len(f[i])-1
    for node in b[i]-f[i]:
        if same(i, node):
            ans -= 1
    print(ans, end=" " if i!=n-1 else "\n")
Buggy python submission (verdict: Runtime Error):
def comb(n, k):
    ans = 1
    for i in range(k):
        ans *= (n-i)
    for i in range(k):
        ans //= (k-i)
    return ans

def count(n, k):
    if k == 0:
        return 1
    if int(n) == 0:
        return 0
    if n[0] == "0":
        return count(n[1:], k)
    return count(n[1:], k-1) + comb(len(n)-1, k)*9**(k) + (int(n[0])-1)*comb(len(n)-1, k-1)*9**(k-1)

n = input()
k = int(input())
print(count(n, k))

Fixed submission:
def comb(n, k):
    ans = 1
    for i in range(k):
        ans *= (n-i)
    for i in range(k):
        ans //= (k-i)
    return ans

def count(n, k):
    if len(n) < k:
        return 0
    if k == 0:
        return 1
    if int(n) == 0:
        return 0
    if n[0] == "0":
        return count(n[1:], k)
    return count(n[1:], k-1) + comb(len(n)-1, k)*9**(k) + (int(n[0])-1)*comb(len(n)-1, k-1)*9**(k-1)

n = input()
k = int(input())
print(count(n, k))
Buggy python submission (verdict: Time Limit Exceeded):
def comb(n, k):
    ans = 1
    for i in range(k):
        ans *= n-i
    for i in range(k):
        ans //= i+1
    return ans%(10**9+7)

def path(x, y):
    return comb(x+y+2, min(x+1, y+1))-1

r1, c1, r2, c2 = list(map(int, input().split()))
print((path(r2, c2)-path(r1-1, c2)-path(r2, c1-1)+path(r1-1, c1-1))%(10**9+7))

Fixed submission:
MOD = 10**9+7

fact = [1]*(2*10**6+10)
for i in range(1, len(fact)):
    fact[i] = (fact[i-1]*i)%MOD

def comb(n, k):
    return fact[n]*pow(fact[n-k], MOD-2, MOD)*pow(fact[k], MOD-2, MOD)

def path(x, y):
    return comb(x+y+2, min(x+1, y+1))-1

r1, c1, r2, c2 = list(map(int, input().split()))
print((path(r2, c2)-path(r1-1, c2)-path(r2, c1-1)+path(r1-1, c1-1))%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()[::-1]
mod = [i for i in range(10)]
dp = [[0]*13 for _ in range(len(S)+1)]
dp[0][0] = 1
for i in range(len(S)):
    for j in range(13):
        if S[i] == "?":
            for k in range(10):
                dp[i+1][(j+mod[k])%13] += (dp[i][j])%(10**9+7)
        else:
            dp[i+1][(j+mod[int(S[i])])%13] = (dp[i][j])%(10**9+7)
    mod = [(10*x)%13 for x in mod]
print(dp[-1][5]%(10**9+7))

Fixed submission:
S = input()[::-1]
mod = [i for i in range(10)]
dp = [[0]*13 for _ in range(len(S)+1)]
dp[0][0] = 1
for i in range(len(S)):
    for j in range(13):
        if S[i] == "?":
            for k in range(10):
                dp[i+1][(j+mod[k])%13] += (dp[i][j])%(10**9+7)
        else:
            dp[i+1][(j+mod[int(S[i])])%13] = (dp[i][j])%(10**9+7)
    mod = [(10*x)%13 for x in mod]
print(dp[-1][5]%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
c = list(map(int, input().split(" ")))

ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i]+b[j])
ab.sort(reverse=True)
ab = ab[:min(x*y, k)]
abc = []
for i in range(len(ab)):
    for j in range(z):
        abc.append(ab[i]+c[j])
abc.sort(reverse=True)
for i in range(k):
    print(abc[i])

Fixed submission:
x, y, z, k = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
c = list(map(int, input().split(" ")))

ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i]+b[j])
ab.sort(reverse=True)
ab = ab[:min(x*y, k)]
abc = []
for i in range(len(ab)):
    for j in range(z):
        abc.append(ab[i]+c[j])
abc.sort(reverse=True)
for i in range(k):
    print(abc[i])
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
n,k = map(int,input().split())
P = list(map(int,input().split()))

ans = float('inf')
for t in combinations(range(n),k):
    res = 0
    for i in range(k):
        res+=P[t[i]]
    ans = min(res,ans)
    
print(ans)

Fixed submission:
n,k = map(int,input().split())
P = list(map(int,input().split()))

P.sort()
ans = 0
for i in range(k):
    ans+=P[i]
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
A = list(map(int,input().split()))
q = int(input())
BC = [list(map(int,input().split())) for _ in range(q)]
A = np.array(A)
 
def main(A,BC):
    for bc in BC:
      A = np.where(A==bc[0],bc[1],A)
      print(sum(A))
        
if __name__ == '__main__':
    main(A,BC)

Fixed submission:
import numpy as np
from numba import njit

n = int(input())
A = list(map(int,input().split()))
q = int(input())
BC = [list(map(int,input().split())) for _ in range(q)]
A = np.array(A)

ans = sum(A)

#aの個数を管理するlist a_num
a_num = [0]*10**5
for  a in A:
    a_num[a-1]+=1

for bc in BC:
    change = bc[1]-bc[0]
    ans += change*a_num[bc[0]-1]
    a_num[bc[1]-1] += a_num[bc[0]-1]
    a_num[bc[0]-1] = 0
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
A = list(map(int,input().split()))
q = int(input())
BC = [list(map(int,input().split())) for _ in range(q)]
A = np.array(A)

for bc in BC:
    A = np.where(A==bc[0],bc[1],A)
    print(sum(A))

Fixed submission:
import numpy as np
from numba import njit

n = int(input())
A = list(map(int,input().split()))
q = int(input())
BC = [list(map(int,input().split())) for _ in range(q)]
A = np.array(A)

ans = sum(A)

#aの個数を管理するlist a_num
a_num = [0]*10**5
for  a in A:
    a_num[a-1]+=1

for bc in BC:
    change = bc[1]-bc[0]
    ans += change*a_num[bc[0]-1]
    a_num[bc[1]-1] += a_num[bc[0]-1]
    a_num[bc[0]-1] = 0
    print(ans)
Buggy python submission (verdict: Runtime Error):
x,n = map(int,input().split())
P = list(map(int,input().split()))


all_l = [i for i in range(1,101)]
for p in P:
    all_l.remove(p)

ans = []
c = 0
dic = {}
for a in all_l:
    if c == 0:
        diff = abs(x-a)
    c+=1
    diff_now = abs(x-a)
    diff = min(diff,diff_now)
    memo = diff_now
    if memo == diff:
        dic['{}'.format(str(a))] = diff
        
l = []
for k,v in  dic.items():
    l.append(v)
m = min(l)
k_list = []
for k,v in dic.items():
    if v==m:
        k_list.append(k)
print(int(max(k_list)))

Fixed submission:
x,n = map(int,input().split())
P = list(map(int,input().split()))


all_l = [i for i in range(0,101)]
for p in P:
    all_l.remove(p)

kouho = x
for i in range(200):
    kouho1 = x-i
    kouho2 = x+i
    if kouho1 not in P:
        print(x-i)
        break
    elif kouho2 not in P:
        print(x+i)
        break

Buggy python submission (verdict: Runtime Error):
x,n = map(int,input().split())
P = list(map(int,input().split()))


all_l = [i for i in range(1,101)]
for p in P:
    all_l.remove(p)

ans = []
c = 0
dic = {}
for a in all_l:
    if c == 0:
        diff = abs(x-a)
    c+=1
    diff_now = abs(x-a)
    diff = min(diff,diff_now)
    #print(diff,diff_now)
    memo = diff_now
    #print('memo:',memo,'diff:',diff)
    if memo == diff:
        dic['{}'.format(str(a))] = diff
        
        
l = []
for k,v in  dic.items():
    l.append(v)
m = min(l)
k_list = []
for k,v in dic.items():
    if v==m:
        k_list.append(k)
#print(k_list)
int(max(k_list))

Fixed submission:
x,n = map(int,input().split())
P = list(map(int,input().split()))


all_l = [i for i in range(0,101)]
for p in P:
    all_l.remove(p)

kouho = x
for i in range(200):
    kouho1 = x-i
    kouho2 = x+i
    if kouho1 not in P:
        print(x-i)
        break
    elif kouho2 not in P:
        print(x+i)
        break

Buggy python submission (verdict: Runtime Error):
x,n = map(int,input().split())
P = list(map(int,input().split()))


all_l = [i for i in range(1,101)]
for p in P:
    all_l.remove(p)

ans = []
c = 0
dic = {}
for a in all_l:
    if c == 0:
        diff = abs(x-a)
    c+=1
    diff_now = abs(x-a)
    diff = min(diff,diff_now)
    #print(diff,diff_now)
    memo = diff_now
    #print('memo:',memo,'diff:',diff)
    if memo == diff:
        dic['{}'.format(str(a))] = diff
        
        
l = []
for k,v in  dic.items():
    l.append(v)
m = min(l)
k_list = []
for k,v in dic.items():
    if v==m:
        k_list.append(k)
#print(k_list)
max(k_list)

Fixed submission:
x,n = map(int,input().split())
P = list(map(int,input().split()))


all_l = [i for i in range(0,101)]
for p in P:
    all_l.remove(p)

kouho = x
for i in range(200):
    kouho1 = x-i
    kouho2 = x+i
    if kouho1 not in P:
        print(x-i)
        break
    elif kouho2 not in P:
        print(x+i)
        break
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]

ans = 1
for i in range(n):
    
    ans *=a[i]
    
if ans >10**18:
    ans = -1
print(ans)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

ans = 1
for i in range(n):
    ans *=a[i]
    if ans>10**18:
        ans = -1
        break

if 0 in a:
    ans = 0
        
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
height = list(map(int,input().split()))
lower_list = []
for i in range(m):
    r = list(map(int,input().split()))
    if height[r[0]-1] > height[r[1]-1]:
        lower_list.append(r[1])
    elif height[r[0]-1] < height[r[1]-1]:
        lower_list.append(r[0],r[1])
    else:
        lower_list.append(r[0])
count = len(set(lower_list))
print(n-count)

Fixed submission:
n,m = map(int,input().split())
height = list(map(int,input().split()))
lower_list = []
for i in range(m):
    r = list(map(int,input().split()))
    if height[r[0]-1] > height[r[1]-1]:
        lower_list.append(r[1])
    elif height[r[0]-1] == height[r[1]-1]:
        lower_list.append(r[0])
        lower_list.append(r[1])
    else:
        lower_list.append(r[0])
count = len(set(lower_list))
print(n-count)

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
height = list(map(int,input().split()))
lower_list = []
for i in range(m):
    r = list(map(int,input().split()))
    if height[r[0]-1] > height[r[1]-1]:
        lower_list.append(r[1])
    elif:
        lower_list.append(r[0],r[1])
    else:
        lower_list.append(r[0])
count = len(set(lower_list))
print(n-count)

Fixed submission:
n,m = map(int,input().split())
height = list(map(int,input().split()))
lower_list = []
for i in range(m):
    r = list(map(int,input().split()))
    if height[r[0]-1] > height[r[1]-1]:
        lower_list.append(r[1])
    elif height[r[0]-1] == height[r[1]-1]:
        lower_list.append(r[0])
        lower_list.append(r[1])
    else:
        lower_list.append(r[0])
count = len(set(lower_list))
print(n-count)