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

Fixed submission:
c = input()
print(chr(ord(c) + 1))

Buggy submission (verdict: Runtime Error):
n,k,m = map(int,input().split())
a = list(map(int,input().split()))
x = 0
for i in range(n-1):
    x+=a[i]
if n*m - x <= k:
    print(n*m-x)
else:
    print(-1)
Problem p02811 (python)

Fixed submission:
k,x = map(int,input().split())
if 500*k >= x:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(input())
count = 0
for i in range (n-2):
    if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
        count += 1
print(count)
Problem p02817 (python)

Fixed submission:
s,t = input().split()
print(t+s)

Buggy submission (verdict: Runtime Error):
s,t = map(input().split())
print(t+s)
Problem p03282 (python)

Fixed submission:
s=input()
k=int(input())
ans=1
for i in range(k):
    if s[i] != '1':
        ans=s[i]
        break
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())
ans=1
for i in range(k+1):
    if s[i] != '1':
        ans=s[i]
        break
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())
ans=1
for i in range(k+1):
    if s[i] != '1':
        ans=s[i]
        break
print(ans)
Problem p03434 (python)

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
alice = 0
bob = 0
a.sort(reverse=True)
for i in range(N):
    if i%2 == 0:
        alice += a[i]
    else:
        bob += a[i]
print(alice - bob)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
alice=0
bob=0
a=sorted(a)
while a:
    alice+=a[-1]
    a.pop()
    bob+=a[-1]
    a.pop()
print(alice-bob)
Problem p03457 (python)

Fixed submission:
n=int(input())
t=[0]*(n+1)
x=[0]*(n+1)
y=[0]*(n+1)
for i in range(n):
    t[i+1],x[i+1],y[i+1] = map(int,input().split())

flag=True
for i in range(n):
    time=t[i+1]-t[i]
    dist=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
    if dist>time:
        flag=False
    if dist%2 != time%2:
        flag=False
if flag == True:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
t=[0]*3
x=[0]*3
y=[0]*3
for i in range(n):
    t[i+1],x[i+1],y[i+1] = map(int,input().split())

flag=True
for i in range(n):
    time=t[i+1]-t[i]
    dist=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
    if dist>time:
        flag=False
    if dist%2 != time%2:
        flag=False
if flag == True:
    print('Yes')
else:
    print('No')
Problem p03778 (python)

Fixed submission:
w,a,b=map(int,input().split())
if a<b:
    if b-(a+w) < 0:
        print(0)
    else:
        print(b-(a+w))
else:
    if a-(b+w) < 0:
        print(0)
    else:
        print(a-(b+w))

Buggy submission (verdict: Runtime Error):
,a,b=map(int,input().split())
if a<b:
    if b-(a+w) < 0:
        print(0)
    else:
        print(b-(a+w))
else:
    if a-(b+w) < 0:
        print(0)
    else:
        print(a-(b+w))
Problem p03971 (python)

Fixed submission:
n,a,b=map(int,input().split())
s=input()
cnt=0
cnt_f=0
for i in range(n):
    if s[i] == 'a' and cnt < a+b:
        print('Yes')
        cnt+=1
    elif s[i] == 'b' and cnt < a+b and cnt_f < b:
        print('Yes')
        cnt+=1
        cnt_f+=1
    elif s[i] == 'c':
        print('No')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
s=input()
cnt=0
for i in range(n):
    if s[i] == 'a' and cnt < a+b:
        print('Yes')
        cnt+=1
    elif s[i] == 'b' and cnt < a+b and i+1 <=b:
        print('Yes')
        cnt+=1
    elif s[i] == 'c':
        print('No')
    else:
        print('No')
Problem p02607 (python)

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
c=0
for i in range(n):
  if (i+1)%2!=0 and arr[i]%2!=0:
    c+=1
print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
arr=list(map(int,input().split()))
c=0
for i in range n:
  if i%2!=0 and arr[i]%2!=0:
    c+=1
print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
arr=list(map(int,input().split()))
c=0
for i in range n:
  if 1%2!=0 and arr[i]%2!=0:
    c+=1
print(c)
Problem p02717 (python)

Fixed submission:
a, b, c = map(int, input().split())
print('{} {} {}'.format(c, a, b))

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
print('{} {} {}'.format(c, a, b)
Problem p02719 (python)

Fixed submission:
a, b = map(int, input().split())
print(min(a % b, b - (a % b)))

Buggy submission (verdict: Runtime Error):
print(int(input()) % int(input()))
Problem p02714 (python)

Fixed submission:
N = int(input())
S = input()
count_R = 0
count_G = 0
count_B = 0
count = 0
for i in range(N):
    if S[i] == 'R':
        count_R = count_R+1
    elif S[i] == 'G':
        count_G = count_G+1
    else:
        count_B = count_B+1
count = count_R*count_G*count_B

for i in range(N):
  for j in range(i+1,N):
    if S[i] != S[j]:
      k = 2*j-i
      if k>=N:
        break
      else:
        if S[i] != S[k] and S[j] != S[k]:
          count = count-1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
count_R = 0
count_G = 0
count_B = 0
count = 0
for i in range(N):
    if S[i] == 'R':
        count_R = count_R+1
    elif S[i] == 'G':
        count_G = count_G+1
    else:
        count_B = count_B+1
count = count_R*count_G*count_B

for i in range(N):
  for j in range(i+1,N):
    if S[i] != S[j]:
      k = 2*j-1
      if k>N:
        break
      else:
        if S[i] != S[k] and S[j] != S[k]:
          count = count-1
print(count)
Problem p02789 (python)

Fixed submission:
import sys

N,M = map(int,input().split())
if M == 0:
  print('No')
  sys.exit()
if N/M == 1:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
H,M = map(int,input().split())
if H/M == 1:
  print('Yes')
else:
  print('No')
Problem p02802 (python)

Fixed submission:
N,M = map(int,input().split())
p = ['0']*M
S = ['0']*M
for i in range(M):
  p[i],S[i]= map(str,input().split())
AC = [0]*(N+1)
WA = [0]*(N+1)
i = 0
for i in range(M):
  if S[i] == 'WA':
    if AC[int(p[i])] == 0:
      WA[int(p[i])] = WA[int(p[i])]+1
    else:
      None
  else:
    AC[int(p[i])]=1
count = 0
for i in range(N+1):
  if AC[i]==0:
    count = count+WA[i]
print(sum(AC),sum(WA)-count)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
pS = [[0,0] for i in range(M)]
for i in range(M):
  pS[i]= list(map(str,input().split()))
p = [0]*M
S = [0]*M
for i in range(M):
  p[i] = pS[i][0]
  S[i] = pS[i][1]
NM = N*M
AC = [0]*NM
WA = [0]*NM
i = 0
while i < M:
  if S[i] == 'WA':
    if AC[int(p[i])] != 1:
      WA[int(p[i])] = WA[int(p[i])]+1
    i = i+1
  elif S[i] == 'AC':
    AC[int(p[i])]=1
    i = i+1
  else:
    i = i+1
print(sum(AC),sum(WA))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
pS = [[0,0] for i in range(M)]
for i in range(M):
  pS[i]= list(map(str,input().split()))
p = [0]*M
S = [0]*M
for i in range(M):
  p[i] = pS[i][0]
  S[i] = pS[i][1]
NM = N*M
AC = [0]*NM
WA = [0]*NM
i = 0
while i < M:
  if S[i] == 'WA':
    if AC[int(p[i])] == 0:
      WA[int(p[i])] = WA[int(p[i])]+1
    i = i+1
  elif S[i] == 'AC':
    AC[int(p[i])]=1
    i = i+1
  else:
    i = i+1
print(sum(AC),sum(WA))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
pS = [[0,0] for i in range(M)]
for i in range(M):
  pS[i]= list(map(str,input().split()))
p = [0]*M
S = [0]*M
for i in range(M):
  p[i] = pS[i][0]
  S[i] = pS[i][1]
NM = N*M
AC = [0]*NM
WA = [0]*NM
i = 0
while i < M:
  if S[i] != 'AC':
    if AC[int(p[i])] == 0:
      WA[int(p[i])] = WA[int(p[i])]+1
    i = i+1
  elif S[i] == 'AC':
    AC[int(p[i])]=1
    i = i+1
  else:
    i = i+1
print(sum(AC),sum(WA))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
pS = [[0,0] for i in range(M)]
for i in range(M):
  pS[i]= list(map(str,input().split()))
p = [0]*M
S = [0]*M
for i in range(M):
  p[i] = pS[i][0]
  S[i] = pS[i][1]
AC = [0]*N
WA = [0]*N
i = 0
while i < M:
  if S[i] != 'AC':
    if AC[int(p[i])] == 0:
      WA[int(p[i])] = WA[int(p[i])]+1
    i = i+1
  elif S[i] == 'AC':
    AC[int(p[i])]=1
    i = i+1
  else:
    i = i+1
print(sum(AC),sum(WA))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
p = [0]*M
S = [0]*M
pS = [[0,0] for i in range(M)]
for i in range(M):
  pS[i]= list(map(str,input().split()))
pS.sort()
for i in range(M):
  p[i] = pS[i,0]
  S[i] = PS[i,1]
AC = 0
WA = 0
p1 = '0'
i = 0
while i < M:
  if p[i] != p1 and S[i] != 'AC':
    WA = WA+1
    i = i+1
  elif p[i] != p1 and S[i] == 'AC':
    p1 = p[i]
    AC = AC+1
    i = i+1
  else:
    i = i+1
print(AC,WA)
Problem p02945 (python)

Fixed submission:
A,B = list(map(int,input().split()))
a=[0]*3
a[0]=A+B
a[1]=A-B
a[2]=A*B
print(max(a))

Buggy submission (verdict: Runtime Error):
A,B = list(map(int,input().split()))
ans=[0]*3
a[0]=A+B
a[1]=A-B
a[2]=A*B
print(max(a))
Problem p02971 (python)

Fixed submission:
N=int(input())
A=[int(input()) for i in range(N)]
MAX1=max(A)
copyA=A.copy()
copyA.remove(MAX1)
MAX2=max(copyA)
for i in A:
  if (i==MAX1):
    print(MAX2)
  else:
    print(MAX1)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=[int(input()) for i in range(N)]
MAX1=max(A)
copyA=A.copy()
copyA.remove(MAX)
MAX2=max(copyA)
for i in A:
  if (i==MAX1):
    print(MAX2)
  else:
    print(MAX1)
Problem p02607 (python)

Fixed submission:
import sys
from io import StringIO
import unittest
import numpy as np

def resolve():
    li = sys.stdin.readlines()
    N = int(li[0].strip())
    a = list(map(int, li[1].strip().split(' ')))
    A = np.array(a[0::2])
    A = (A % 2 == 1)
    print(A.sum())
resolve()

Buggy submission (verdict: Runtime Error):
import sys
from io import StringIO
import unittest
import numpy as np

def resolve():
    li = sys.stdin.readlines()
    N = int(li[0].strip())
    a = list(map(int, li[1].strip().split(' ')))
    A = np.array(a[0::2])
    A = (A % 2 == 1)
    print(A.sum())
resolve()
Problem p02618 (python)

Fixed submission:
import sys
import numpy as np
TYPE_NUM = 26

def resolve():

    inp = sys.stdin.readlines()
    D = int(inp[0])
    c = np.array(list(map(int, inp[1].split(' '))))
    s = []
    last = np.zeros(TYPE_NUM, dtype=int)
    types = []

    for i in range(2, len(inp)):
        s.append(list(map(int, inp[i].split(' '))))
    s = np.array(s, dtype=int)

    for d in range(D):
        opt_delta_satis = -10 ** 32
        opt_idx = 0
        for idx in range(TYPE_NUM):
            val = s[d, idx]
            org = last[idx]
            last[idx] = d+1
            temp_delta_satis = np.sum(-c*(d+1-last)) + val
            if opt_delta_satis < temp_delta_satis:
                opt_delta_satis = temp_delta_satis
                opt_idx = idx
            last[idx] = org
        types.append(opt_idx+1)
    print(*types, sep='\n')

resolve()

Buggy submission (verdict: Runtime Error):
import numpy as np
TYPE_NUM = 26

def resolve():

    inp = sys.stdin.readlines()
    D = int(inp[0])
    c = np.array(list(map(int, inp[1].split(' '))))
    s = []
    last = np.zeros(TYPE_NUM, dtype=int)
    types = []

    for i in range(2, len(inp)):
        s.append(list(map(int, inp[i].split(' '))))
    s = np.array(s, dtype=int)

    for d in range(D):
        opt_delta_satis = -10 ** 32
        opt_idx = 0
        for idx in range(TYPE_NUM):
            val = s[d, idx]
            org = last[idx]
            last[idx] = d+1
            temp_delta_satis = np.sum(-c*(d+1-last)) + val
            if opt_delta_satis < temp_delta_satis:
                opt_delta_satis = temp_delta_satis
                opt_idx = idx
            last[idx] = org
        types.append(opt_idx+1)
    print(*types, sep='\n')

resolve()
Problem p03680 (python)

Fixed submission:
import sys
from io import StringIO
import unittest

def resolve():
    lines = sys.stdin.readlines()
    lines = list(map(lambda x: int(x.rstrip()), lines))
    n = lines[0]
    i = 1
    for c in range(1, n+1):
        i = lines[i]
        if i == 2:
            print(c)
            return
    print(-1)
    
resolve()

Buggy submission (verdict: Runtime Error):
import sys
from io import StringIO
import unittest

    lines = sys.stdin.readlines()
    lines = list(map(lambda x: int(x.rstrip()), lines))
    n = lines[0]
    i = 1
    for c in range(1, n+1):
        i = lines[i]
        if i == 2:
            print(c)
            return
    print(-1)

Buggy submission (verdict: Runtime Error):
    lines = sys.stdin.readlines()
    lines = list(map(lambda x: int(x.rstrip()), lines))
    n = lines[0]
    i = 1
    for c in range(1, n+1):
        i = lines[i]
        if i == 2:
            print(c)
            return
    print(-1)
Problem p02639 (python)

Fixed submission:
a,b,c,d,e = map(int, input().split())
if a ==0:
    print(1)
    exit()
elif b ==0:
    print(2)
    exit()
elif c ==0:
    print(3)
    exit()
elif d ==0:
    print(4)
    exit()
else:
    print(5)

Buggy submission (verdict: Runtime Error):
x,y = map(int, input().split())
cnt2 = 0
cnt4 = 0
for i in range(x+1):
    cnt2 = 2*(i)
    cnt4 = 4*(x-i)
    if cnt2 + cnt4 == y:
        print("Yes")
        exit()

print("No")
Problem p02741 (python)

Fixed submission:
i=[ 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K= int(input())
print(i[K-1])

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if 4*a*b<(c-a-b)**2 and c-a-b>0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
h,w = map(int, input().split())

if h ==1 or w==1 :
    print(0)
elif h * w %2 ==0:
    print(h*w//2)
else:
    print(h*w//2 +1)

Buggy submission (verdict: Runtime Error):
i=[ 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K= int(input())
print(i[K])
Problem p02742 (python)

Fixed submission:
h,w = map(int, input().split())

if h ==1 or w==1 :
    print(1)
elif h * w %2 ==0:
    print(h*w//2)
else:
    print(h*w//2 +1)

Buggy submission (verdict: Runtime Error):
h,w = map(int, input().split())
if h * w 2% ==0:
    print(h*w/2)
else:
    print(h*w/2 +1)
Problem p02743 (python)

Fixed submission:
a,b,c=map(int,input().split())
if 4*a*b<(c-a-b)**2 and c-a-b>0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import math

a,b,c= map(int, input().split())
a1 =double(math.sqrt(a))
b1 =double(math.sqrt(b))
c1 =double(math.sqrt(c))

if a1+ b1 <c1:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import math

a,b,c= map(int, input().split())
a1 =double(math.sqrt(a))
b1 =double(math.sqrt(b))
c1 =double(math.sqrt(c))
print(a1)

if a1+ b1 ,c1:
    print('Yes')
else:
    print('No')
Problem p02747 (python)

Fixed submission:
S = input()

while len(S) >= 2:
    if S[0:2]== 'hi':
        S=S[2:]
    else:
        break
if len(S)==0:
    print('Yes')
else:
    print('No')

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

while len(S) >= 2:
    if S[0:2]== 'hi':
        S==[2:]
    else:
        break
if len(S)==0:
    print('Yes')
else:
    print('No')

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

while len(S) >= 2:
    if S[0:1]== 'hi':
        S==[2:]
    else:
        break
if len(S)==0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
S=str(input())
A= int(S.count('hi'))
B= int(len(S))

if B // A ==2 :
    print('Yes')
else :
    print('No')

Buggy submission (verdict: Runtime Error):
S=str(input())
A= int(S.count('hi'))
B= int(len(S))

if B / A ==2 :
    print('Yes')
else :
    print('No')

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

if ('hi' in S):
    print('Yes')
elif ('hii' in S)
    print('No')
else:
    print('No')
Problem p02765 (python)

Fixed submission:
x, y = map(int, input().split())

#print(a ,type(a))
if x<10:
    print(y+(100*(10-x)))
else:
    print(y)

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())

#print(a ,type(a))
if x<10:
    print(y+(100*(10-x)))
else:
    print(y)

Buggy submission (verdict: Runtime Error):

e = input()
R = input()

if int(e) >= 10:
     print(R)
else :
     K = 100 * (10 - int(e))
     print(K)

Buggy submission (verdict: Runtime Error):
 N = input()
 R = input()
 if N >= 10:
     print(R)
 else :
     K = 100 * (10 - int(N))
     print(K)
Problem p02811 (python)

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

if 500* K >= X:
    print('Yes')
else:
    print('No')

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

#Y = len(S.replace('ABC',''))
#print((N-Y)//3)

print(S.count('ABC'))
Problem p03285 (python)

Fixed submission:
N = int(input())

for i in range(25):
    for j in range(15):
        if N == 4*i + 7*j:
            print('Yes')
            exit()

print('No')

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

for i in range(25)
    for j in range(15)
        if N == 4*i + 7*j:
            print('Yes')
            break

print('No')
Problem p03485 (python)

Fixed submission:
a, b = map(int, input().split())

if (a + b) %2 ==0:
    print(int((a+b)/2))
else:
    print(int((a+b+1)//2))

Buggy submission (verdict: Runtime Error):
s = input()
t = input()

if sorted(s) < sorted(t, reverse=True):
    print('Yes')
else:
    print('No')
Problem p03486 (python)

Fixed submission:
s = sorted((input()))
t = sorted((input()), reverse=True)

if s<t:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = input()
t = input()

s1 = s.sort()
t1 = t.sort(reserve = True)

if s1 < t1:
    print('Yes')
else:
    print('No')
Problem p03493 (python)

Fixed submission:
S = input()
print(S.count('1'))

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

cnt =0

while True:
    if [i for i in A if i%2 == 1]:
        break
    A = [i/2 for i in A if i%2 ==0]
    cnt += 1
    
prnt(cnt)
Problem p03494 (python)

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

cnt =0

while True:
    if [i for i in A if i%2 == 1]:
        break
    A = [i/2 for i in A if i%2 ==0]
    cnt += 1

print(cnt)

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

cnt =0

while True:
    if [i for i in A if i%2 == 1]:
        break
    A = [i/2 for i in A if i%2 ==0]
    cnt += 1
    
prnt(cnt)
Problem p03693 (python)

Fixed submission:
r, g, b = map(int, input().split())
num = int(str(r)+str(g)+str(b))

if  num %4 == 0:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
r, g, b = map(int, input().split())
num = int(str(r)+str(g)+str(b)

if  num %4 == 0:
    print('YES')
else:
    print('NO')
Problem p02761 (python)

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


def judge():
    ans="-"*n
    if m==0:
        if n==1:
            return 0
    for i in range(m):
        s,c = map(int,input().split())
        if ans[s-1]!="-" and int(ans[s-1])!=c:
            return -1
        else:
            a = list(ans)
            a[s-1] = str(c)
            ans = "".join(a)
    if ans[0]=="-":
        a=list(ans)
        a[0]="1"
        ans="".join(a)
    ans=ans.replace("-","0")
    # print(ans[0])
    if ans[0]==str(0):
        if n==1:
            return 0
        else:
            return -1
    return ans

print(judge())

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())


def judge():
    ans="-"*n
    for i in range(m):
        s,c = map(int,input().split())
        if ans[s-1]!="-" and int(ans[s-1])!=c:
            return -1
        else:
            a = list(ans)
            a[s-1] = str(c)
            ans = "".join(a)
    ans=ans.replace("-","0")
    if ans[s-1]==str(0):
        if n==1:
            return 0
        else:
            return -1
    return ans

print(judge())

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())


def judge():
    ans="-"*n
    for i in range(m):
        s,c = map(int,input().split())
        if ans[s-1]!="-" and int(ans[s-1])!=c:
            return -1
        else:
            a = list(ans)
            a[s-1] = str(c)
            ans = "".join(a)
    ans=ans.replace("-","0")
    if ans[s-1]==str(0):
        if n==0:
            return 0
        else:
            return -1
    return ans

print(judge())
Problem p02936 (python)

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

readline = sys.stdin.readline

n,q = map(int,readline().split())
a=[[] for i in range(n)]
l=[0 for _ in range(n)]
ans=[0 for _ in range(n)]

def dfs(parent,current,value):
    value += l[current]
    ans[current] = value
    for i in a[current]:
        if i == parent:
            continue
        dfs(current,i,value)


for i in range(n-1):
    t1,t2 = map(int,readline().split())
    a[t1-1].append(t2-1)
    a[t2-1].append(t1-1)
    
for i in range(q):
    t1,t2 = map(int,readline().split())
    l[t1-1]+=t2
dfs(-1,0,0)

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

Buggy submission (verdict: Runtime Error):
n,q = map(int,input().split())
a=[[] for i in range(n)]
p=[]*n
l=[0]*n

def dfs(parent,current):
    for i in a[current-1]:
        if i != parent:
            l[i-1] += l[current-1]
            dfs(current,i)


for i in range(n-1):
    t1,t2 = map(int,input().split())
    a[t1-1].append(t2)
    a[t2-1].append(t1)
    
for i in range(q):
    t1,t2 = map(int,input().split())
    l[t1-1]+=t2
dfs(-1,1)

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

Buggy submission (verdict: Runtime Error):
n,q = map(int,input().split())
a=[[] for i in range(n)]
p=[]
l=[0]*n

def plus(tl,ta,t2):
    # print(tl)
    for i in ta:
        tl[i-1]+=t2
        # print(ta[t1-1],t1)
        plus(tl,a[i-1],t2)

for i in range(n-1):
    t1,t2 = map(int,input().split())
    a[t1-1].append(t2)
# print(a)
for i in range(q):
    t1,t2 = map(int,input().split())
    # print(a[t1-1],t1)
    l[t1-1]+=t2
    plus(l,a[t1-1],t2)
    
print(" ".join(map(str,l)))

Buggy submission (verdict: Runtime Error):
n,q = map(int,input().split())
a=[[] for i in range(n)]
p=[]
l=[0]*n

def plus(tl,ta,t2):
    # print(tl)
    for i in ta:
        tl[i-1]+=t2
        # print(ta[t1-1],t1)
        plus(tl,a[i-1],t2)

for i in range(n-1):
    t1,t2 = map(int,input().split())
    a[t1-1].append(t2)
# print(a)
for i in range(q):
    t1,t2 = map(int,input().split())
    # print(a[t1-1],t1)
    l[t1-1]+=t2
    plus(l,a[t1-1],t2)
    



print(l)
Problem p02947 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10000000)
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

n = int(input())
s=[]
m={}
sum=0
for i in range(0,n):
    # print((list(input()))
    tmp = "".join(sorted(input()))
    if tmp in m:
        m[tmp]+=1
    else:
        m[tmp] = 1
for k in m:
    if m[k]>1:
        # print(m[k])
        # print("["+k)
        sum+=cmb(m[k],2)
print(sum)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

n = int(input())
s=[]
m={}
sum=0
for i in range(0,n):
    # print((list(input()))
    tmp = "".join(sorted(input()))
    if tmp in m:
        m[tmp]+=1
    else:
        m[tmp] = 1
for k in m:
    if m[k]>1:
        # print(m[k])
        # print("["+k)
        sum+=cmb(m[k],2)
print(sum)

Buggy submission (verdict: Runtime Error):
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

n = int(input())
s=[]
m={}
sum=0
for i in range(0,n):
    # print((list(input()))
    tmp = "".join(sorted(input()))
    if tmp in m:
        m[tmp]+=1
    else:
        m[tmp] = 1
for k in m:
    if m[k]>1:
        # print(m[k])
        # print("["+k)
        sum+=cmb(m[k],2)
print(sum)
Problem p02639 (python)

Fixed submission:
a = list(map(int, input().split()))

ans = a.index(0) + 1
print(ans)

Buggy submission (verdict: Runtime Error):
a=[]
a=[int(x) for x in input().split()]

ans = list.index(0) + 1
print(ans)