Buggy python submission (verdict: Time Limit Exceeded):
def submit():
  n,q = map(int,input().split())
  y = [[] for _ in range(n)]
  c = [0]*n
  for _ in range(n-1):
    ai,bi = map(int,input().split())
    y[ai-1].append(bi-1)
    y[bi-1].append(ai-1)
  for _ in range(q):
    pi,xi = map(int,input().split())
    c[pi-1] += xi
  z = [[0,-1]]
  while z:
    j,b = z.pop(0)
    for yj in y[j]:
      if yj != b:
        z.append([yj,j])
        c[yj] += c[j]
  for i in range(n):
    print(c[i],end=" ")
submit()

Fixed submission:
from collections import deque
def submit():
  n,q = map(int,input().split())
  y = [[] for _ in range(n)]
  c = [0]*n
  for _ in range(n-1):
    ai,bi = map(int,input().split())
    y[ai-1].append(bi-1)
    y[bi-1].append(ai-1)
  for _ in range(q):
    pi,xi = map(int,input().split())
    c[pi-1] += xi
  z = deque([[0,-1]])
  while z:
    j,b = z.popleft()
    for yj in y[j]:
      if yj != b:
        z.append([yj,j])
        c[yj] += c[j]
  for i in range(n):
    print(c[i],end=" ")
submit()

Buggy python submission (verdict: Time Limit Exceeded):
def submit():
  n,q = map(int,input().split())
  y = [[] for _ in range(n)]
  c = [0]*n
  for _ in range(n-1):
    ai,bi = map(int,input().split())
    y[ai-1].append(bi-1)
    y[bi-1].append(ai-1)
  for _ in range(q):
    pi,xi = map(int,input().split())
    c[pi-1] += xi
  z = [(0,-1)]
  while z:
    j,b = z.pop(0)
    for yj in y[j]:
      if yj != b:
        z.append((yj,j))
        c[yj] += c[j]
  for i in range(n):
    print(c[i],end=" ")
submit()

Fixed submission:
from collections import deque
def submit():
  n,q = map(int,input().split())
  y = [[] for _ in range(n)]
  c = [0]*n
  for _ in range(n-1):
    ai,bi = map(int,input().split())
    y[ai-1].append(bi-1)
    y[bi-1].append(ai-1)
  for _ in range(q):
    pi,xi = map(int,input().split())
    c[pi-1] += xi
  z = deque([[0,-1]])
  while z:
    j,b = z.popleft()
    for yj in y[j]:
      if yj != b:
        z.append([yj,j])
        c[yj] += c[j]
  for i in range(n):
    print(c[i],end=" ")
submit()

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
y = [[] for _ in range(n)]
c = [0 for _ in range(n)]
for _ in range(n-1):
  ai,bi = map(int,input().split())
  y[ai-1].append(bi-1)
  y[bi-1].append(ai-1)
for _ in range(q):
  pi,xi = map(int,input().split())
  c[pi-1] += xi
z = [[0,-1]]
while z:
  j,b = z.pop(0)
  for yj in y[j]:
    if yj != b:
      z.append([yj,j])
      c[yj] += c[j]
for i in range(n):
  print(c[i],end=" ")

Fixed submission:
from collections import deque
def submit():
  n,q = map(int,input().split())
  y = [[] for _ in range(n)]
  c = [0]*n
  for _ in range(n-1):
    ai,bi = map(int,input().split())
    y[ai-1].append(bi-1)
    y[bi-1].append(ai-1)
  for _ in range(q):
    pi,xi = map(int,input().split())
    c[pi-1] += xi
  z = deque([[0,-1]])
  while z:
    j,b = z.popleft()
    for yj in y[j]:
      if yj != b:
        z.append([yj,j])
        c[yj] += c[j]
  for i in range(n):
    print(c[i],end=" ")
submit()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(200000)
n,q = map(int,input().split())
y = [[] for _ in range(n)]
c = [0 for _ in range(n)]
for _ in range(n-1):
  ai,bi = map(int,input().split())
  y[ai-1].append(bi-1)
  y[bi-1].append(ai-1)
for _ in range(q):
  pi,xi = map(int,input().split())
  c[pi-1] += xi
def f(j,b):
  for yj in y[j]:
    if yj != b:
      c[yj] += c[j]
      f(yj,j)
f(0,-1)
for i in range(n):
  print(c[i],end=" ")
    
  
  

Fixed submission:
from collections import deque
def submit():
  n,q = map(int,input().split())
  y = [[] for _ in range(n)]
  c = [0]*n
  for _ in range(n-1):
    ai,bi = map(int,input().split())
    y[ai-1].append(bi-1)
    y[bi-1].append(ai-1)
  for _ in range(q):
    pi,xi = map(int,input().split())
    c[pi-1] += xi
  z = deque([[0,-1]])
  while z:
    j,b = z.popleft()
    for yj in y[j]:
      if yj != b:
        z.append([yj,j])
        c[yj] += c[j]
  for i in range(n):
    print(c[i],end=" ")
submit()

Buggy python submission (verdict: Runtime Error):
n,q = map(int,input().split())
y = [[] for _ in range(n)]
c = [0 for _ in range(n)]
for _ in range(n-1):
  ai,bi = map(int,input().split())
  y[ai-1].append(bi-1)
  y[bi-1].append(ai-1)
for _ in range(q):
  pi,xi = map(int,input().split())
  c[pi-1] += xi
def f(j,b):
  for yj in y[j]:
    if yj != b:
      c[yj] += c[j]
      f(yj,j)
f(0,-1)
for i in range(n):
  print(c[i],end=" ")
    
  
  

Fixed submission:
from collections import deque
def submit():
  n,q = map(int,input().split())
  y = [[] for _ in range(n)]
  c = [0]*n
  for _ in range(n-1):
    ai,bi = map(int,input().split())
    y[ai-1].append(bi-1)
    y[bi-1].append(ai-1)
  for _ in range(q):
    pi,xi = map(int,input().split())
    c[pi-1] += xi
  z = deque([[0,-1]])
  while z:
    j,b = z.popleft()
    for yj in y[j]:
      if yj != b:
        z.append([yj,j])
        c[yj] += c[j]
  for i in range(n):
    print(c[i],end=" ")
submit()