Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from scipy.sparse import*
h,w,*a=map(int,open(0).read().split())
print(int(sum(csgraph.dijkstra(csr_matrix([a[i*10:-~i*10]for i in range(10)]))[i][1]for i in a[100:]if i>=0)))

Fixed submission:
from scipy.sparse import*
i=lambda:list(map(int,input().split()))
h,w=i()
c=csgraph.dijkstra(csr_matrix([i()for _ in[0]*10]))
print(int(sum(c[j][1]for i in eval('i(),'*h)for j in i if j>=0)))
Buggy python submission (verdict: Runtime Error):
print(['NO','YES'][input()==input().reverse()])

Fixed submission:
print(['NO','YES'][input()==input()[::-1]])

Buggy python submission (verdict: Runtime Error):
print(['NO','YES'][input()=input().reverse()])

Fixed submission:
print(['NO','YES'][input()==input()[::-1]])
Buggy python submission (verdict: Runtime Error):
print((int(input())+int(input())/2)

Fixed submission:
r=int(input())
g=int(input())
print(g+g-r)
Buggy python submission (verdict: Runtime Error):
n=int(input());k=int(input()),r=1
for _ in[0]*n:r+=min(r,k)
print(r)

Fixed submission:
n=int(input());k=int(input());r=1
for _ in[0]*n:r+=min(r,k)
print(r)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=s.replace('x','')
if t!=t[::-1] and len(t)!=1:
  print(-1)
  exit()
c=0
while True:
  if s==s[::-1]:
    print(c)
    exit()
  for i in range(len(s)//2):
    if s[i]=='x'and s[len(s)-i-1]!='x':
      s=s[:len(s)-i]+'x'+s[len(s)-i:]
      break
  else:
    for i in range(len(s)//2,len(s)):
      if s[i]=='x'and s[len(s)-i-1]!='x':
        s=s[:len(s)-i-1]+'x'+s[len(s)-i-1:]
        break
  c+=1

Fixed submission:
s=input()
c=0
while len(s)>1:
  if s[0]==s[len(s)-1]:
    s=s[1:len(s)-1]
  elif s[0]=='x':
    c+=1
    s=s[1:]
  elif s[len(s)-1]=='x':
    c+=1
    s=s[:len(s)-1]
  else:
    print(-1)
    exit()
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
c=0
while len(s)>1:
  if s[0]==s[len(s)-1]:
    s=s[1:len(s)-1]
  elif s[0]=='x':
    c+=1
    s=s[1:]
  elif s[len(s)-1]=='x':
    c+=1
    s=s[:len(s)-1]
  else:
    print(-1)
    exit()
print(c)

Fixed submission:
s=input()
c=0
while len(s)>1:
  if s[0]==s[len(s)-1]:
    s=s[1:len(s)-1]
  elif s[0]=='x':
    c+=1
    s=s[1:]
  elif s[len(s)-1]=='x':
    c+=1
    s=s[:len(s)-1]
  else:
    print(-1)
    exit()
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=s.replace('x','')
if t!=t[::-1] and len(t)!=1:
  print(-1)
  exit()
c=0
while True:
  if s==s[::-1]:
    print(c)
    exit()
  for i in range(len(s)//2):
    if s[i]=='x'and s[len(s)-i-1]!='x':
      s=s[:len(s)-i]+'x'+s[len(s)-i:]
      break
  else:
    for i in range(len(s)//2,len(s)):
      if s[i]=='x'and s[len(s)-i-1]!='x':
        s=s[:len(s)-i-1]+'x'+s[len(s)-i-1:]
        break
  c+=1

Fixed submission:
s=input()
c=0
while len(s)>1:
  if s[0]==s[len(s)-1]:
    s=s[1:len(s)-1]
  elif s[0]=='x':
    c+=1
    s=s[1:]
  elif s[len(s)-1]=='x':
    c+=1
    s=s[:len(s)-1]
  else:
    print(-1)
    exit()
print(c)
Buggy python submission (verdict: Runtime Error):
a=input().split()
a.sort()
print(a[4] if a[2]==a[3] else a[2])

Fixed submission:
a=input().split()
a.sort()
print(a[2] if a[0]==a[1] else a[0])

Buggy python submission (verdict: Runtime Error):
a=list(input()).sort
print(a[0] if a[0]!=a[1] else a[2])

Fixed submission:
a=input().split()
a.sort()
print(a[2] if a[0]==a[1] else a[0])

Buggy python submission (verdict: Runtime Error):
s=list(input)
a=[i for i in set(s) if s.count(i)>1]
print(a[0])

Fixed submission:
a=input().split()
a.sort()
print(a[2] if a[0]==a[1] else a[0])
Buggy python submission (verdict: Time Limit Exceeded):
input()
s=input()
input()
for t in input().split():
  if s.find(t)<0:
    print('NO')
    break
  s=s.replace(t,'',1)
else:
  print('YES')

Fixed submission:
input()
d={}
for k in input().split():
  d[k]=d.get(k,0)+1
input()
for i in input().split():
  if d.get(i,0)>0:
    d[i]-=1
  else:
    print('NO')
    break
else:
  print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
input()
s=input()
input()
for t in input().split():
  if s.find(t)<0:
    print('NO')
    break
  s=s.replace(t,'',1)
else:
  print('YES')

Fixed submission:
input()
d={}
for k in input().split():
  d[k]=d.get(k,0)+1
input()
for i in input().split():
  if d.get(i,0)>0:
    d[i]-=1
  else:
    print('NO')
    break
else:
  print('YES')
Buggy python submission (verdict: Runtime Error):
N=int(input())
for h in range(1,3501):
  for n in range(1,3501):
    w=(N*h*n)/(4*h*n-N*(n+h))
    if w==int(w):
      print(h,n,w)
      exit()

Fixed submission:
N=int(input())
for h in range(1,3501):
  for n in range(1,3501):
    if (4*h*n-N*n-N*h)>0:
      w=(N*h*n)/(4*h*n-N*n-N*h)
      if w==int(w) and w>0:
        print(h,n,int(w))
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
print(min(eval('sum(map(int,input().split())),'*int(input()))))

Fixed submission:
n,*t=map(int,open(0).read().split());print(sum(sorted(zip(t[::2],t[1::2]))[-1]))

Buggy python submission (verdict: Time Limit Exceeded):
print(min(eval('eval(input().replace(" ","+")),'*int(input()))))

Fixed submission:
n,*t=map(int,open(0).read().split());print(sum(sorted(zip(t[::2],t[1::2]))[-1]))

Buggy python submission (verdict: Time Limit Exceeded):
print(min(eval('eval(input().replace(" ","+")),'*int(input()))))

Fixed submission:
n,*t=map(int,open(0).read().split());print(sum(sorted(zip(t[::2],t[1::2]))[-1]))
Buggy python submission (verdict: Runtime Error):
t,_,s=open(0).read().partition('\n')
h,w=map(int,t.split())
a,b=h//2*(w//2),h%2and w%2
d=[b,(h*w-a*4-b)//2,0,a]
for i in map(s.count,set(s)-{'\n'}):
  for j in(3,1,0):
    while d[j]and i>j:
      i-=j+1
      d[j]-=1
print('YNeos'[sum(d.values())>0::2])

Fixed submission:
t,_,s=open(0).read().partition('\n')
h,w=map(int,t.split())
a=b=c=0
if h%2and w%2:
    a=h//2*(w//2)
    c=1
    b=(h*w-a*4-c)//2
elif h%2or w%2:
    a=h//2*(w//2)
    b=(h*w-a*4)//2
else:
    a=h*w//4
l=[]
for i in set(s.replace('\n','')):
    l.append(s.count(i))
for i in l:
    if i>3:
        while i>3and a:
            i-=4
            a-=1
    if i>1:
        while i>1and b:
            i-=2
            b-=1
    if i and c:
        i-=1
        c-=1
if all(not t for t in(a,b,c)):
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
t,_,s=open(0).read().partition('\n')
h,w=map(int,t.split())
d={}
d[3]=h//2*(w//2)
d[0]=h%2and w%2
d[1]=(h*w-a*4-c)//2
for i in set(s)-{'\n'}:
  i=s.count(i)
  for j in[3,1,0]:
    while d[j]and i>j:
      i-=j+1
      d[j]-=1
print('YNeos'[any(t for t in d.values())::2])

Fixed submission:
t,_,s=open(0).read().partition('\n')
h,w=map(int,t.split())
a=b=c=0
if h%2and w%2:
    a=h//2*(w//2)
    c=1
    b=(h*w-a*4-c)//2
elif h%2or w%2:
    a=h//2*(w//2)
    b=(h*w-a*4)//2
else:
    a=h*w//4
l=[]
for i in set(s.replace('\n','')):
    l.append(s.count(i))
for i in l:
    if i>3:
        while i>3and a:
            i-=4
            a-=1
    if i>1:
        while i>1and b:
            i-=2
            b-=1
    if i and c:
        i-=1
        c-=1
if all(not t for t in(a,b,c)):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
_,k,*x=map(open(0).read().split());print(sum(min(t,k-t)*2for t in x))

Fixed submission:
_,k,*x=map(int,open(0).read().split());print(sum(min(t,k-t)*2for t in x))
Buggy python submission (verdict: Runtime Error):
d={}
for _ in[0]*int(input()):
 i=input()
 d[i]=!d.get(i,0)
print(sum(d.values()))

Fixed submission:
d={}
for _ in[0]*int(input()):
 i=input()
 d[i]=d.get(i,0)^1
print(sum(d.values()))

Buggy python submission (verdict: Time Limit Exceeded):
d=set()
for i in[0]*int(input()):d^={input()}
print(len(d))

Fixed submission:
d={}
for _ in[0]*int(input()):
 i=input()
 d[i]=d.get(i,0)^1
print(sum(d.values()))

Buggy python submission (verdict: Time Limit Exceeded):
d=set()
for i in[0]*input():d^={input()}
print len(d)

Fixed submission:
d={}
for _ in[0]*int(input()):
 i=input()
 d[i]=d.get(i,0)^1
print(sum(d.values()))

Buggy python submission (verdict: Runtime Error):
d=set()
for i in[0]*int(input()):d^={input()}
print(len(p))

Fixed submission:
d={}
for _ in[0]*int(input()):
 i=input()
 d[i]=d.get(i,0)^1
print(sum(d.values()))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import*
n,m,R=map(int,input().split())
r=map(int,input().split())
d=[[10**18]*n for _ in range(n)]
for i in range(m):
    a,b,c=map(int,input().split())
    d[a-1][b-1]=c
    d[b-1][a-1]=c
for i in range(n):
    d[i][i]=0
for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j]=min(d[i][j],d[i][k]+d[k][j])
m=10**18
for e in permutations(r):
    t=0
    for i,j in zip(e,e[1:]):
        t+=d[i-1][j-1]
    m=min(m,t)
print(m)

Fixed submission:
from itertools import*
n,m,R=map(int,input().split())
r=map(int,input().split())
d=[[10**18]*n for _ in range(n)]
for i in range(m):
    a,b,c=map(int,input().split())
    d[a-1][b-1]=c
    d[b-1][a-1]=c
for i in range(n):
    d[i][i]=0
for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j]=min(d[i][j],d[i][k]+d[k][j])
m=10**18
for e in permutations(r):
    t=0
    for i,j in zip(e,e[1:]):
        t+=d[i-1][j-1]
    m=min(m,t)
print(m)
Buggy python submission (verdict: Runtime Error):
print(eval('('+input().replace(' ','-1)*(')+('-1)'))

Fixed submission:
print(eval('('+input().replace(' ','-1)*(')+'-1)'))
Buggy python submission (verdict: Runtime Error):
print(2<<len(bin(int(input())))-4)

Fixed submission:
print(2**(len(bin(int(input())))-3))
Buggy python submission (verdict: Runtime Error):
from numpy import*
a=loadtxt(open(0),'i',skiprows=1)
n=x=len(a)
while a.any():
  t=bincount(a[:,0])
  x,a=min(x,max(t)),reshape(a[a!=argmax(t)],(n,-1))
print(x)

Fixed submission:
from numpy import*
a=loadtxt(open(0),'i',skiprows=1,ndmin=2)
n=x=len(a)
while a.any():
  t=bincount(a[:,0])
  x,a=min(x,max(t)),reshape(a[a!=argmax(t)],(n,-1))
print(x)
Buggy python submission (verdict: Runtime Error):
t,l=open(0);print(sum(sorted(map(int,l.split()))[-int(t[2:])]))

Fixed submission:
_,k,*l=map(int,open(0).read().split());print(sum(sorted(l)[-k:]))
Buggy python submission (verdict: Runtime Error):
from networkx import*
N,*t=map(str.split,open(0))
s=shortest_path_length
x=s(G:=Graph(t),'1')
y=s(G,N)
print('FSennunkeec'[sum(x[k]>y[k]for k in x)*2>=int(*N)::2])

Fixed submission:
from collections import*
input=open(0).readline
n=int(input())
e=[[]for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    e[a-1].append(b-1)
    e[b-1].append(a-1)
f=[0]*n
v=[1]+[0]*~-n
q=deque([(0,0)])
while q:
    t,c=q.pop()
    v[t]=1
    f[t]=c
    for i in e[t]:
        if not v[i]:
            q.append((i,c+1))
s=[0]*n
v=[0]*~-n+[1]
q=deque([(n-1,0)])
while q:
    t,c=q.pop()
    v[t]=1
    s[t]=c
    for i in e[t]:
        if not v[i]:
            q.append((i,c+1))
a=b=0
for i,j in zip(f,s):
    if i<=j:
        a+=1
    else:
        b+=1
if a>b:
    print('Fennec')
else:
    print('Snuke')
Buggy python submission (verdict: Runtime Error):
n,a,b,c,d=map(int,input().split());print('NYOE S'[any(i*c-(~i+n)*d<=b-a<=i*d-(~i+n)*cfor i in range(n))::2])

Fixed submission:
n,a,b,c,d=map(int,input().split())
f=0
for i in range(n):f|=i*c-(~i+n)*d<=b-a<=i*d-(~i+n)*c
print('NYOE S'[f::2])
Buggy python submission (verdict: Time Limit Exceeded):
n,*a=map(int,open(0).read().split())
b=[]
for i in range(n):b=(b+[a[i]])[::-1]
print(*b)

Fixed submission:
n,*a=map(int,open(0).read().split())
b=a[1::2][::-1]+a[::2]
print(*b[::n%2<1or-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,*a=map(int,open(0).read().split())
b=[]
for i in range(n):b=(b+[a[i]])[::-1]
print(*b)

Fixed submission:
n,*a=map(int,open(0).read().split())
b=a[1::2][::-1]+a[::2]
print(*b[::n%2<1or-1])
Buggy python submission (verdict: Time Limit Exceeded):
print([1/id('hoge')%5%2]*2**28**id('fuga')and'Yes')

Fixed submission:
n,a=open(0)
n=int(n)
a=sorted(map(int,a.split()))
if a[0]==a[-1]:
  if n-1==a[0]or n//a[0]>=2:
    print('Yes')
  else:
    print('No')
elif a[-1]-1==a[0]:
  x=a.count(a[0])
  if x<a[-1]and(n-x)//(a[-1]-x)>=2:
    print('Yes')
  else:
    print('No')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b,*h=map(int,open(0).read().split());i,j=0,2**47
while j-i>1:
 k=c=(j+i)//2
 for t in h:c+=min(0,(b*k-t)//(a-b))
 if c<0:i=k
 else:j=k
print(j)

Fixed submission:
n,a,b,*h=map(int,open(0).read().split())
i,j=0,-(-max(h)*n//a)
while True:
  if j-i<2:
    print(j)
    break
  k=c=(j+i+1)//2
  for t in h:
    t-=b*k
    if t>0:
      c+=-t//(a-b)
  if c>=0:
    j=k
  else:
    i=k

Buggy python submission (verdict: Time Limit Exceeded):
n,a,b,*h=map(int,open(0).read().split());i,j=0,-(-max(h)*n//a)
while j-i>1:
 k=c=(j+i+1)//2
 for t in h:c+=min(0,(b*k-t)//(a-b))
 if c>=0:j=k
 else:i=k
print(j)

Fixed submission:
n,a,b,*h=map(int,open(0).read().split())
i,j=0,-(-max(h)*n//a)
while True:
  if j-i<2:
    print(j)
    break
  k=c=(j+i+1)//2
  for t in h:
    t-=b*k
    if t>0:
      c+=-t//(a-b)
  if c>=0:
    j=k
  else:
    i=k
Buggy python submission (verdict: Runtime Error):
_,w,*s=open(0).read().split();t=['#'*(int(w)+2)];print(t,*['#'+t+'#'for t in s],t)

Fixed submission:
_,w,*s=open(0).read().split();t=['#'*(int(w)+2)];a=t+['#'+t+'#'for t in s]+t;print(*a,sep='\n')
Buggy python submission (verdict: Runtime Error):
n,_,*r=map(int,open(0).read().split());for i in range(n):print(r.count(-~i))

Fixed submission:
n,_,*r=map(int,open(0).read().split())
for i in range(n):print(r.count(-~i))
Buggy python submission (verdict: Runtime Error):
l=[0]*2**14
for i in open(0).read().split()[2:]:l[int(i)]+=1
print('YNEOS'[any(i%2for i in l)::2])

Fixed submission:
l=[0]*2**17
for i in open(0).read().split()[2:]:l[int(i)]+=1
print('YNEOS'[any(i%2for i in l)::2])

Buggy python submission (verdict: Time Limit Exceeded):
*c,=open(0).read().split()[2:]
print('YNEOS'[any(c.count(i)%2for i in set(c))::2])

Fixed submission:
l=[0]*2**17
for i in open(0).read().split()[2:]:l[int(i)]+=1
print('YNEOS'[any(i%2for i in l)::2])
Buggy python submission (verdict: Runtime Error):
import re;a,b=re.findall('. .',input());print('YNEOS'[a[0]+b[2]!=a[2]+b[0]::2])

Fixed submission:
a,b,c=input().split();print('YNEOS'[a[::-1][0]!=b[0]or b[::-1][0]!=c[0]::2])

Buggy python submission (verdict: Runtime Error):
s=input().find;i=s(' ');j=s(' ',i);print('YNEOS'[s[i-1]+s[j+1]!=s[i+1]+s[j-1]::2])

Fixed submission:
a,b,c=input().split();print('YNEOS'[a[::-1][0]!=b[0]or b[::-1][0]!=c[0]::2])

Buggy python submission (verdict: Runtime Error):
a,b,c=input().split();print('YNEOS'[a[-1]+c[0]!=b[::len(b)-1]::2])

Fixed submission:
a,b,c=input().split();print('YNEOS'[a[::-1][0]!=b[0]or b[::-1][0]!=c[0]::2])
Buggy python submission (verdict: Runtime Error):
from numpy import*;a,b,c=int_(input().split());print('YNEOS'[c%gcd(a,b)>0::2])

Fixed submission:
from fractions import*;a,b,c=map(int,input().split());print('YNEOS'[c%gcd(a,b)>0::2])
Buggy python submission (verdict: Runtime Error):
print([*zip(*input().split())][0].upper())

Fixed submission:
a,b,c=input().upper().split();print(''.join([a[0],b[0],c[0]]))

Buggy python submission (verdict: Runtime Error):
a,b,c=input().upper().split();print(''.join(a[0],b[0],c[0]))

Fixed submission:
a,b,c=input().upper().split();print(''.join([a[0],b[0],c[0]]))
Buggy python submission (verdict: Time Limit Exceeded):
mod=10**9+7
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
xl=0
yl=0
for i in range(n-1):
  r=i+1
  while r<n:
    xl=(xl+x[r]-x[i])%mod
    r+=1
for i in range(m-1):
  u=i+1
  while u<m:
    yl=(yl+y[u]-y[i])%mod
    u+=1
print(xl*yl%mod)

Fixed submission:
mod=10**9+7
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
xl=0
xt=0
yl=0
yt=0
for i in range(n-1):
  if i==0:
    for j in range(1,n):
      xt+=x[j]-x[i]
    xl=xt
  else:
    xt-=(x[i]-x[i-1])*(n-i)
    xl=(xl+xt)%mod
for i in range(m-1):
  if i==0:
    for j in range(1,m):
      yt+=y[j]-y[i]
    yl=yt
  else:
    yt-=(y[i]-y[i-1])*(m-i)
    yl=(yl+yt)%mod
print(xl*yl%mod)

Buggy python submission (verdict: Time Limit Exceeded):
mod=10**9+7
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
xl=0
yl=0
for i in range(n-1):
  r=i+1
  while r<n:
    xl=(xl+x[r]-x[i])%mod
    r+=1
for i in range(m-1):
  u=i+1
  while u<m:
    yl=(yl+y[u]-y[i])%mod
    u+=1
print(xl*yl%mod)

Fixed submission:
mod=10**9+7
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
xl=0
xt=0
yl=0
yt=0
for i in range(n-1):
  if i==0:
    for j in range(1,n):
      xt+=x[j]-x[i]
    xl=xt
  else:
    xt-=(x[i]-x[i-1])*(n-i)
    xl=(xl+xt)%mod
for i in range(m-1):
  if i==0:
    for j in range(1,m):
      yt+=y[j]-y[i]
    yl=yt
  else:
    yt-=(y[i]-y[i-1])*(m-i)
    yl=(yl+yt)%mod
print(xl*yl%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input());a=eval('list(input()),'*n);print(-all(t.count('#')<1for t in a)or min(n*2-sum(n==t.count('#')for t in zip(*a))-b.count('#')+all(a[j][i]>'#'for j in range(n))for i,b in enumerate(a)))

Fixed submission:
n=int(input())
a=eval('list(input()),'*n)
if all(t.count('#')<1for t in a):
  print(-1)
  exit()
f=sum(n==t.count('#')for t in zip(*a))
c=10**18
for i,b in enumerate(a):
  v=b.count('#')
  t=0
  if b[i]!='#':
    for j in range(n):
      if a[j][i]=='#':
        break
    else:
      t+=1
    t+=n-v
  else:
    t+=n-v
  c=min(c,t+n-f)
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input());a=eval('list(input()),'*n);print(-all(t.count('#')<1for t in a)or min(n*2-sum(n==t.count('#')for t in zip(*a))-b.count('#')+all(a[j][i]>'#'for j in range(n))for i,b in enumerate(a)))

Fixed submission:
n=int(input())
a=eval('list(input()),'*n)
if all(t.count('#')<1for t in a):
  print(-1)
  exit()
f=sum(n==t.count('#')for t in zip(*a))
c=10**18
for i,b in enumerate(a):
  v=b.count('#')
  t=0
  if b[i]!='#':
    for j in range(n):
      if a[j][i]=='#':
        break
    else:
      t+=1
    t+=n-v
  else:
    t+=n-v
  c=min(c,t+n-f)
print(c)
Buggy python submission (verdict: Runtime Error):
n=input();print(n*800-n//15*200)

Fixed submission:
n=int(input());print(n*800-n//15*200)
Buggy python submission (verdict: Runtime Error):
import math;print(math.factorial(int(input()))%(1e9+7))

Fixed submission:
n = int(input())
ans = 1
for i in range(1, n + 1):
    ans = ans * i % 1000000007
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()*2
for a in['SS','SW','WS','WW']:
    for i in range(1,n+1):
        f=a[i]+s[i]
        if f=='So'or'Wx'==f:
            a+=a[i-1]
        else:
            a+=a[i-1].translate({83:87,87:83})
    if a[:2]==a[n:]:
        print(a[:n])
        break
else:
    print(-1)

Fixed submission:
n=int(input())
s=input()*2
for a in['SS','SW','WS','WW']:
    for i in range(1,n+1):
        f=a[i]+s[i]
        if f=='So'or'Wx'==f:
            a+=a[i-1]
        else:
            a+=a[i-1].translate({83:87,87:83})
    if a[:2]==a[n:]:
        print(a[:n])
        break
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
n,a=open(0)
*a,=map(int,a.split())
c,d={},{}
m=0
for j,i in enumerate(a):
  if i>m:d[i],m=j,i
  c[i]=c.get(i,0)+1
i=sorted(d)[::-1]
a=[0]*int(n)
for i,j in zip(i,i[1:]):
  a[d[i]]=(i-j)*c[i]
  c[j]+=c[i]
a[d[j]]=j*c[j]
print(*a)

Fixed submission:
e=enumerate
n,a=open(0)
a=sorted((int(i),j)for j,i in e(('0 '+a).split()))[::-1]
c=[0]*int(n)
t=10**18
for k,(i,j)in e(a[:-1],1):
  t=min(t,j)
  c[t-1]+=(i-a[k][0])*k
print(*c)
Buggy python submission (verdict: Time Limit Exceeded):
I=lambda:list(map(int,input().split()))
n,Ma,Mb=I()
m=[[0,0,0]]+[I()for _ in range(n)]
dp=[[[10**18]*(10*n+1)for _ in range(10*n+1)]for _ in range(n+1)]
dp[0][0][0]=0
for i in range(1,n+1):
    for j in range(10*n+1):
        if j-m[i][0]<0:
            dp[i][j]=dp[i-1][j]
            continue
        for k in range(10*n+1):
            if k-m[i][1]<0:
                dp[i][j][k]=dp[i-1][j][k]
            else:
                dp[i][j][k]=min(dp[i-1][j-m[i][0]][k-m[i][1]]+m[i][2],dp[i-1][j][k])
ans=10**18
for i in range(1,10*n+1):
    j=Mb*i/Ma
    if j==int(j) and j<10*n+2:
        ans=min(ans,dp[-1][i][int(j)])
print(-(ans==10**18)or ans)

Fixed submission:
I=lambda:list(map(int,input().split()))
n,Ma,Mb=I()
m=[[0,0,0]]+[I()for _ in range(n)]
dp=[[[10**18]*(10*n+1)for _ in range(10*n+1)]for _ in range(n+1)]
dp[0][0][0]=0
for i in range(1,n+1):
    for j in range(10*n+1):
        if j-m[i][0]<0:
            dp[i][j]=dp[i-1][j]
            continue
        for k in range(10*n+1):
            if k-m[i][1]<0:
                dp[i][j][k]=dp[i-1][j][k]
            else:
                dp[i][j][k]=min(dp[i-1][j-m[i][0]][k-m[i][1]]+m[i][2],dp[i-1][j][k])
ans=10**18
for i in range(1,10*n+1):
    j=Mb*i/Ma
    if j==int(j) and j<10*n+2:
        ans=min(ans,dp[-1][i][int(j)])
print(-(ans==10**18)or ans)
Buggy python submission (verdict: Runtime Error):
input();print('YNEOS'[eval(input().replace(' ','^'))&1::2])

Fixed submission:
input();print('YNEOS'[sum(int(i)%2for i in input().split())%2::2])

Buggy python submission (verdict: Runtime Error):
input();print('YNEOS'[eval(input().replace(' ','^'))::2])

Fixed submission:
input();print('YNEOS'[sum(int(i)%2for i in input().split())%2::2])
Buggy python submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
b,m=sum(a),n*-~n//2
n-=1
c=b//m
f=b%m>0
for i,j in zip(*[iter([a[-1]]+a*2)]*2):
  j-=i
  t=min(0,j//n)
  f|=c!=j+n*-t-t
print('YNEOS'[f::2])

Fixed submission:
n,*a=map(int,open(0).read().split())
b,m=sum(a),n*-~n//2
n-=1
c=b//m
f=b%m>0
for i,j in zip(*[iter([a[-1]]+a*2)]*2):
  j-=i
  if n:
    t=min(0,j//n)
    f|=c!=j+n*-t-t
print('YNEOS'[f::2])
Buggy python submission (verdict: Runtime Error):
print('ABC'(int(input())<1200)or'ARC')

Fixed submission:
print('ABC'*(int(input())<1200)or'ARC')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)
e=enumerate
def dfs(v):
  d=sorted(map(dfs,t[v]))
  l=len(d)
  return max([0]+[l-i+d for i,d in e(d)])
n,*a=map(int,open(0))
t=[[]for _ in[0]+a]
for i,v in e(a,1):t[v-1]+=i,
print(dfs(0))

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
e=enumerate
def dfs(v):
  d=sorted(map(dfs,t[v]))
  l=len(d)
  return max([0]+[l-i+d for i,d in e(d)])
n,*a=map(int,open(0))
t=[[]for _ in[0]+a]
for i,v in e(a,1):t[v-1]+=i,
print(dfs(0))

Buggy python submission (verdict: Runtime Error):
def dfs(v):
  d=sorted(map(dfs,t[v]))
  l=len(d)
  return max([0]+[l-i+d for i,d in e(d)])
e=enumerate
n,*a=map(int,open(0))
t=[[]for _ in[0]+a]
for i,v in e(a,1):t[v-1]+=i,
print(dfs(0))

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
e=enumerate
def dfs(v):
  d=sorted(map(dfs,t[v]))
  l=len(d)
  return max([0]+[l-i+d for i,d in e(d)])
n,*a=map(int,open(0))
t=[[]for _ in[0]+a]
for i,v in e(a,1):t[v-1]+=i,
print(dfs(0))
Buggy python submission (verdict: Time Limit Exceeded):
import math
n=math.factorial(int(input()))
a=i=1
while i*i<=n:
  c=1
  while n%i==0:
    c+=1
    n//=i
  a*=c
  i+=1
print(a*2**(n!=1)%(10**9+7))

Fixed submission:
import math
n=math.factorial(int(input()))
a,i=1,2
while i*i<=n:
  c=1
  while n%i==0:
    c+=1
    n//=i
  a*=c
  i+=1
print(a*2**(n!=1)%(10**9+7))
Buggy python submission (verdict: Runtime Error):
k,s=map(int,input().split());k+=1;print(sum(k>=s-x//k-y%k>=0for I in range(k**2)))

Fixed submission:
k,s=map(int,input().split());r=k+1;print(sum(k>=s-I//r-I%r>=0for I in range(r*r)))
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=[0]+list(map(int,input().split()))
s=[0]
p=[0]
for i in range(1,n+1):
  s[i].append(s[i-1]+a[i])
  p[i].append(p[i-1]+max(0,a[i]))
ans=0
for i in range(1,n-k+1):
  t=max(0,s[i+k]-s[i-1])
  t+=p[i-1]+p[n]-p[i+k]
  ans=max(ans,t)
print(ans)

Fixed submission:
n,k=map(int,input().split())
a=[0]+list(map(int,input().split()))
s=[0]
p=[0]
for i in range(1,n+1):
  s.append(s[i-1]+a[i])
  p.append(p[i-1]+max(0,a[i]))
ans=0
for i in range(1,n-k+2):
  t=max(0,s[i+k-1]-s[i-1])
  t+=p[i-1]+p[n]-p[i+k-1]
  ans=max(ans,t)
print(ans)