Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline

N,Q=map(int,input().split())
a=[0]*(N-1)
b=[0]*(N-1)
p=[0]*Q
x=[0]*Q
c=[[] for _ in range(N)]  #接続リスト
cnt=[0]*N  #カウンター値

for i in range(N-1):
  a[i],b[i]=map(int,input().split())
  c[a[i]-1].append(b[i]-1)
  c[b[i]-1].append(a[i]-1)
for i in range(Q):
  p[i],x[i]=map(int,input().split())
  cnt[p[i]-1] += x[i]

def dfs(x,parent):
  if parent!=-1:
    cnt[x] += cnt[parent]
  for child in c[x]:
    if child!=parent:
      dfs(child,x)

dfs(0,-1)
print(*cnt)

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

N,Q=map(int,input().split())
a=[0]*(N-1)
b=[0]*(N-1)
p=[0]*Q
x=[0]*Q
c=[[] for _ in range(N)]  #接続リスト
cnt=[0]*N  #カウンター値

for i in range(N-1):
  a[i],b[i]=map(int,input().split())
  c[a[i]-1].append(b[i]-1)
  c[b[i]-1].append(a[i]-1)
for i in range(Q):
  p[i],x[i]=map(int,input().split())
  cnt[p[i]-1] += x[i]

def dfs(x,parent):
  if parent!=-1:
    cnt[x] += cnt[parent]
  for child in c[x]:
    if child!=parent:
      dfs(child,x)

dfs(0,-1)
print(*cnt)

Buggy python submission (verdict: Runtime Error):
N,Q=map(int,input().split())
a=[0]*(N-1)
b=[0]*(N-1)
p=[0]*Q
x=[0]*Q
c=[[] for _ in range(N)]  #接続リスト
cnt=[0]*N  #カウンター値

for i in range(N-1):
  a[i],b[i]=map(int,input().split())
  c[a[i]-1].append(b[i]-1)
  c[b[i]-1].append(a[i]-1)
for i in range(Q):
  p[i],x[i]=map(int,input().split())
  cnt[p[i]-1] += x[i]

def dfs(x,parent):
  if parent!=-1:
    cnt[x] += cnt[parent]
  for child in c[x]:
    if child!=parent:
      dfs(child,x)

dfs(0,-1)
print(*cnt)

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

N,Q=map(int,input().split())
a=[0]*(N-1)
b=[0]*(N-1)
p=[0]*Q
x=[0]*Q
c=[[] for _ in range(N)]  #接続リスト
cnt=[0]*N  #カウンター値

for i in range(N-1):
  a[i],b[i]=map(int,input().split())
  c[a[i]-1].append(b[i]-1)
  c[b[i]-1].append(a[i]-1)
for i in range(Q):
  p[i],x[i]=map(int,input().split())
  cnt[p[i]-1] += x[i]

def dfs(x,parent):
  if parent!=-1:
    cnt[x] += cnt[parent]
  for child in c[x]:
    if child!=parent:
      dfs(child,x)

dfs(0,-1)
print(*cnt)

Buggy python submission (verdict: Runtime Error):
N,Q=map(int,input().split())
a=[0]*(N-1)
b=[0]*(N-1)
p=[0]*Q
x=[0]*Q
c=[[] for _ in range(N)]  #接続リスト
cnt=[ 0 for _ in range(N)]  #カウンター値

for i in range(N-1):
  a[i],b[i]=map(int,input().split())
  c[a[i]-1].append(b[i]-1)
  c[b[i]-1].append(a[i]-1)
for i in range(Q):
  p[i],x[i]=map(int,input().split())
  cnt[p[i]-1] += x[i]

def dfs(x,parent):
  if parent!=-1:
    cnt[x] += cnt[parent]
  for child in c[x]:
    if child!=parent:
      dfs(child,x)

dfs(0,-1)
print(*cnt)

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

N,Q=map(int,input().split())
a=[0]*(N-1)
b=[0]*(N-1)
p=[0]*Q
x=[0]*Q
c=[[] for _ in range(N)]  #接続リスト
cnt=[0]*N  #カウンター値

for i in range(N-1):
  a[i],b[i]=map(int,input().split())
  c[a[i]-1].append(b[i]-1)
  c[b[i]-1].append(a[i]-1)
for i in range(Q):
  p[i],x[i]=map(int,input().split())
  cnt[p[i]-1] += x[i]

def dfs(x,parent):
  if parent!=-1:
    cnt[x] += cnt[parent]
  for child in c[x]:
    if child!=parent:
      dfs(child,x)

dfs(0,-1)
print(*cnt)