Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# E - Max GCD
import sympy
import sys

def check(targetSet):

    # Aiを割り切れる整数を大きいものから順に、指定回数の値操作で実現可能か判定する
    for target in sorted(targetSet, reverse=True):
        ret = True
        incDecList = [[0, 0, 0]]
        for ai in a:
            dec = -(ai % target)
            inc = target + dec
            if min(inc, abs(dec)) > k:
                ret = False
                break
            updateList = list()
            for incDec in incDecList:
                if inc <= k:
                    updateList.append([incDec[0] + inc, incDec[1] + inc, incDec[2]])
                if abs(dec) <= k:
                    updateList.append([incDec[0] + dec, incDec[1], incDec[2] + dec])
            incDecList = updateList
        if ret:
            for incDec in incDecList:
                if incDec[0] == 0 and incDec[1] <= k:
                    print(target)
                    return

                
                
input1 = list(map(int, input().split()))
n = input1[0]
k = input1[1]
a = list(map(int, input().split()))

# Aiの合計値を素因数分解
a.sort(reverse=True)
sumFact = sympy.factorint(sum(a))
targetSet = {1}
for fact, power in sumFact.items():
    for i in range(power):
        for ele in list(targetSet):
            targetSet.add(ele * fact)
check(targetSet)

Fixed submission:
# E - Max GCD ★

def slvDivisor(summary):
    divisor = set()
    for d in range(1, int(summary ** 0.5) + 1):
        if summary % d == 0:
            divisor.add(d)
            divisor.add(summary // d)
    return divisor



input1 = list(map(int, input().split()))
n = input1[0]
k = input1[1]
a = list(map(int, input().split()))

# 和の約数を求める
sumA = sum(a)
divisor = slvDivisor(sumA)

# 各値を約数で割った際の余りも約数の整数倍（i倍とする）になるはず
# → ＋－する操作はその余りを他の値に移動して約数を作る操作になる
# → 余りが小さい値から大きい値へ余りを寄せていくのが効率的
# → 寄せきると約数 * i個、0 * (N - i)個の2ブロックに分かれる
# → 寄せきるまでの回数がk以下ならOK
for d in sorted(divisor, reverse=True):
    modA = [x % d for x in a]
    modA.sort()
    i = sum(modA) // d
    cnt = sum(modA[:-i])
    if cnt <= k:
        print(d)
        break
Buggy python submission (verdict: Runtime Error):
a = list(input())
s = list(input())
if a >= 3200:
   print('{}'format.(s))
else:
  print('red')

Fixed submission:
a = int(input())
s = input()
if a >= 3200:
   print((s))
else:
  print('red')
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
ans = 0
white True:
  if ans * (a - 1) + 1 >= b:
    break
  ans += 1
print(ans)


Fixed submission:
a, b = map(int, input().split())
ans = 0
while True:
  if ans * (a - 1) + 1 >= b:
    break
  ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
ans = 0
white True:
  if ans * (a - 1) + 1 >= b:
    break
print(ans)

Fixed submission:
a, b = map(int, input().split())
ans = 0
while True:
  if ans * (a - 1) + 1 >= b:
    break
  ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
print(math.ceil((B-1)/(A-1))

Fixed submission:
A, B = map(int, input().split())
empty = 1
socket = 0
while empty < B:
    empty += A - 1
    socket += 1
print(socket)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
start = N - 1
moves = []
for i in range(N-1, 0, -1):
    if H[i] <= H[i-1]:
        continue
    moves.append(start - i)
    start = i - 1
if H[1] <= H[1]:
    moves.append(start - i + 1)
print(max(moves))

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

if N == 1:
    print(0)
    quit()
start = N - 1
moves = []
for i in range(N-1, 0, -1):
    if H[i] <= H[i-1]:
        continue
    moves.append(start - i)
    start = i - 1
if H[1] <= H[0]:
    moves.append(start - i + 1)
print(max(moves))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

print(*max(A[1:N]))
for i in range(1, N-1):
    print(*max(max(A[0:i]), max(A[i+1:N])))
print(*max(A[0:N-1]))


Fixed submission:
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

max_num = max(A)
max_i = A.index(max_num)
A.remove(max_num)
second_max = max(A)
new_list = [max_num for _ in range(N)]

new_list[max_i] = second_max
print(*[val for sublist in new_list for val in sublist], sep='\n')
Buggy python submission (verdict: Runtime Error):
    n = int(input())
    p_list = list(map(int, input().split()))
    count = 0
    for i in range(len(p_list)-2):
    	if (p_list[i]<p_list[i+1] and p_list[i+1]<p_list[i+2]) or (p_list[i]>p_list[i+1] and p_list[i+1]>p_list[i+2]):
    		count += 1
    print(count)

Fixed submission:
n = int(input())
p_list = list(map(int, input().split()))
count = 0
for i in range(len(p_list)-2):
  if (p_list[i]<p_list[i+1] and p_list[i+1]<p_list[i+2]) or (p_list[i]>p_list[i+1] and p_list[i+1]>p_list[i+2]):
    count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
from math import gcd
A, B, C, D = map(int, input().split())
if(A % C == 0):
    c_div = (B // C) - (A // C) + 1
else:
    c_div = (B // C) - (A // C + 1) + 1
if(A % D == 0):
    d_div = (B // D) - (A // D) + 1
else:
    d_div = (B // D) - (A // D + 1) + 1
cd_lcm = (C * D) // gcd(C, D)
cd_div = (B // cd_lcm) - (A // cd_lcm + 1) + 1
print((B - A) - (c_div + d_div - cd_div) + 1)

Fixed submission:
from fractions import gcd
A, B, C, D = map(int, input().split())
if(A % C == 0):
    c_div = (B // C) - (A // C) + 1
else:
    c_div = (B // C) - (A // C + 1) + 1
if(A % D == 0):
    d_div = (B // D) - (A // D) + 1
else:
    d_div = (B // D) - (A // D + 1) + 1
cd_lcm = (C * D) // gcd(C, D)
if(A % cd_lcm == 0):
    cd_div = (B // cd_lcm) - (A // cd_lcm) + 1
else:
    cd_div = (B // cd_lcm) - (A // cd_lcm + 1) + 1
print((B - A) - (c_div + d_div - cd_div) + 1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = list(map(int, input().split()))
F = "Yes"

for i in range(0, N):
	for k in range(i+1, N):
		if H[i] > H[k] + 1:
			F = "No"
			break

print(F)


Fixed submission:
N = int(input())
H = list(map(int, input().split()))
F = "Yes"
l = H[0]

for i in range(1, N):
	if l < H[i]:
		l = H[i]
	if l - 1 > H[i]:
		F = "No"
		break

print(F)

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

for i in range(0, N):
	for k in range(i+1, N):
		if H[i] > H[k] + 1:
			F = "No"

print(F)


Fixed submission:
N = int(input())
H = list(map(int, input().split()))
F = "Yes"
l = H[0]

for i in range(1, N):
	if l < H[i]:
		l = H[i]
	if l - 1 > H[i]:
		F = "No"
		break

print(F)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
L = [list(map(int, input().split())) for i in range(N)]
A = []
B = []
for i in range(N):
	A.append(L[i][0])
	B.append(L[i][1])
cost = 0
num = 0
while True:
	if num == M:
		break
	cost = cost + min(A)*min(B[A.index(min(A))], M - num)
	num = num + min(B[A.index(min(A))], M - num)
	B.pop(A.index(min(A)))
	A.remove(min(A))
print(cost)
exit()

Fixed submission:
N, M = map(int, input().split())
L = [list(map(int, input().split())) for i in range(N)]
L.sort()

A = []
B = []
for i in range(N):
	A.append(L[i][0])
	B.append(L[i][1])
num = 0
cost = 0
i = 0
while num < M:
	cost = cost + A[i]*min(B[i], M - num)
	num = num + min(B[i], M - num)
	i = i + 1

print(cost)
Buggy python submission (verdict: Time Limit Exceeded):
def remove_01_10(S):
	N = len(S) 
	while True:
		if '01' in S or '10' in S:
			S = S.replace('10', '')
			S = S.replace('01', '')
		else:
			return(N - len(S))	

print(remove_01_10(input()))

Fixed submission:
S = list(input())
N = len(S)
num0 = 0
for i in range(N):
	if S[i] == '0':
		num0 = num0 + 1

num1 = 0
for i in range(N):
	if S[i] == '1':
		num1 = num1 + 1
print(N - abs(num0 - num1))

Buggy python submission (verdict: Time Limit Exceeded):
def remove_01_10(S):
	S = S.replace('10', '')
	S = S.replace('01', '')
	return S	

S = input()
N = len(S)
while True:
	if '01' in S or '10' in S:
		S = remove_01_10(S)
	else:
		print(N - len(S))
		exit()

Fixed submission:
S = list(input())
N = len(S)
num0 = 0
for i in range(N):
	if S[i] == '0':
		num0 = num0 + 1

num1 = 0
for i in range(N):
	if S[i] == '1':
		num1 = num1 + 1
print(N - abs(num0 - num1))

Buggy python submission (verdict: Time Limit Exceeded):
def remove_01_10(S):
	S = S.replace('10', '')
	S = S.replace('01', '')
	return S	

S = input()
N = len(S)
for i in range(N):
	if len(S) == len(remove_01_10(S)):
		print(N - len(S))
		exit()
	else:
		S = remove_01_10(S)

Fixed submission:
S = list(input())
N = len(S)
num0 = 0
for i in range(N):
	if S[i] == '0':
		num0 = num0 + 1

num1 = 0
for i in range(N):
	if S[i] == '1':
		num1 = num1 + 1
print(N - abs(num0 - num1))

Buggy python submission (verdict: Time Limit Exceeded):
def remove_01_10(S):
	S = S.replace('10', '')
	S = S.replace('01', '')
	return S	


S = input()
N = len(S)
while True:
	if len(S) == len(remove_01_10(S)):
		print(N - len(S))
		exit()
	else:
		S = remove_01_10(S)


Fixed submission:
S = list(input())
N = len(S)
num0 = 0
for i in range(N):
	if S[i] == '0':
		num0 = num0 + 1

num1 = 0
for i in range(N):
	if S[i] == '1':
		num1 = num1 + 1
print(N - abs(num0 - num1))
Buggy python submission (verdict: Runtime Error):
D, N = map(int, input().split())
if N == 100:
	print(100**D*(N+1)
else:	
	print(100**D*N)

Fixed submission:
D, N = map(int, input().split())
if N == 100:
	print(100**D*(N+1))
else:	
	print(100**D*N)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int,input().split()))


getter = 0
def solver(now,count,to):
  global getter
  if now+1 < len(H) and H[now] >= H[now+1] and to != 2:
    solver(now+1,count+1,1)
  getter = max(getter,count)

for i in range(N):
  solver(i,0,0)

print(getter)


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

cnt = 0
ret = 0
for i in range(N-1):
  if H[i] >= H[i+1]:
    cnt += 1
  else:
    ret = max(cnt,ret)
    cnt = 0
  if i == N-2:
    ret = max(cnt,ret)
print(ret)
Buggy python submission (verdict: Runtime Error):
import itertools

N = int(input())

NUMBERS = list(itertools.permutations(range(N)))
ret = 0
for numbers in NUMBERS:
  sum = 0
  for num,i in zip(numbers,range(N)):
    sum += (num+1)%(i+1)
  ret = max(ret,sum)

print(ret)


Fixed submission:
N = int(input())
print((N-1)*N//2)
Buggy python submission (verdict: Runtime Error):
N,Q = map(int,input().split())

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

counter = [0]*N

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

def dfs(p,x):
  counter[p] += x
  if flag[p]: return
  flag[p] = True
  for cmd in to[p]:
    if p < cmd: dfs(cmd,x)

for i in range(Q):
  flag = [False]*N
  p,x = map(int,input().split())
  dfs(p-1,x)

#print(to)

print(*counter)


Fixed submission:
import collections

n,q=map(int,input().split())
cnt=[0]*(n+1)
g=[[] for _ in range(n+1)]
for _ in range(n-1):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
for _ in range(q):
  v,val=map(int,input().split())
  cnt[v]+=val
q=collections.deque()
q.append(1)
checked=[0]*(n+1)
while q:
  v=q.pop()
  checked[v]=1
  for u in g[v]:
    if checked[u]==1:
      continue
    cnt[u]+=cnt[v]
    q.append(u)
print(*cnt[1:])

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

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

counter = [0]*N

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

def dfs(p,x):
  counter[p] += x
  if flag[p]: return
  flag[p] = True
  for cmd in to[p]:
    if p < cmd: dfs(cmd,x)

for i in range(Q):
  flag = [False]*N
  p,x = map(int,input().split())
  dfs(p-1,x)

#print(to)

print(counter)


Fixed submission:
import collections

n,q=map(int,input().split())
cnt=[0]*(n+1)
g=[[] for _ in range(n+1)]
for _ in range(n-1):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
for _ in range(q):
  v,val=map(int,input().split())
  cnt[v]+=val
q=collections.deque()
q.append(1)
checked=[0]*(n+1)
while q:
  v=q.pop()
  checked[v]=1
  for u in g[v]:
    if checked[u]==1:
      continue
    cnt[u]+=cnt[v]
    q.append(u)
print(*cnt[1:])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [[]]*N
for i in range(N):
  k = input()
  s[i] = [c for c in k]
  s[i].sort()

cnt = 0
for i in range(N-1):
  for j in range(i+1,N):
    if s[i] == s[j]:
      cnt += 1
print(cnt)
#print(list(set(s)))

Fixed submission:
N = int(input())
s = [input() for _ in range(N)]
for i in range(N):
  s[i] = "".join(sorted(s[i]))
t = {}
for i in range(N):
  if s[i] in t:
    t[s[i]] += 1
  else:
    t[s[i]] = 1
print(sum(t[k]*(t[k]-1)//2 for k in t))
Buggy python submission (verdict: Runtime Error):
a = input()
b = int(input())

if b >= 3200:
  print(a)
else:
  print("red")

Fixed submission:
a = int(input())
b = input()

if a >= 3200:
  print(b)
else:
  print('red')
Buggy python submission (verdict: Runtime Error):
    string = input()

    ans = string.replace(',', ' ')
    print(ans)

Fixed submission:
string = input()

ans = string.replace(',', ' ')
print(ans)
Buggy python submission (verdict: Runtime Error):
    a, op, b = map(str, input().split())
    a = int(a)
    b = int(b)

    if op == "+":
        result = a + b
    else:
        result = a - b

    print(result)

Fixed submission:
def iroha():
    a, op, b = map(str, input().split())
    a = int(a)
    b = int(b)

    if op == "+":
        result = a + b
    else:
        result = a - b

    print(result)




if __name__ == "__main__":
    iroha()

Buggy python submission (verdict: Runtime Error):
    a, op, b = map(str, input().split())
    a = int(a)
    b = int(b)

    if op == "+":
        result = a + b
    else:
        result = a - b

    print(result)

Fixed submission:
def iroha():
    a, op, b = map(str, input().split())
    a = int(a)
    b = int(b)

    if op == "+":
        result = a + b
    else:
        result = a - b

    print(result)




if __name__ == "__main__":
    iroha()

Buggy python submission (verdict: Runtime Error):
    a, op, b = map(str, input().split())
    a = int(a)
    b = int(b)

    if op == "+":
        result = a + b
    else:
        result = a - b

    print(result

Fixed submission:
def iroha():
    a, op, b = map(str, input().split())
    a = int(a)
    b = int(b)

    if op == "+":
        result = a + b
    else:
        result = a - b

    print(result)




if __name__ == "__main__":
    iroha()
Buggy python submission (verdict: Runtime Error):
string = input()
    Capital = string[0]
    print("A" + Capital + "C")



Fixed submission:
def iroha():
    head, string, heel = map(str, input().split())
    headC = head[0]
    Capital = string[0]
    heelC = heel[0]
    print(headC + Capital + heelC)

if __name__ == "__main__":
    iroha()
Buggy python submission (verdict: Runtime Error):
def iroha():
    a, b, c = map(int, input().split())
    if a == b and b == c and a == c:
        print(1)
    elif a != b and b != c and a != c:
        print(3)
    elif else:
        print(2)

if __name__ == "__main__":
    iroha()



Fixed submission:
def iroha():
    a, b, c = map(int, input().split())
    if a == b and b == c and a == c:
        print(1)
    elif a != b and b != c and a != c:
        print(3)
    else:
        print(2)

if __name__ == "__main__":
    iroha()

Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
    if a == b == c:
        print(1)
    elif a != b != c:
        print(3)
    else:
        print(2)



Fixed submission:
def iroha():
    a, b, c = map(int, input().split())
    if a == b and b == c and a == c:
        print(1)
    elif a != b and b != c and a != c:
        print(3)
    else:
        print(2)

if __name__ == "__main__":
    iroha()
Buggy python submission (verdict: Runtime Error):
    n, k, price, special = map(int, input().split())
    result = 0
    for i in range(n):
        if i < k:
            result += price
        else:
            result += special
 

Fixed submission:
def iroha():
    n, k, price, special = [int(input()) for i in range(4)]
    result = 0
    for i in range(n):
        if i < k:
            result += price
        else:
            result += special
    print(result)

if __name__ == "__main__":
    iroha()

Buggy python submission (verdict: Runtime Error):
    n, k, price, special = map(int, input().split())
    result = 0
    for i in range(n):
        if i < k:
            result += price
        else:
            result += special
    
    print(result)
 

Fixed submission:
def iroha():
    n, k, price, special = [int(input()) for i in range(4)]
    result = 0
    for i in range(n):
        if i < k:
            result += price
        else:
            result += special
    print(result)

if __name__ == "__main__":
    iroha()

Buggy python submission (verdict: Runtime Error):
def iroha():
    n, k, price, special = map(int, input().split())
    result = 0
    for i in range(n):
        if i < k:
            result += price
        else:
            result += special
    
    print(result)
            

if __name__ == "__main__":
    iroha()



Fixed submission:
def iroha():
    n, k, price, special = [int(input()) for i in range(4)]
    result = 0
    for i in range(n):
        if i < k:
            result += price
        else:
            result += special
    print(result)

if __name__ == "__main__":
    iroha()

Buggy python submission (verdict: Runtime Error):
def iroha():
    n, k, price, special = map(int, input().split())
    result = 0
    for i in range(n):
        if i < k:
            result += price
        else:
            result += special
    
    print(result)
            

if __name__ == "__main__":
    iroha()

Fixed submission:
def iroha():
    n, k, price, special = [int(input()) for i in range(4)]
    result = 0
    for i in range(n):
        if i < k:
            result += price
        else:
            result += special
    print(result)

if __name__ == "__main__":
    iroha()

Buggy python submission (verdict: Runtime Error):
n, k, price, special = map(int, input().split())
    result = 0
    for i in range(n):
        if i < k:
            result += price
        else:
            result += special
    
    print(result)

Fixed submission:
def iroha():
    n, k, price, special = [int(input()) for i in range(4)]
    result = 0
    for i in range(n):
        if i < k:
            result += price
        else:
            result += special
    print(result)

if __name__ == "__main__":
    iroha()
Buggy python submission (verdict: Runtime Error):
def iroha():
    count = int(input())
    result = 0
    for i in range(count+1):
        result += i

    print(result)


if __name__ == "__main__":
    iroha(

Fixed submission:
def iroha():
    count = int(input())
    result = 0
    for i in range(count+1):
        result += i

    print(result)


if __name__ == "__main__":
    iroha()

Buggy python submission (verdict: Runtime Error):
  count = int(input())
    result = 0
    for i in range(count+1):
        print(i)
        result += i

    print(result

Fixed submission:
def iroha():
    count = int(input())
    result = 0
    for i in range(count+1):
        result += i

    print(result)


if __name__ == "__main__":
    iroha()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
print(sum(range(n)))

Fixed submission:
n = int(input())
 
print(int(n * (n - 1) // 2))
Buggy python submission (verdict: Runtime Error):
list(S)
list(T)

a=0

if S[0] = T[0]:
  a = a + 1

if S[1] = T[1]:
  a = a + 1

if S[2] = T[2]:
  a = a +1

Fixed submission:
S = input()
T = input()
 
q = 0
for n in range(3):
  if S[n] ==T[n]:
    q +=1
print(q)
Buggy python submission (verdict: Runtime Error):
A,B = map(int, input().split())
for x in range(20):
  s = (A-1)*(x-1)+A
  if B <= s:
    print(x)
	break

Fixed submission:
A, B = map(int, input().split())
for x in range(20):
  s = (A-1)*(x-1) + A
  if B<=s:
    print(x)
    exit()
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int,input().split()))
s = 0
l =[]
for n in range(N-1):
  if H[n]>=H[n+1]:
    s += 1
    l.append(s)
  else:
    l.append(s)
    s = 0
print(max(l))

Fixed submission:
N = int(input())
H = list(map(int,input().split()))
s = 0
l =[0]
for n in range(N-1):
  if H[n]>=H[n+1]:
    s += 1
    l.append(s)
  else:
    l.append(s)
    s = 0
print(max(l))

Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int,input().split()))
l =[]
for n in range(N-1):
  s = 0
  for j in range(n+1,N):
    if H[n] >= H[j]:
      s += 1
    else:
      l.append(s)
      break
print(max(l))

Fixed submission:
N = int(input())
H = list(map(int,input().split()))
s = 0
l =[0]
for n in range(N-1):
  if H[n]>=H[n+1]:
    s += 1
    l.append(s)
  else:
    l.append(s)
    s = 0
print(max(l))

Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int,input().split()))
l =[]
for n in range(N):
  s = 0
  for j in range(N-1):
    if H[n] >= H[j+1]:
      s += 1
    else:
      l.append(s)
print(max(l))

Fixed submission:
N = int(input())
H = list(map(int,input().split()))
s = 0
l =[0]
for n in range(N-1):
  if H[n]>=H[n+1]:
    s += 1
    l.append(s)
  else:
    l.append(s)
    s = 0
print(max(l))
Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())
t = [[] for i in range(n)]# 空の2次元配列を作る
for i in range(n-1):
    a, b = map(int, input().split())
    t[a - 1].append(b -1)
    t[b - 1].append(a -1)
# 配列は０から始まるから１、２、３、４の木を０、１、２、３として扱ってる
# 配列の０番目（つまり頂点０）が持つ値がその頂点が持つリンクとなる

v = [0] * (n) #空の配列を作る
for j in  range(q):# 0からqまで
    a, b = map(int, input().split())
    v[a-1] += b


def csum(now, bef):  # 累積和
    for nxt in t[now]:
        if nxt != bef:
            v[nxt] += v[now]
            csum(nxt, now)

csum(0, -1)
print(*v)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
input=sys.stdin.readline

n, q = map(int, input().split())
t = [[] for i in range(n)]# 空の2次元配列を作る
for i in range(n-1):
    a, b = map(int, input().split())
    t[a - 1].append(b -1)
    t[b - 1].append(a -1)
# 配列は０から始まるから１、２、３、４の木を０、１、２、３として扱ってる
# 配列の０番目（つまり頂点０）が持つ値がその頂点が持つリンクとなる

v = [0] * (n) #空の配列を作る
for j in  range(q):# 0からqまで
    a, b = map(int, input().split())
    v[a-1] += b


def csum(now, bef):  # 累積和
    for nxt in t[now]:
        if nxt != bef:
            v[nxt] += v[now]
            csum(nxt, now)

csum(0, -1)
print(*v)

Buggy python 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)

v = [0] * (n)
for j in  range(q):
    a, b = map(int, input().split())
    v[a-1] += b


def csum(now, bef):
    for nxt in t[now]:
        if nxt != bef:
            v[nxt] += v[now]
            dfs(nxt, now)

csum(0, -1)
print(*v)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
input=sys.stdin.readline

n, q = map(int, input().split())
t = [[] for i in range(n)]# 空の2次元配列を作る
for i in range(n-1):
    a, b = map(int, input().split())
    t[a - 1].append(b -1)
    t[b - 1].append(a -1)
# 配列は０から始まるから１、２、３、４の木を０、１、２、３として扱ってる
# 配列の０番目（つまり頂点０）が持つ値がその頂点が持つリンクとなる

v = [0] * (n) #空の配列を作る
for j in  range(q):# 0からqまで
    a, b = map(int, input().split())
    v[a-1] += b


def csum(now, bef):  # 累積和
    for nxt in t[now]:
        if nxt != bef:
            v[nxt] += v[now]
            csum(nxt, now)

csum(0, -1)
print(*v)
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
a_set = {1}
b_set = {1}
for i in range(1,a):
    if a % i == 0:
        a_set.add(i)

for i in range(1,b):
    if b % i == 0:
        b_set.add(i)

c_list = list(a_set & b_set)
c_list.sort()
print(c_list[c - 1])


Fixed submission:
A, B, C = map(int, input().split())#入力された値を空白で区切ってその値をint型に変換して代入している
print(min(int(B / A), C))#intで囲うことで少数を切り捨てている

Buggy python submission (verdict: Runtime Error):
a = int(input())#一回にかかる料金
b = int(input())#所持している金額
c = int(input())#満足する回数
if b//a > c:
    print(c)
else:
    print(b//c)



Fixed submission:
A, B, C = map(int, input().split())#入力された値を空白で区切ってその値をint型に変換して代入している
print(min(int(B / A), C))#intで囲うことで少数を切り捨てている