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

Fixed submission:
n,r=map(int,input().split())
if n>10:
	print(r)
else:
	print(r+1000-100*n)

Buggy submission (verdict: Runtime Error):
n,r=map(int,input().split())
if n>10:
	print(r)
else:
	print(r-1000+100*k)
Problem p02969 (python)

Fixed submission:
a=int(input())
print(a*a*3)

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  	cin>>n;
  cout<<n*n*3<<endl;
}
Problem p02983 (python)

Fixed submission:
l,r=map(int,input().split())
ans=int(10000000)
if r-l>2019:
    print(0)
    exit()

for i in range(l,r):
    for j in range(i+1,r+1):
        now=int((i*j)%2019)
        if ans>now:
            ans=now

print(ans)

Buggy submission (verdict: Runtime Error):
l,r=map(int,input().split())
if r-l>2019:
    print(0)
    exit()

ans=int(10000000)
for i in range(l,r):
    for j in range(j+1,r+1):
        if ans>i*j:
            ans=i*j

print(ans)
Problem p03264 (python)

Fixed submission:
n=int(input())
o=int(n/2)
e=int((n+1)/2)
print(o*e)

Buggy submission (verdict: Runtime Error):
n=int(input())
print((k//2)*((k+1)//2))

Buggy submission (verdict: Runtime Error):
n=int(input())
print((k//2)*(k//2+1))
Problem p03387 (python)

Fixed submission:
A=list(map(int,input().split()))
ans=int(0)
m=max(A)
for i in range(3):
    now=int((m-A[i])/2)
    ans+=now
    A[i]+=2*now

check=int(0)
for i in range(3):
    check+=m-A[i]
if check==0:
    print(ans)
elif check==2:
    print(ans+1)
else:
    print(ans+2)

Buggy submission (verdict: Runtime Error):
A=lsit(map(int,input().split()))
ans=int(0)
m=max(A)
for i in range(3):
    now=int((m-A[i])/2)
    ans+=now
    A[i]+=2*now

check=int(0)
for i in range(3):
    check+=m-A[i]
if check==0:
    print(ans)
elif check==2:
    print(ans+1)
else:
    print(ans+2)
Problem p03658 (python)

Fixed submission:
n,k=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
ans=int(0)
for i in range(n-k,n):
	ans+=A[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
ans=int(0)
for i in ramge(n-k,n):
	ans+=A[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
ans=int(0)
for i in ramge(n-k,n):
    ans+=A[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
ans=int(0)
for i in ramge(n-k,n):
    ans+=A[i]
print(ans)
Problem p03681 (python)

Fixed submission:
n,m=map(int,input().split())
if abs(n-m)>1:
    print(0)

else:
    ans=int(1)
    for i in range(1,n+1):
        ans*=i
        ans%=1000000007
    
    for i in range(1,m+1):
        ans*=i
        ans%=1000000007

    if n==m:
        ans*=2
        ans%=1000000007
    
    print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
if abs(n-m)>1:
    print(0)

ans=int(1)
for i in range(1,n+1):
    ans*=i
    
for i in range(1,m+1):
    ans*=i

if n==m:
    ans*=2

if abs(n-m)>1:
    ans=0

print(ans%=1000000007)
Problem p03695 (python)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
B=[0,0,0,0,0,0,0,0]
red=int(0)
for i in range(n):
    now=int(A[i]/400)
    if now<8:
        B[now]=1
    else:
        red+=1

ans=B.count(1)
if ans==0:
    ans=1
    red-=1
print("{} {}".format(ans,ans+red))

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
B=[0,0,0,0,0,0,0,0]
red=int(0)
for i in range(n):
    now=int(A[i]/400)
    if now<=8:
        B[now]=1
    else:
        red+=1

ans=B.count(1)
print("{} {}".format(ans,ans+red))

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
B=[0,0,0,0,0,0,0,0,0]
for i in range(n):
    now=int(A[i]/400)
    B[now]+=1

ans=int(0)
for i in range(8):
    if B[i]>0:
        ans+=1
    
print("{} {}".format(ans,ans+B[8]))
Problem p03796 (python)

Fixed submission:
n=int(input())
ans=int(1)
for i in range(1,n+1):
    ans*=i
    ans%=1000000007
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=int(1)
for i in range(1,n+1):
	ans*=i
    ans%=1000000007
print(ans)
Problem p03807 (python)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
co=int(0)
for i in range(n):
    if A[i]%2==1:
        co+=1
if co%2==1:
    print("NO")
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
n=int(input())
co=int(0)
for i in range(n):
    now=int(input())
    if now%2==1:
        co+=1
if co%2==1:
    print("NO")
else:
    print("YES")
Problem p03963 (python)

Fixed submission:
n,k=map(int,input().split())
print(k*pow(k-1,n-1))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
print(n*pow(n-1,k-1))
Problem p04043 (python)

Fixed submission:
a,b,c=map(int,input().split())
if	a*b*c==5*5*7:
	print("YES")
else:
	print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if	a*b*c==5*5*7
	print("YES")
else
	print("NO")
Problem p02554 (python)

Fixed submission:
n,m=int(input()),10**9+7
print((pow(10,n,m)-2*pow(9,n,m)+pow(8,n,m))%m)

Buggy submission (verdict: Runtime Error):
n,m=int(input()),10**9+7
print((pow(10,p,m)-2*pow(9,p,m)+pow(8,p,m))%m)
Problem p02576 (python)

Fixed submission:
import math
n,x,t=map(int,input().split())
print(math.ceil(n/x)*t)

Buggy submission (verdict: Runtime Error):
h,w,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(m)]
b,c=[0]*h,[0]*w
for t1,t2 in a:
    b[t1-1]+=1
    c[t2-1]+=1
bm,cm=max(b),max(c)
b1,c1=[],[]
d=[]
for x,y in a:
    d.append((x-1,y-1))
d=set(d)
for i in range(h):
    if b[i]==bm:
        b1.append(i)
for i in range(w):
    if c[i]==cm:
        c1.append(i)
f=1
for i in b1:
    for j in c1:
        if (i,j) not in d:
            f=0
print(bm+cm-f)
Problem p02586 (python)

Fixed submission:
r,c,k=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(k)]
dp=[[[0 for _ in range(c+1)]for _ in range(r+1)]for _ in range(5)]
for x,y,z in a:
    dp[4][x][y]=z
for i in range(1,r+1):
    for j in range(1,c+1):
        v=dp[4][i][j]
        dp[0][i][j]=max(dp[0][i][j-1],dp[0][i-1][j],dp[1][i-1][j],dp[2][i-1][j],dp[3][i-1][j])
        dp[1][i][j]=max(dp[1][i][j-1],dp[0][i][j-1]+v,dp[0][i-1][j]+v,dp[1][i-1][j]+v,dp[2][i-1][j]+v,dp[3][i-1][j]+v)
        dp[2][i][j]=max(dp[2][i][j-1],dp[1][i][j-1]+v)
        dp[3][i][j]=max(dp[3][i][j-1],dp[2][i][j-1]+v)
print(max([dp[i][r][c] for i in range(4)]))

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
input = sys.stdin.readline
def main():
    r,c,k=map(int,input().split())
    a=[list(map(int,input().split())) for _ in range(k)]
    dp=np.array([[[0,0,0,0,0]for _ in range(c+1)]for _ in range(r+1)])
    b=[[0 for _ in range(c+1)] for _ in range(r+1)]
    for x,y,z in a:
        b[x][y]=z
    for i in range(1,r+1):
        for j in range(1,c+1):
            v=b[i][j]
            if b==0:
                dp[i][j][0]=max(dp[i][j-1][0],dp[i-1][j][0],dp[i-1][j][1],dp[i-1][j][2],dp[i-1][j][3])
                dp[i][j][1]=dp[i][j-1][1]
                dp[i][j][2]=dp[i][j-1][2]
                dp[i][j][3]=dp[i][j-1][3]
            else:
                dp[i][j][0]=max(dp[i][j-1][0],dp[i-1][j][0],dp[i-1][j][1],dp[i-1][j][2],dp[i-1][j][3])
                dp[i][j][1]=max(dp[i][j-1][1],dp[i][j-1][0]+v,dp[i-1][j][0]+v,dp[i-1][j][1]+v,dp[i-1][j][2]+v,dp[i-1][j][3]+v)
                dp[i][j][2]=max(dp[i][j-1][2],dp[i][j-1][1]+v)
                dp[i][j][3]=max(dp[i][j-1][3],dp[i][j-1][2]+v)
    print(max(dp[i][j]))

if __name__ == "__main__":
    main()
Problem p02630 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
q=int(input())
l=[0]*10**6
s=sum(a)
for i in range(n):
    l[a[i]]+=1
for i in range(q):
    b,c=map(int,input().split())
    s+=(c-b)*l[b]
    l[c]+=l[b]
    l[b]=0
    print(s)

Buggy submission (verdict: Runtime Error):
import math
n,k=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
l,r=-1,10**19
while r-l>1:
    m=(l+r)//2
    b=0
    for w,d in a:
        b+=(m-w+d)//d
    if b<k:
        l=m
    else:
        r=m
print(r+1)
Problem p02642 (python)

Fixed submission:
n,x=int(input()),10**6+100
a,b,c=list(map(int,input().split())),[0]*(2*x),0
for i in a:
    b[i]+=1
for i in range(x):
    c+=1 if b[i]==1 else 0
    if b[i]==0:
        continue
    for j in range(1,x):
        if i*j>=x:
            break
        b[i*j]=0
print(c)

Buggy submission (verdict: Runtime Error):
def ra(a): #圧縮された要素を非保持
    ll,l=[],1
    for i in range(len(a)-1):
        if a[i]==a[i+1]:
            l+=1
        else:
            ll.append(l)
            l=1
    ll.append(l)
    return ll

n=int(input())
a=list(map(int,input().split()))
b=[1]*(10**6+10)
c=0
d=ra(a)
for i in d:
    if i!=1:
        c-=i
for i in range(n):
    e=a[i]
    for j in range(2,10**6+4):
        b[a[i]*j]=0
        if a[i]*(j+1)>=10**6+5:
            break
for i in range(n):
    c+=b[a[i]]
print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=[1]*(2*10**6)
c=0
for i in range(n):
    j=a[i]
    while j<19*10**5:
        b[j+a[i]]=0
        j+=a[i]
a.sort()
if a==[a[0]]*n:
    c-=1
for i in range(n-1):
    if a[i]==a[i+1]:
        c-=1
        f=1
        if f==0:
            c-=1
    else:
        f=0
for i in range(n):
    c+=b[a[i]]
print(c)
Problem p02765 (python)

Fixed submission:
a,b=map(int,input().split())
if a>=10:
    print(b)
else:
    print(b+(100*(10-a)))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a>9:
    print(b)
else:
    print(b+(100＊(10-a))
Problem p02802 (python)

Fixed submission:
n,m=map(int,input().split())
a=[]
for i in range(n):
    a.append([0,0])
b=[]
c=0
d=0
for i in range(m):
    b.append(list(input().split()))
    b[i][0]=int(b[i][0])
a=sorted(a,key=lambda x:x[0])
for i in range(m):
    if b[i][1]=='WA':
        if a[b[i][0]-1][0]==0:
            a[b[i][0]-1][1]+=1
    else:
        if a[b[i][0]-1][0]==0:
            a[b[i][0]-1][0]=1
for i in range(n):
    c+=a[i][0]
    if a[i][0]==1:
        d+=a[i][1]
print(c,d)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
w,l=0,[0]*n
for i in range(m):
    p,s=input().split()
    p,f=int(p)-1,l[p]>=0
    if s=='AC':
        w+=l[p]*f
        l[p]=-1
    else:
        l[p]+=f
print(l.count(-1),w)
Problem p02837 (python)

Fixed submission:
n=int(input())
s=[]
ans=0
for i in range(n):
    a=int(input())
    s.append([list(map(int,input().split())) for _ in range(a)])
for i in range(2**n):
    bit=bin(i)[2:].zfill(n)
    flag=1
    for j in range(n):
        if bit[j]=='0':
            continue
        for sh in s[j]:
            if int(bit[sh[0]-1])!=sh[1]:
                flag=0
    if flag:
        ans=max(ans,bit.count('1'))
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a,c,e,f=[],[],0,0
for i in range(n):
    a.append(int(input()))
    b=[]
    for i in range(a[-1]):
        b.append(list(map(int,input().split())))
    c.append(b)
for i in range(2**n):
    d=bin(i)[2:-1]+bin(i)[-1]
    d='0'*(n-len(d))+d
    for j in range(n):
        if d[j]==1:
            e+=1
    for j in range(n):
        if d[j]==0:
            continue
        for k in range(a[j]):
            if d[c[j][k][0]]!=c[j][k][1]:
                g=True
                continue
    if g:
        continue
    f=max(e,f)
print(f)
Problem p02900 (python)

Fixed submission:
import math
def euclid(a,b):
    if b==0:
        return a
    else:
        return euclid(b,a%b)
def factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a
z=list(map(int,input().split()))
print(len(set(factorize(euclid(z[0],z[1]))))+1)

Buggy submission (verdict: Runtime Error):
import math
def factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a
z=list(map(int,input().split()))
print(len(set(factorize(math.gcd(z[0],z[1]))))+1)

Buggy submission (verdict: Runtime Error):
import math
def factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a
z=list(map(int,input().split()))
print(len(set(factorize(math.gcd(z[0],z[1]))))+1)
Problem p02918 (python)

Fixed submission:
import sys
n=list(map(int,input().split()))
s=input()
a,b,c=[],s[0],0
if n[0]==1:
    print('0')
    sys.exit()
for i in range(n[0]-1):
    if b==s[i+1]:
        c+=1
    else:
        a.append(c)
        c=0
    b=s[i+1]
if c!=0:
    a.append(c)
if s[-2]==s[-1]:
    a[-1]+=1
else:
    a.append(1)
if n[1]>=len(a)//2:
    print(n[0]-1)
else:
    print(sum(a)+2*n[1]-1)

Buggy submission (verdict: Runtime Error):
n=list(map(int,input().split()))
s=input()
a,b,c=[],s[0],0
if n[0]==1:
    print('0')
for i in range(n[0]-1):
    if b==s[i+1]:
        c+=1
    else:
        a.append(c)
        c=0
    b=s[i+1]
if c!=0:
    a.append(c)
if s[-2]==s[-1]:
    a[-1]+=1
else:
    a.append(1)
if n[1]>=len(a)//2:
    print(n[0]-1)
else:
    print(sum(a)+2*n[1]-1)
Problem p02923 (python)

Fixed submission:
import sys
n=int(input())
h=list(map(int,input().split()))
a,b=0,[]
if len(h)==1:
    print('0')
    sys.exit()
for i in range(1000000):
    if h[i]<h[i+1]:
        b.append(i-a)
        a=i+1
    if i+2==len(h):
        b.append(i-a+1)
        break
print(max(b))

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
a,b=0,[]
for i in range(1000000):
    if h[i]<h[i+1]:
        b.append(i-a)
        a=i+1
    if i+2==len(h):
        b.append(i-a+1)
        break
print(max(b))

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
a,b=0,[]
for i in range(1000000):
    if h[i]<h[i+1]:
        b.append(i-a)
        a=i+1
    if i+2==len(h):
        b.append(i-a+1)
        break
print(b)
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
n,q=map(int,input().split())
edge=[[] for i in range(n)]
a=[0]*n
b=[0]*n
for i in range(n-1):
    x,y=map(int,input().split())
    edge[x-1].append(y-1)
    edge[y-1].append(x-1)
for i in range(q):
    p,x=map(int,input().split())
    a[p-1]+=x
def dfs(node,tmp):
    a[node]+=tmp
    b[node]=1
    for i in edge[node]:
        if b[i]==0:
            dfs(i,a[node])
dfs(0,0)
print(*a)

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
edge=[[] for i in range(n)]
a=[0]*n
b=[0]*n
for i in range(n-1):
    x,y=map(int,input().split())
    edge[x-1].append(y-1)
    edge[y-1].append(x-1)
for i in range(q):
    p,x=map(int,input().split())
    a[p-1]+=x
def dfs(node,tmp):
    a[node]+=tmp
    b[node]=1
    for i in edge[node]:
        if b[i]==0:
            dfs(i,a[node])
dfs(0,0)
print(*a)
Problem p02947 (python)

Fixed submission:
def ra(a): #圧縮された要素を非保持
    ll,l=[],1
    for i in range(len(a)-1):
        if a[i]==a[i+1]:
            l+=1
        else:
            ll.append(l)
            l=1
    ll.append(l)
    return ll

n=int(input())
print(sum([i*(i-1)//2 for i in ra(sorted([''.join(sorted(i)) for i in [input() for i in range(n)]]))]))

Buggy submission (verdict: Runtime Error):
n=int(input())
print(len(set([sorted(i) for i in [input() for i in range(n)]])))
Problem p02969 (python)

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

Buggy submission (verdict: Runtime Error):
N=int(input()) 
a=[int(input()) for i in range(N)]
b=sorted(a)
n=0
while True:
    if n==a.index(max(a)):
        print(b[-2])
    else:
        print(b[-1])
    n+=1
    if n==N:
        break
Problem p02975 (python)

Fixed submission:
import sys
N=int(input())
a=list(map(int,input().split()))
b,c,d=0,1,0
while True:
    while True:
        if a[b]%(2**c)>=2**(c-1):
            d+=1
        b+=1
        if b==N:
            if d%2==1:
                print('No')
                sys.exit()
            else:
                break
    b,d=0,0
    c+=1
    if c==27:
        break
print('Yes')

Buggy submission (verdict: Runtime Error):
import sys
N=int(input())
a=list(map(int,input().split()))
b,c,d=0,1,0
while True:
    while True:
        e==2**c
        if a[b]%(e)>=e/2:
            d+=1
        b+=1
        if b==N:
            if d%2==1:
                print('No')
                sys.exit()
            else:
                break
    b,d=0,0
    c+=1
    if c==27:
        break
print('Yes')
Problem p02981 (python)

Fixed submission:
a=list(map(int,input().split()))
print(min(a[0]*a[1],a[2]))

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().sprit()))
print(min(a[0]*a[1],a[2]))

Buggy submission (verdict: Runtime Error):
a=list(map(int,input.split()))
print(min(a[0]*a[1],a[2]))

Buggy submission (verdict: Runtime Error):
a=list(map(int,input.sprit()))
print(min(a[0]*a[1],a[2]))
Problem p02993 (python)

Fixed submission:
a=input()
if a[0]==a[1] or a[1]==a[2] or a[2]==a[3]:
    print('Bad')
else:
    print('Good')

Buggy submission (verdict: Runtime Error):
a=int(input())
if a[0]==a[1] or a[1]==a[2] or a[2]==a[3]:
    print('Bad')
else:
    print('Good')
Problem p03000 (python)

Fixed submission:
a=list(map(int,input().split()))
L=list(map(int,input().split()))
N=a[0]
X=a[1]
l=[0]
n=0
n1=0
while True:
    l.append(L[n]+l[n])
    n=n+1
    if n==N:
        break
while True:
    if l[n1]<=X:
        n1+=1
    else:
        print(n1)
        break
    if n1==N:
        if X>=l[-1]:
            print(n1+1)
            break
        else:            
            print(n1)
            break

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().split()))
L=list(map(int,input().split()))
N=a[0]
X=a[1]
l=[0]
n=0
n1=0
while True:
    l.append(L[n]+l[n])
    n=n+1
    if n==N:
        break
while True:
    if l[n1]<=X:
        n1+=1
    else:
        print(n1)
        break
Problem p03031 (python)

Fixed submission:
n,m=map(int,input().split())
a,c=[],0
for i in range(m):
    a.append(list(map(int,input().split())))
p=list(map(int,input().split()))
for i in range(2**n):
    i,b='0'*(n-len(bin(i))+2)+bin(i)[2:],0
    for j in range(m):
        f=0
        for k in range(a[j][0]):
            f+=int(i[a[j][k+1]-1])
        if f%2==p[j]:
            b+=1
    if b==m:
        c+=1
print(c)

Buggy submission (verdict: Runtime Error):
N,M=input().strip().split()
l1=[]
while True:
    try:
        l1.append(list(map(int,input().split())))
    except:
        break;
l2=l1[-1]
del l1[-1]
n=0
tate=0
yoko=1
count1=0
count2=0
count3=0
while True:
    while True:        
        sw=str(bin(n))
        del sw[0]
        a=l1[tate][yoko]
        if int(sw[a])==1:
            count1=count1+1
        yoko=yoko+1
        if yoko==l1[tate][0]:
            yoko=1
            if count1%2==l2[tate]:
                count2=count2+1
            break
    tate=tate+1
    if tate==M:
        if count2==N:
            count3=1
        n=n=1
        break
Problem p03043 (python)

Fixed submission:
import math
n,k=map(int,input().split())
a=0
k=math.log2(k)
for i in range(n):
    a+=2**-max(math.ceil(k-math.log2(i+1)),0)/n
print(a)

Buggy submission (verdict: Runtime Error):
a=input().split()
N=int(a[0])
K=int(a[1])
count=0
n=1
while True:
    count=count+0.5**math.ceil(math.log2(K)-math.log2(n))/n
    n=n+1
    if n==N:
        break
print(count)
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
n=int(input())
edge=[[] for _ in range(n)]
dist=[-1]*n
for i in range(n-1):
    x,y,z=map(int,input().split())
    edge[x-1].append([y-1,z])
    edge[y-1].append([x-1,z])
def dfs(node,d):
    dist[node]=d
    for i in edge[node]:
        if dist[i[0]]==-1:
            dfs(i[0],d+i[1])
dfs(0,0)
print(*[i%2 for i in dist],sep='\n')

Buggy submission (verdict: Runtime Error):
n=int(input())
edge=[[] for _ in range(n)]
dist=[-1]*n
for i in range(n-1):
    x,y,z=map(int,input().split())
    edge[x-1].append([y-1,z])
    edge[y-1].append([x-1,z])
def dfs(node,d):
    dist[node]=d
    for i in edge[node]:
        if dist[i[0]]==-1:
            dfs(i[0],d+i[1])
dfs(0,0)
print(*[i%2 for i in dist],sep='\n')
Problem p03062 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[abs(i) for i in a]
print(sum(b)-sum(i<0 for i in a)%2*min(b)*2)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
count=0
countk=0
saidaiti=0
while True:
    saidaiti=saidaiti+abs(a[count])
    count=count+1
    if a[count]%2==1:
        countk=countk+1
    if count==n:
        break
if countk%2==1:
    saidaiti=saidaiti-2*a[-1]
print(saidaiti)
Problem p03071 (python)

Fixed submission:
a=0
b=0
s=list(map(int, input().split()))
if s[0]==s[1]:
    print(2*s[0])
    b=1
elif s[0]>s[1]:
    a=s[0]
    s[0]=s[0]-1
else:
    a=s[1]
    s[1]=s[1]-1
if s[0]==s[1]:
    a=a+s[0]
elif s[0]>s[1]:
    a=a+s[0]
else:
    a=a+s[1]
if b==0:
    print(a)

Buggy submission (verdict: Runtime Error):
b=0
s=list(map(int, input().split()))
if s[0]==s[1]:
    print(2*s[0])
    b=1
elif s[0]>s[1]:
    a=s[0]
    s[0]=s[0]-1
else:
    a=s[1]
    s[1]=s[1]-1
if s[0]==s[1]:
    a=a+s[0]
elif s[0]>s[1]:
    a=a+s[0]
else:
    a=a+s[1]
if b==0:
    print(a)
Problem p03087 (python)

Fixed submission:
def Csum(a):
    b,c=[0],0
    for i in range(len(a)-1):
        c+=(a[i]=='A' and a[i+1]=='C')
        b.append(c)
    return b
n,q=map(int,input().split())
s=Csum(input())
for i in range(q):
    a,b=map(int,input().split())
    print(s[b-1]-s[a-1])

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().split()))
n,q,b,c=a[0],a[1],[],[]
s=input()
for i in range(q):
    b.append(list(map(int,input().split())))
for i in range(len(s)):
    if s[i]=='A' and s[i+1]=='C':
        c.append(1)
    else:
        c.append(0)
for i in range(q):
    print(sum(c[b[i][0]-1:b[i][1]-1]))

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().split()))
n,q,b,c=a[0],a[1],[],[]
s=input()
for i in range(q):
    b.append(list(map(int,input().split())))
for i in range(len(s)):
    if s[i]=='A' and s[i+1]=='C':
        c.append(1)
    else:
        c.append(0)
for i in range(q):
    print(sum(c[b[i][0]-1:b[i][1]-1]))
Problem p03125 (python)

Fixed submission:
a=list(map(int,input().split()))
if a[1]%a[0]==0:
    print(a[0]+a[1])
else:
    print(a[1]-a[0])

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().sprit()))
if a[1]%a[0]==0:
    print(a[0]+a[1])
else:
    print(a[1]-a[0])
Problem p03160 (python)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
dp=[10**9]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(n-1):
    dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]))
    if i+2<n:
        dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]))
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**9]*n
dp[0]=0
for i in range(n-1):
    for j in range(i+1,min(i+k+1,n)):
        dp[j]=min(dp[j],dp[i]+abs(h[j]-h[i]))
print(dp[-1])