Buggy python submission (verdict: Runtime Error):
n,q = map(int,input().split())
ab = [[int(x) for x in input().split()]for _ in range(n-1)]
px = [[int(x) for x in input().split()]for _ in range(q)]

gr = [[]for _ in range(n+1)]
for a,b in ab:
    gr[a].append(b)
    gr[b].append(a)

value = [0]*(n+1)
for p,x in px:
    value[p] += x

def dfs(v,parent,add):
    value[v] += add
    for x in gr[v]:
        if x ==parent:
            continue
        dfs(x,v,value[v])
dfs(1,0,0)

ans = ' '.join(map(str,value[1:]))
print(ans)

Fixed submission:
n,q=list(map(int,input().split()))
GR=[[] for _ in range(n)]
for i in range(n-1):
  a,b=list(map(int,input().split()))
  GR[a-1].append(b)
  GR[b-1].append(a)
 
ans=[0 for _ in range(n)]
for i in range(q):
  p,x=list(map(int,input().split()))
  ans[p-1] += x
  
gr=[1]
parent=[0 for _ in range(n)]
while gr:
  po=gr.pop()
  for no in GR[po-1]:
    if no == parent[po-1]:
      continue
    gr.append(no)
    parent[no-1]=po
    ans[no-1] += ans[po-1]
      
print(' '.join(map(str,ans)))

Buggy python submission (verdict: Runtime Error):
n,q = map(int,input().split())
ab = [[int(x) for x in input().split()]for _ in range(n-1)]
px = [[int(x) for x in input().split()]for _ in range(q)]

gr = [[]for _ in range(n+1)]
for a,b in ab:
    gr[a].append(b)
    gr[b].append(a)

value = [0]*(n+1)
for p,x in px:
    value[p] += x

def dfs(v,parent,add):
    value[v] += add
    for x in gr[v]:
        if x ==parent:
            continue
        dfs(x,v,value[v])
dfs(1,0,0)

ans = ' '.join(map(str,value[1:]))
print(ans)

Fixed submission:
n,q=list(map(int,input().split()))
GR=[[] for _ in range(n)]
for i in range(n-1):
  a,b=list(map(int,input().split()))
  GR[a-1].append(b)
  GR[b-1].append(a)
 
ans=[0 for _ in range(n)]
for i in range(q):
  p,x=list(map(int,input().split()))
  ans[p-1] += x
  
gr=[1]
parent=[0 for _ in range(n)]
while gr:
  po=gr.pop()
  for no in GR[po-1]:
    if no == parent[po-1]:
      continue
    gr.append(no)
    parent[no-1]=po
    ans[no-1] += ans[po-1]
      
print(' '.join(map(str,ans)))

Buggy python submission (verdict: Runtime Error):
n,q = map(int,input().split())
ab = [[int(x) for x in input().split()]for _ in range(n-1)]
px = [[int(x) for x in input().split()]for _ in range(q)]

gr = [[]for _ in range(n+1)]
for a,b in ab:
    gr[a].append(b)
    gr[b].append(a)

value = [0]*(n+1)
for p,x in px:
    value[p] += x

def dfs(v,parent,add):
    value[v] += add
    for x in gr[v]:
        if x ==parent:
            continue
        dfs(x,v,value[v])
dfs(1,0,0)

ans = ' '.join(map(str,value[v]))
print(ans)

Fixed submission:
n,q=list(map(int,input().split()))
GR=[[] for _ in range(n)]
for i in range(n-1):
  a,b=list(map(int,input().split()))
  GR[a-1].append(b)
  GR[b-1].append(a)
 
ans=[0 for _ in range(n)]
for i in range(q):
  p,x=list(map(int,input().split()))
  ans[p-1] += x
  
gr=[1]
parent=[0 for _ in range(n)]
while gr:
  po=gr.pop()
  for no in GR[po-1]:
    if no == parent[po-1]:
      continue
    gr.append(no)
    parent[no-1]=po
    ans[no-1] += ans[po-1]
      
print(' '.join(map(str,ans)))

Buggy python submission (verdict: Runtime Error):
n,q = map(int,input().spliot())
ki = [0]*(n+1)
for i in range(n-1):
    a,b = map(int,input().split())
    ki[b] = a

c = [0]*(n+1)
for i in range(q):
    p,x = map(int,input().split())
    c[p] += x
for i in range(1,n+1):
    c[i] += c[ki[i]]
print("".join(map(str,c[1:])))

Fixed submission:
n,q=list(map(int,input().split()))
GR=[[] for _ in range(n)]
for i in range(n-1):
  a,b=list(map(int,input().split()))
  GR[a-1].append(b)
  GR[b-1].append(a)
 
ans=[0 for _ in range(n)]
for i in range(q):
  p,x=list(map(int,input().split()))
  ans[p-1] += x
  
gr=[1]
parent=[0 for _ in range(n)]
while gr:
  po=gr.pop()
  for no in GR[po-1]:
    if no == parent[po-1]:
      continue
    gr.append(no)
    parent[no-1]=po
    ans[no-1] += ans[po-1]
      
print(' '.join(map(str,ans)))