Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
M,s=998244353,0
d=[1]+[0]*7**6
e=d[:]
for _ in'_'*input():
 a=input();s+=a;i=s
 while~i:d[i]+=d[i-a]*2%M;e[i]+=e[i-a]%M;i-=1
print(sum(d)+~s%2*e[s/2]*3-3*sum(d[:s/2+1]))%M

Fixed submission:
M,z,s=998244353,1,0
d=[1]+[0]*7**6
e=[1]+[0]*7**6
for _ in'_'*input():
 a=input();s+=a;i=s;z*=3
 while~i:d[i]+=d[i]+d[i-a]%M;e[i]+=e[i-a]%M;i-=1
i=s
while i*2>=s:z-=d[i]*3;i-=1
print(z+~s%2*e[i+1]*3)%M

Buggy python submission (verdict: Time Limit Exceeded):
M,z,s=998244353,1,0
d=[1]+[0]*7**6
e=d[:]
for _ in'_'*input():
 a=input();s+=a;i=s;z*=3
 while~i:d[i]+=d[i]+d[i-a]%M;e[i]+=e[i-a];i-=1
print(z+~s%2*e[s//2]*3-3*sum(d[-~s//2:]))%M

Fixed submission:
M,z,s=998244353,1,0
d=[1]+[0]*7**6
e=[1]+[0]*7**6
for _ in'_'*input():
 a=input();s+=a;i=s;z*=3
 while~i:d[i]+=d[i]+d[i-a]%M;e[i]+=e[i-a]%M;i-=1
i=s
while i*2>=s:z-=d[i]*3;i-=1
print(z+~s%2*e[i+1]*3)%M

Buggy python submission (verdict: Time Limit Exceeded):
z,s=1,0
d=[1]+[0]*7**6
e=d[:]
for _ in'_'*input():
 a=input();s+=a;i=s;z*=3
 while~i:d[i]+=d[i]+d[i-a];e[i]+=e[i-a];i-=1
print(z+~s%2*e[s//2]*3-3*sum(d[-~s//2:]))%998244353

Fixed submission:
M,z,s=998244353,1,0
d=[1]+[0]*7**6
e=[1]+[0]*7**6
for _ in'_'*input():
 a=input();s+=a;i=s;z*=3
 while~i:d[i]+=d[i]+d[i-a]%M;e[i]+=e[i-a]%M;i-=1
i=s
while i*2>=s:z-=d[i]*3;i-=1
print(z+~s%2*e[i+1]*3)%M
Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
print(sum(max(h[:i])<=h[i]for i in range(n)))

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
print(sum(max(h[:i]+[0])<=h[i]for i in range(n)))

Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
print(count(max(h[:i]+[0])<=h[i]for i in range(n)))

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
print(sum(max(h[:i]+[0])<=h[i]for i in range(n)))

Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
print(count(max(h[:i])<=h[i]for i in range(n)))

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
print(sum(max(h[:i]+[0])<=h[i]for i in range(n)))
Buggy python submission (verdict: Runtime Error):
N,X,*S=map(int,open(0).read().split())
e=enumerate
d=range(X+1)
for i,s in e(sorted(S)):d=[(t*i+x[j%s])%(10**9+7)for j,t in e(d)]
print(d[-1])

Fixed submission:
N,X,*S=map(int,open(0).read().split())
e=enumerate
d=range(X+1)
for i,s in e(sorted(S)):d=[(t*i+d[j%s])%(10**9+7)for j,t in e(d)]
print(d[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,X,*S=map(int,open(0).read().split())
e=enumerate
d=range(X+1)
for i,s in e(sorted(S)):x=d;d=[t*i+x[j%s]for j,t in e(x)]
print(d[-1]%(10**9+7))

Fixed submission:
N,X,*S=map(int,open(0).read().split())
e=enumerate
d=range(X+1)
for i,s in e(sorted(S)):d=[(t*i+d[j%s])%(10**9+7)for j,t in e(d)]
print(d[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,X,*S=map(int,open(0).read().split())
e=enumerate
d=range(X+1)
for i,s in e(sorted(S)):x=d;d=[t*i+x[j%s]for j,t in e(x)]
print(d[-1]%(10**9+7))

Fixed submission:
N,X,*S=map(int,open(0).read().split())
e=enumerate
d=range(X+1)
for i,s in e(sorted(S)):d=[(t*i+d[j%s])%(10**9+7)for j,t in e(d)]
print(d[-1])
Buggy python submission (verdict: Runtime Error):
a=b=c=d=e=f=0;g=1;exec('a,b,c,d,e,f,g=b,e,e-d,f,g,g-c,g*4-b-c-d-a*3;'*input());print g%=10**9+7

Fixed submission:
a=b=c=d=e=f=0;g=1;exec('a,b,c,d,e,f,g=b,e,e-d,f,g,g-c,g*4-b-c-d-a*3;'*input());print g%(10**9+7)
Buggy python submission (verdict: Runtime Error):
_,b,_=input().split('/')
print("Heisei"if b<5 else"TBD")

Fixed submission:
_,b,_=input().split('/')
print("Heisei"if int(b)<5 else"TBD")
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
for _ in range(n):
  _,*b=map(int,input().split())
  a+=b
print(sum(n==a.count i+1for i in range(m)))

Fixed submission:
n,m=map(int,input().split())
a=[]
for _ in range(n):
  _,*b=map(int,input().split())
  a+=b
print(sum(n==a.count(i+1)for i in range(m)))
Buggy python submission (verdict: Runtime Error):
s=int(input())
i=4
while s>4or3==s:s=[s//2,s*3+1][s%2];i+=1
print(i)

Fixed submission:
s=int(input())
i=2
while s>1:s=[s//2,s*3+1][s%2];i+=1
print(max(i,4))
Buggy python submission (verdict: Time Limit Exceeded):
n,k,*h=map(int,open(0).read().split());
dp=[0];
for i in range(1,n):dp+=[min(10**9*(i-j>k)+dp[j]+abs(h[j]-h[i])for j in range(i))];
print(dp[-1])

Fixed submission:
n,k,*h=map(int,open(0).read().split());
dp=[0]*n;
for i in range(1,n):
    dp[i]=min(dp[j+max(i-k,0)]+abs(a-h[i])for j,a in enumerate(h[max(i-k,0):i]));
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k,*h=map(int,open(0).read().split());
dp=[0]*n;
for i in range(1,n):
    dp[i]=min(dp[j+max(i-k,0)]+abs(a-h[i])for j,a in enumerate(h[max(i-k,0):i]));
print(dp[-1])

Fixed submission:
n,k,*h=map(int,open(0).read().split());
dp=[0]*n;
for i in range(1,n):
    dp[i]=min(dp[j+max(i-k,0)]+abs(a-h[i])for j,a in enumerate(h[max(i-k,0):i]));
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=[list(map(int,input().split()))for _ in[0]*n]
p=[0]*2**n
p[0]=1
for I in range(2**n-1):
 a=A[bin(I).count('1')]
 for j in range(n):
  if(I>>j)%2<a[j]:p[I|1<<j]+=p[I]
print(p[-1]%(10**9+7))

Fixed submission:
n=int(input());
A=[int(input().replace(' ',''),2)for _ in[0]*n]
dp=[0]*2**n
dp[0]=1
for I in range(2**n-1):
    a=A[bin(I).count('1')]&~I
    for j in range(n):
        if a&1<<j:dp[I|1<<j]=(dp[I|1<<j]+dp[I])%(10**9+7)
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=[int(input().replace(' ',''),2)for _ in[0]*n]
p=[0]*2**n
p[0]=1
for I in range(2**n-1):
 a=A[bin(I).count('1')]&~I
 for j in range(n):
  if a&1<<j:p[I|1<<j]+=p[I];p[I|1<<j]%=10**9+7
print(p[-1])

Fixed submission:
n=int(input());
A=[int(input().replace(' ',''),2)for _ in[0]*n]
dp=[0]*2**n
dp[0]=1
for I in range(2**n-1):
    a=A[bin(I).count('1')]&~I
    for j in range(n):
        if a&1<<j:dp[I|1<<j]=(dp[I|1<<j]+dp[I])%(10**9+7)
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input());
A=[int(input().replace(' ',''),2)for _ in[0]*n]
p=[0]*2**n
p[0]=1
for I in range(2**n-1):
 for j,s in enumerate(bin(A[bin(I).count('1')]&~I)[:1:-1]):
  if s=='1':p[I|1<<j]+=p[I];p[I|1<<j]%=10**9+7
print(p[-1])

Fixed submission:
n=int(input());
A=[int(input().replace(' ',''),2)for _ in[0]*n]
dp=[0]*2**n
dp[0]=1
for I in range(2**n-1):
    a=A[bin(I).count('1')]&~I
    for j in range(n):
        if a&1<<j:dp[I|1<<j]=(dp[I|1<<j]+dp[I])%(10**9+7)
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input());
A=[int(input().replace(' ',''),2)for _ in[0]*n]
p=[0]*2**n
p[0]=1
for I in range(2**n-1):
 a=A[bin(I).count('1')]&~I
 for j in range(n):
  if a&2**j:p[I+2**j]+=p[I];p[I+2**j]%=10**9+7
print(p[-1])

Fixed submission:
n=int(input());
A=[int(input().replace(' ',''),2)for _ in[0]*n]
dp=[0]*2**n
dp[0]=1
for I in range(2**n-1):
    a=A[bin(I).count('1')]&~I
    for j in range(n):
        if a&1<<j:dp[I|1<<j]=(dp[I|1<<j]+dp[I])%(10**9+7)
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input());
A=[int(input().replace(' ',''),2)for _ in[0]*n]
dp=[0]*2**n
dp[0]=1
for I in range(2**n-1):
 a=A[bin(I).count('1')]&~I
 for j in range(n):
  x=1<<j;
  if a&x:dp[I|x]+=dp[I];dp[I|x]%=10**9+7
print(dp[-1])

Fixed submission:
n=int(input());
A=[int(input().replace(' ',''),2)for _ in[0]*n]
dp=[0]*2**n
dp[0]=1
for I in range(2**n-1):
    a=A[bin(I).count('1')]&~I
    for j in range(n):
        if a&1<<j:dp[I|1<<j]=(dp[I|1<<j]+dp[I])%(10**9+7)
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input());
A=[int(input().replace(' ',''),2)for _ in[0]*n]
dp=[0]*2**n
dp[0]=1
for I in range(2**n-1):
 a=A[bin(I).count('1')]&~I
 for j in range(n):
  x=1<<j;
  if a&x:dp[I+x]+=dp[I];dp[I+x]%=10**9+7
print(dp[-1])

Fixed submission:
n=int(input());
A=[int(input().replace(' ',''),2)for _ in[0]*n]
dp=[0]*2**n
dp[0]=1
for I in range(2**n-1):
    a=A[bin(I).count('1')]&~I
    for j in range(n):
        if a&1<<j:dp[I|1<<j]=(dp[I|1<<j]+dp[I])%(10**9+7)
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
from numpy import*
M=10**9+7
f=lambda*s:[*map(int,input().split())]
n,k=f()
a=matrix([*map(f,[0]*n)])
b=eye(n,dtype=int)
while k:
 if k&1:b=b*a%M
 a=a*a%M;k>>=1
print(sum(b)%M)

Fixed submission:
from numpy import*
M=10**9+7
m=lambda:map(int,input().split())
n,k=m()
a=matrix([list(m())for i in[0]*n],'O')
b=eye(n,n,0,'O')
while k:b=[b,b*a][k&1];a=a*a%M;k>>=1
print(sum(b)%M)
Buggy python submission (verdict: Time Limit Exceeded):
n,C,*H=map(int,open(0).read().split());
dp=[0];
P=[0];
def f(I,h):
    return dp[I]+H[I]*(H[I]-2*h)
for i in range(1,n):
    h=H[i]
    while len(P)>1 and f(P[0],h)>f(P[1],h):P.pop(0)
    dp+=[f(P[0],h)+h**2+C]
    while len(P)>1 and (H[P[-1]]-H[P[-2]])*(f(P[-1],0)-f(i,0))>(h-H[P[-1]])*(f(P[-2],0)-f(P[-1],0)):P.pop()
    P+=[i]
print(dp[-1])

Fixed submission:
n,C,*H=map(int,open(0).read().split());
dp=[0];
P=[0];
def f(I,h):
    return dp[I]+H[I]*(H[I]-2*h)
def c(x,y,z):
    return (H[y]-H[x])*(f(y,0)-f(z,0))>(H[z]-H[y])*(f(x,0)-f(y,0))
for i in range(1,n):
    while len(P)>1 and f(P[0],H[i])>f(P[1],H[i]):P.pop(0)
    dp+=[f(P[0],H[i])+H[i]**2+C]
    while len(P)>1 and c(P[-2],P[-1],i):P.pop()
    P+=[i]
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,C,*H=map(int,open(0).read().split());
dp=[0];
P=[0];
f=lambda I,h:dp[I]+H[I]*(H[I]-2*h)
for i in range(1,n):
    h=H[i]
    while len(P)>1 and f(P[0],h)>f(P[1],h):P.pop(0)
    dp+=[f(P[0],h)+h**2+C]
    while len(P)>1 and (H[P[-1]]-H[P[-2]])*(f(P[-1],0)-f(i,0))>(h-H[P[-1]])*(f(P[-2],0)-f(P[-1],0)):P.pop()
    P+=[i]
print(dp[-1])

Fixed submission:
n,C,*H=map(int,open(0).read().split());
dp=[0];
P=[0];
def f(I,h):
    return dp[I]+H[I]*(H[I]-2*h)
def c(x,y,z):
    return (H[y]-H[x])*(f(y,0)-f(z,0))>(H[z]-H[y])*(f(x,0)-f(y,0))
for i in range(1,n):
    while len(P)>1 and f(P[0],H[i])>f(P[1],H[i]):P.pop(0)
    dp+=[f(P[0],H[i])+H[i]**2+C]
    while len(P)>1 and c(P[-2],P[-1],i):P.pop()
    P+=[i]
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,C,*H=map(int,open(0).read().split());
dp=[0];
P=[0];
f=lambda I,h:dp[I]+H[I]*(H[I]-2*h)
c=lambda x,y,z:(H[y]-H[x])*(f(y,0)-f(z,0))>(H[z]-H[y])*(f(x,0)-f(y,0))
for i in range(1,n):
    h=H[i]
    while len(P)>1 and f(P[0],h)>f(P[1],h):P.pop(0)
    dp+=[f(P[0],h)+h**2+C]
    while len(P)>1 and c(P[-2],P[-1],i):P.pop()
    P+=[i]
print(dp[-1])

Fixed submission:
n,C,*H=map(int,open(0).read().split());
dp=[0];
P=[0];
def f(I,h):
    return dp[I]+H[I]*(H[I]-2*h)
def c(x,y,z):
    return (H[y]-H[x])*(f(y,0)-f(z,0))>(H[z]-H[y])*(f(x,0)-f(y,0))
for i in range(1,n):
    while len(P)>1 and f(P[0],H[i])>f(P[1],H[i]):P.pop(0)
    dp+=[f(P[0],H[i])+H[i]**2+C]
    while len(P)>1 and c(P[-2],P[-1],i):P.pop()
    P+=[i]
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
N,*a=map(int,open(0))
n=N//2
a.sort()
print(2*sum(a[n+2:])-2*sum(a[:n])+a[n+1]-a[n]-N%2*min(a[~n]+a[n],2*a[n+1]))

Fixed submission:
N,*a=map(int,open(0))
n=N//2-1
a.sort()
print(2*sum(a[n+2:])-2*sum(a[:n])+a[n+1]-a[n]-N%2*min(a[~n]+a[n],2*a[n+1]))
Buggy python submission (verdict: Runtime Error):
n=int(input())
x=[0]*n
y=[0]*n
for i in range(n):
  x[i],y[i]=map(int,input().split())
  if(abs(x[i])+abs(y[i]))%2!=(abs(x[0])+abs(y[0]))%2:
    print(-1)
    exit()
d=[]
for i in reversed(range(33)):d.append(1<<i)
d+=[1,1]
if(abs(x[0])+abs(y[0]))%2==0:d.append(1)
print(len(d))
print(*d)
for i in range(n):
  X,Y=x[i],y[i]
  s=''
  for d in d:
    if abs(X)>abs(Y):
      if X>0:
        X-=d
        s+='R'
      else:
        X+=d
        s+='L'
    else:
      if Y>0:
        Y-=d
        s+='U'
      else:
        Y+=d
        s+='D'
  print(s)

Fixed submission:
n=int(input())
x=[0]*n
y=[0]*n
for i in range(n):
  x[i],y[i]=map(int,input().split())
  if(abs(x[i])+abs(y[i]))%2!=(abs(x[0])+abs(y[0]))%2:
    print(-1)
    exit()
D=[]
for i in reversed(range(33)):D.append(1<<i)
D+=[1,1]
if(abs(x[0])+abs(y[0]))%2==0:D.append(1)
print(len(D))
print(*D)
for i in range(n):
  X,Y=x[i],y[i]
  s=''
  for d in D:
    if abs(X)>abs(Y):
      if X>0:
        X-=d
        s+='R'
      else:
        X+=d
        s+='L'
    else:
      if Y>0:
        Y-=d
        s+='U'
      else:
        Y+=d
        s+='D'
  print(s)
Buggy python submission (verdict: Runtime Error):
a=map(int,input().split());print(sum(a)+9*max(a))

Fixed submission:
a=list(map(int,input().split()));print(sum(a)+9*max(a))
Buggy python submission (verdict: Runtime Error):
n=int(input());
f=0;
while n>=0:
  if n%7<1:f+=1;
  n-=4;
print(["No","Yes"][f])

Fixed submission:
n=int(input());
f=0;
while n>=0:
  if n%7<1:f+=1;
  n-=4;
print("Yes"if f>0 else"No")
Buggy python submission (verdict: Runtime Error):
a=map(int,input().split());
print(max(a)-min(a))

Fixed submission:
a=list(map(int,input().split()));print(max(a)-min(a))
Buggy python submission (verdict: Runtime Error):
eval"A,B="+gets.split*?,;p (B+B/100)*100**A

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

Fixed submission:
a,b=map(int,input().split());print(max(a+b,a-b,a*b))
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
p=list(map(int,input().split()))
pa=list(range(n))
def find(u):
  if u!=pa[u]:pa[u]=find(pa[u])
  return pa[u]
for i in range(m):
  a,b=map(int,input().split())
  a=find(a-1)
  b=find(b-1)
  if a!=b:pa[a]=b
c=0
for i in range(n):
  if find(p[i])==find(i):c+=1
print(c)

Fixed submission:
n,m=map(int,input().split())
p=list(map(int,input().split()))
pa=list(range(n))
def find(u):
  if u!=pa[u]:pa[u]=find(pa[u])
  return pa[u]
for i in range(m):
  a,b=map(int,input().split())
  a=find(a-1)
  b=find(b-1)
  if a!=b:pa[a]=b
c=0
for i in range(n):
  if find(p[i]-1)==find(i):c+=1
print(c)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print(['YES','NO'][a>c||c>a+b])

Fixed submission:
a,b,c=map(int,input().split());print(['YES','NO'][a>c or c>a+b])
Buggy python submission (verdict: Runtime Error):
a=input()
print('Yes'if a[0]!=a[1]and a[0]!=a[2]and a[1]!=a[2]else'No)

Fixed submission:
a=input()
print('Yes'if a[0]!=a[1]and a[0]!=a[2]and a[1]!=a[2]else'No')
Buggy python submission (verdict: Time Limit Exceeded):
from numpy import*
a,b=loadtxt(open(0),'i',skiprows=1)
c=0
l=2**29
while l:u=l;l//=2;c+=sum(diff(searchsorted(sort(hstack((b%u-u,b%u))),([u],[l])-a%u).T))%2*l
print(c)

Fixed submission:
from numpy import*;B=searchsorted;a,b=loadtxt(open(0),'i',skiprows=1);c=0;l=2**29
while l:h=l;l//=2;y=sort(hstack((b%h-h,b%h)));c+=sum(B(y,h-a%h)-B(y,l-a%h))%2*l
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
from numpy import*
a,b=loadtxt(open(0),'i',skiprows=1)
c=0
l=2**29
while l:u=l;l//=2;c+=sum(diff(searchsorted(sort(hstack((b%u-u,b%u))),([u],[l])-a%u).T))%2*l
print(c)

Fixed submission:
from numpy import*;B=searchsorted;a,b=loadtxt(open(0),'i',skiprows=1);c=0;l=2**29
while l:h=l;l//=2;y=sort(hstack((b%h-h,b%h)));c+=sum(B(y,h-a%h)-B(y,l-a%h))%2*l
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
from numpy import*
a,b=loadtxt(open(0),'i',skiprows=1)
c=0
l=2**29
while l:u=l;l//=2;c+=sum(diff(searchsorted(sort(hstack((b%u-u,b%u))),[[u],[l]]-a%u).T))%2*l
print(c)

Fixed submission:
from numpy import*;B=searchsorted;a,b=loadtxt(open(0),'i',skiprows=1);c=0;l=2**29
while l:h=l;l//=2;y=sort(hstack((b%h-h,b%h)));c+=sum(B(y,h-a%h)-B(y,l-a%h))%2*l
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
from numpy import*
a,b=loadtxt(open(0),'i',skiprows=1)
c=0
l=2**29
while l:u=l;l//=2;c+=sum(diff(searchsorted(sort(hstack((b%u-u,b%u))),[u-a%u,l-a%u]).T))%2*l
print(c)

Fixed submission:
from numpy import*;B=searchsorted;a,b=loadtxt(open(0),'i',skiprows=1);c=0;l=2**29
while l:h=l;l//=2;y=sort(hstack((b%h-h,b%h)));c+=sum(B(y,h-a%h)-B(y,l-a%h))%2*l
print(c)
Buggy python submission (verdict: Runtime Error):
input();print("Four"if len(Set(input().split()))>3 else"Three")

Fixed submission:
input();print("Four"if len(set(input().split()))>3 else"Three")
Buggy python submission (verdict: Runtime Error):
n,y=map(int,input().split())
for a in range(n+1):
  for b in range(9):
    c=n-a-b
    if c>=0 and a*10000+b*5000+c*1000=y:
      print(a,b,c)
      exit()
print(-1,-1,-1)

Fixed submission:
n,y=map(int,input().split())
for a in range(n+1):
  for b in range(9):
    c=n-a-b
    if c>=0 and a*10000+b*5000+c*1000==y:
      print(a,b,c)
      exit()
print(-1,-1,-1)
Buggy python submission (verdict: Runtime Error):
print(48-input())

Fixed submission:
print(48-int(input()))
Buggy python submission (verdict: Runtime Error):
import sys,itertools as o,scipy.sparse as s;_,r,*t=[map(int,i.split())for i in sys.stdin];a,b,c=zip(*t);l=s.csgraph.dijkstra(s.csr_matrix((c,(a,b)),[201]*2),0);print min(sum(int(l[i][j])for i,j in zip(a,a[1:]))for a in o.permutations(r))

Fixed submission:
import sys,itertools as o,scipy.sparse as s;_,r,*t=[map(int,i.split())for i in sys.stdin];a,b,c=zip(*t);l=s.csgraph.dijkstra(s.csr_matrix((c,(a,b)),[201]*2),0);print(min(sum(int(l[i][j])for i,j in zip(a,a[1:]))for a in o.permutations(r)))
Buggy python submission (verdict: Runtime Error):
<?php
	$s=fgets(STDIN);
	$a="None";
	for($c='a';$c<='z'&&strlen($c)==1;$c++){
		$f=0;
		for($i=0;$i<strlen($s);$i++)$f|=$s[$i]==$c;
		if(!$f){
			$a=$c;
			break;
		}
	}
	echo $a;


Fixed submission:
s=input()
a='None'
for c in 'abcdefghijklmnopqrstuvwxyz':
    f=0
    for t in s:f|=c==t
    if not f:a=c;break
print(a)
Buggy python submission (verdict: Runtime Error):
from scipy.sparse import*
f=lambda*z:list(map(int,input().split()))
n,=f()
c=[1]*~-n
print('FSennunkeec'[sum(g>h for g,h in zip(*csgraph.dijkstra(csr_matrix((c,zip(*map(f,c))),[n+1]*2),0,[1,n])))*2>=n::2])

Fixed submission:
from scipy.sparse import*;f=lambda*z:map(int,raw_input().split());n,=f();a,b=zip(*map(f,[0]*~-n));g,h=csgraph.dijkstra(csr_matrix(([1]*~-n,(a,b)),[n+1]*2),0,[1,n]);print'FSennunkeec'[sum(g[i]>h[i]for i in range(n+1))*2>=n::2]

Buggy python submission (verdict: Runtime Error):
from scipy.sparse import*;f=lambda*z:map(int,input().split());n,=f();g,h=csgraph.dijkstra(csr_matrix(([1]*~-n,zip(*map(f,[0]*~-n))),[n+1]*2),0,[1,n]);print('FSennunkeec'[sum(g[i]>h[i]for i in range(n+1))*2>=n::2])

Fixed submission:
from scipy.sparse import*;f=lambda*z:map(int,raw_input().split());n,=f();a,b=zip(*map(f,[0]*~-n));g,h=csgraph.dijkstra(csr_matrix(([1]*~-n,(a,b)),[n+1]*2),0,[1,n]);print'FSennunkeec'[sum(g[i]>h[i]for i in range(n+1))*2>=n::2]

Buggy python submission (verdict: Runtime Error):
from scipy.sparse import*;f=lambda*z:map(int,input().split());n,=f();g,h=csgraph.dijkstra(csr_matrix(([1]*~-n,zip(*map(f,[0]*~-n))),[n+1]*2),0,[1,n]);print('FSennunkeec'[sum(g[i]>h[i]for i in range(n+1))*2/n::2])

Fixed submission:
from scipy.sparse import*;f=lambda*z:map(int,raw_input().split());n,=f();a,b=zip(*map(f,[0]*~-n));g,h=csgraph.dijkstra(csr_matrix(([1]*~-n,(a,b)),[n+1]*2),0,[1,n]);print'FSennunkeec'[sum(g[i]>h[i]for i in range(n+1))*2>=n::2]

Buggy python submission (verdict: Runtime Error):
from scipy.sparse import*;f=lambda*z:map(int,input().split());n,=f();a,b=zip(*map(f,[0]*~-n));g,h=csgraph.dijkstra(csr_matrix(([1]*~-n,(a,b)),[n+1]*2),0,[1,n]);print('FSennunkeec'[sum(g[i]>h[i]for i in range(n+1))*2/n::2])

Fixed submission:
from scipy.sparse import*;f=lambda*z:map(int,raw_input().split());n,=f();a,b=zip(*map(f,[0]*~-n));g,h=csgraph.dijkstra(csr_matrix(([1]*~-n,(a,b)),[n+1]*2),0,[1,n]);print'FSennunkeec'[sum(g[i]>h[i]for i in range(n+1))*2>=n::2]
Buggy python submission (verdict: Runtime Error):
a,b,c=input().split()
print("YES" if a[-1]==b[0]&&b[-1]==c[0] else "NO")

Fixed submission:
a,b,c=input().split()
print("YES" if a[-1]==b[0] and b[-1]==c[0] else "NO")
Buggy python submission (verdict: Runtime Error):
a,b=(int(i)+11)%13 for i in input().split()
print("Bob" if a<b else "Alice" if a>b else "Draw")

Fixed submission:
a,b=[(int(i)+11)%13 for i in input().split()]
print("Bob" if a<b else "Alice" if a>b else "Draw")
Buggy python submission (verdict: Runtime Error):
s=input()
a=-1
z=0
for i in range(s.len()):
  if a<0 and s[i]=='A':a=i
  if s[i]=='Z':z=i
print(z-a+1)

Fixed submission:
s=input()
a=-1
z=0
for i in range(len(s)):
  if a<0 and s[i]=='A':a=i
  if s[i]=='Z':z=i
print(z-a+1)
Buggy python submission (verdict: Runtime Error):
a,b=input().split();for _ in[0]*int(a):print(input()*2)

Fixed submission:
a,b=input().split();
for _ in[0]*int(a):print((input()+"\n")*2)
Buggy python submission (verdict: Runtime Error):
from numpy import*
n,*a=map(int,open(0).read().split())
x=a[:n]
d=diff(x)
t=arange(n-1)
*s,=t
for i in a[-a[n]:]:t[i-2],t[i-1]=t[i-1],t[i-2]
k=a[n+1]
while k:
    if k%2:s=t[s]
    t=t[t]
    k//=2
print(*cumsum([x[0],*d[s]]))

Fixed submission:
from numpy import*
n,*a=map(int,open(0).read().split())
t=arange(n-1)
*s,=t
for i in a[-a[n]:]:t[i-2],t[i-1]=t[i-1],t[i-2]
k=a[n+1]
while k:
    if k%2:s=t[s]
    t=t[t]
    k//=2
print(*cumsum(a[:1]+list(diff(a[:n])[s])))
Buggy python submission (verdict: Runtime Error):
<?php fscanf(STDIN,"%d%d",$n,$k);echo $k*($k-1)**~-$n;

Fixed submission:
n,k=map(int,input().split());print(k*(k-1)**(n-1))
Buggy python submission (verdict: Runtime Error):
f=lambda:map(int,input().split())
h,w,n=f()
c=[(h-2)*(w-2),*[0]*9]
d={}
while n:
 n-=1;x,y=f()
 for i in range(9):
  a=(x+i%3,y+i//3)
  if h>=x+i%3>2<y+i//3<=w:d[a]=d.get(a,0)+1;c[d[a]-1]-=1;c[d[a]]+=1
print(*c)

Fixed submission:
f=lambda:map(int,input().split())
h,w,n=f()
c=[0]*10
c[0]=(h-2)*(w-2)
d={}
while n:
 n-=1;x,y=f()
 for i in range(9):
  a=(x+i%3,y+i//3)
  if h>=x+i%3>2<y+i//3<=w:d[a]=d.get(a,0)+1;c[d[a]-1]-=1;c[d[a]]+=1
print(*c)
Buggy python submission (verdict: Runtime Error):
s=input();c=[f=0]*26
for i in s:c[ord(i)-97]+=1
for i in c:f+=i%2
print("YNeos"[(f>0)::2])

Fixed submission:
s=input();c=[0]*26;f=0
for i in s:c[ord(i)-97]+=1
for i in c:f+=i%2
print("YNeos"[(f>0)::2])

Buggy python submission (verdict: Runtime Error):
s=input();c=[f=0]*26
for i in s:c[ord(i)-97]+=1
for i in c:f+=i%2
print("YNeos"[!!f::2])

Fixed submission:
s=input();c=[0]*26;f=0
for i in s:c[ord(i)-97]+=1
for i in c:f+=i%2
print("YNeos"[(f>0)::2])
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
M=len(input())
O=10**9+7
D=[pow(-~O//2,M,O)]+[0]*N
for _ in'_'*N:D=[D[0]+D[1]]+[(i+2*j)%O for i,j in zip(D[2:]+[0],D[:-1])]
print(D[M])

Fixed submission:
N=int(input())
M=len(input())
O=10**9+7
D=[pow(-~O//2,M,O)]+[0]*-~N
for _ in'_'*N:D=[((2*D[i-1]if i else D[0])+D[i+1])%O for i in range(N+1)]+[0]
print(D[M])
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
A = [i for i in range(a, b + 1)]
B = [i for i in range(c, d + 1)]
for i in A:
    if i in B:
        a = True
        break
if a == True:
    print("Yes")
else:
    print("No")


Fixed submission:
k=int(input())
print("ACL" * k)