Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from scipy.misc import comb
N=int(input())
A=list(map(int,input().split()))
nset=set([])
ndict={}
for a in A:
  if a in nset:
    ndict[a]+=1
  else:
    nset.add(a)
    ndict[a]=1
#print(nset,ndict)
all=0
for n in nset:
  tmp=ndict[n]
  if tmp>=2:
    all+=comb(tmp,2,exact=True)
all=int(all)
for a in A:
  tmp=ndict[a]
  if tmp==1:
    print(all)
  elif tmp==2:
    print(all-1)
  else:
    print( all-comb(tmp,2,exact=True)+comb(tmp-1,2,exact=True) )


Fixed submission:
from scipy.misc import comb
N=int(input())
A=list(map(int,input().split()))
nset=set([])
ndict={}
for a in A:
  if a in nset:
    ndict[a]+=1
  else:
    nset.add(a)
    ndict[a]=1
#print(nset,ndict)
all=0
for n in nset:
  tmp=ndict[n]
  if tmp>=2:
    all+=comb(tmp,2,exact=True)
all=int(all)
for a in A:
  tmp=ndict[a]
  if tmp==1:
    print(all)
  elif tmp==2:
    print(all-1)
  else:
    print( all-comb(tmp,2,exact=True)+comb(tmp-1,2,exact=True) )
Buggy python submission (verdict: Time Limit Exceeded):
S=input()
Q=input()
#rev -1:False 0:True
rev=-1
for i in range(int(Q)):
  tmp=input().split()
  if tmp[0]=='1':
    rev = abs(rev)-1
  else:
    if rev+int(tmp[1])==1:
      S = S + tmp[2]
    else:
      S = tmp[2] + S
if rev==-1:
  print(S)
else:
  print(S[::-1])

Fixed submission:
S=input()
Q=input()
#rev -1:False 0:True
L=''
R=''
rev=-1
for i in range(int(Q)):
  tmp=input().split()
  if tmp[0]=='1':
    rev = abs(rev)-1
  else:
    if rev+int(tmp[1])==1:
      R = R + tmp[2]
    else:
      L = L + tmp[2]
if rev==-1:
  print(L[::-1]+S+R)
else:
  print(R[::-1]+S[::-1]+L)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*N
dp[0]=0
dp[1]=abs(h[0]-h[1])
for i in range(2,N):
  dp[i] = min( dp[j] + abs(h[i]-h[j]) for j in range(max(0,i-K),i) )
print(dp[-1])

Fixed submission:
N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*N
dp[0]=0
dp[1]=abs(h[0]-h[1])
for i in range(2,N):
  dp[i] = min( dp[j] + abs(h[i]-h[j]) for j in range(max(0,i-K),i) )
print(dp[-1])

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

if K>N: K=N
cost=[0]

for i in range(K-1):
  i+=1
  tmp=[]
  for j in range(i):
    j+=1
    tmp.append(cost[i-j]+abs(H[i]-H[i-j]))
  cost.append(min(tmp))

for i in range(N-K):
  i+=K
  tmp=[]
  for j in range(K):
    j+=1
    #print(i-j,len(cost))
    tmp.append(cost[i-j]+abs(H[i]-H[i-j]))
  cost.append(min(tmp))

print(cost[-1])

Fixed submission:
N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*N
dp[0]=0
dp[1]=abs(h[0]-h[1])
for i in range(2,N):
  dp[i] = min( dp[j] + abs(h[i]-h[j]) for j in range(max(0,i-K),i) )
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,W=map(int,input().split())
dp=[ [0]*(W+1) for i in range(N+1) ]
#print(dp)
Wl=[]
Vl=[]
for i in range(N):
  w,v=map(int,input().split())
  Wl.append(w)
  Vl.append(v)

for i in range(1,N+1):
  for w in range(W+1):
    #print(i,w)
    if w>=Wl[i-1]:
      dp[i][w]=max(dp[i-1][w-Wl[i-1]]+Vl[i-1],dp[i-1][w])
    else:
      dp[i][w]=dp[i-1][w]
print(dp[-1][-1])

Fixed submission:
N,W=map(int,input().split())
dp=[ [0]*(W+1) for i in range(N+1) ]
#print(dp)
Wl=[]
Vl=[]
for i in range(N):
  w,v=map(int,input().split())
  Wl.append(w)
  Vl.append(v)

for i in range(1,N+1):
  for w in range(W+1):
    #print(i,w)
    if w>=Wl[i-1]:
      dp[i][w]=max(dp[i-1][w-Wl[i-1]]+Vl[i-1],dp[i-1][w])
    else:
      dp[i][w]=dp[i-1][w]
print(dp[-1][-1])
Buggy python submission (verdict: Time Limit Exceeded):
S=input()
T=input()
dp=[ [0]*(len(T)+1) for i in range(len(S)+1) ]
for i in range(len(S)):
  for j in range(len(T)):
    if S[i]==T[j]:
      dp[i+1][j+1]=dp[i][j]+1
    else:
      dp[i+1][j+1]=max( dp[i+1][j], dp[i][j+1] )

i=len(S)
j=len(T)
ans=''
while(i>0 and j>0):
  if dp[i][j]==dp[i-1][j]:
    i-=1
  elif dp[i][j]==dp[i][j-1]:
    j-=1
  else:
    ans=S[i-1]+ans
    i-=1
    j-=1
print(ans)

Fixed submission:
S=input()
T=input()
dp=[ [0]*(len(T)+1) for i in range(len(S)+1) ]
for i in range(len(S)):
  for j in range(len(T)):
    if S[i]==T[j]:
      dp[i+1][j+1]=dp[i][j]+1
    else:
      dp[i+1][j+1]=max( dp[i+1][j], dp[i][j+1] )

i=len(S)
j=len(T)
ans=''
while(i>0 and j>0):
  if dp[i][j]==dp[i-1][j]:
    i-=1
  elif dp[i][j]==dp[i][j-1]:
    j-=1
  else:
    ans=S[i-1]+ans
    i-=1
    j-=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
h,w,d=map(int,input().split())
a=[ [ [] for j in range(int(h*w/d+1)) ] for i in range(d) ]

for i in range(h):
  i+=1
  tmp=list(map(int,input().split()))
  for j in range(w):
    num=tmp[j]
    j+=1
    a[num%d][int( (num-1)/d)]=[i,j]

q=int(input())
for i in range(q):
  l,r=map(int,input().split())
  ans=0
  x=-1
  y=-1
  for j in a[l%d][int((l-1)/d):int((r-1)/d)+1]:
    if x==-1:
      x,y=j[0],j[1]
    else:
      ans+=abs(x-j[0])+abs(y-j[1])
      x,y=j[0],j[1]
  print(ans)

Fixed submission:
h,w,d=map(int,input().split())
a=[ [ [] for j in range(int(h*w/d+1)) ] for i in range(d) ]
a1=[ [ [] for j in range(int(h*w/d+1)) ] for i in range(d) ]
for i in range(h):
  i+=1
  tmp=list(map(int,input().split()))
  for j in range(w):
    num=tmp[j]
    j+=1
    a[num%d][int( (num-1)/d)]=[i,j]
for i in range(len(a)):
  a1[i][0]=0
  for j in range(len(a[i])-1):
    j=j+1
    if a[i][j]!=[]:
      a1[i][j]=a1[i][j-1]+abs(a[i][j][0]-a[i][j-1][0])+abs(a[i][j][1]-a[i][j-1][1])

q=int(input())
for i in range(q):
  l,r=map(int,input().split())
  print(a1[l%d][int((r-1)/d)]-a1[l%d][int((l-1)/d)])
Buggy python submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
res=0
for i in range(len(a)):
  res+=a-b
if res<=0:
  print('Yes')
else:
  print('No')

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
res=0
for i in range(len(a)):
  tmp=a[i]-b[i]
  if tmp<0:
    tmp+=tmp%2
    tmp=tmp/2
  res+=tmp
if res>0:
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Runtime Error):
N,M=input().split(' ')
dict={}
for i in range(int(M)):
  a,b=input().split(' ')
  a=int(a)
  b=int(b)
  if a not in dict:
    dict[a]=0
  dict[a]+=1
  if b not in dict:
    dict[b]=0
  dict[b]+=1
for i in range(int(N)):
  print(dict[i+1])

Fixed submission:
N,M=input().split(' ')
dict={}
for i in range(int(N)):
  dict[i+1]=0
for i in range(int(M)):
  a,b=input().split(' ')
  a=int(a)
  b=int(b)
  dict[a]+=1
  dict[b]+=1
for i in range(int(N)):
  print(dict[i+1])
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

import numpy as np

def main():
    n = int(input())
    l = list(map(int,input().split()))
    pro=1
    for num in l:
        pro = pro*num
    if pro > 10**18:
        print(-1)
    else:
        print(pro)

if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/env python3

import numpy as np

def main():
    n = int(input())
    l = list(map(int,input().split()))
    if 0 in l:
        print(0)
        exit()
    pro=1
    for num in l:
        pro = pro*num
        if pro > 10**18:
            print(-1)
            exit()
    else:
        print(pro)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
a=input().split(' ')
X=int(a[0])
N=int(a[1])

if N!=0:
  Ls=input().split(' ')
  L=[]
  for i in range(N):
    L.append(int(Ls[i]))
  for i in range (N):
    if X-i in L and X+i in L:
      pass
    elif X-i not in L:
      s=X-i
      break
    elif X-i in L and X+i not in L:
      s=X+i
      break
else:
  s=X


print(s)

Fixed submission:
a=input().split(' ')
X=int(a[0])
N=int(a[1])

if N!=0:
  Ls=input().split(' ')
  L=[]
  for i in range(N):
    L.append(int(Ls[i]))
  for i in range (N+1):
    if X-i in L and X+i in L:
      pass
    elif X-i not in L:
      s=X-i
      break
    elif X-i in L and X+i not in L:
      s=X+i
      break
else:
  s=X


print(s)

Buggy python submission (verdict: Runtime Error):
a=input().split(' ')
X=int(a[0])
N=int(a[1])

if N!=0:
  Ls=input().split(' ')
  L=[]
  for i in range(N):
    L.append(int(Ls[i]))
else:
  s=X

for i in range (N):
  if X-i in L and X+i in L:
    pass
  elif X-i not in L:
    s=X-i
    break
  elif X-i in L and X+i not in L:
    s=X+i
    break
print(s)

Fixed submission:
a=input().split(' ')
X=int(a[0])
N=int(a[1])

if N!=0:
  Ls=input().split(' ')
  L=[]
  for i in range(N):
    L.append(int(Ls[i]))
  for i in range (N+1):
    if X-i in L and X+i in L:
      pass
    elif X-i not in L:
      s=X-i
      break
    elif X-i in L and X+i not in L:
      s=X+i
      break
else:
  s=X


print(s)

Buggy python submission (verdict: Runtime Error):
a=input().split(' ')
X=int(a[0])
N=int(a[1])

if N!=0:
  Ls=input().split(' ')
  L=[]
  for i in range(N):
    L.append(int(Ls[i]))
else:
  s=X

for i in range (N):
  if X-i in L and X+i in L:
    pass
  elif X-i not in L:
    s=X-i
    break
  elif X-i in L and X+i not in L:
    s=X+i
    break
print(s)

Fixed submission:
a=input().split(' ')
X=int(a[0])
N=int(a[1])

if N!=0:
  Ls=input().split(' ')
  L=[]
  for i in range(N):
    L.append(int(Ls[i]))
  for i in range (N+1):
    if X-i in L and X+i in L:
      pass
    elif X-i not in L:
      s=X-i
      break
    elif X-i in L and X+i not in L:
      s=X+i
      break
else:
  s=X


print(s)

Buggy python submission (verdict: Runtime Error):
a=input().split(' ')
X=int(a[0])
N=int(a[1])

if N!=0:
  Ls=input().split(' ')
  L=[]
  for i in range(N):
    L.append(int(Ls[i]))
else:
  s=X

for i in range (N):
  if X-i in L and X+i in L:
    pass
  elif X-i not in L:
    s=X-i
    break
  elif X-i in L and X+i not in L:
    s=X+i
    break
print(s)
  

Fixed submission:
a=input().split(' ')
X=int(a[0])
N=int(a[1])

if N!=0:
  Ls=input().split(' ')
  L=[]
  for i in range(N):
    L.append(int(Ls[i]))
  for i in range (N+1):
    if X-i in L and X+i in L:
      pass
    elif X-i not in L:
      s=X-i
      break
    elif X-i in L and X+i not in L:
      s=X+i
      break
else:
  s=X


print(s)
Buggy python submission (verdict: Runtime Error):
W,H,N=map(int.input().split())
a,b,c,d=0,W,0,H

for i in range(N):
  x,y,A=map(int.input().split())
  if A==1:
    a=max(a,x)
  if A==2:
    b=min(b,x)
  if A==3:
    c=max(c,y)
  if A==4:
    d=min(d,y)
  
print(max(0,b-a)*max(0,d-c))

Fixed submission:
W,H,N=map(int,input().split())
a,b,c,d=0,W,0,H

for i in range(N):
  x,y,A=map(int,input().split())
  if A==1:
    a=max(a,x)
  if A==2:
    b=min(b,x)
  if A==3:
    c=max(c,y)
  if A==4:
    d=min(d,y)
  
print(max(0,b-a)*max(0,d-c))

Buggy python submission (verdict: Runtime Error):
W,H,N=map(int.input().split())
a,b,c,d=0,W,0,H

for i in range(N):
  x,y,A=map(int.input().split())
  if A==1: a=max(a,x)
  if A==2: b=min(b,x)
  if A==3: c=max(c,y)
  if A==4: d=min(d,y)
  
print(max(0,b-a)*max(0,d-c))

Fixed submission:
W,H,N=map(int,input().split())
a,b,c,d=0,W,0,H

for i in range(N):
  x,y,A=map(int,input().split())
  if A==1:
    a=max(a,x)
  if A==2:
    b=min(b,x)
  if A==3:
    c=max(c,y)
  if A==4:
    d=min(d,y)
  
print(max(0,b-a)*max(0,d-c))
Buggy python submission (verdict: Runtime Error):
A=input()
B=input()
C=input()

l='a'

for i in range(300):
  if l=='a':
    
    if len(A)==0:
      print('A')
      exit()
    elif len(A)==1:
      l=A[0]
      A=''
    else:
      l=A[0]
      A=A[1:]
  elif l=='b':
    l=B[0]
    if len(B)==0:
      print('B')
      exit()
    elif len(B)==1:
      l=B[0]
      B=''
    else:
      l=B[0]
      B=B[1:]
  else:
    l=C[0]
    if len(C)==0:
      print('C')
      exit()
    elif len(C)==1:
      l=C[0]
      C=''
    else:
      l=C[0]
      C=C[1:]    

Fixed submission:
A=input()
B=input()
C=input()

l='a'

for i in range(300):
  if l=='a':
    if len(A)==0:
      print('A')
      exit()
    elif len(A)==1:
      l=A[0]
      A=''
    else:
      l=A[0]
      A=A[1:]
  elif l=='b':
    if len(B)==0:
      print('B')
      exit()
    elif len(B)==1:
      l=B[0]
      B=''
    else:
      l=B[0]
      B=B[1:]
  else:
    if len(C)==0:
      print('C')
      exit()
    elif len(C)==1:
      l=C[0]
      C=''
    else:
      l=C[0]
      C=C[1:]
Buggy python submission (verdict: Runtime Error):
A, B = int(input().split())
print(A*B)

Fixed submission:
A, B = map(int, input().split())
print(A*B)
Buggy python submission (verdict: Runtime Error):
import sys
import heapq

def end(flag):
    if flag:
        print('Yes')
    else:
        print('No')
    exit(0) #プログラムを終了

n = int(input())
plus = []
minus = []
zero = []
total = 0
for i in range(n):
    s = input()[:-1] #入力の右端の値を除去
    cnt = 0
    M = 0
    m = 0
    for t in s:
        if t == ')': #前から探索
            cnt += 1
            M = max(M,cnt) #'('が多い場合はcnt=0,')'が多い場合はcntは'('と')'の個数の差
        else:
            cnt -= 1
    cnt = 0
    for t in s[::-1]: #後ろから探索
        if t == ')':
            cnt += 1
        else:
            cnt -= 1
            m = min(m,cnt) #')'が多い場合はcnt=0,'('が多い場合はcntは'('と')'の個数の差
    if cnt > 0:
        minus.append((-m,cnt))
    elif cnt == 0:
        zero.append((-m,M))
    else:
        plus.append((M,-cnt))
    S = (M,-cnt)
    total += cnt
if total != 0:
    end(0)
plus.sort()
minus.sort()
cnt = 0
for need,increase in plus:
    if cnt < need:
        end(0)
    else:
        cnt += increase
cnt = 0
for need,increase in minus:
    if cnt < need:
        end(0)
    else:
        cnt += increase
for m,M in zero:
    if m > cnt or M > cnt:
        end(0)
end(1)

Fixed submission:
S = input()
T = input()
length = len(S)
T2 = T[0:length]

if S == T2:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
n = 0
eq = True


for i in range(N):
    s = input()
    n += 1
    length = len(S)
    for i in range(length):
        if s == S[i]:
            eq = False
    if not eq:
        n -= 1
    S.append(s)

print(n)

Fixed submission:
N = int(input())

S = [input() for i in range(N)]
print(len(list(set(S))))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
n = 0
eq = True

for i in range(N):
    s = input()
    n += 1
    for i in range(len(S)):
        if s == S[i]:
            eq = False
    if not eq:
        n -= 1
    S.append(s)
print(n)

Fixed submission:
N = int(input())

S = [input() for i in range(N)]
print(len(list(set(S))))
Buggy python submission (verdict: Runtime Error):
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
s = (A - B) / (V - W)
if (V > W):
  if (s <= T and s >= -T):
    print("YES") 
else:
  print("NO")

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

if (V > W):
    if (-(V-W)*T <= A - B <= (V-W)*T):
        print("YES")
    else:
        print("NO")

else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
a, b, c, k = map(int, input().split())

if k <= a:
  print(k)
elif k <= a+b:
  print(a)
else:
  print(a - (k - (a + b))

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

if k <= a:
  print(k)
elif k <= a+b:
  print(a)
else:
  print(2*a - k + b)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int,input().split())
A = list(map(int, input().split()))

X = 0
for i in range(K):
  X = A[X]-1

print(X + 1)

Fixed submission:
N, K = map(int,input().split())
A = list(map(int, input().split()))
V = [-1]*N

X = 0
V[0] = 0
T = 0

while T < K:
  T += 1
  X = A[X]-1
  if V[X] != -1:
    t = T - V[X]
    k = (K - T) % t
    for i in range(k):
      X = A[X]-1
    break
  V[X] = T

print(X+1)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools as it

def xyz(a,b,c,k):
    if k==a:
        return(k)
    arr=[]
    for i in range(a):
        arr.append(1)
    for i in range(b):
        arr.append(0)
    for i in range(c):
        arr.append(-1)
    res=list(it.combinations(arr,k))
    re=[]
    for i in res:
        re.append(sum(i))
    return(max(re))


a,b,c,k=list(map(int,input().split()))
d=xyz(a,b,c,k)
print(d)

Fixed submission:
def xyz(a,b,c,k):
    if k==a:
        return(k)
    if a>k:
        return(k)
    sum1=a
    if a+b>=k:
        return(a)
    d=k-a-b
    sum1=sum1-d
    return(sum1)
    
    


a,b,c,k=list(map(int,input().split()))
d=xyz(a,b,c,k)
print(d)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools as it
a,b,c,k=list(map(int,input().split()))
arr=[]
for i in range(a):
    arr.append(1)
for i in range(b):
    arr.append(0)
for i in range(c):
    arr.append(-1)
res=list(it.combinations(arr,k))
re=[]
for i in res:
    re.append(sum(i))
print(max(re))

Fixed submission:
def xyz(a,b,c,k):
    if k==a:
        return(k)
    if a>k:
        return(k)
    sum1=a
    if a+b>=k:
        return(a)
    d=k-a-b
    sum1=sum1-d
    return(sum1)
    
    


a,b,c,k=list(map(int,input().split()))
d=xyz(a,b,c,k)
print(d)
Buggy python submission (verdict: Runtime Error):
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10 ** 7)
     
    # 遅延評価で加えてあげるだけ
     
    N,Q = map(int,input().split())
    AB = [[int(x) for x in input().split()] for _ in range(N-1)]
    PX = [[int(x) for x in input().split()] for _ in range(Q)]
     
    graph = [[] for _ in range(N+1)]
    for a,b in AB:
        graph[a].append(b)
        graph[b].append(a)
     
    value = [0] * (N+1)
    for p,x in PX:
        value[p] += x
     
    def dfs(v,parent,add):
        value[v] += add
        for x in graph[v]:
            if x == parent:
                continue
            dfs(x,v,value[v])
     
    dfs(1,0,0)
     
    answer = ' '.join(map(str,value[1:]))
    print(answer)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
    
# 遅延評価で加えてあげるだけ
    
N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
    
graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)
    
value = [0] * (N+1)
for p,x in PX:
    value[p] += x
    
def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])
    
dfs(1,0,0)
    
answer = ' '.join(map(str,value[1:]))
print(answer)
Buggy python submission (verdict: Runtime Error):
X, Y = map(int,input().split())

crain = (4 * X - Y) / 2
turtle = (Y - 2 * X) / 2

if (crain.is_integer() and crain >= 0) and ( turtle.is_integer() and turtle >= 0):n*2))
    print ("Yes")
else:
    print ("No")


Fixed submission:
X, Y = map(int,input().split())

crain = (4 * X - Y) / 2
turtle = (Y - 2 * X) / 2

if (crain.is_integer() and crain >= 0) and ( turtle.is_integer() and turtle >= 0):
    print ("Yes")
else:
    print ("No")
Buggy python submission (verdict: Runtime Error):
import random

i=input()
a=random.sample(i, 3)
print(a*)

Fixed submission:
str = input()
print(str[:3])
Buggy python submission (verdict: Runtime Error):
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

if A < B:
  if V <= W:
    print("NO")
  else:
    if b-a <= T * (V-W):
      print("YES")
    else:
      print("NO")
elif A > B:
  if V <= W:
    print("NO")
  else:
    if a - b <= t * (v - w):
      print('YES')
    else:
      print('NO')

Fixed submission:
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
 
if a < b:
    if v <= w:
        print('NO')
    else:
        if b - a <= t * (v - w):
            print('YES')
        else:
            print('NO')
elif a > b:
    if v <= w:
        print('NO')
    else:
        if a - b <= t * (v - w):
            print('YES')
        else:
            print('NO')
Buggy python submission (verdict: Runtime Error):
import functools
import operator

N = int(input())
A =[]
A = list(map(int,input().split()))

result = functools.reduce(operator.mul, A)

if result > 10^18:
  print("-1")
else:
  print(ANS)

Fixed submission:
def main():
	N = int(input())
	A = list(map(int, input().split()))
	if 0 in A:
		print(0)
		return
	prod = 1
	for a in A:
		prod *= a
		if prod > 1000000000000000000:
			print(-1)
			return
	print(prod)
main()
Buggy python submission (verdict: Runtime Error):
T=int(input())
N =[]

for i in range(T):
  x=0
  N = map(int,input().split())
  x += N[3]
  min = min(N)
if N[0] == 2:
	print(x + N[1])  
elif N[0] == 3:
      print(x + N[2])
elif N[0] == 5:
      print(x + N[3])
elif N[0] % min == 0:
      print(x + (min * ( N[0] / min)))
elif N[0] % min == 1:
      print(x + (min * ( N[0] / min) + N[3]))
        
      

Fixed submission:
T = int(input())
for i in range(T):
    n, A, B, C, D = map(int, input().split())
    memo = {}
 
    def herasu(N):
        if N == 0:
            return 0
        if N == 1:
            return D
        if N in memo:
            return memo[N]
        m = 100000000000000000000000
        if N % 2 == 0:
            m = min([m, A + herasu(N//2)])
        else:
            m = min([m, A + herasu(N//2) + D])
            m = min([m, A + herasu(N//2 + 1) + D])
        if N % 3 == 0:
            m = min(m, B + herasu(N//3))
        else:
            m = min([m, B + herasu(N//3) + (N%3) * D])
            m = min([m, B + herasu(N//3 + 1) + (3-(N%3)) * D])
        if N % 5 == 0:
            m = min(m, C + herasu(N // 5))
        else:
            m = min([m, C + herasu(N//5) + (N%5) * D])
            m = min([m, C + herasu(N//5 + 1) + (5-(N%5)) * D])
        m = min([m, D * N])
        memo[N] = m
        return m
 
    print(herasu(n))
Buggy python submission (verdict: Runtime Error):
sys.stdin=f

S=input()
T=input()

for i in range(len(S)):
    if S[i]==T[i]:
        continue
    else:
        print("No")
        sys.exit()

print("Yes")

Fixed submission:
import sys

S=input()
T=input()

for i in range(len(S)):
    if S[i]==T[i]:
        continue
    else:
        print("No")
        sys.exit()

print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
H=list(map(int,input().split()))
connect=[[0]*N for i in range(N)]

for i in range(M):
    A,B=map(int,input().split())
    connect[A-1][B-1]=H[B-1]
    connect[B-1][A-1]=H[A-1]

count=0
for i in range(N):
    if H[i]>max(connect[i]) or max(connect[i])==0:
        count+=1
# for i in range(N):
#     print(connect[i])
print(count)

Fixed submission:
N,M=map(int,input().split())
H=list(map(int,input().split()))
connect=[[] for i in range(N)]

for i in range(M):
    A,B=map(int,input().split())
    connect[A-1].append(H[B-1])
    connect[B-1].append(H[A-1])

count=0
for i in range(N):
    if not connect[i]:
        count+=1
    elif H[i]>max(connect[i]):
        count+=1
# for i in range(N):
#     print(connect[i])
print(count)
Buggy python submission (verdict: Runtime Error):
X=int(input())
for j in range(100):
    for i in range(100):
        if abs(pow(i,5)-X) == pow(j,5):
            if pow(i,5)-pow(j,5)==X:
                print(i,j)
                sys.exit()
            else:
                print(i,-j)
                sys.exit()

Fixed submission:
import sys
X=int(input())
for j in range(-118,120):
    for i in range(-118,120):
        if pow(i,5)-pow(j,5)==X:
            print(i,j)
            sys.exit()