Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
l = input().split()
if abs(l[2] - l[1]) > l[3]:
    print("Yes")
elif abs(l[0] - l[1]) > l[3] and abs(l[1] - l[2]) > l[3]:
    print("Yes")
else:
    print("No")


Fixed submission:
l = input().split()
if abs(int(l[2]) - int(l[0])) <= int(l[3]):
    print("Yes")
elif abs(int(l[0]) - int(l[1])) <= int(l[3]) and abs(int(l[1]) - int(l[2])) <= int(l[3]):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
l = input().split()
if abs(l[2] - l[1]) > l[3]:
    print("Yes")
elif abs(l[0] - l[1]) > l[3] and abs(l[1] - l[2]) > l[3]:
    print("Yes")
else:
    print("No")


Fixed submission:
l = input().split()
if abs(int(l[2]) - int(l[0])) <= int(l[3]):
    print("Yes")
elif abs(int(l[0]) - int(l[1])) <= int(l[3]) and abs(int(l[1]) - int(l[2])) <= int(l[3]):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())
l = list(s)
for i in range(len(s)-1):
    for j in range(1, len(s)+1):
        if i < j:
            l.append(s[i:j])
l = list(set(l))
l.sort()
print(l[k-1])

Fixed submission:
s = input()
k = int(input())
lis = list()
for i in range(len(s)):
    for j in range(i+1, i+6):
        if s[i:j] not in lis:
            lis.append(s[i:j])
lis = list(set(lis))
lis.sort()
print(lis[k-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
S,T=map(str,input().split())

cnt = 0
ans = ""

for cnt in range(N):
  ans=ans+S[cnt]+T[cnt]
  
print(ans)

Fixed submission:
A= int(input())
B= int(input())

ans = 6-A-B

print(ans)
Buggy python submission (verdict: Runtime Error):
import heapq
N = int(input())
V = list(map(int, input().split()))
heapq.heapify(V)
for i in range(N-2):
  heapq.heappush((heapq.heappop(V)+heapq.heappop(V))/2)
print(sum(V)/2)

Fixed submission:
a = int(input())
print("red" if a < 3200 else input())
Buggy python submission (verdict: Runtime Error):
import heapq
N = int(input())
V = list(map(int, input().split()))
heapq.heapify(V)
for i in range(N-2):
  heapq.heappush((heapq.heappop(V)+heapq.heappop(V))/2)
print(sum(V)/2)

Fixed submission:
import heapq
N = int(input())
V = list(map(int, input().split()))
 
heapq.heapify(V)
for i in range(N-2):
  heapq.heappush(V, (heapq.heappop(V)+heapq.heappop(V))/2)
print(sum(V)/2)

Buggy python submission (verdict: Runtime Error):
import heapq
N = int(input())
V = list(map(int, input().split()))
 
heapq.heapfy(V)
for i in range(N-2):
  heapq.heappush((heapq.heappop(V)+heapq.heappop(V))/2)
print(sum(V)/2)
  

Fixed submission:
import heapq
N = int(input())
V = list(map(int, input().split()))
 
heapq.heapify(V)
for i in range(N-2):
  heapq.heappush(V, (heapq.heappop(V)+heapq.heappop(V))/2)
print(sum(V)/2)

Buggy python submission (verdict: Runtime Error):
import heapq
N = input()
V = input().split()

heapq.heapfy(V)
for i in range(N-2):
  heapq.heappush((heapq.heappop(V)+heapq.heappop(V))/2)
print(sum(V)/2)
  

Fixed submission:
import heapq
N = int(input())
V = list(map(int, input().split()))
 
heapq.heapify(V)
for i in range(N-2):
  heapq.heappush(V, (heapq.heappop(V)+heapq.heappop(V))/2)
print(sum(V)/2)
Buggy python submission (verdict: Runtime Error):
import math

def lcm(a,b):
    print((a * b) // math.gcd(a,b))

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

lcm(a,b)

Fixed submission:
import fractions

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

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

n = int(input())
array = []
for i in range(1,10):
    for j in range(1,10):
        array.append(i * j)
        
if n in array:
    print("Yes")
else:
    print("No")

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

if a >9 or b > 9:
    print("-1")
else:
    ans = a * b
    print(ans)
Buggy python submission (verdict: Runtime Error):
a,b =(int(i) for i in input().split())

try:
  print(a - (b*2))
else:
  print("0")

Fixed submission:
a,b =(int(i) for i in input().split())
result = a - (b*2)
if result > 0:
  print(result)
else:
  print("0")
Buggy python submission (verdict: Runtime Error):
a, b = [int(x) for x in input().split()]

import math
print(a*b//math.gcd(a, b))

Fixed submission:
N = input()
L = N.split()
a = int(L[0])
b = int(L[1])

if a < b:
    c = a
    a = b
    b = c

r = a % b
    
while r != 0:
    a = b
    b = r
    r = a % b

# この時のbが最大公約数

print(int(int(L[0])*int(L[1])/b))

Buggy python submission (verdict: Runtime Error):
import math
import numpy as np

N = input()
l = N.split()

print(np.lcm(int(l[0]), int(l[1])))

Fixed submission:
N = input()
L = N.split()
a = int(L[0])
b = int(L[1])

if a < b:
    c = a
    a = b
    b = c

r = a % b
    
while r != 0:
    a = b
    b = r
    r = a % b

# この時のbが最大公約数

print(int(int(L[0])*int(L[1])/b))

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

input = input()
l = input.split()

print(math.gcd(int(l[0]), int(l[1])))

Fixed submission:
N = input()
L = N.split()
a = int(L[0])
b = int(L[1])

if a < b:
    c = a
    a = b
    b = c

r = a % b
    
while r != 0:
    a = b
    b = r
    r = a % b

# この時のbが最大公約数

print(int(int(L[0])*int(L[1])/b))
Buggy python submission (verdict: Runtime Error):
ans = [1,2,3]
A = input()
B = input()

ans.del(A)
ans.del(B)

print(ans[0])


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

ans = [1,2,3]

ans.remove(int(a))
ans.remove(int(b))

print(ans[0])
Buggy python submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

line = input()
arr =  [int(n) for n in line.split(' ')]

print(lcm(*arr))


Fixed submission:
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

line = input()
arr =  [int(n) for n in line.split(' ')]

print(lcm(*arr))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S, T = input().split()

res = ''

for i in range(n):
  res = res + str(S[i]) + str(T[i])
  
print(res)

Fixed submission:
n = int(input())
s, t = input().split()
 
res = ''
 
for i in range(n):
  res = res + str(s[i]) + str(t[i])
  
print(res)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if (a == 1 or b == 2) and (a == 1 or b == 2):
    print(3)
elif (a == 2 or b == 3) and (a == 2 or b == 3):
    print(1)
else
    print(2)


Fixed submission:
a = int(input())
b = int(input())
print(6 - a - b)

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

if (a == 1 or b == 2) and (a == 1 or b == 2):
    print(3)
elif (a == 2 or b == 3) and (a == 2 or b == 3):
    print(1)
else
    print(2)


Fixed submission:
a = int(input())
b = int(input())
print(6 - a - b)

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

if (a == 1 || b == 2) && (a == 1 || b == 2):
    print(3)
elif (a == 2 || b == 3) && (a == 2 || b == 3):
    print(1)
else
    print(2)


Fixed submission:
a = int(input())
b = int(input())
print(6 - a - b)
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if A + B + C > 21:
    print("bust")
else
    print("win")

Fixed submission:
A, B, C = map(int, input().split())
if A + B + C > 21:
    print("bust")
else:
    print("win")
Buggy python submission (verdict: Time Limit Exceeded):
input_line=int(input())
ARC = [int(i)for i in input().split()]
count=0
for i in range(10**5):
  AARC = ARC
  for s in ARC:
    if s<i:
      while s in AARC:
        AARC.remove(s)
  if (input_line//2)== len(AARC):
    count+=1

print(count)

Fixed submission:
input_line=int(input())
ARC = [int(i)for i in input().split()]
ARC.sort()
middle = input_line //2
s = ARC[middle]-ARC[middle-1]

print(s)

Buggy python submission (verdict: Time Limit Exceeded):
input_line=int(input())
ARC = [int(i)for i in input().split()]
ABC = []
count=0
for i in range(10**5):
  AARC = ARC
  AABC = ABC
  for s in ARC:
    if s < i :
      AABC.append(s)
      AARC.remove(s)
      while s in AARC:
        AABC.append(s)
        AARC.remove(s)
  if len(AABC) == len(AARC):
    count+=1

print(count)

Fixed submission:
input_line=int(input())
ARC = [int(i)for i in input().split()]
ARC.sort()
middle = input_line //2
s = ARC[middle]-ARC[middle-1]

print(s)
Buggy python submission (verdict: Runtime Error):
W,H,x,y= map(int,input().split())
big_square = W * H
square_1 = x * H
square_12 = big_square - square_1
if square_1 <= square_12:
  s = square_1
elif square_1> square_12:
  s = square_12

square_2 = W * y
square_22 = big_square - square_2
if square_2 <= square_22:
  t = square_2
elif square_2> square_22:
  t = square_22

if s<=t:
  big = t
else:
  big = s


  
if W == x *2 and H == y *2:
  way = 1
else:
  way = 0
  

print(big,way)

Fixed submission:
X ,a = map(int,input().split())
if X < a:
  print(0)
if X >= a :
  print(10)
Buggy python submission (verdict: Runtime Error):
list = [int(i) for i in input().split()] 
s = min(list)
list.strip(s)
t = min(list)
Time = s+t
print(Time)

Fixed submission:
list = [int(i) for i in input().split()] 
s = min(list)
list.remove(s)
t = min(list)
Time = s+t
print(Time)
Buggy python submission (verdict: Runtime Error):
N = int(input())
W = [int(i) for i in input().split()]
for i in range (N):
  slice1 =  W[0,i]
  slice2 = W[i,0]
  print(slice1,slice2)



list.append(s1 -s2)
z =min(list)
print(z)

Fixed submission:
N = int(input())
W = [int(i) for i in input().split()]
list = []


for i in range (N):
  s1 =0
  s2 =0
  slice1 =  W[0:i]
  for t in slice1:
    s1 += t
  slice2 = W[i:N]
  for t in slice2:
    s2 += t
  z = s1 - s2
  if z < 0:
    z*= -1
  list.append(z)
z =min(list)

print(z)

Buggy python submission (verdict: Runtime Error):

list = [0,1,2,3,4,5,6,7]    
    
for i in list(0,3):
  s += i
  print(s)

Fixed submission:
N = int(input())
W = [int(i) for i in input().split()]
list = []


for i in range (N):
  s1 =0
  s2 =0
  slice1 =  W[0:i]
  for t in slice1:
    s1 += t
  slice2 = W[i:N]
  for t in slice2:
    s2 += t
  z = s1 - s2
  if z < 0:
    z*= -1
  list.append(z)
z =min(list)

print(z)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input()split())
c =  a*b
if c%2 ==0:
  print('Even')
else:
  print('Odd')

Fixed submission:
a,b = map(int,input().split())
c =  a*b
if c%2 ==0:
  print('Even')
else:
  print('Odd')
Buggy python submission (verdict: Runtime Error):
a,b = map (str,input().split())
s = a+b
for i in range(400):
  if s == i ** 2:
    count += 1
  else:
    count+=0
if count>1:
  print('Yes')
else:
  print('No')

Fixed submission:
a,b = map (str,input().split())
c = a+b
s = int(c)
count=0
for i in range(400):
  if s == i ** 2:
    count += 1
  else:
    count+=0
if count>0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n=int(input())
sp = 0
for i in range(1,n+1):
  s_i=i
  count =0
  a =True
  while a:
    if i % 2 ==0:
      i=i/2
      count += 1
    else:
      a =False
  if count >sp:
    sp = count
    sp_i = s_i
    
    
print(sp_i)


Fixed submission:
n=int(input())
sp = 0
sp_i=1
for i in range(1,n+1):
  s_i=i
  count =0
  a =True
  while a:
    if i % 2 ==0:
      i=i/2
      count += 1
    else:
      a =False
  if count >sp:
    sp = count
    sp_i = s_i
    
    
print(sp_i)
Buggy python submission (verdict: Runtime Error):
fac = []


def init():
    fac.append(1)
    for i in range(1, 2003):
        fac.append(fac[i - 1] * i)


def c(a, b):
    return fac[a] // fac[b] // fac[a - b]


init()
data = input().split(" ")
n = int(data[0])
b = int(data[1])
r = n - b
for i in range(1, b+1):
    print(int(c(b-1, i-1) * c(r+1, i) % (1e9 + 7)))


Fixed submission:
fac = []


def init():
    fac.append(1)
    for i in range(1, 2003):
        fac.append(fac[i - 1] * i)


def c(a, b):
    return fac[a] // fac[b] // fac[a - b]


init()
data = input().split(" ")
n = int(data[0])
b = int(data[1])
r = n - b
for i in range(1, b+1):
    print(int(c(b-1, i-1) * c(r+1, i) % int(1e9 + 7)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s, t = input().split()

merge = ''
for i in range(n):
  metge += s[i] + t[i]
  
print(merge)

Fixed submission:
n = int(input())
s, t = input().split()

merge = ''
for i in range(n):
  merge += s[i] + t[i]
  
print(merge)
Buggy python submission (verdict: Runtime Error):
A,B=input().split()

if A>=B*2:
  print(A-2*B)
else:
  print(0)

Fixed submission:
A,B=input().split()
a=int(A)
b=int(B)
if a>=b*2:
  print(a-2*b)
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
n=int(input())
S=input()
s=list(S)
 

def jokyolist(s):
  jokyo=[]
  #jokyo配列はこれから除去すべき奴の番号のリスト
  for i in range(len(s)-1):
    if s[i]==s[i+1]:
      jokyo.append(i)
    jokyo=sorted(jokyo,reverse=True)
  return jokyo
 
def remov(s,jokyo):
  for i in range(len(jokyo)):
    s.pop(jokyo[i])
    return s
def removtimes(jokyo):
  t=len(jokyo)
  return t
 
i=0
while i<=n:
  jokyo=jokyolist(s)
  if removtimes(jokyo)==0:
    break
  s=remov(s,jokyo)
  i+=1

print(len(s))


Fixed submission:
A,B=input().split()
a=int(A)
b=int(B)
if a>=b*2:
  print(a-2*b)
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
S=input()
s=list(S)
 
#print(s)
def jokyolist(s):
  jokyo=[]
  #jokyo配列はこれから除去すべき奴の番号のリスト
  for i in range(len(s)-1):
    if s[i]==s[i+1]:
      jokyo.append(i)
    jokyo=sorted(jokyo,reverse=True)
  return jokyo
 
def remov(s,jokyo):
  for i in range(len(jokyo)):
    s.pop(jokyo[i])
    return s

def removtimes(jokyo):
  t=len(jokyo)
  return t
 
i=0
while i<=n:
  jokyo=jokyolist(s)
  if removtimes(jokyo)==0:
    break
  s=remov(s,jokyo)
  i+=1

#print(s)
print(len(s))


Fixed submission:
n=int(input())
S=input()
s=list(S)

p=[]
#print(s)
for i in range(n-1):
  if s[i]==s[i+1]:
    p.append(i)
p.sort(reverse=True)
l=len(p)

for i in range(l):
    #print(p[i])
    s.pop(p[i])

print(len(s))

Buggy python submission (verdict: Runtime Error):
n=int(input())
S=input()
s=list(S)


def jokyolist(s):
  jokyo=[]
  #jokyo配列はこれから除去すべき奴の番号のリスト
  for i in range(len(s)-1):
    if s[i]==s[i+1]:
      jokyo.append(i)
    jokyo=sorted(jokyo,reverse=TRUE)
  return jokyo

def remov(s,jokyo):
  for i in range(len(jokyo)):
    s.pop(jokyo[i])
    return s
def removtimes(jokyo):
  t=len(jokyo)
  return t


while:
  jokyo=jokyolist(s)
  if removtimes(jokyo)==0:
    break:
  s=remov(s,jokyo)

print(len(s))


Fixed submission:
n=int(input())
S=input()
s=list(S)

p=[]
#print(s)
for i in range(n-1):
  if s[i]==s[i+1]:
    p.append(i)
p.sort(reverse=True)
l=len(p)

for i in range(l):
    #print(p[i])
    s.pop(p[i])

print(len(s))
Buggy python submission (verdict: Runtime Error):
S=input()
s=list(S)

odd=[]
even=[]

for i in range(n):
  if i%2==0:
    odd.append(s[i])
  if i%2==1:
    even.append(s[i])

    
oddsum=0
evensum=0

for i in range(len(odd)):
  if odd[i]=="R" or odd[i]=="U" or odd[i]=="D":
    oddsum+=1
  else:
    oddsum+=0

for i in range(len(even)):
  if even[i]=="L" or even[i]=="U" or even[i]=="D":
    evensum+=1
  else:
    evensum=0

if oddsum==len(odd) and evensum==len(even):
  print("Yes")
else:
  print("No")

Fixed submission:
S=input()
s=list(S)
 
odd=[]
even=[]
 
for i in range(len(s)):
  if i%2==0:
    odd.append(s[i])
  if i%2==1:
    even.append(s[i])
 
    
oddsum=0
evensum=0
 
for i in range(len(odd)):
  if odd[i]=="R" or odd[i]=="U" or odd[i]=="D":
    oddsum+=1
  else:
    oddsum+=0
 
for i in range(len(even)):
  if even[i]=="L" or even[i]=="U" or even[i]=="D":
    evensum+=1
  else:
    evensum=0
 
if oddsum==len(odd) and evensum==len(even):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
L = list(map(int, input().split()))

L.sort()

ans = 0
for i in range(N):
    for j in range(i+1,N):
        ans += bisect.bisect_left(L[j+1::], L[i]+L[j])
print(ans)

Fixed submission:
import bisect
N = int(input())
L = list(map(int, input().split()))
index = [-1 for i in range(2001)]
L.sort()

ans = 0
for i in range(N):
    for j in range(i+1,N):
        if index[L[i]+L[j]] == -1:
            index[L[i]+L[j]] = bisect.bisect_left(L, L[i]+L[j])
        ans += max(0, index[L[i]+L[j]]-j-1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
L = list(map(int, input().split()))

L.sort()

ans = 0
for i in range(N):
    for j in range(i+1,N):
        ans += bisect.bisect_left(L[j+1::], L[i]+L[j])
print(ans)

Fixed submission:
import bisect
N = int(input())
L = list(map(int, input().split()))
index = [-1 for i in range(2001)]
L.sort()

ans = 0
for i in range(N):
    for j in range(i+1,N):
        if index[L[i]+L[j]] == -1:
            index[L[i]+L[j]] = bisect.bisect_left(L, L[i]+L[j])
        ans += max(0, index[L[i]+L[j]]-j-1)
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
max_num = 10**6
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

is_prime = [1 for i in range(max_num+1)]
primes = [0 for i in range(max_num+1)]
primes[0] = 2
index = 1
for i in range(3, max_num, 2):
    if is_prime[i] == 0:
        continue
    primes[index] = i
    index += 1
    for j in range(i, max_num, i):
        is_prime[j] = 0

r = gcd(A, B)
ans = 1
index = 0
while r != 1:
    mod = primes[index]
    if r % mod == 0:
        ans += 1
        i=1
        while r % mod**(i+1) == 0:
            i+=1
        r = r // mod**i
    index+=1
print(ans)

Fixed submission:
A, B = map(int, input().split())
max_num = 10**12
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

r = gcd(A, B)
ans = len(set(prime_factorize(r)))+1
print(ans)

Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
max_num = 10**6
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

is_prime = [1 for i in range(max_num+1)]
primes = [0 for i in range(max_num+1)]
primes[0] = 2
index = 1
for i in range(3, max_num, 2):
    if is_prime[i] == 0:
        continue
    primes[index] = i
    index += 1
    for j in range(i, max_num, i):
        is_prime[j] = 0

r = gcd(A, B)
index = 0
while r != 1:
    if r % primes[index] == 0:
        r = r // primes[index]
    if r % primes[index] != 0:
        index+=1
print(index+1)

Fixed submission:
A, B = map(int, input().split())
max_num = 10**12
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

r = gcd(A, B)
ans = len(set(prime_factorize(r)))+1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())

adj = {}
val = [0 for i in range(N+1)]
ans = [0 for i in range(N+1)]
check = [False for i in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    if a not in adj:
        adj[a] = []
    if b not in adj:
        adj[b] = []
    adj[a].append(b)
    adj[b].append(a)

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

queue = [(1,0)]

while len(queue):
    q, c = queue.pop()
    check[q]=True
    ans[q] = val[q] + c
    for nq in adj[q]:
        if check[nq] == False:
            queue.append((nq,ans[q]))

print(*ans[1::])

Fixed submission:
from collections import deque

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

adj = {}
val = [0 for i in range(N+1)]
ans = [0 for i in range(N+1)]
check = [False for i in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    if a not in adj:
        adj[a] = []
    if b not in adj:
        adj[b] = []
    adj[a].append(b)
    adj[b].append(a)

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

queue = deque([(1,0)])

while len(queue):
    q, c = queue.pop()
    check[q]=True
    ans[q] = val[q] + c
    for nq in adj[q]:
        if check[nq] == False:
            queue.append((nq,ans[q]))
print(*ans[1::])

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

adj = {}
val = [0 for i in range(N+1)]
ans = [0 for i in range(N+1)]
check = [False for i in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    if a not in adj:
        adj[a] = []
    if b not in adj:
        adj[b] = []
    adj[a].append(b)
    adj[b].append(a)

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

queue = [(1,0)]

while len(queue):
    q, c = queue.pop()
    check[q]=True
    ans[q] = val[q] + c
    for nq in adj[q]:
        if check[nq] == False:
            queue.append((nq,ans[q]))

print(*ans[1::])

Fixed submission:
from collections import deque

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

adj = {}
val = [0 for i in range(N+1)]
ans = [0 for i in range(N+1)]
check = [False for i in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    if a not in adj:
        adj[a] = []
    if b not in adj:
        adj[b] = []
    adj[a].append(b)
    adj[b].append(a)

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

queue = deque([(1,0)])

while len(queue):
    q, c = queue.pop()
    check[q]=True
    ans[q] = val[q] + c
    for nq in adj[q]:
        if check[nq] == False:
            queue.append((nq,ans[q]))
print(*ans[1::])
Buggy python submission (verdict: Time Limit Exceeded):
S = input()


table = {}
pairs = [[((i*10 + j)%13, i) for i in range(13)] for j in range(13)]
mod = 10**9 + 7
for i in range(13):
    table[i] = tuple((i + j*13)//10 for j in range(10))

dp =[[0 for i in range(13)] for i in range(len(S))]

if S[0] == "?":
    for i in range(10):
        dp[0][i] = 1
else:
    s = int(S[0])
    dp[0][s] = 1

for i in range(1, len(S)):
    s = S[i]
    if s == "?":
        for j in range(13):
            for k in table[j]:
                dp[i][j] += dp[i-1][k] % mod
    else:
        s = int(s)
        for pair in pairs[s]:
            dp[i][pair[0]] = dp[i-1][pair[1]] % mod

print(dp[len(S)-1][5] % mod)


Fixed submission:
S = input()


table = {}
pairs = [[((i*10 + j)%13, i) for i in range(13)] for j in range(13)]
mod = 10**9 + 7
for i in range(13):
    table[i] = tuple((i + j*13)//10 for j in range(10))

dp =[[0 for i in range(13)] for i in range(len(S))]

if S[0] == "?":
    for i in range(10):
        dp[0][i] = 1
else:
    s = int(S[0])
    dp[0][s] = 1

for i in range(1, len(S)):
    s = S[i]
    if s == "?":
        for j in range(13):
            for k in table[j]:
                dp[i][j] += dp[i-1][k]
            dp[i][j] %= mod
    else:
        s = int(s)
        for pair in pairs[s]:
            dp[i][pair[0]] = dp[i-1][pair[1]] % mod

print(dp[len(S)-1][5] % mod)
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = list(map(int, input().split()))

cnt = 0
m = 0
while m <= X:
    m += L[cnt]
    cnt += 1

print(cnt)

Fixed submission:
N, X = map(int, input().split())
L = list(map(int, input().split()))
 
D = 0
cnt = 1
for i in range(N):
    D += L[i]
    if D <= X:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
pos = [list(map(int, input().split())) for i in range(N)]

diffs = {}

for i in range(N):
    for j in range(i+1,N):
        diff = (pos[j][0] - pos[i][0], pos[j][1] - pos[i][1])
        if diff not in diffs:
            diffs[diff] = 0
        diffs[diff] += 1

print(N-max(diffs.values()))

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

diffs = {(0,0):0}

for i in range(N):
    for j in range(N):
        if i==j:
            continue
        diff = (pos[j][0] - pos[i][0], pos[j][1] - pos[i][1])
        if diff not in diffs:
            diffs[diff] = 0
        diffs[diff] += 1

print(N-max(diffs.values()))