Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=0
q=[(1+pp)/2 for pp in p]
for i in range(k,n+1):
    ans=max(ans,sum(q[i-k:i]))
print(ans)

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
ans=0
q=[0]
for  i in p:
    q.append((1+i)/2)
from itertools import accumulate
q=list(accumulate(q))
for i in range(k,n+1):
    ans=max(ans,q[i]-q[i-k])
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
p=list(map(int,input().split()))
q=[(1+pp)/2 for pp in p]
ans=0
c=[0]
for qq in q:
      c.append(c[-1]+qq)
ans=0

for qq in range(k,1+n):
  ans=max(ans,c[qq]-c[qq-k])

print(ans)


Fixed submission:
h,w=map(int,input().split())
s=[input() for _ in range(h)]
from collections import deque
ans=0
dd=[(1,0),(-1,0),(0,1),(0,-1)]
for i in range(h):
  for j in range(w):
    if  s[i][j]=="#":
          continue
    
    g=[[0]*w for _ in range(h)]
    v=[[0]*w for _ in range(h)]
    g[i][j]=1
    q=deque([(j,i)])
    while q:
      x,y=q.popleft()
      for dx,dy in dd:
        nx=x+dx
        ny=y+dy
        if not 0<=nx<w:
          continue
        if not 0<=ny<h:
          continue
        if g[ny][nx]:
          continue
        if s[ny][nx]=="#":
          continue
        g[ny][nx]=1
        v[ny][nx]=v[y][x]+1
        q.append((nx,ny))
    for ii in v:
      ans=max(ans,max(ii))

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**8)
N = int(input())
n=int(input())
c=[[] for _ in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  a-=1
  b-=1
  c[a].append((b,i))
  c[b].append((a,i))

ans=[0]*(n-1)
g=[0]*n
def dfs(v,h=-1):
  res=1
  for i,j in c[v]:
      if g[i]:
            continue
      g[v]=1
      if h==res:
            res+=1
      ans[j]=res
      dfs(i,res)
      res+=1

dfs(0)
print(max(ans))
for i in ans:
      print(i)


Fixed submission:
import sys
sys.setrecursionlimit(10**8)
N = int(input())
AB = [tuple(map(int,input().split())) for i in range(N-1)]
es = [[] for i in range(N)]
for i,(a,b) in enumerate(AB):
    a,b = a-1,b-1
    es[a].append((b,i))
    es[b].append((a,i))
ans=[0]*(N-1)
g=[0]*N
def dfs(v,h=-1):
  res=1
  for i,j in es[v]:
      if g[i]:
            continue
      g[v]=1
      if h==res:
            res+=1
      ans[j]=res
      dfs(i,res)
      res+=1

dfs(0)
print(max(ans))
for i in ans:
      print(i)

Buggy python submission (verdict: Runtime Error):
n=int(input())
c=[[] for _ in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  a-=1
  b-=1
  c[a].append((b,i))
  c[b].append((a,i))

ans=[0]*(n-1)
g=[0]*n
def dfs(v,h=-1):
  res=1
  for i,j in c[v]:
      if g[i]:
            continue
      g[v]=1
      if h==res:
            res+=1
      ans[j]=res
      dfs(i,res)
      res+=1

dfs(0)
print(max(ans))
for i in ans:
      print(i)


Fixed submission:
import sys
sys.setrecursionlimit(10**8)
N = int(input())
AB = [tuple(map(int,input().split())) for i in range(N-1)]
es = [[] for i in range(N)]
for i,(a,b) in enumerate(AB):
    a,b = a-1,b-1
    es[a].append((b,i))
    es[b].append((a,i))
ans=[0]*(N-1)
g=[0]*N
def dfs(v,h=-1):
  res=1
  for i,j in es[v]:
      if g[i]:
            continue
      g[v]=1
      if h==res:
            res+=1
      ans[j]=res
      dfs(i,res)
      res+=1

dfs(0)
print(max(ans))
for i in ans:
      print(i)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
l=len(s)
mod=10**9+7
dp=[[0]*13 for i in range(l)]
if s[0]=="?":
  dp[0]=[1]*10+[0]*3
else:
  dp[0][int(s[0])]=1
for i in range(1,l):
  if s[i]=="?":
    for j in range(10):
      for k in range(13):
          dp[i][(10*k+j)%13]+=dp[i-1][k]%mod
  else:
    for k in range(13):          
      dp[i][(int(s[i])+10*k)%13]+=dp[i-1][k]%mod

print(dp[-1][5]%mod)

Fixed submission:
s=input()
l=len(s)
mod=10**9+7
dp=[[0]*13 for i in range(l)]
if s[0]=="?":
  dp[0]=[1]*10+[0]*3
else:
  dp[0][int(s[0])]=1
for i in range(1,l):
  if s[i]=="?":
    for j in range(10):
      for k in range(13):
          dp[i][(10*k+j)%13]+=dp[i-1][k]%mod
  else:
    for k in range(13):          
      dp[i][(int(s[i])+10*k)%13]+=dp[i-1][k]%mod

print(dp[-1][5]%mod)
Buggy python submission (verdict: Runtime Error):
from scipy.misc import comb
n, k = map(int, input().split())
for i in range(1, k+1):
	print( comb(k-1, i-1, exact=True)*comb(n-k+1, i, exact=True)%(10**9+7) )


Fixed submission:
from scipy.misc import comb
n, k = map(int, input().split())
for i in range(1, k+1):
	print( comb(k-1, i-1, exact=True)*comb(n-k+1, i, exact=True)%(10**9+7) )
Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
def k(n):
    aa=n//c
    bb=n//d
    f=n//((c*d)//math.gcd(c,d))
    return n-aa-bb+f
print(k(b)-k(a-1))

Fixed submission:
from fractions import gcd
A,B,C,D = map(int,input().split())
def f(n):
    x = n//C
    y = n//D
    z = n//(C*D//gcd(C,D))
    return n - x - y + z

print(f(B) - f(A-1))

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
def k(n):
    aa=n//c
    bb=n//d
    f=n//((c*d)//math.gcd(c,d))
    return n-aa-bb+f
print(k(b)-k(a-1))

Fixed submission:
from fractions import gcd
A,B,C,D = map(int,input().split())
def f(n):
    x = n//C
    y = n//D
    z = n//(C*D//gcd(C,D))
    return n - x - y + z

print(f(B) - f(A-1))

Buggy python submission (verdict: Runtime Error):
from  math import gcd
import math
a,b,c,d=map(int,input().split())
def k(n):
    aa=n//c
    bb=n//d
    f=n//((c*d)//math.gcd(c,d))
    return n-aa-bb+f
print(k(b)-k(a-1))

Fixed submission:
from fractions import gcd
A,B,C,D = map(int,input().split())
def f(n):
    x = n//C
    y = n//D
    z = n//(C*D//gcd(C,D))
    return n - x - y + z

print(f(B) - f(A-1))
Buggy python submission (verdict: Runtime Error):
ans=10**10
n=int(input())
w=list(map(int,input().split()))
for i in range(1,n):
    ans=min(ans,abs(sum(w[:i])-sum(w[i:])))

print(ans)AC

Fixed submission:
ans=10**10
n=int(input())
w=list(map(int,input().split()))
for i in range(1,n):
    ans=min(ans,abs(sum(w[:i])-sum(w[i:])))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
S = [input() for i in range(H)]

rs = [[0]*W for i in range(H)]
ls = [[0]*W for i in range(H)]
ds = [[0]*W for i in range(H)]
us = [[0]*W for i in range(H)]

for i in range(H):
    tmp = 0
    for j in range(W):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            rs[i][j] = tmp
    tmp = 0
    for j in reversed(range(W)):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            ls[i][j] = tmp

for j in range(W):
    tmp = 0
    for i in range(H):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            ds[i][j] = tmp
    tmp = 0
    for i in reversed(range(H)):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            us[i][j] = tmp

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#': continue
        tmp = rs[i][j] + ls[i][j] + ds[i][j] + us[i][j] - 3
        ans = max(ans, tmp)
print(ans)


Fixed submission:
H,W = map(int,input().split())
S = [input() for i in range(H)]

rs = [[0]*W for i in range(H)]
ls = [[0]*W for i in range(H)]
ds = [[0]*W for i in range(H)]
us = [[0]*W for i in range(H)]

for i in range(H):
    tmp = 0
    for j in range(W):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            rs[i][j] = tmp
    tmp = 0
    for j in reversed(range(W)):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            ls[i][j] = tmp

for j in range(W):
    tmp = 0
    for i in range(H):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            ds[i][j] = tmp
    tmp = 0
    for i in reversed(range(H)):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            us[i][j] = tmp

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#': continue
        tmp = rs[i][j] + ls[i][j] + ds[i][j] + us[i][j] - 3
        ans = max(ans, tmp)
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
l=[0]
r=[0]
ans=0
from  math import gcd
for i in range(n-1):
    l.append(gcd(l[i],a[i]))
    r.append(gcd(r[i],a[-1-i]))
for i in range(n):
    ans=max(ans,gcd(l[i],r[-1-i]))

print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
l=[0]
r=[0]
ans=0
from  fractions import gcd
for i in range(n-1):
    l.append(gcd(l[i],a[i]))
    r.append(gcd(r[i],a[-1-i]))
for i in range(n):
    ans=max(ans,gcd(l[i],r[-1-i]))

print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
l=[0]
r=[0]
ans=0
from  math import gcd
for i in range(n-1):
    l.append(gcd(l[i],a[i]))
    r.append(gcd(r[i],a[-1]-i))
for i in range(n):
    ans=max(ans,gcd(l[i],r[-1-i]))

print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
l=[0]
r=[0]
ans=0
from  fractions import gcd
for i in range(n-1):
    l.append(gcd(l[i],a[i]))
    r.append(gcd(r[i],a[-1-i]))
for i in range(n):
    ans=max(ans,gcd(l[i],r[-1-i]))

print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
for i in range(n-1):
    if s[i]=="0" and i%2==0:
        ans+=1
    elif s[i]=="1" and i%2==1:
        ans+=1
ans1=0
for i in range(n-1):
    if s[i]=="1" and i%2==0:
        ans1+=1
    elif s[i]=="0" and i%2==1:
        ans1+=1

print(min(ans,ans1))A

Fixed submission:
s=input()
n=len(s)
ans=0
for i in range(n):
    if s[i]=="0" and i%2==0:
        ans+=1
    elif s[i]=="1" and i%2==1:
        ans+=1
ans1=0
for i in range(n):
    if s[i]=="1" and i%2==0:
        ans1+=1
    elif s[i]=="0" and i%2==1:
        ans1+=1

print(min(ans,ans1))
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import nlargest
x,y,z,k=map(int,input().split())
A,B,C=[list(map(int,input().split()))for _ in[0]*3]
E=nlargest(k,(a+b+c for a in A for b in B for c in C))
for i in E:
    print(i)


Fixed submission:
from heapq import nlargest
x,y,z,k=map(int,input().split())
A,B,C=[list(map(int,input().split()))for _ in[0]*3]
D=nlargest(k,(a+b for a in A for b in B ))
E=nlargest(k,(d+c for c in C for d in D ))
for i in E:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
from heapq import nlargest
x,y,z,k=map(int,input().split())
A,B,C=[list(map(int,input().split()))for _ in[0]*3]
E=nlargest(k,(a+b+c for a in A for b in B for c in C))
for i in E:
    print(i)


Fixed submission:
from heapq import nlargest
x,y,z,k=map(int,input().split())
A,B,C=[list(map(int,input().split()))for _ in[0]*3]
D=nlargest(k,(a+b for a in A for b in B ))
E=nlargest(k,(d+c for c in C for d in D ))
for i in E:
    print(i)
Buggy python submission (verdict: Runtime Error):
n=int(input())
from collections import Counter
v=list(map(int,input().split()))
from collections import Counter
a=Counter(v[0::2]).most_common()
b=Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
if a[0][0]!=b[0][0]:
    print(n-(a[0][1]+b[0][1]))
else:
    print(min(n-(b[0][1]+a[1][1],n-(a[0][1]+b[1][1])))

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

a = Counter(v[0::2]).most_common()
b = Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
if a[0][0] != b[0][0]:
    print(n - (a[0][1] + b[0][1]))
else:
    print(min(n-(a[1][1]+b[0][1]), n-(a[0][1]+b[1][1])))

Buggy python submission (verdict: Runtime Error):
n=int(input())
v=list(map(int,input().split()))
from collections import Counter
a=Counter(v[0::2]).most_common()
b=Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
if a[0][0]!=b[0][0]:
    print(n-(a[0][1]+b[0][1]))
else:
    print(min(n-(b[0][1]+a[1][1],n-(a[0][1]+b[1][1])))

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

a = Counter(v[0::2]).most_common()
b = Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])
if a[0][0] != b[0][0]:
    print(n - (a[0][1] + b[0][1]))
else:
    print(min(n-(a[1][1]+b[0][1]), n-(a[0][1]+b[1][1])))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=0
j=0
b=0
for  i in range(n):
    while j<n and b^a[j]==b+a[jl:
        b^=a[j]
        j+=1
    ans+=j-i    
    b^=a[i]
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
j=0
b=0
for  i in range(n):
    while j<n and b^a[j]==b+a[j]:
        b^=a[j]
        j+=1
    ans+=j-i    
    b^=a[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
ans=0
j=0
b=0
for  i in range(n):
    while j<n and b^a[j]==sum(a[i:j+1]):
        b^=a[j]
        j+=1
    ans+=j-i    
    b^=a[i]
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
j=0
b=0
for  i in range(n):
    while j<n and b^a[j]==b+a[j]:
        b^=a[j]
        j+=1
    ans+=j-i    
    b^=a[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
m=a[-1]
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]
d={}
for i in range(n-1):
    d[i]=cmb(m,a[i])
print(a[-1],a[max(d,key=d.get)])

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[10**10]
a.sort(reverse=True)
c=a[0]
e=c//2
for i in range(1,n):
    b.append(abs(a[i]-e))
d=a[b.index(min(b))]
print(c,d)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=[False]*n
g=[[] for _ in [0]*n]
for _ in range(m):
    l,r,d=map(int,input().split())
    g[l-1].append((r-1,d))
    g[r-1].append((l-1,-d))
for i in range(n):
    if not(a[i]):
        a[i]=0
        q=[i]
    while q:
        j=q.pop()
        for x,e in g[j]:
            if not(a[x]):
                a[x]=a[j]+e
                q.append(x)
            elif a[x]!=a[j]+e:
                print("No")
                exit()
                
print("Yes")


Fixed submission:
n,m=map(int,input().split())
a=[None]*n
g=[[] for _ in range(n)]
for _ in range(m):
    l,r,d=map(int,input().split())
    g[l-1].append((r-1,d))
    g[r-1].append((l-1,-d))
for i in range(n):
    if a[i]==None:
        a[i]=0
        q=[i]
    while q:
        j=q.pop()
        for x,e in g[j]:
            if a[x]==None:
                a[x]=a[j]+e
                q.append(x)
            elif a[x]!=a[j]+e:
                print("No")
                exit()
                
print("Yes")

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=[False]*n
g=[[] for _ in [0]*n]
for _ in range(m):
    l,r,d=map(int,input().split())
    g[l-1].append((r-1,d))
    g[r-1].append((l-1,-d))
for i in range(n):
    if not(a[i]):
        a[i]=0
        q=[i]
    while q:
        j=q.pop()
        for x,e in g[j]:
            if not(a[x]):
                a[x]=a[j]+e
                q.append(x)
            elif a[x]!=a[j]+e:
                print("No")
                exit()
                
print("Yes")

Fixed submission:
n,m=map(int,input().split())
a=[None]*n
g=[[] for _ in range(n)]
for _ in range(m):
    l,r,d=map(int,input().split())
    g[l-1].append((r-1,d))
    g[r-1].append((l-1,-d))
for i in range(n):
    if a[i]==None:
        a[i]=0
        q=[i]
    while q:
        j=q.pop()
        for x,e in g[j]:
            if a[x]==None:
                a[x]=a[j]+e
                q.append(x)
            elif a[x]!=a[j]+e:
                print("No")
                exit()
                
print("Yes")

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=[False]*n
g=[[] for _ in range(n)]
for _ in range(m):
    l,r,d=map(int,input().split())
    g[l-1].append((r-1,d))
    g[r-1].append((l-1,-d))
for i in range(n):
    if not(a[i]):
        a[i]=0
        q=[i]
    while q:
        j=q.pop()
        for x,e in g[j]:
            if not(a[x]):
                a[x]=a[j]+e
                q.append(x)
            elif a[x]!=a[j]+e:
                print("No")
                exit()
                
print("Yes")

Fixed submission:
n,m=map(int,input().split())
a=[None]*n
g=[[] for _ in range(n)]
for _ in range(m):
    l,r,d=map(int,input().split())
    g[l-1].append((r-1,d))
    g[r-1].append((l-1,-d))
for i in range(n):
    if a[i]==None:
        a[i]=0
        q=[i]
    while q:
        j=q.pop()
        for x,e in g[j]:
            if a[x]==None:
                a[x]=a[j]+e
                q.append(x)
            elif a[x]!=a[j]+e:
                print("No")
                exit()
                
print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
s=[len(c) for c in list(input().split("T"))]
x,y=map(int,input().split())
XX=s[::2]
YY=s[1::2]
X=[XX[0]]
Y=[0]
XXX=[]
for i in range(1,len(XX)):
    for j in X:
        XXX.append(j+XX[i])
        XXX.append(j-XX[i])
    X=XXX
    XXX=[]

YYY=[]
for i in range(len(YY)):
    for j in Y:
        YYY.append(j+YY[i])
        YYY.append(j-YY[i])
    Y=YYY
    YYY=[]

if x in X and y in Y:
    print("Yes")
else:
    print("No")

Fixed submission:
s=[len(c) for c in list(input().split("T"))]
x,y=map(int,input().split())
XX=s[::2]
YY=s[1::2]
X=set([XX[0]])
Y=set([0])
XXX=[]
for i in range(1,len(XX)):
    for j in X:
        XXX.append(j+XX[i])
        XXX.append(j-XX[i])
    X=set(XXX)
    XXX=[]

YYY=[]
for i in range(len(YY)):
    for j in Y:
        YYY.append(j+YY[i])
        YYY.append(j-YY[i])
    Y=set(YYY)
    YYY=[]

if x in X and y in Y:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
print(2*n-1)
if abs(max(a))>=abs(min(a)):
     b=a.index(max(a))
    for i in range(n):
        print(b+1,i)
    for j in range(n-1):
        print(j+1,j+2)
    
else:
    b=a.index(min(a))
    for i in range(n):
        print(b+1,i+1)
    for j in range(n-1,0,-1):
        print(j+1,j)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
print(2*n-1)
if abs(max(a))>=abs(min(a)):
    b=a.index(max(a))
    for i in range(n):
        print(b+1,i+1)
    for j in range(n-1):
        print(j+1,j+2)
    
else:
    b=a.index(min(a))
    for i in range(n):
        print(b+1,i+1)
    for j in range(n-1,0,-1):
        print(j+1,j)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
print(2*n-1)
if abs(a)>max(a):
    b=a.index(min(a))
    for i in range(n):
        print(b+1,i+1)
    for j in range(n-1,0,-1):
        print(j+1,j)
else:
    b=a.index(max(a))
    for i in range(n):
        print(b+1,i)
    for j in range(n-1):
        print(j+1,j+2)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
print(2*n-1)
if abs(max(a))>=abs(min(a)):
    b=a.index(max(a))
    for i in range(n):
        print(b+1,i+1)
    for j in range(n-1):
        print(j+1,j+2)
    
else:
    b=a.index(min(a))
    for i in range(n):
        print(b+1,i+1)
    for j in range(n-1,0,-1):
        print(j+1,j)
Buggy python submission (verdict: Runtime Error):
a,b,c,d,e,f=map(int,input().split())
q=set()
ans=0
p=set()
for i in range(0,f+1,100*a):
    for j in range(0,f+1-i,100*b):
        q.add(i+j)
for i in range(0,f+1,c):
    for j in range(0,f+1-i,d):
        p.add(i+j)
for pp in p:
    for qq in q:
        if 0<pp+qq and qq<=pp*e/100:
            if ans<qq/(pp+qq):
                ans=qq/(pp+qq)
                s=pp+qq
                ss=pp

print(s,ss)

Fixed submission:
a,b,c,d,e,f = map(int,input().split())
w = set()
for x in range(0,f+1,100*a):
    for y in range(0,f+1-x,100*b):
        w.add(x+y)
s = set()
for x in range(0,f+1,c):
    for y in range(0,f+1-x,d):
        s.add(x+y)
ans = -1
sugerwater = 0
suger = 0
for x in w:
    for y in s:
        if  0<x+y<=f and y <= x*e/100:
            if ans < y/(x+y):
                ans = y/(x+y)
                sugerwater = x+y
                suger = y
print(sugerwater,suger)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
ans=0
n=int(input())
l=[list(map(int,input().split())) for _ in [0]*n]
o=copy.deepcopy(l)

for k in range(n):
  for i in range(n):
    for j in range(n):
      if l[i][j]>l[i][k]+l[k][j]:
        print(-1)
        exit()
for k in range(n):
  for i in range(n):
    for j in range(n):
        if i==j or j==k or k==i :
            continue
        if o[i][j]==o[i][k]+o[k][j]:
            o[i][j]=float("inf")
for i in range(n):
    for j in range(n):
        if o[i][j] != float("inf") :
            ans+=o[i][j]
print(ans//2)


Fixed submission:
INF = 10 ** 12

N = int(input())
a = [list(map(int, input().split())) for _ in range(N)]

for i in range(N):
    for j in range(N):
        for k in range(N):
            if a[i][j] > a[i][k] + a[k][j]:
                print(-1)
                exit()

res = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(N):
            if i != k and j != k and a[i][j] == a[i][k] + a[k][j]:
                break
        else:
            res += a[i][j]

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
ans=0
n=int(input())
a=[int(input()) for _ in range(n)]
b=list(set(a))
for i in b:
    if a.count(i)%2==0:
        continue
    else:
        ans+=1
print(ans)

Fixed submission:
from collections import Counter
n=int(input())
a=[int(input()) for i in range(n)]

c=Counter(a)
ans=0
for i in c.values():
    if i%2!=0:
        ans+=1

print(ans)
Buggy python submission (verdict: Runtime Error):
from itertools import permutations
from scipy.sparse.csgraph import floyd_warshall

n,m,R=map(int,input().split())
r=list(map(int,input().split()))
s=[[0]*n for i in range(n)]
for i in range(m):
    a, b, c = list(map(int, input().split()))
    a, b = a-1, b-1
    s[a][b] = c
    s[b][a] = c
s=floyd_warshall(s)   

ans=float('inf')
for i in permutations(r):
    an=0
    for j in range(R-1):
        an+=s[i[j]-1][i[j+1]-1]
    ans=min(ans,an)
print(int(ans))


Fixed submission:
from itertools import permutations
from scipy.sparse.csgraph import floyd_warshall

n,m,R=map(int,input().split())
r=list(map(int,input().split()))
s=[[0]*n for i in range(n)]
for i in range(m):
    a, b, c = list(map(int, input().split()))
    a, b = a-1, b-1
    s[a][b] = c
    s[b][a] = c
s=floyd_warshall(s)   

ans=float('inf')
for i in permutations(r):
    an=0
    for j in range(R-1):
        an+=s[i[j]-1][i[j+1]-1]
    ans=min(ans,an)
print(int(ans))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for _ in range(n)]
ans=a[0]
import math
for i in range(1, n):
    ans = ans * a[i] // math.gcd(ans, a[i])
print(ans)

Fixed submission:
n=int(input())
a=[int(input()) for _ in range(n)]
ans=a[0]
from fractions import gcd
for i in range(1, n):
    ans = ans * a[i] // gcd(ans, a[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

que = deque()
for i in range(N):
    if i % 2 == 0:
        que.append(A[i])
    else:
        que.appendleft(A[i])
if N % 2:
    que.reverse()
print(*que)


Fixed submission:
n = int(input())
a = input().split()
b = []
for i in range(n - 1, -1, -2):
  b.extend([a[i]])
for j in range(n % 2, n, 2):
  b.extend([a[j]])
print(" ".join(b))

Buggy python submission (verdict: Runtime Error):
from collections import deque
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

que = deque()
for i in range(N):
    if i % 2 == 0:
        que.append(A[i])
    else:
        que.appendleft(A[i])
if N % 2:
    que.reverse()
print(*que)


Fixed submission:
n = int(input())
a = input().split()
b = []
for i in range(n - 1, -1, -2):
  b.extend([a[i]])
for j in range(n % 2, n, 2):
  b.extend([a[j]])
print(" ".join(b))