Buggy python submission (verdict: Time Limit Exceeded):
I=lambda:map(int,input().split());
n,q=I();
r=[0]*n;
e=[[]for _ in range(n)];
exec("a,b=I();e[a-1]+=b-1,;e[b-1]+=a-1,;"*(n-1));
exec("q,x=I();r[q-1]+=x;"*q);
y=[0]+[1]*n;
s=[0]
while s:
  p=s.pop();
  for c in e[p]:
    exec("y[c]=0;r[c]+=r[p];s+=c,;"*y[c])
print(*r)

Fixed submission:
n,q=map(int,input().split())
edge=[[] for _ in range(n)] #木
cnt=[0]*n #出力用
for i in range(n-1): #辺の本数は頂点数-1
  a,b=map(int,input().split())
  a-=1
  b-=1
  edge[a].append(b)
  edge[b].append(a)
for _ in range(q):
  p,x=map(int,input().split())
  p-=1
  cnt[p]+=x
done=[False]*n #到達
par=0 #0からスタート
done[par]=True
stack=[par]
while stack:
  par=stack.pop()
  for chi in edge[par]:
    if done[chi]:
      None
    else:
      done[chi]=True
      cnt[chi]+=cnt[par]
      stack.append(chi)
    
print(*cnt)

Buggy python submission (verdict: Time Limit Exceeded):
I=lambda:map(int,input().split());n,q=I();r=[0]*n;e=[[]for _ in range(n)];exec("a,b=I();e[a-1]+=b-1,;e[b-1]+=a-1,;"*(n-1));exec("q,x=I();r[q-1]+=x;"*q);y=[0]+[1]*n;s=[0]
while s:
 p=s.pop();[exec("y[c]=0;r[c]+=r[p];s+=c,;"*y[c]) for c in e[p]]
print(*r)

Fixed submission:
n,q=map(int,input().split())
edge=[[] for _ in range(n)] #木
cnt=[0]*n #出力用
for i in range(n-1): #辺の本数は頂点数-1
  a,b=map(int,input().split())
  a-=1
  b-=1
  edge[a].append(b)
  edge[b].append(a)
for _ in range(q):
  p,x=map(int,input().split())
  p-=1
  cnt[p]+=x
done=[False]*n #到達
par=0 #0からスタート
done[par]=True
stack=[par]
while stack:
  par=stack.pop()
  for chi in edge[par]:
    if done[chi]:
      None
    else:
      done[chi]=True
      cnt[chi]+=cnt[par]
      stack.append(chi)
    
print(*cnt)

Buggy python submission (verdict: Time Limit Exceeded):
I=lambda:map(int,input().split());n,q=I();r=[0]*n;e=[[]for _ in range(n)];exec("a,b=I();e[a-1]+=b-1,;e[b-1]+=a-1,;"*(n-1));exec("q,x=I();r[q-1]+=x;"*q);y=[0]+[1]*n;s=[0]
while s:
 p=s.pop();[exec("y[c]=0;r[c]+=r[p];s+=c,;"*y[c]) for c in e[p]]
print(*r)


Fixed submission:
n,q=map(int,input().split())
edge=[[] for _ in range(n)] #木
cnt=[0]*n #出力用
for i in range(n-1): #辺の本数は頂点数-1
  a,b=map(int,input().split())
  a-=1
  b-=1
  edge[a].append(b)
  edge[b].append(a)
for _ in range(q):
  p,x=map(int,input().split())
  p-=1
  cnt[p]+=x
done=[False]*n #到達
par=0 #0からスタート
done[par]=True
stack=[par]
while stack:
  par=stack.pop()
  for chi in edge[par]:
    if done[chi]:
      None
    else:
      done[chi]=True
      cnt[chi]+=cnt[par]
      stack.append(chi)
    
print(*cnt)

Buggy python submission (verdict: Runtime Error):
N,Q=map(int,input().split())
egde=[[] for _ in range(N)]
cnt=[0]*N
for _ in range(N-1):
  a,b=map(int,input().split())
  edge[a-1]+=(b-1),
  edge[b-1]+=(a-1),
for _ in range(Q):
  p,x=map(int,input().split())
  cnt[p-1]+=x
done=[False]*N
done[0]=True
stack=[0]
while stack:
  par=stack.pop()
  for child in edge[par]:
    if not done[child]:
      done[child]=True
      cnt[child]+=cnt[par]
      stack.append(child)
print(*cnt)

Fixed submission:
n,q=map(int,input().split())
edge=[[] for _ in range(n)] #木
cnt=[0]*n #出力用
for i in range(n-1): #辺の本数は頂点数-1
  a,b=map(int,input().split())
  a-=1
  b-=1
  edge[a].append(b)
  edge[b].append(a)
for _ in range(q):
  p,x=map(int,input().split())
  p-=1
  cnt[p]+=x
done=[False]*n #到達
par=0 #0からスタート
done[par]=True
stack=[par]
while stack:
  par=stack.pop()
  for chi in edge[par]:
    if done[chi]:
      None
    else:
      done[chi]=True
      cnt[chi]+=cnt[par]
      stack.append(chi)
    
print(*cnt)