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

Fixed submission:
a,p=map(int,input().split(' '))
print(int((3*a+p)/2))

Buggy submission (verdict: Runtime Error):
a,p=map(int,input().split(' '))
print(int((3*a+p)/2)
Problem p03037 (python)

Fixed submission:
isstr=input()
n,m = [int(i) for i in isstr.split(' ')]
l=[0]*m
r=[0]*m
for i in range(m):
    l[i],r[i]=[int(i)-1 for i in input().split(' ')]
x=min(r)-max(l)+1
x=x if x>0 else 0
print(x)

Buggy submission (verdict: Runtime Error):
isstr=input()
n,m = [int(i) for i in isstr.split(' ')]
l=[0]*m
r=[0]*m
for i in range(m):
    l[i],r[i]=[int(i)-1 for i in input().split(' ')]
a=[0]*n
for i in range(m):
    for j in range(l[i],r[i]+1):
        a[j]+=1
print(len([_ for i in a if i==m]))

Buggy submission (verdict: Runtime Error):
isstr=input()
n,m = [int(i) for i in isstr.split(' ')]
l=[0]*m
r=[0]*m
for i in range(m):
    l[i],r[i]=[int(i) for i in input().split(' ')]
a=[0]*n
for i in range(m):
    for j in range(l[i],r[i]+1):
        a[j+1]=1
print(sum(a))

Buggy submission (verdict: Runtime Error):
isstr=input()
n,m = [int(i) for i in isstr.split(' ')]
l=[0]*m
r=[0]*m
for i in range(m):
    l[i],r[i]=[int(i) for i in input().split(' ')]
a=[0]*n
for i in range(m):
    a[l[i]-1]=1
    a[l[i]]=1
    a[r[i]-1]=1
print(sum(a))
Problem p02789 (python)

Fixed submission:
n,m=map(int,input().split())

if n==m:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
mod=10**9+7

n=int(input())

a=list(map(int,input().split()))

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(a,b):
    return a//gcd(a,b)*b

lcma=1

for i in range(n):
    lcma=lcm(lcma,a[i])

ans=0

for i in range(n):
    ans=(ans+lcma//a[i])

print(ans%mod)

Buggy submission (verdict: Runtime Error):
import fractions

mod=10**9+7

n=int(input())

a=list(map(int,input().split()))

def lcm(a,b):
    return a//fractions.gcd(a,b)*b

lcma=1

for i in range(n):
    lcma=lcm(lcma,a[i])%mod

def modpow(x,y,mod):
    res=1
    while y>0:
        if y&1:
            res=res*x%mod
        x=x*x%mod
        y>>=1
    return res

def modinv(x,mod):
    return modpow(x,mod-2,mod)

ans=0

for i in range(n):
    ans=(ans+lcma*modinv(a[i],mod)%mod)%mod

print(ans)
Problem p02924 (python)

Fixed submission:
N=int(input())

s=N*(N+1)//2

print(s-N)

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

print(sum(list(range(N+1)))-N)
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10000000)
input=sys.stdin.readline

N,Q=map(int,input().split())

T=[[] for i in range(N)]

for i in range(N-1):
    a,b=map(int,input().split())
    T[a-1].append(b-1)
    T[b-1].append(a-1)

O=[0 for i in range(N)]

for i in range(Q):
    p,x=map(int,input().split())
    O[p-1]+=x

def dfs(n):
    for i in T[n]:
        if r[i]:continue
        r[i]=1
        O[i]+=O[n]
        dfs(i)

r=[1]+[0]*(N-1)

dfs(0)

print(*O)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

N,Q=map(int,input().split())

T=[[] for i in range(N)]

for i in range(N-1):
    a,b=map(int,input().split())
    T[a-1].append(b-1)
    T[b-1].append(a-1)

O=[0 for i in range(N)]

for i in range(Q):
    p,x=map(int,input().split())
    O[p-1]+=x

def dfs(n):
    for i in T[n]:
        if r[i]==1:continue
        r[i]=1
        O[i]+=O[n]
        dfs(i)

r=[1]+[0]*(N-1)

dfs(0)

print(*O)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

N,Q=map(int,input().split())

T=[[] for i in range(N)]

for i in range(N-1):
    a,b=map(int,input().split())
    T[a-1].append(b-1)
    T[b-1].append(a-1)

O=[0 for i in range(N)]

for i in range(Q):
    p,x=map(int,input().split())
    O[p-1]+=x

def dfs(n):
    for i in T[n]:
        if r[i]==1:continue
        r[i]=1
        O[i]+=O[n]
        dfs(i)

f=[1]+[0]*(N-1)

dfs(0,-1)

print(*O)

Buggy submission (verdict: Runtime Error):
N,Q=map(int,input().split())

T=[[] for i in range(N)]

for i in range(N-1):
    a,b=map(int,input().split())
    T[a-1].append(b-1)
    T[b-1].append(a-1)

O=[0 for i in range(N)]

for i in range(Q):
    p,x=map(int,input().split())
    O[p-1]+=x

def dfs(n,r):
    for i in T[n]:
        if i!=r:
            O[i]+=O[n]

            dfs(i,n)

dfs(0,-1)

print(*O)

Buggy submission (verdict: Runtime Error):
N,Q=map(int,input().split())

T=[[] for i in range(N)]

for i in range(N-1):
    a,b=map(int,input().split())
    T[a-1].append(b-1)
    T[b-1].append(a-1)

O=[0 for i in range(N)]

for i in range(Q):
    p,x=map(int,input().split())
    O[p-1]+=x

def dfs(n,r):
    for i in T[n]:
        if i==r:
            continue
        O[i]+=O[n]

        dfs(i,n)

dfs(0,-1)

print(*O)

Buggy submission (verdict: Runtime Error):
N,Q=map(int,input().split())

T=[[] for i in range(N)]

for i in range(N-1):
    a,b=map(int,input().split())
    T[a-1].append(b-1)
    T[b-1].append(a-1)

O=[0 for i in range(N)]

for i in range(Q):
    p,x=map(int,input().split())
    O[p-1]+=x

def dfs(n,r):
    for i in T[n]:
        if i==r:
            continue
        O[i]+=O[n]

        dfs(i,n)

dfs(0,-1)

print(*O)
Problem p02953 (python)

Fixed submission:
N=int(input())

H=list(map(int,input().split()))

H[0]-=1

s=0

if N>1:
    if H[0]>H[1]:
        s=1
    
    for i in range(1,N-1):
        if H[i]>H[i-1]:
            H[i]-=1
        if H[i]>H[i+1]:
            s=1


if s==1:
    print('No')
else:
    print('Yes')

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

H=list(map(int,input().split()))

H[0]-=1

s=0

if H[0]>H[1]:
    s=1
    
for i in range(1,N-1):
    if H[i]>H[i-1]:
        H[i]-=1
    if H[i]>H[i+1]:
        s=1

if s==1:
    print('No')
else:
    print('Yes')
Problem p03006 (python)

Fixed submission:
N=int(input())

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

XY.sort()

d={}

if N==1:
    print(1)
else:
    for i in range(N-1):
        for j in range(i+1,N):
            if str(XY[j][0]-XY[i][0])+' '+str(XY[j][1]-XY[i][1]) in d:
                d[str(XY[j][0]-XY[i][0])+' '+str(XY[j][1]-XY[i][1])]+=1
            else:
                d[str(XY[j][0]-XY[i][0])+' '+str(XY[j][1]-XY[i][1])]=1
            
    print(N-max(d.values()))

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

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

XY.sort()

d={}

for i in range(N-1):
    for j in range(i+1,N):
        if str(XY[j][0]-XY[i][0])+' '+str(XY[j][1]-XY[i][1]) in d:
            d[str(XY[j][0]-XY[i][0])+' '+str(XY[j][1]-XY[i][1])]+=1
        else:
            d[str(XY[j][0]-XY[i][0])+' '+str(XY[j][1]-XY[i][1])]=1
            
print(N-max(d.values()))

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

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

XY.sort()

d={}

for i in range(N):
    for j in range(i+1,N):
        if str(XY[j][0]-XY[i][0])+' '+str(XY[j][1]-XY[i][1]) in d:
            d[str(XY[j][0]-XY[i][0])+' '+str(XY[j][1]-XY[i][1])]+=1
        else:
            d[str(XY[j][0]-XY[i][0])+' '+str(XY[j][1]-XY[i][1])]=1
            
print(N-max(d.values()))
Problem p03031 (python)

Fixed submission:
N,M=map(int,input().split())

s=[[0 for i in range(N)] for j in range(M)]

for i in range(M):
    tmp=list(map(int,input().split()))

    k=tmp[0]
    for j in range(k):
        s[i][tmp[j+1]-1]=1

p=list(map(int,input().split()))

out=0

for i in range(2**N):
    b=list(map(int,list(bin(i))[2:]))
    b=[0 for j in range((N-len(b)))]+b
    ss=1
    for j in range(M):
        t=0
        for k in range(N):
            if b[k]==1 and s[j][k]==1:
                t+=1
        if t%2!=p[j]:
            ss=0
    if ss==1:
        out+=1

print(out)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())

s=[[0 for i in range(N)] for j in range(M)]

for i in range(M):
    tmp=list(map(int,input().split()))

    k=tmp[0]
    for j in range(k):
        s[i][tmp[j+1]-1]=1

p=list(map(int,input().split()))

out=0

for i in range(2**N):
    b=list(map(int,list(bin(i))[2:]))
    b=[0 * (N-len(b))]+b
    ss=1
    for j in range(M):
        t=0
        for k in range(N):
            if b[k]==s[j][k]:
                t+=1
        if t%2!=p[j]:
            ss=0
    if ss==1:
        out+=1

print(out)
Problem p03076 (python)

Fixed submission:
A=[]

for i in range(5):
    A.append(int(input()))

m=10
s=10

for i in range(5):
    if A[i]%10<m and A[i]%10!=0:
        m=A[i]%10
        s=i

su=0

for i in range(5):
    if i==s:
        su+=A[i]
    elif A[i]%10!=0:
        su+=(A[i]//10+1)*10
    else:
        su+=A[i]
        
print(su)

Buggy submission (verdict: Runtime Error):
A=[]

for i in range(5):
    A.append(int(input()))

m=10

for i in range(5):
    if A[i]%10<m and A[i]%10!=0:
        m=A[i]%10
        s=i

su=0

for i in range(5):
    if i==s:
        su+=A[i]
    elif A[i]%10!=0:
        su+=(A[i]//10+1)*10
    else:
        su+=A[i]
print(su)
Problem p03078 (python)

Fixed submission:
X,Y,Z,K=map(int,input().split())
     
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
     
r=[]
out=[]
     
for i in range(X):
    for j in range(Y):
        r.append(A[i]+B[j])
     
r.sort(reverse=True)
     
if len(r)>K:
    for i in range(K):
        for j in range(Z):
            out.append(r[i]+C[j])
else:
    for i in range(len(r)):
        for j in range(Z):
           out.append(r[i]+C[j])
     
out.sort(reverse=True)
     
for i in range(K):
    print(out[i])

Buggy submission (verdict: Runtime Error):
X,Y,Z,K=map(int,input().split())

A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

r=[]
out=[]

for i in range(X):
    for j in range(Y):
        r.append(A[i]+B[j])

r.sort(reverse=True)

for i in range(K):
    for j in range(Z):
        out.append(r[i]+C[j])

out.sort(reverse=True)

for i in range(K):
    print(out[i])
Problem p03087 (python)

Fixed submission:
N,Q=map(int,input().split())
S=input()

c=0
s=[0]
for i in range(1,N):
    if S[i-1]=='A' and S[i]=='C':
        c+=1
    s.append(c)
    
for i in range(Q):
    l,r=map(int,input().split())
    out=s[r-1]-s[l-1]

    print(out)

Buggy submission (verdict: Runtime Error):
N,Q=map(int,input().split())
S=input()

c=0
s=[0]
for i in range(1,N):
    if S[i-1]=='A' and S[i]=='C':
        c+=1
    s.append(c)

    print(s)
    
for i in range(Q):
    l,r=map(int,input().split())
    out=s[r-1]-s[l-1]

    print(out)
Problem p03111 (python)

Fixed submission:
N,A,B,C=map(int,input().split())

l=[int(input()) for i in range(N)]

INF=3000

def mp(co,a,b,c):
    if co==N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF

    ret0=mp(co+1,a,b,c)
    ret1=mp(co+1,a+l[co],b,c)+10
    ret2=mp(co+1,a,b+l[co],c)+10
    ret3=mp(co+1,a,b,c+l[co])+10

    return min(ret0,ret1,ret2,ret3)

print(mp(0,0,0,0))

Buggy submission (verdict: Runtime Error):
N,A,B,C=map(int,input().split())

l=[int(input()) for i in range(N)]

INF=3000

def mp(co,a,b,c):
    if co==N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF

    ret0=mp(co+1,a,b,c)
    ret1=mp(co+1,a+1,b,c)+10
    ret2=mp(co+1,a,b+1,c)+10
    ret3=mp(co+1,a,b,c+1)+10

    return min(ret0,ret1,ret2,ret3)

print(mp(0,0,0,0))
N,A,B,C=map(int,input().split())

l=[int(input()) for i in range(N)]

INF=3000

def mp(co,a,b,c):
    if co==N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF

    ret0=mp(co+1,a,b,c)
    ret1=mp(co+1,a+1,b,c)+10
    ret2=mp(co+1,a,b+1,c)+10
    ret3=mp(co+1,a,b,c+1)+10

    return min(ret0,ret1,ret2,ret3)

print(mp(0,0,0,0))

Buggy submission (verdict: Runtime Error):
N,A,B,C=map(int,input().split())

l=[int(input()) for i in range(N)]

INF=3000

def mp(c,a,b,c):
    if c==N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF

    ret0=mp(c+1,a,b,c)
    ret1=mp(c+1,a+1,b,c)+10
    ret2=mp(c+1,a,b+1,c)+10
    ret3=mp(c+1,a,b,c+1)+10

    return min(ret0,ret1,ret2,ret3)

print(mp(0,0,0,0))

Buggy submission (verdict: Runtime Error):
N,A,B,C=map(int,input().split())

l=[int(input()) for i in range(N)]

INF=3000

def mp(c,a,b,c):
    return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF

    ret0=mp(c+1,a,b,c)
    ret1=mp(c+1,a+1,b,c)+10
    ret2=mp(c+1,a,b+1,c)+10
    ret3=mp(c+1,a,b,c+1)+10

    return min(ret0,ret1,ret2,ret3)

print(mp(0,0,0,0))
Problem p03455 (python)

Fixed submission:
a,b=map(int,input().split())
if a%2==0 or b%2==0:
  print('Even')
else:
  print('Odd')

Buggy submission (verdict: Runtime Error):
  a,b=map(int,input().split())
  if a//2==0 or b//2==0:
    print('Even')
  else:
    print('Odd')
Problem p02823 (python)

Fixed submission:
def main():
    n, a, b = map(int, input().split())
    if abs(a - b) % 2 == 0:
        print(abs(a - b) // 2)
    else:
        mi = min(a, b) - 1
        ma = n - max(a, b)
        print(min(mi, ma) + (abs(a - b) + 1) // 2)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
 def main():
    n, a, b = map(int, input().split())
    if abs(a - b) % 2 == 0:
        print(abs(a - b) // 2)
    else:
        mi = min(a, b) - 1
        ma = n - max(a, b)
        print(min(mi, ma) + (abs(a - b) + 1 // 2))


if __name__ == '__main__':
    main()
Problem p03282 (python)

Fixed submission:
s = input()
k = int(input())

for i in range(k):
    if s[i] == '1':
        continue
    else:
        print(s[i])
        break
else:
    print(1)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())

if all(s[i] == '1' for i in range(k + 1)):
    print(1)

print(s.replace('1', '')[0])

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())

for i in range(k + 1):
    if s[i] == '1':
        continue
    else:
        print(s[i])
        break
else:
    print(1)
Problem p03659 (python)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]

left = 0
right = sum(a)

diff = []

for i in range(n - 1):
    left += a[i]
    right -= a[i]
    diff.append(abs(left - right))

print(min(diff))

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
a = [int(x) for x in input().split()]

l = 0
r = sum(a)

d = math.inf

for i in range(n - 1):
    l += a[i]
    r -= a[i]
    d = min(d, abs(l - r))

print(d)
Problem p03681 (python)

Fixed submission:
import math

n, m = map(int, input().split())

if abs(n - m) > 1:
    print(0)
    exit()

a = max(n, m)
b = min(n, m)


if a - b == 1:
    print(math.factorial(a) * math.factorial(b) % (10 ** 9 + 7))
else:
    print(math.factorial(a) * math.factorial(b) * 2 % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
import math

n, m = map(int, input().split())

diff = abs(n - m)

if diff > 1:
    print(0)
elif diff == 1:
    print(math.factorial(a) * math.factorial(b) % (10 ** 9 + 7))
else:
    print(math.factorial(a) * math.factorial(b) * 2 % (10 ** 9 + 7))
Problem p02850 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 6)

N = int(input())

edges = [[] for _ in range(N)]

for i in range(N - 1):
    a, b = map(int,input().split())
    edges[a - 1].append([b - 1, i])

colors = [-1] * (N - 1)

def func(a, p_color=-1):
    color = 1
    for b, i in edges[a]:
        if color == p_color:
            color += 1
        colors[i] = color
        func(b, color)
        color += 1

func(0, -1)

print(max(colors))
for c in colors:
    print(c)

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

edges = [[] for _ in range(N)]

for i in range(N - 1):
    a, b = map(int,input().split())
    edges[a - 1].append([b - 1, i])

colors = [-1] * (N - 1)

def func(a, p_color=-1):
    color = 1
    for b, i in edges[a]:
        if color == p_color:
            color += 1
        colors[i] = color
        func(b, color)
        color += 1

func(0, -1)

print(max(colors))
for c in colors:
    print(c)

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

edges = [[] for _ in range(N)]

for i in range(N - 1):
    a, b = map(int,input().split())
    edges[a - 1].append([b - 1, i])

colors = [-1] * (N - 1)

def func(a, p_color=-1):
    edge_index = []
    color = 1
    for b, i in edges[a]:
        if color == p_color:
            color += 1
        colors[i] = color
        func(b, color)
        color += 1

func(1, -1)

print(max(colors))
for c in colors:
    print(c)

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

edges = []

for _ in range(N - 1):
    a, b = map(int,input().split())
    edges.append([a, b])

colors = [-1] * (N - 1)

def func(a, p_color=-1):
    edge_index = []
    for i in range(N - 1):
        _a, _b = edges[i]
        if _a == a:
            edge_index.append(i)

    color = 1
    for e_i in edge_index:
        if color == p_color:
            color += 1
        __a, __b = edges[e_i]
        colors[e_i] = color
        func(__b, color)
        color += 1

func(1)

print(max(colors))
for c in colors:
    print(c)
Problem p02886 (python)

Fixed submission:
N = int(input())

d = list(map(int, input().split()))

total = 0
for i in range(N):
    for j in range(i+1, N):
        total += d[i] * d[j]

print(total)

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

d = map(int, input().split())

total = 0
for i in range(N):
    for j in range(i+1, N):
        total += d[i] * d[j]

print(total)
Problem p02887 (python)

Fixed submission:
N = int(input())
S = input()

prev = S[0]

num = 1
for s in S[1:]:
    if prev != s:
        num += 1
    prev = s

print(num)

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

prev = S[0]:

num = 1
for s in S[1:]:
    if prev != s:
        num += 1
    prev = s

print(num)
Problem p02900 (python)

Fixed submission:
import fractions

A, B = map(int, input().split())

C = fractions.gcd(A, B)

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b += 1
    if n > 1:
        fct.append(n)
    return fct

print(len(list(set(factorize(C)))) + 1)

Buggy submission (verdict: Runtime Error):
import fractions

A, B = map(int, input().split())

C = fractions.gcd(A, B)

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b += 1
    if n > 1:
        fct.append(n)
    return act

print(len(list(set(factorize(C)))) + 1)

Buggy submission (verdict: Runtime Error):
import fractions

A, B = map(int, input().split())

C = fractions.gcd(A, B)

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b += 1
    if n > 1:
        fct.append(n)
    return act

print(len(list(set(factorize(C))) + 1)

Buggy submission (verdict: Runtime Error):
import math

A, B = map(int, input().split())

C = math.gcd(A, B)

def factorization(n):
    count = 0
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            count += 1
            while temp % i == 0:
                temp //= i

    return count

print(factorization(C) + 1)
Problem p02901 (python)

Fixed submission:
N, M = map(int, input().split())

inf = 10 ** 10

dp = [inf] * (1 << N)
dp[0] = 0

for _ in range(M):
    a, b = map(int, input().split())
    c = sum([2 ** (i - 1) for i in map(int, input().split())])

    for j in range(1 << N):
      dp[j | c] = min(dp[j] + a, dp[j | c])

res = dp[-1] if dp[-1] != inf else -1
print(res)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input.split())

inf = 10 ** 10

dp = [inf] * (1 << N)

for _ in range(M):
    a, b = map(int, input.split())
    c = sum([2 ** (i - 1) for i in map(int, input.split())])

    for j in range(1 << N):
        if dp[j] + a < dp[j | c]:
            dp[j | c] = dp[j] + a

res = dp[-1] if dp[-1] != inf else -1
print(res)
Problem p02922 (python)

Fixed submission:
import math

A, B = map(float, input().split())

print(int(math.ceil((B - 1.0) / (A - 1.0))))

Buggy submission (verdict: Runtime Error):
import math

A = float(input())
B = float(input())

print(int(math.ceil((B - 1.0) / (A - 1.0))))
Problem p02936 (python)

Fixed submission:
from collections import deque

N, Q = map(int, input().split())

edges = [[] for _ in range(N)]

for _ in range(N - 1):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

counter = [0] * N
checked = [False] * N

for i in range(Q):
    p, x = map(int, input().split())
    counter[p - 1] += x

queue = deque()
queue.append(0)

while queue:
    root = queue.pop()
    checked[root] = True
    for e in edges[root]:
        if checked[e] == False:
            queue.append(e)
            counter[e] += counter[root]

print(" ".join(map(str, counter)))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 6)

N, Q = map(int, input().split())

edges = [[] for _ in range(N)]

for _ in range(N - 1):
    a, b = map(int, input().split())
    edges[a-1].append(b - 1)

counter = [0] * N

def process(root, value):
    counter[root] += value
    for next_root in edges[root]:
        process(next_root, value)

for _ in range(Q):
    p, x = map(int, input().split())
    process(p - 1, x)

print(" ".join(counter))

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())

edges = [[] for _ in range(N)]

for _ in range(N - 1):
    a, b = map(int, input().split())
    edges[a-1].append(b - 1)

counter = [0] * N

def process(root, value):
    counter[root] += value
    for next_root in edges[root]:
        process(next_root, value)

for _ in range(Q):
    p, x = map(int, input().split())
    process(p - 1, x)

print(" ".join(map(str, counter)))
Problem p02946 (python)

Fixed submission:
K, X = map(int, input().split())

print(" ".join(list(map(str, range(X - K + 1, X + K)))))

Buggy submission (verdict: Runtime Error):
K, X = map(int, input())

print(" ".join(list(range(X - K, X + K + 1))))
Problem p04001 (python)

Fixed submission:
S = input()

def func(num, code):
    total = 0
    start = 0
    length = len(num)

    for i in range(1, length):
        if code & 1 == 1: #一番下にビットが立ってるなら
            total = total + int(num[start:i])
            start = i
        code = code >> 1

    total = total + int(num[start:length])

    return total

total_of_all = 0

for i in range(2 ** (len(S) - 1)):
    total_of_all = total_of_all + func(S, i)

print(total_of_all)

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

def func(num, code):
    total = 0
    start = 0
    length = len(num)

    for i in range(1, length):
        if code & 1 == 1: #一番下にビットが立ってるなら
            total = total + int(num[start:i])
            start = i
        code = code >> 1

    total = total + int(num[start:i + 1])

    return total

total_of_all = 0

for i in range(2 ** (len(S) - 1)):
    total_of_all = total_of_all + func(S, i)

print(total_of_all)

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

def func(num, code):
    total = 0
    start = 0
    length = len(num)

    for i in range(1, length):
        if code & 1 == 1: #一番下にビットが立ってるなら
            total = total + int(num[start:i])
            start = i
        code = code >> 1

    total = total + int(num[start:i + 1])

    return total

total_of_all = 0

for i in range(2 ** (len(S) - 1)):
    print(func(S, i))
    total_of_all = total_of_all + func(S, i)

print(total_of_all)
Problem p02882 (python)

Fixed submission:
import math

a, b, x = (int(_) for _ in input().split())

L3 = b * (a**2)
x2  = L3 - x

if x >= x2:
    h = 2 * (x2 / (a**2))
    print(math.degrees(math.atan(h/a)))
else:
    h = 2 * (x  / (a*b))
    print(90-math.degrees(math.atan(h/b)))

Buggy submission (verdict: Runtime Error):
import math

a, b, x = (int(_) for _ in input().split())

aab  = b * (a**2)
y    = aab-x

if y <= x:
    tan0 = y / (a**3)
    tan0 = tan0 * 2
    print(math.degrees(math.atan(tan0)))
else:
    tan0 = x / a
    tan0 = (tan0 * 4)/(b**2)
    print(90-math.degrees(math.asin(tan0))/2)

Buggy submission (verdict: Runtime Error):
import math

a, b, x = (int(_) for _ in input().split())

aab  = b * (a**2)
y    = aab-x

if aab/2 <= x:
    tan0 = y / (a**3)
    tan0 = tan0 * 2
    print(math.degrees(math.atan(tan0)))
else:
    tan0 = x / a
    tan0 = (tan0 * 4)/(b**2)
    print(90-math.degrees(math.asin(tan0))/2)