Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split)
if (a+b)>(c+d):
    print('Left')
elif (a+b)==(c+d):
    print('Balanced')
else:
    print('Right')

Fixed submission:
a,b,c,d=map(int,input().split())
if (a+b)>(c+d):
    print('Left')
elif (a+b)==(c+d):
    print('Balanced')
else:
    print('Right')
Buggy python submission (verdict: Runtime Error):
S=set(input())
alpha='abcdefghijklmnopqrstuvwxyz'
ans=sorted(set(alpha)^S)
print('None' if ans=='' else ans[0])

Fixed submission:
S=input()
alpha=set([i for i in "abcdefghijklmnopqrstuvwxyz"])
ans=alpha-set(list(S))
ans=sorted(ans)
print(ans[0] if len(ans)>0 else 'None')
Buggy python submission (verdict: Runtime Error):
,b,c,d=map(int,input().split())
print(max(0,min(b,d)-max(a,c)))

Fixed submission:
a,b,c,d=map(int,input().split())
print(max(0,min(b,d)-max(a,c)))
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
count=3
if a==b:
    count=count-1
if b==c:
    count=count-1
if c==a:
    count=count-1
print(count)


Fixed submission:
a,b,c=map(int,input().split())
if a==b==c:
    print(1)
elif a==b or b==c or c==a:
    print(2)
else:
    print(3)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = int(input())
a_li = list(map(int, (input().split())))

product = 1

if 0 in a_li:
    product = 0
else:
    for i in a_li:
        product *= i
        if product > 10**18:
            product = -1
            break
    break
            
print(product)

Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
a_li = list(map(int, (input().split())))

product = 1

if 0 in a_li:
    product = 0
else:
    for i in a_li:
        product *= i
        if product > 10**18:
            print(-1)
            exit()

print(product)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

from decimal import decimal

a, b = input().split()

print(int(decimal(a)*decimal(b)))


Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
a_li = list(map(int, (input().split())))

product = 1

if 0 in a_li:
    product = 0
else:
    for i in a_li:
        product *= i
        if product > 10**18:
            print(-1)
            exit()

print(product)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import numpy as np

n = int(input())
s_li = input().split()
num = list(map(int, s_li))

product = 1

for i in range(n):
    product = product * num[i-1]


if product > 10**18:
    print("-1")
else:
    print(product)

Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
a_li = list(map(int, (input().split())))

product = 1

if 0 in a_li:
    product = 0
else:
    for i in a_li:
        product *= i
        if product > 10**18:
            print(-1)
            exit()

print(product)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n = int(input())
s_li = input().split()
num = list(map(int, s_li))

product = 1

for i in range(n):
    product = product * num[i-1]

if product > 10**18:
    print("-1")
else:
    print(product)

Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
a_li = list(map(int, (input().split())))

product = 1

if 0 in a_li:
    product = 0
else:
    for i in a_li:
        product *= i
        if product > 10**18:
            print(-1)
            exit()

print(product)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n = int(input())
s_li = input().split()
num = list(map(int, s_li))

product = 1

for i in range(n):
    product = product * num[i-1]

if product > 10**18:
    print("-1")
else:
    print(product)


Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())
a_li = list(map(int, (input().split())))

product = 1

if 0 in a_li:
    product = 0
else:
    for i in a_li:
        product *= i
        if product > 10**18:
            print(-1)
            exit()

print(product)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

from decimal import Decimal

a, b = input().split()

print(int(decimal(a)*decimal(b)))


Fixed submission:
# -*- coding: utf-8 -*-

from decimal import Decimal

a, b = input().split()

print(int(Decimal(a)*Decimal(b)))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

S = input()
T = input()
length = len[S] - 1

for i in range(length):
    if S[i] == T[i]:
        i = i + 1
        if i == len[T]:
            print('Yes')
            break
        break
    else:
        print('No')
        break


Fixed submission:
# -*- coding: utf-8 -*-

S = input()
T = input()
l = len(S)

for i in range(0,l):
    if S[i] == T[i]:
        i = i + 1
        if i == l:
            print('Yes')
            break
    else:
        print('No')
        break

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

S = input()
T = input()

if S in T == True:
    if T[len(T)-1] == S[len(S)-1]
    print('Yes')
else:
    print('No')

Fixed submission:
# -*- coding: utf-8 -*-

S = input()
T = input()
l = len(S)

for i in range(0,l):
    if S[i] == T[i]:
        i = i + 1
        if i == l:
            print('Yes')
            break
    else:
        print('No')
        break
Buggy python submission (verdict: Runtime Error):
#-*- coding:utf-8 -*-

n, k, q = map(int, input().split())
a_li = [int(input()) for i in range(q)]

pt_li = [] #所持点数のリストを作る
for i in range(n):
    pt_li.append(k)

for t in range(q):
    for u in range(n):
        pt_li[u] -= 1
    pt_li[a_li[t]-1] += 1

print(pt_li)

for s in range(n):
     if pt_li[s] <= 0:
         print("No")
     else:
         print("Yes")


Fixed submission:
# -*- coding:utf-8 -*-

S = input()

if S == "Sunny":
    print("Cloudy")
elif S == "Cloudy":
    print("Rainy")
else:
    print("Sunny")

Buggy python submission (verdict: Runtime Error):
#-*- coding:utf-8 -*-

n, k, q = map(int, input().split())
a_li = [int(input()) for i in range(q)]

pt_li = [] 
for i in range(n):
    pt_li.append(k)

for t in range(q):
    for u in range(n):
        pt_li[u] -= 1
    pt_li[a_li[t]-1] += 1

for s in range(n):
     if pt_li[s] <= 0:
         print("No")
     else:
         print("Yes")

Fixed submission:
# -*- coding:utf-8 -*-

S = input()

if S == "Sunny":
    print("Cloudy")
elif S == "Cloudy":
    print("Rainy")
else:
    print("Sunny")
Buggy python submission (verdict: Time Limit Exceeded):
#-*- coding:utf-8 -*-

n, k, q = map(int, input().split())
a_li = [int(input()) for i in range(q)]

pt_li = [] #所持点数のリストを作る
for i in range(n):
    pt_li.append(k)

for t in range(q):
    for u in range(n):
        pt_li[u] -= 1
    pt_li[a_li[t]-1] += 1

for s in range(n):
     if pt_li[s] <= 0:
         print("No")
     else:
         print("Yes")


Fixed submission:
#-*- coding:utf-8 -*-

n, k, q = map(int, input().split())
a_li = [int(input()) for i in range(q)]

b_li = [0]*n

for i in range(q):
    b_li[a_li[i]-1] += 1

for t in range(n):
    pt = k -q + b_li[t]
    if pt > 0:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
#-*- coding:utf-8 -*-
 
n, k, q = map(int, input().split())
a_li = [int(input()) for i in range(q)]
 
pt_li = []
for i in range(n):
    pt_li.append(k)
 
for t in range(q):
    for u in range(n):
        pt_li[u] -= 1 
    pt_li[a_li[t]-1] += 1
 
for v in range(n):
    if pt_li[v] <= -1:
        pt_li[v] = 0
 
for s in range(n):
     if pt_li[s] == 0:
         print("No")
     else:
         print("Yes")

Fixed submission:
#-*- coding:utf-8 -*-

n, k, q = map(int, input().split())
a_li = [int(input()) for i in range(q)]

b_li = [0]*n

for i in range(q):
    b_li[a_li[i]-1] += 1

for t in range(n):
    pt = k -q + b_li[t]
    if pt > 0:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
#-*- coding:utf-8 -*-

n, k, q = map(int, input().split())
a_li = [int(input()) for i in range(q)]

pt_li = []
for i in range(n):
    pt_li.append(k)

for t in range(q):
    for u in range(n):
        pt_li[u] -= 1 
    pt_li[a_li[t]-1] += 1

for v in range(n):
    if pt_li[v] <= -1:
        pt_li[v] = 0

for s in range(n):
     if pt_li[s] == 0:
         print("No")
     else:
         print("Yes")

Fixed submission:
#-*- coding:utf-8 -*-

n, k, q = map(int, input().split())
a_li = [int(input()) for i in range(q)]

b_li = [0]*n

for i in range(q):
    b_li[a_li[i]-1] += 1

for t in range(n):
    pt = k -q + b_li[t]
    if pt > 0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
count = 0
for i in range(n):
  if v[i] > c[i]:
    x += v[i]
    y += c[i]
print(x-y)

Fixed submission:
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
x, y = 0, 0
for i in range(n):
  if v[i] > c[i]:
    x += v[i]
    y += c[i]
print(x-y)
Buggy python submission (verdict: Runtime Error):
R = int(input())
return R*R

Fixed submission:
R = int(input())
print(R*R)
Buggy python submission (verdict: Runtime Error):
import sys


def main(window_len, cartain_len):
    ret = int(window_len) - int(cartain_len)*2
    if ret >= 0:
        return ret
    else:
        return 0


if __name__ == "__main__":
    args = sys.argv
    window_len = args[1]
    cartain_len = args[2]
    print(main(window_len, cartain_len))


Fixed submission:
window, cartain = map(int, input().split())

ret = window - cartain * 2
if ret > 0:
    print(ret)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
import sys


def main():
    ret = window_len - cartain_len*2
    if ret >= 0:
        return ret
    else:
        return 0


if __name__ == "__main__":
    args = sys.argv
    window_len = args[1]
    cartain_len = args[2]
    main(window_len, cartain_len)


Fixed submission:
window, cartain = map(int, input().split())

ret = window - cartain * 2
if ret > 0:
    print(ret)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = str(input())

r = 0
g = 0
b = 0
for s in range(N):
    if S[s] == 'R':
        r += 1
    elif S[s] == 'G':
        g += 1
    elif S[s] == 'B':
        b += 1

ans = (r*g*b)

for i in range(N):
    for k in range(N):
        j = int((i+k)/2)
        if k <= i or (i+k)%2 != 0 or j <= i or k <= j:
            continue
        if (S[i] != S[j]) and (S[j] != S[k]) and (S[i] != S[k]):
            ans -= 1

print(ans)

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

r = 0
g = 0
b = 0
for s in range(N):
    if S[s] == 'R':
        r += 1
    elif S[s] == 'G':
        g += 1
    elif S[s] == 'B':
        b += 1

ans = (r*g*b)

for i in range(N):
    for k in range(N):
        j = int((i+k)/2)
        if k <= i or (i+k)%2 != 0 or j <= i or k <= j:
            continue
        if (S[i] != S[j]) and (S[j] != S[k]) and (S[i] != S[k]):
            ans -= 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
P = list(map(int, input().split()))

S = []
max_num = 0
for i in range(N):
    if i+K <= N:
        tmp = sum(P[i:i+K])
        if tmp  > max_num:
            max_num = tmp
            S = P[i:i+K]
    else:
        break

ans = 0
for i in range(len(S)):
    gausu = (S[i])*(S[i]+1)/2
    ans += (gausu/S[i])

print(ans)

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

S = [0]
before = 0
for i in range(N):
    S.append(P[i]+before)
    before += P[i]

max_num = 0
l = 0
m = 0
for i in range(N):
    if K+i > N:
        break
    tmp = S[K+i]-S[i]
    if tmp > max_num :
        l = K+i
        m = i
        max_num = tmp

S = P[m:l]
ans = 0
for i in range(len(S)):
    gausu = (S[i])*(S[i]+1)/2
    ans += (gausu/S[i])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
H = list(map(int, input().split()))
 
H.sort(reverse=True)
 
K = min(K, len(H))
for k in range(K):
    H.pop(0)
 
print(sum(H))

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

H.sort(reverse=True)

K = min(K, len(H))
HH = H[K:]

print(sum(HH))

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
H = list(map(int, input().split()))

H.sort(reverse=True)

K = min(K, len(H))
for k in range(K):
    H.pop(0)

print(sum(H))

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

H.sort(reverse=True)

K = min(K, len(H))
HH = H[K:]

print(sum(HH))
Buggy python submission (verdict: Time Limit Exceeded):
from queue import Queue

def bfs(HW, q, goal):
    num = 0
    mem = []
    while not q.empty():
        current = q.get()
        if current[0] >= H or current[0] < 0 or current[1] >= W or current[1] < 0:
            continue
        if HW[current[0]][current[1]] == '#':
            continue

        if (current[0] == goal[0]) and (current[1] == goal[1]):
            return current[2]

        if [current[0]+1,current[1]]  not in mem:
            mem.append([current[0]+1,current[1]])
            q.put([current[0]+1,current[1],current[2]+1])
        if [current[0],current[1]+1]  not in mem:
            mem.append([current[0],current[1]+1])
            q.put([current[0],current[1]+1,current[2]+1])
        if [current[0]-1,current[1]]  not in mem:
            mem.append([current[0]-1,current[1]])
            q.put([current[0]-1,current[1],current[2]+1])
        if [current[0],current[1]-1]  not in mem:
            mem.append([current[0],current[1]-1])
            q.put([current[0],current[1]-1,current[2]+1])
    return -1


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

HW = [[''] * W for i in range(H)]
for i in range(H):
    h = str(input())
    for j in range(len(h)):
        HW[i][j] = h[j]

ans = 0
for si in range(H):
    for sj in range(W):
        if HW[si][sj] == '#':
            continue
        for gi in range(H):
            for gj in range(W):
                if HW[gi][gj] == '#':
                    continue
                q = Queue()
                q.put([si,sj,0])
                ans = max(ans, bfs(HW, q, [gi,gj]))
print(ans)

Fixed submission:
from queue import Queue

def bfs(HW, q, x, y):
    num = 0
    mem = [[-1]*(W+1) for i in range(H+1)]
    max_dist = 0
    mem[x][y] = 0
    while not q.empty():
        current = q.get()
        if current[0] >= H or current[0] < 0 or current[1] >= W or current[1] < 0:
            continue
        if HW[current[0]][current[1]] == '#':
            continue
        dist = mem[current[0]][current[1]]
        max_dist = max(max_dist, dist)
        if mem[current[0]+1][current[1]] == -1:
            mem[current[0]+1][current[1]] = dist+1
            q.put([current[0]+1,current[1]])
        if mem[current[0]][current[1]+1] == -1:
            mem[current[0]][current[1]+1] = dist+1
            q.put([current[0],current[1]+1])
        if mem[current[0]-1][current[1]] == -1:
            mem[current[0]-1][current[1]] = dist+1
            q.put([current[0]-1,current[1]])
        if mem[current[0]][current[1]-1] == -1:
            mem[current[0]][current[1]-1] = dist+1
            q.put([current[0],current[1]-1])
    return max_dist


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

HW = [[''] * W for i in range(H)]
for i in range(H):
    h = str(input())
    HW[i] = h

ans = 0
for si in range(H):
    for sj in range(W):
        if HW[si][sj] == '#':
            continue
        q = Queue()
        q.put([si,sj,0])
        ans = max(ans, bfs(HW, q, si, sj))
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B,X = map(int, input().split())

def func(N):
    return (A*N + B*len(str(N)))


def search(start, end):
    median = int((end - start)//2)
    if median == 0:
        if func(end) <= X:
            return end
        elif func(start) <= X:
            return start
        else:
            return 0

    val = func(start+median)
    if val == X:
        return (start+median)
    elif val > X:
        return search(start, start+median)
    elif val < X:
        return search(start+median, end)

result = search(1,10**9)
if result >= 1000000000:
    print(1000000000)
else:
    print(result)

Fixed submission:
S = input()

if S == "SUN":
    print("7")
elif S == "MON":
    print("6")
elif S == "TUE":
    print("5")
elif S == "WED":
    print("4")
elif S == "THU":
    print("3")
elif S == "FRI":
    print("2")
elif S == "SAT":
    print("1")
Buggy python submission (verdict: Runtime Error):
N = int(input())

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

def search(par, ans, own):
    ans =  max(ans, len(ki[own]))
    for child in ki[own]:
        if child == par:
            continue
        else:
            ans = max(search(own, ans, child),ans)
    return ans

print(search(-1, 0, 0))


def search(par, ans, own, par_num):
    ans =  max(ans, len(ki[own]))
    i = 1
    for child in ki[own]:
        if child == par:
            continue
        else:
            if i == par_num:
                i += 1
            print(i)
            ans = max(search(own, ans, child, i),ans)
            i += 1
    return ans

search(-1, 0, 0, -1)

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

N = int(input())

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

result = [0]*(N-1)
def search(par, ans, own, par_num):
    ans =  max(ans, len(ki[own]))
    i = 1
    for child in ki[own]:
        if child[0] == par:
            continue
        else:
            if i == par_num:
                i += 1
            result[child[1]] = i
            ans = max(search(own, ans, child[0], i),ans)
            i += 1
    return ans

print(search(-1, 0, 0, -1))
for i in result:
    print(i)
Buggy python submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10**6)
input=sys.stdin.readline

def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p


X, Y = map(int, input().split())

if (X+Y)%3 != 0:
    print(0)
    sys.exit()

val = [X,Y]
val_min = min(val)

val_min_sho = int(val_min/3)

X_henkan = X - 3*val_min_sho
Y_henkan = Y - 3*val_min_sho
if (X_henkan == 0 and Y_henkan == 0):
    n = (val_min_sho)*2
    n_2 = int(n/2)
    print(comb(n,n_2,10**9+7))
elif Y_henkan != 0 and (X_henkan / Y_henkan == 2):
    n = (val_min_sho)*2 + Y_henkan
    n_2 = val_min_sho
    print(comb(n,n_2,10**9+7))
elif X_henkan != 0 and (Y_henkan / X_henkan == 2):
    n = (val_min_sho)*2 + X_henkan
    n_2 = val_min_sho
    print(comb(n,n_2,10**9+7))
else:
    print(0)

Fixed submission:
import itertools

N = int(input())
Town = []
for _ in range(N):
    Town.append(list(map(int, input().split())))

kyori = 0
num = 0
for v in itertools.permutations(Town, N):
    num += 1
    for i in range(N-1):
        kyori += ((v[i][0]-v[i+1][0])**2 + (v[i][1]-v[i+1][1])**2)**0.5

print(kyori/num)
Buggy python submission (verdict: Runtime Error):
N = int(input())

for i in reversed(range(int(N**0.5))):
    j = int(N/i)
    if i*j == N:
        print(i-1+j-1)
        break

Fixed submission:
N = int(input())

for i in reversed(range(1, int(N**0.5)+1)):
    j = int(N/i)
    if i*j == N:
        print(i-1+j-1)
        break
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = input().split()

B = [0]*N
j = 0
for i in A:
    j += 1
    B[int(i)-1] = j
    if

resutl = ""
for i in B:
    resutl += (str(i) + " ")
print(resutl.rstrip())

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

B = [0]*N
j = 0
for i in A:
    j += 1
    B[int(i)-1] = j

resutl = ""
for i in B:
    resutl += (str(i) + " ")
print(resutl.rstrip())

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = input().split()

B = sorted(range(len(A)), key=lambda k: A[k])
resutl = ""
for i in B:
    resutl += (str(i+1) + " ")
print(resutl.rstrip())N = int(input())
A = input().split()

B = [0]*N
j = 0
for i in A:
    j += 1
    B[int(i)-1] = j

resutl = ""
for i in B:
    resutl += (str(i) + " ")
print(resutl.rstrip())

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

B = [0]*N
j = 0
for i in A:
    j += 1
    B[int(i)-1] = j

resutl = ""
for i in B:
    resutl += (str(i) + " ")
print(resutl.rstrip())
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q = map(int, input().split())

A = list(map(int, [K]*N))
s = [input() for i in range(Q)]

for i in s:
    A[int(i)-1] += 1
    num = 0
    for _ in A:
        A[num] -= 1
        num += 1

for i in A:
    if i <= 0:
        print('No')
    else:
        print('Yes')

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

A = list(map(int, [K]*N))
s = [input() for i in range(Q)]

for i in s:
    A[int(i)-1] += 1

num = 0
for i in A:
    A[num] -= int(len(s))
    num += 1

for i in A:
    if i <= 0:
        print('No')
    else:
        print('Yes')
Buggy python submission (verdict: Runtime Error):
num = int(input())
input_list = input().split()

i = 0
j = 1
tmp = 0L
score = 0L
while True:
    if j > (num - 1):
        break
    elif input_list[i] >= input_list[j]:
        tmp += 1
        i += 1
        j += 1
    else:
        if tmp > score:
            score = tmp
        tmp = 0
        i += 1
        j += 1
if tmp >= score:
    score = tmp
print(score)

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

ans = 0
tmp = 0
before = H[0]
for i in range(1, N):
    if before >= H[i]:
        tmp += 1
        before = H[i]
    else:
        ans = max(ans, tmp)
        tmp = 0
        before = H[i]

print(max(ans,tmp))
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
ki = [[[],0] for i in range(N)]
result = [0]*N

def dfs(i, num, parent):
    num_tmp = num+ki[i][1]
    result[i] = num_tmp
    if not ki[i][0]:
        return
    for j in ki[i][0]:
        if j == parent:
            continue
        dfs(j, num_tmp, i)
    return

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

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

dfs(0, 0, -1)
print(*result)

Fixed submission:
a = int(input())
s = str(input())

if a >= 3200:
    print(s)
else:
    print('red')

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

if a >= 3200:
    print(s)
else:
    print('red')

Fixed submission:
a = int(input())
s = str(input())

if a >= 3200:
    print(s)
else:
    print('red')
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
import copy

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

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

baito.sort(key=lambda x: x[0])

que = []
ans = 0
for i in range(1, M+1):
    tmp = copy.copy(baito)
    for val in baito:
        if val[0] <= i:
            heapq.heappush(que, val[1]*-1)
            tmp.pop(0)
        else:
            break
    baito = tmp
    if len(que) != 0:
        ans += heapq.heappop(que)*-1

print(ans)

Fixed submission:
import heapq

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

baito = [[] for i in range(M+1)]
for i in range(N):
    A,B = map(int,input().split())
    if A <= M:
        baito[A].append(B)

que = []
ans = 0
for i in range(1, M+1):
    if len(baito[i]) != 0:
        for val in baito[i]:
            heapq.heappush(que, val*-1)
    if len(que) != 0:
        ans += heapq.heappop(que)*-1

print(ans)