Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02761 (python)

Fixed submission:
N,M=map(int,input().split())
S=[]
C=[]
for i in range(M):
  s,c=map(int,input().split())
  S+=[s]
  C+=[c]
tf=1
ans=[]
for i in range(N):
  ans+=[-1]
for i in range(M):
  if ans[S[i]-1] ==-1:
    ans[S[i]-1]=C[i]
  else:
    if ans[S[i]-1]!=C[i]:
      tf=0
      break
    else:
      continue
for i in range(N):
  if ans[i]==-1:
    if i!=0 or (i==0 and N==1):
      ans[i]=0
    else:
      ans[i]=1
  elif ans[i]==0 and i==0 and N!=1:
    tf=0
    break
if tf==0:
  print('-1')
else:
  ansnum=''
  for i in range(N):
    ansnum+=str(ans[i])
  print(ansnum)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
S=[]
C=[]
for i in range(M):
  s,c=map(int,input().split())
  S+=[s]
  C+=[c]
tf=1
ans=[]
for i in range(N):
  ans+=[-1]
for i in range(M):
  if ans[S[i]-1] ==-1:
    ans[S[i]-1]=C[i]
  else:
    if ans[S[i]-1]!=C[i]:
      tf=0
      break
    else:
      continue
for i in range(M):
  if ans[i]==-1:
    if i!=0:
      ans[i]=0
    else:
      ans[i]=1
if ans[0]==0:
  print('-1')
else:
  ansnum=''
  for i in range(M):
    ansnum+=str(ans[i])
  print(ansnum)
Problem p02778 (python)

Fixed submission:
S=input()
L=len(S)
ans=""
for i in range(L):
  ans+="x"
print(ans)

Buggy submission (verdict: Runtime Error):
S=input()
L=len(S)
for i in range(L):
  S[i]="x"
print(S)
Problem p02789 (python)

Fixed submission:
N,M=map(int,input().split())
if N==M:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N,M=map(int(input()))
if N==M:
  print("Yes")
else:
  print("No")
Problem p02802 (python)

Fixed submission:
N,M=map(int,input().split())
p=[]
s=[]
for i in range(M):
  p0,S0=map(str,input().split())
  p0=int(p0)-1
  p+=[p0]
  s+=[S0]
awlist=[0 for i in range(N)]
walist=[0 for i in range(N)]
wacount=0
account=0
for i in range(M):
  if s[i]=='WA' and awlist[p[i]]==0:
    walist[p[i]]+=1
  elif s[i]=='AC' and awlist[p[i]]==0:
    account+=1
    awlist[p[i]]=1
    wacount+=walist[p[i]]
Answer=[account,wacount]
print(*Answer)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
p=[]
S=[]
for i in range(M):
  p0,S0=map(int,input().split())
  p+=[p0]
  S+=[S0]
awlist=[0 for i in range(N)]
walist=[0 for i in range(N)]
wacount=0
account=0
for i in range(M):
  if s[i]=='WA' and awlist[s[i]]==0:
    walist[s[i]]+=1
  elif s[i]=='AC' and awlist[s[i]]==0:
    account+=1
    awlist[s[i]]=1
    wacount+=walist[s[i]]
Answer=[account,wacount]
print(*Answer)
Problem p02813 (python)

Fixed submission:
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
def sn(a,n):
  c=0
  for i in a:
    if i<n:
      c+=1
  return c
def comb(n):
  k=1
  if n<=1:
    return 1
  for i in range(1,n+1):
    k=k*i
  return k
def numberorder(a,n):
  s=set({})
  for i in range(1,n+1):
    s=s|{i}
  c=0
  for p in range(n):
    c+=(sn(s,a[p]))*comb(n-1-p)
    s=s-{a[p]}
  return c
P_num=numberorder(P,N)
Q_num=numberorder(Q,N)
print(abs(P_num-Q_num))

Buggy submission (verdict: Runtime Error):
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
def sn(a,n):
  c=0
  for i in a:
    if i<n:
      c+=1
  return c
def comb(n):
  k=1
  if n<=1:
    return 1
  for i in range(1,n+1):
    k=k*i
  return k
def numberorder(a):
  s={1,2,3,4,5,6,7,8}
  c=0
  for p in range(8):
    c+=(sn(s,a[p]))*comb(7-p)
    s=s-{a[p]}
  return c
P_num=numberorder(P)
Q_num=numberorder(Q)
print(abs(P_num-Q_num))
Problem p02841 (python)

Fixed submission:
M1,D1=map(int,input().split())
M2,D2=map(int,input().split())
if M2==M1+1:
  print(1)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
import math
N=int(input())
Min=N/1.08
Max=(N+1)/1.08
Mi=int(math.ceil(Min))
Ma=int(math.floor(Max))
if Ma<Mi:
  print(":(")
else:
  print(Mi)
Problem p02888 (python)

Fixed submission:
import bisect
counter=0
N=int(input())
L=sorted(list(map(int,input().split())))
for a in range(N-2):
  for b in range(a+1,N-1):
    k=bisect.bisect_left(L,L[a]+L[b])
    counter+=k-b-1
print(counter)

Buggy submission (verdict: Runtime Error):
N=int(input())
L=list(map(int,input().split()))
counter=0
for t in range(N):
  for i in range(t+1,N):
    for p in range(i+1,N):
      if L[p]<L[t]+L[i] and L[t]<L[i]+L[p] and L[i]<L[p]+L[t]:
        counter+=1
print(counter
Problem p02899 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
Answer=[0 for i in range(N)]
for t in range(N):
  Answer[A[t]-1]=t+1
print(*Answer)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(str,input().split()))
ans=[o for i in range(N)]
for i in range(N):
  ans[i]=A.index("i")
print(*ans)
Problem p02922 (python)

Fixed submission:
A,B=map(int,input().split())
if (B-1)%(A-1)==0:
  print((B-1)//(A-1))
else:
  print((B-1)//(A-1)+1)

Buggy submission (verdict: Runtime Error):
A,B=map(int,input(),split())
print((B-1)//A+1)
Problem p02969 (python)

Fixed submission:
r=int(input())
print(3*(r**2))

Buggy submission (verdict: Runtime Error):
n,d=input().split()
N=int(n)
D=int(d)
if N%(2*D+1)==0:
  print(N//(2*D+1))
else:
  print(N//(2*D+1)+1)

Buggy submission (verdict: Runtime Error):
A=input()
print(3*A**2)
Problem p02981 (python)

Fixed submission:
S=[int (i) for i in input().split()]
N=S[0]
A=S[1]
B=S[2]
TRAIN=A*N
BUS=B
if TRAIN > BUS:
  print(BUS)
else:
  print(TRAIN)

Buggy submission (verdict: Runtime Error):
S=input().split()
L=int(S[0])
R=int(S[1])
list=2018
L1=L
L2=L
while list <> 1:  
  while L2 <= R:
    while L1 < L2:
      if (L1*L2)%2019 <= list:
        list = (L1*L2)%2019
      L1 += 1
    L1 =int(L)
    L2 += 1
print(list)
Problem p03035 (python)

Fixed submission:
A,B =map(int,input().split())
if A>=13: print(B)
elif A>=6: print(int(B/2))
else : print (0)

Buggy submission (verdict: Runtime Error):
r,D,x = [int(i) for i in input().split()]
n=2000
X=r*x-D
x=X
while n <=2010: 
  print(x) 
  X=r*x-D
  x=X
  n=n+1

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
if A>=13: print(B)
elif A>=6: print(int(B/2))
else : print (0)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
if A>=13: print(B)
elif A>=6: print(B/2)
else : print (0)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
if A>=13: print(B)
elif A>=6: print(int(B/2))
else : print (0)
Problem p03136 (python)

Fixed submission:
N=int(input())
L=list(map(int,input().split()))
T=0
for i in range(N):
  T+=L[i]  
if max(L)<T-max(L):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N=int(inout())
L=list(map(int,input().split()))
T=0
for i in range(N):
  T+=L[i]  
if max(L)>T-max(L):
  print("Yes")
else:
  print("No")
Problem p03160 (python)

Fixed submission:
N=int(input())
H=list(map(int,input().split()))
dplist=[0 for i in range(N)]
dplist[0]=0
dplist[1]=abs(H[1]-H[0])
for i in range(2,N):
  dplist[i]=min(dplist[i-1]+abs(H[i]-H[i-1]),dplist[i-2]+abs(H[i-2]-H[i]))
print(dplist[N-1])

Buggy submission (verdict: Runtime Error):
N,W=map(int,input().split())
Wlist=[]
Vlist=[]
for i in range(N):
  w,v=map(int,input().split())
  Wlist+=[w]
  Vlist+=[v]
dp=[[0 for p in range(W+1)] for i in range(N)]
for i in range(W+1):
  if i>=Wlist[0]:
    dp[0][i]=Vlist[0]
for i in range(1,N):
  wi=Wlist[i]
  for j in range(W+1):
    if j-wi>=0:
      dp[i][j]=max(dp[i-1][j-wi]+Vlist[i],dp[i-1][j])
    else:
      dp[i][j]=max(dp[i-1][j],dp[i][j])
print(max(dp[N-1]))

Buggy submission (verdict: Runtime Error):
N=int(input())
ABC=[]
for i in range(N):
  l=list(map(int,input().split()))
  ABC=ABC+[l]
dp=[0,0,0]*N#dp[i][j]はi+1日目にアクティビティjを選んだ時の活動終了時の幸福量
for i in range(3):
  dp[0][i]=ABC[0][i]
for i in range(1,N):
  dp[i][1]=max(dp[i-1][2]+ABC[i][1],dp[i-1][0]+ABC[i][1])
  dp[i][0]=max(dp[i-1][1]+ABC[i][0],dp[i-1][2]+ABC[i][0])
  dp[i][2]=max(dp[i-1][1]+ABC[i][2],dp[i-1][0]+ABC[i][2])
ans=max(dp[N-1])
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
dplist=[0 for i in range(N)]
dplist[0]=0
dplist[1]=H[1]-H[0]
for i in range(2,N-1):
  dplist[i]=min(dplist(i-1)+abs(H[i]-H[i-1]),dplist(i-2)+abs(H[i-2]-H[i]))
print(dplist[N-1])

Buggy submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
dplist=[0 for i in range(N)]
dplist[0]=0
dplist[1]=H[1]-H[0]
for i in range(2,N-1):
  dplist[i]=min(dplist(i-1)+abs(H[i]-H[i-1]),dplist(i-2)+abs(H[i-2]-H[i]))
print(dolist(N-1))
Problem p03161 (python)

Fixed submission:
N,K=map(int,input().split())
H=list(map(int,input().split()))
dp=[0 for i in range(N)]
def calcmin(n,d):#インデックスがnのノードまでいくための最小コスト（最大移動距離はd）
  p=dp[n-d]+abs(H[n-d]-H[n])
  for q in range(d):
    if p>dp[n-(d-q)]+abs(H[n-(d-q)]-H[n]):
      p=dp[n-(d-q)]+abs(H[n-(d-q)]-H[n])
  return p
for i in range(min(K,N)):
  dp[i]=calcmin(i,i)
for i in range(K,N):
  dp[i]=calcmin(i,K)
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
H=list(map(int,input().split()))
dp=[0 for i in range(N)]
def calcmin(n,d):
  dp=dp[n-d]+abs(H[n-d]-H[n])
  for q in range(d):
    if dp>dp[n-(d-q)]+abs(H[n-(d-q)]-H[n]):
      dp=dp[n-(d-q)]+abs(H[n-(d-q)]-H[n])
  return dp
for i in range(K):
  dp[i]=dp[0]+abs(H[0]-H[i])
  for j in range(i-1):
    if dp[i]>dp[j]+abs(H[j]-H[i]):
      dp[i]=dp[j]+abs(H[j]-H[i])
for i in range(K,N):
  dp[i]=calcmin(i,K)
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
H=list(map(int,input().split()))
dp=[0 for i in range(N)]
def calcmin(n,d):
  dp=dp[n-d]+abs(H[n-d]-H[n])
  for q in range(d):
    if dp>dp[n-(d-q)]+abs(H[n-(d-q)]-H[n]):
      dp=dp[n-(d-q)]+abs(H[n-(d-q)]-H[n])
  return dp
for i in range(K):
  dp[i]=dp[0]+abs(H[0]-H[i])
  for j in range(i-1):
    if dp[i]>dp[j]+abs(H[j]-H[i]):
      dp[i]=dp[j]+abs(H[j]-H[i])
for i in range(K,N):
  dp[i]=calcmin(i,K)
print(dp[N-1])
Problem p03162 (python)

Fixed submission:
N=int(input())
A=[]
B=[]
C=[]
for i in range(N):
  l1,l2,l3=map(int,input().split())
  A+=[l1]
  B+=[l2]
  C+=[l3]
dp=[[0,0,0] for i in range(N)]#dp[i][j]はi+1日目にアクティビティjを選んだ時の活動終了時の幸福量
dp[0][0]=A[0]
dp[0][1]=B[0]
dp[0][2]=C[0]
for i in range(1,N):
  dp[i][1]=max(dp[i-1][2]+B[i],dp[i-1][0]+B[i])
  dp[i][0]=max(dp[i-1][1]+A[i],dp[i-1][2]+A[i])
  dp[i][2]=max(dp[i-1][1]+C[i],dp[i-1][0]+C[i])
ans=max(dp[N-1])
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
ABC=[]
for i in range(N):
  l=list(map(int,input().split()))
  ABC=ABC+[l]
dp=[0,0,0]*N#dp[i][j]はi+1日目にアクティビティjを選んだ時の活動終了時の幸福量
for i in range(3):
  dp[0][i]=ABC[0][i]
for i in range(1,N):
  dp[i][1]=max(dp[i-1][2]+ABC[i][1],dp[i-1][0]+ABC[i][1])
  dp[i][0]=max(dp[i-1][1]+ABC[i][0],dp[i-1][2]+ABC[i][0])
  dp[i][2]=max(dp[i-1][1]+ABC[i][2],dp[i-1][0]+ABC[i][2])
ans=max(dp[N-1])
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
ABC=[]
for i in range(N):
  l=list(map(int,input().split()))
  ABC=ABC+[l]
dp=[[0,0,0]*N]#dp[i][j]はi+1日目にアクティビティjを選んだ時の活動終了時の幸福量
for i in range(3):
  dp[0][i]=ABC[0][i]
for i in range(1,N):
  dp[i][1]=max(dp[i-1][2]+ABC[i][1],dp[i-1][0]+ABC[i][1])
  dp[i][0]=max(dp[i-1][1]+ABC[i][0],dp[i-1][2]+ABC[i][0])
  dp[i][2]=max(dp[i-1][1]+ABC[i][2],dp[i-1][0]+ABC[i][2])
ans=max(dp[N-1])
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
ABC=[[0 for i in range(3)]*N]
for i in range(N):
  l=list(map(int,inpujt().split()))
  ABC[i]=l
dp=[[0,0,0] for i in range(N)]#dp[i][j]はi+1日目にアクティビティjを選んだ時の活動終了時の幸福量
dp[0]=max(A[0],B[0],C[0])
for i in range(1,N):
  dp[i][1]=max(dp[i-1][2]+ABC[i][1],dp[i-1][0]+ABC[i][1])
  dp[i][0]=max(dp[i-1][1]+ABC[i][0],dp[i-1][2]+ABC[i][0])
  dp[i][2]=max(dp[i-1][1]+ABC[i][2],dp[i-1][0]+ABC[i][2])
ans=max(dp[N-1])
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=[0 for i in range(N)]
B=[0 for i in range(N)]
C=[0 for i in range(N)]
for i in range(N):
  a,b,c=map(int,input().split())
  A+=[a]
  B+=[b]
  C+=[c]
dp=[0 for i in range(N)]#dp[i]はi+1日目の活動終了時の幸福量
dpk=[o for i in range(N)]#dpk[i]はi+1日目に選んだアクティビティ
def maxk(n,x):#n番めにxになるもの（a,b,cのいずれか）
  if A[n]==x:
    return a
  elif B[n]==x:
    return b
  elif C[n]==x:
    return c
  else:
    return "error"
dp[0]=max(A[0],B[0],C[0])
dpk[0]=maxk(0,dp[0])
dp[1]=
Problem p03163 (python)

Fixed submission:
N,W=map(int,input().split())
Wlist=[]
Vlist=[]
for i in range(N):
  w,v=map(int,input().split())
  Wlist+=[w]
  Vlist+=[v]
dp=[[0 for p in range(W+1)] for i in range(N)]
for i in range(W+1):
  if i>=Wlist[0]:
    dp[0][i]=Vlist[0]
for i in range(1,N):
  wi=Wlist[i]
  for j in range(W+1):
    if j-wi>=0:
      dp[i][j]=max(dp[i-1][j-wi]+Vlist[i],dp[i-1][j])
    else:
      dp[i][j]=max(dp[i-1][j],dp[i][j])
print(max(dp[N-1]))

Buggy submission (verdict: Runtime Error):
N,W=map(int,input().split())
Wlist=[]
Vlist=[]
for i in range(N):
  w,v=map(int,input().split())
  Wlist+=[w]
  Vlist+=[v]
dp=[[0 for p in range(W)] for i in range(N)]
for i in range(N):
  wi=Wlist[i]
  if i==0:
    dp[0][Wlist[0]-1]=Vlist[0]
  else:
    for j in range(W):
      if j+wi<W:
        if j==0:
          dp[i][wi-1]=max(Vlist[i],dp[i][wi-1])
        if dp[i-1][j]!=0:
          dp[i][j+wi]=max(dp[i-1][j]+Vlist[i],dp[i][j+wi])
      dp[i][j]=max(dp[i-1][j],dp[i][j])
print(max(dp[N-1])

Buggy submission (verdict: Runtime Error):
N,W=int(input())
Wlist=[]
Vlist=[]
for i in range(N):
  w,v=map(int,input().split())
  Wlist+=[w]
  Vlist+=[v]
dp=[[0 for p in range(N)] for i in range(W)]
for i in range(N):
  wi=Wlist[i]
  for j in range(W):
    if j+wi<W:
    dp[i][j+wi]=max(dp[i-1][j]+Vlist[i],dp[i][j+wi])
    else:
      break
print(max(dp[N-1]))
Problem p03164 (python)

Fixed submission:
def main():
  N,W=map(int,input().split())
  Wlist=[]
  Vlist=[]
  for i in range(N):
    w,v=map(int,input().split())
    Wlist+=[w]
    Vlist+=[v]
  Vmax=max(Vlist)
  V=Vmax*N
  dp=[[float('inf') for p in range(V+1)] for i in range(N)]
  for i in range(V+1):
    if i<=Vlist[0]:
      dp[0][i]=Wlist[0]
  dp[0][0]=0
  for i in range(1,N):
    vi=Vlist[i]
    wi=Wlist[i]
    for j in range(V+1):
      if j-vi>=0:
        dp[i][j]=min(dp[i-1][j-vi]+wi,dp[i-1][j])
      else:
        dp[i][j]=min(dp[i-1][j],dp[i][j])
  dpn=dp[N-1]
  ans=0
  for i in range(V+1):
    if dpn[i]<=W:
      ans=i
  print(ans)
if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
N,W=map(int,input().split())
Wlist=[]
Vlist=[]
for i in range(N):
  w,v=map(int,input().split())
  Wlist+=[w]
  Vlist+=[v]
dp=[[0 for p in range(V+1)] for i in range(N)]
for i in range(V+1):
  if i<=Vlist[0]:
    dp[0][i]=Wlist[0]
for i in range(1,N):
  vi=Vlist[i]
  for j in range(V+1):
    if j-vi>=0:
      dp[i][j]=min(dp[i-1][j-vi]+Wlist[i],dp[i-1][j])
    else:
      dp[i][j]=min(dp[i-1][j],dp[i][j])
dpn=dp[N-1]
ans=0
for i in range(V+1):
  if dpn[i]<=W:
    ans=i
print(ans)

Buggy submission (verdict: Runtime Error):
N,W=map(int,input().split())
Wlist=[]
Vlist=[]
for i in range(N):
  w,v=map(int,input().split())
  Wlist+=[w]
  Vlist+=[v]
dp=[[0 for p in range(V+1)] for i in range(N)]
for i in range(V+1):
  if i<=Vlist[0]:
    dp[0][i]=Wlist[0]
for i in range(1,N):
  vi=Vlist[i]
  for j in range(V+1):
    if j-vi>=0:
      dp[i][j]=min(dp[i-1][j-vi]+Wlist[i],dp[i-1][j])
    else:
      dp[i][j]=min(dp[i-1][j],dp[i][j])
dpn=dp[N-1]
ans=0
for i in range(V+1):
  if dpn[i]<=W:
    ans=i
print(max(dp[N-1]))
Problem p03363 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
B=[0]
for i in range(N):
  B+=[B[i]+A[i]]
C=[]
ans=0      
B.sort()
c=1
for i in range(1,N+1):
  if B[i]==B[i-1]:
    c+=1
  else:
    ans+=c*(c-1)//2
    c=1
ans+=c*(c-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split())
B=[0]
for i in range(N):
  B+=[B[i]+A[i]]
C=[]
asn+=1      
for i in B:
  if i in C:
     ans+=1
  else:
     C+=[i]
print(ans)
Problem p03434 (python)

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
na=sorted(a)
Alice=0
Bob=0
Alice_turn=0
for i in range(N):
  if Alice_turn%2==0:
    Alice+=na[N-1-i]
    Alice_turn+=1
  else:
    Bob+=na[N-1-i]
    Alice_turn+=1
print(Alice-Bob)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
a=sorted(a)
Alice=0
Bob=0
Alice_turn=0
for i in range(N):
  if Alice_turn%2==even:
    Alice+=a[N-1-i]
    Alice_turn+=1
  else:
    Bob+=a[N-1-i]
print(Alice-Bob)
Problem p03493 (python)

Fixed submission:
S=str(input())
a=0
if S[0]=="1":
  a+=1
if S[1]=="1":
  a+=1
if S[2]=="1":
  a+=1
print(a)

Buggy submission (verdict: Runtime Error):
N=int(input())
L=list(map(int,input().split()))
counter=0
t=0
for p in range (30):
  t=0
  for i in range(N):
    if L[i]%2==0:
      t+=1
  if t==N:
    for i in range(N):
      L[i]=int(L[i]/2)
    counter+=1
print(counter)
Problem p03545 (python)

Fixed submission:
ABCD=input()
L=list(ABCD)

def bfs(i,j,a,c):#i,hidari,migi
  if i==3:
    if j+int(L[3])==7:
      c+=[L[0]+a[0]+L[1]+a[1]+L[2]+"+"+L[3]+"=7"]
    elif j-int(L[3])==7:
      c+=[L[0]+a[0]+L[1]+a[1]+L[2]+"-"+L[3]+"=7"]
    return 
    
  else:
    bfs(i+1,j+int(L[i]),a+"+",c)
    bfs(i+1,j-int(L[i]),a+"-",c)
    return c
  

d=[]

ans=bfs(1,int(L[0]),"",d)
print(d[0])

Buggy submission (verdict: Runtime Error):
ABCD=input()
L=list(ABCD)

def bfs(i,j,a,c):#i,hidari,migi
  if i==3:
    if j+int(L[3])==7:
      c+=[L[0]+a[0]+L[1]+a[1]+L[2]+"+"+L[3]+"=7"]
    elif j-int(L[3])==7:
      c+=[L[0]+a[0]+L[1]+a[1]+L[2]+"-"+L[3]+"=7"]
    return 
    
  else:
    bfs(i+1,j+int(L[i]),a+"+",c)
    bfs(i+1,j-int(L[i]),a+"-",c)
    return c[0]
  


print(bfs(1,int(L[0]),"",[]))
Problem p02630 (python)

Fixed submission:
array = [0 for i in range(100001)]
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

for a in A:
    array[a] += 1
souwa = sum(A)

B = []
C = []
for i in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

for i in range(Q):
    souwa = souwa + (C[i]-B[i])*array[B[i]]
    array[C[i]] += array[B[i]]
    array[B[i]] = 0
    print(souwa)

Buggy submission (verdict: Runtime Error):
array = [0 for i in range(11)]
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

for a in A:
    array[a] += 1
souwa = sum(A)

B = []
C = []
for i in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

for i in range(Q):
    souwa = souwa + (C[i]-B[i])*array[B[i]]
    array[C[i]] += array[B[i]]
    array[B[i]] = 0
    print(souwa)

Buggy submission (verdict: Runtime Error):
array = [0 for i in range(11)]
N = int(input())
A = list(map(int, input().split()))
for a in A:
    array[a] += 1

souwa = sum(A)
Q = int(input())
for i in range(Q):
    B, C = map(int, input().split())
    souwa = souwa + (C-B)*array[B]
    array[C] += array[B]
    array[B] = 0
    print(souwa)
Problem p02640 (python)

Fixed submission:
x, y = map(int, input().split())
if y%2 == 1:
  print("No")
  exit()
b = y//2 -x
a = x - b
if (a >= 0) & (b >= 0):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())
if (y-x) > =x:
  print "Yes"
else:
  print "No"

Buggy submission (verdict: Runtime Error):
x, y = map(int, input())
if (y-x) > =x:
  print "Yes"
else:
  print "No"
Problem p02732 (python)

Fixed submission:
import collections
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
v = c.values()
s = 0
for i in v:
    s += (i*(i-1))//2

for i in range(n):
    d = c[a[i]]
    x = (d*(d-1))//2 if d > 1 else 0
    y = ((d-1)*(d-2))//2 if d > 2 else 0
    print(s-x+y)

Buggy submission (verdict: Runtime Error):
import collections

sys.stdin = io.StringIO(_INPUT)
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    acopy = a.copy()
    del acopy[i]
    c = collections.Counter(acopy)
    itm = c.values()
    ans = 0
    for j in itm:
        ans += j*(j-1)//2
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    acopy = a.copy()
    del acopy[i]
    c = collections.Counter(acopy)
    itm = c.values()
    ans = 0
    for j in itm:
        ans += j*(j-1)//2
    print(ans)
Problem p02780 (python)

Fixed submission:
N, K = map(int,input().split())
p = [int(i) for i in input().split()]
P = []
P_S = [0]
ans_list = []
temp = 0

for i in range(N):
    P.append((p[i] + 1)/2)
    temp = temp + P[i]
    P_S.append(temp)
for i in range(K,N+1):
    ans_list.append(P_S[i] - P_S[i - K])

print(max(ans_list))

Buggy submission (verdict: Runtime Error):
import  copy
N, K = map(int,input().split())
p = [int(i) for i in input().split()]
P = []
P_S = []
ans_list = []
temp = 0

for i in range(N):
    P.append((p[i] + 1)/2)
    temp = temp + P[i]
    P_S.append(temp)
for i in range(N - K):
    ans_list.append(P_S[i + K] - P_S[i])

print(max(ans_list))
Problem p02841 (python)

Fixed submission:
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if M1 == M2:
    print(0)

else:
    print(1)

Buggy submission (verdict: Runtime Error):
N = input()
S = input()

i = 0
j = 0
k = 0
N = int(N)
count = 0
for a in range(10):
    for i in range(N-2):
        if str(a) == S[i]:
            for b in range(10):
                for j in range(i+1, N-1):
                    if str(b) == S[j]:
                        for c in range(10):
                            for k in range(j+1,N):
                                if str(c) == S[k]:
                                    count += 1
                                    break
                        break
            break
print(count)
Problem p02903 (python)

Fixed submission:
h, w, a, b = map(int, input().split())
for i in range(b):
    for j in range(a):
        print(0, end='')
    for j in range(w - a):
        print(1, end='')
    print()
for i in range(h - b):
    for j in range(a):
        print(1, end='')
    for j in range(w - a):
        print(0, end='')
    print()

Buggy submission (verdict: Runtime Error):
h, w, a, b = map(int, input().split())
for i in range(b):
    for j in range(a):
        print(0, end=4)
    for j in range(w - a):
        print(1, end=4)
    print()
for i in range(h - b):
    for j in range(a):
        print(1, end=4)
    for j in range(w - a):
        print(0, end=4)
    print()

Buggy submission (verdict: Runtime Error):
LL = [int(i) for i in input().split()]
H = LL[0]
W = LL[1]
A = LL[2]
B = LL[3]

Math = [[0 for a in range(W)] for b in range(H)] 

for i in range(A):
    for j in range(B):
        Math[i][j] = 1

for i in range(W - A):
    for j in range(H - B):
        Math[H - i][W -j] = 1

for i in range(H):
    print(*Math)

Buggy submission (verdict: Runtime Error):
LL = [int(i) for i in input().split()]
H = LL[0]
W = LL[1]
A = LL[2]
B = LL[3]

Math = [[0 for a in range(W)] for b in range(H)] 

for i in range(A):
    for j in range(B):
        Math[i][j] = 1

for i in range(W - A):
    for j in range(H - B):
        Math[W - i][H -B] = 1

for i in range(H):
    print(*Math)

Buggy submission (verdict: Runtime Error):
LL = [int(i) for i in input().split()]
H = LL[0]
W = LL[1]
A = LL[2]
B = LL[3]

Frag = True
Math = [[0 for a in range(W)] for b in range(H)] 

for i in range(A):
    for j in range(B):
        Math[i][j] = 1

for i in range(W - A):
    for j in range(H - B):
        Math[W - i][H -B] = 1
        
for i in range(H):
    print(*Math)
Problem p02921 (python)

Fixed submission:
S = input()
T = input()

count = 0

for i in range(3):
    if S[i] == T[i]:
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):
N = (int(input()))

print(int((1 / 2) * N * (N - 1)))
Problem p02953 (python)

Fixed submission:
N = int(input())
H_list = list(map(int,input().split()))
Flag = True

if N != 1:
    for i in range(N-1):
        if H_list[N-1-i-1] - H_list[N-1-i] > 1:
            Flag = False
            break
        elif H_list[N-1-i-1] - H_list[N-1-i] == 1:
            H_list[N-1-i-1] = H_list[N-1-i-1] -1
        else:
            continue
    
if Flag == True:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
H_list = list(map(int,input().split()))
Flag = False
if N == 1:

    print("Yes")
    
else:
    for i in range(N):
        if H_list[N-1-i-1] - H_list[N-1-i] > 1:
            print("No")
            break
        elif H_list[N-1-i-1] - H_list[N-1-i] = 1:
            H_list[N-1-i-1] = H_list[N-1-i-1] -1
        else
    
    Flag = True

if Flag = True:
    print("Yes")