Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import sys
from itertools import groupby
sys.setrecursionlimit(10**6) 
n,q = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n-1)]
lin = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)]

kazu = [[]for _ in range(n)]
point = [0]*n

for i in range(n-1):
    kazu[li[i][0]-1].append(li[i][1]-1)
    kazu[li[i][1]-1].append(li[i][0]-1)
for i in range(q):
    point[lin[i][0]-1] += lin[i][1]

def dfs(now,before):
    for i in (kazu[now]):
        if i == before:
            continue
        point[i] += point[now]
        dfs(i,now)
dfs(0,-1)
print(*point)


Fixed submission:
from sys import stdin
import sys
from itertools import groupby
sys.setrecursionlimit(10**6) 
n,q = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n-1)]
lin = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)]

kazu = [[]for _ in range(n)]
point = [0]*n

for i in range(len(li)):
    kazu[li[i][0]-1].append(li[i][1]-1)
    kazu[li[i][1]-1].append(li[i][0]-1)
for i in range(q):
    point[lin[i][0]-1] += lin[i][1]

def dfs(li,li2,now,before):
    for i in (li[now]):
        if i == before:
            continue
        li2[i] += li2[now]
        dfs(kazu,point,i,now)
dfs(kazu,point,0,-1)
print(*point)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import sys
from itertools import groupby
sys.setrecursionlimit(10**6) 
n,q = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n-1)]
lin = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)]

kazu = [[]for _ in range(n)]
point = [0]*n

for i in range(len(li)):
    kazu[li[i][0]-1].append(li[i][1]-1)
    kazu[li[i][1]-1].append(li[i][0]-1)
for i in range(q):
    point[lin[i][0]-1] += lin[i][1]

def dfs(li,li2,now,before):
    for i in (li[now]):
        if i == before:
            continue
        li2[i] += li2[now]
        dfs(kazu,point,i,now)
dfs(kazu,point,0,-1)
print(*point)

Fixed submission:
from sys import stdin
import sys
from itertools import groupby
sys.setrecursionlimit(10**6) 
n,q = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n-1)]
lin = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)]

kazu = [[]for _ in range(n)]
point = [0]*n

for i in range(len(li)):
    kazu[li[i][0]-1].append(li[i][1]-1)
    kazu[li[i][1]-1].append(li[i][0]-1)
for i in range(q):
    point[lin[i][0]-1] += lin[i][1]

def dfs(li,li2,now,before):
    for i in (li[now]):
        if i == before:
            continue
        li2[i] += li2[now]
        dfs(kazu,point,i,now)
dfs(kazu,point,0,-1)
print(*point)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
from itertools import groupby

n,q = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n-1)]
lin = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)]

kazu = [[]for _ in range(n)]
point = [0]*n

for i in range(len(li)):
    kazu[li[i][0]-1].append(li[i][1]-1)
    kazu[li[i][1]-1].append(li[i][0]-1)
for i in range(q):
    point[lin[i][0]-1] += lin[i][1]

def dfs(li,li2,now,before):
    for i in (li[now]):
        if i == before:
            continue
        li2[i] += li2[now]
        dfs(kazu,point,i,now)
dfs(kazu,point,0,-1)
print(*point)

Fixed submission:
from sys import stdin
import sys
from itertools import groupby
sys.setrecursionlimit(10**6) 
n,q = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n-1)]
lin = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)]

kazu = [[]for _ in range(n)]
point = [0]*n

for i in range(len(li)):
    kazu[li[i][0]-1].append(li[i][1]-1)
    kazu[li[i][1]-1].append(li[i][0]-1)
for i in range(q):
    point[lin[i][0]-1] += lin[i][1]

def dfs(li,li2,now,before):
    for i in (li[now]):
        if i == before:
            continue
        li2[i] += li2[now]
        dfs(kazu,point,i,now)
dfs(kazu,point,0,-1)
print(*point)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
from itertools import groupby

n,q = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n-1)]
lin = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)]

kazu = [[]for _ in range(n)]
point = [0]*n

for i in range(len(li)):
    kazu[li[i][0]-1].append(li[i][1]-1)
    kazu[li[i][1]-1].append(li[i][0]-1)
for i in range(q):
    point[lin[i][0]-1] += lin[i][1]

#深さ優先探索を実装したい(liが各ノードを入れたリスト、li2が)

def dfs(li,li2,now,before):
    for i in (li[now]):
        if i == before:
            continue
        li2[i] += li2[now]
        dfs(kazu,point,i,now)
dfs(kazu,point,0,-1)
print(*point)

Fixed submission:
from sys import stdin
import sys
from itertools import groupby
sys.setrecursionlimit(10**6) 
n,q = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n-1)]
lin = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)]

kazu = [[]for _ in range(n)]
point = [0]*n

for i in range(len(li)):
    kazu[li[i][0]-1].append(li[i][1]-1)
    kazu[li[i][1]-1].append(li[i][0]-1)
for i in range(q):
    point[lin[i][0]-1] += lin[i][1]

def dfs(li,li2,now,before):
    for i in (li[now]):
        if i == before:
            continue
        li2[i] += li2[now]
        dfs(kazu,point,i,now)
dfs(kazu,point,0,-1)
print(*point)