Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(100000)

# お約束
INF = float("inf")
MOD = int(1e9 + 7)

N, Q = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N - 1)]
PX = [list(map(int, input().split())) for _ in range(Q)]

sum_val = [0] * N
for p, x in PX:
	p, x = p - 1, x
	sum_val[p] += x

edges = [[] for _ in range(N)]
for a, b in AB:
	a, b = a - 1, b - 1
	edges[a] += [b]
	edges[b] += [a]

visited = [False] * N
vals = [0] * N

def dfs(v, p, add_val):
	global visited, vals
	visited[v] = True
	vals[v] = add_val + sum_val[v]
	for n in edges[v]:
		if visited[n]: continue
		dfs(n, v, add_val + sum_val[v])

dfs(0, -1, 0)
for v in vals:
	print(v)


Fixed submission:
import sys
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def int1(n):
    return int(n) - 1
def input():
    return next(args)
def parse(*params):
    if len(params) == 1:
        return params[0](next(args))
    return tuple(p(v) for p, v in zip(params, next(args).split()))
def debug(*v):
    if __debug__:
        print(*v, file=sys.stderr)

# エントリーポイント
def main():
    N, Q = parse(int, int)
    edges = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = parse(int1, int1)
        edges[a] += [b]
        edges[b] += [a]
    vals = [0] * N
    for _ in range(Q):
        p, x = parse(int1, int)
        vals[p] += x

    counter = [0] * N
    que = [(0, 0)]
    alr = [False] * N
    while que:
        v, x = que.pop()
        alr[v] = True
        counter[v] += x + vals[v]
        for n in edges[v]:
            if not alr[n]:
                que.append((n, counter[v]))

    for v in counter:
        print(v)

if __name__ == '__main__':
    args = iter(sys.stdin.read().split("\n"))
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(100000)

# お約束
INF = float("inf")
MOD = int(1e9 + 7)

N, Q = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N - 1)]
PX = [list(map(int, input().split())) for _ in range(Q)]

sum_val = [0] * N
for p, x in PX:
	p, x = p - 1, x
	sum_val[p] += x

edges = [[] for _ in range(N)]
for a, b in AB:
	a, b = a - 1, b - 1
	edges[a] += [b]
	edges[b] += [a]

visited = [False] * N
vals = [0] * N

def dfs(v, p, add_val):
	global visited, vals
	visited[v] = True
	vals[v] = add_val + sum_val[v]
	for n in edges[v]:
		if visited[n]: continue
		dfs(n, v, add_val + sum_val[v])

dfs(0, -1, 0)
for v in vals:
	print(v)


Fixed submission:
import sys
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def int1(n):
    return int(n) - 1
def input():
    return next(args)
def parse(*params):
    if len(params) == 1:
        return params[0](next(args))
    return tuple(p(v) for p, v in zip(params, next(args).split()))
def debug(*v):
    if __debug__:
        print(*v, file=sys.stderr)

# エントリーポイント
def main():
    N, Q = parse(int, int)
    edges = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = parse(int1, int1)
        edges[a] += [b]
        edges[b] += [a]
    vals = [0] * N
    for _ in range(Q):
        p, x = parse(int1, int)
        vals[p] += x

    counter = [0] * N
    que = [(0, 0)]
    alr = [False] * N
    while que:
        v, x = que.pop()
        alr[v] = True
        counter[v] += x + vals[v]
        for n in edges[v]:
            if not alr[n]:
                que.append((n, counter[v]))

    for v in counter:
        print(v)

if __name__ == '__main__':
    args = iter(sys.stdin.read().split("\n"))
    main()

Buggy python submission (verdict: Runtime Error):
# お約束
INF = float("inf")
MOD = int(1e9 + 7)

N, Q = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N - 1)]
PX = [list(map(int, input().split())) for _ in range(Q)]

sum_val = [0] * N
for p, x in PX:
	p, x = p - 1, x
	sum_val[p] += x

edges = [[] for _ in range(N)]
for a, b in AB:
	a, b = a - 1, b - 1
	edges[a] += [b]
	edges[b] += [a]

visited = [False] * N
vals = [0] * N

def dfs(v, p, add_val):
	global visited, vals
	visited[v] = True
	vals[v] = add_val + sum_val[v]
	for n in edges[v]:
		if visited[n]: continue
		dfs(n, v, add_val + sum_val[v])

dfs(0, -1, 0)
for v in vals:
	print(v)


Fixed submission:
import sys
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def int1(n):
    return int(n) - 1
def input():
    return next(args)
def parse(*params):
    if len(params) == 1:
        return params[0](next(args))
    return tuple(p(v) for p, v in zip(params, next(args).split()))
def debug(*v):
    if __debug__:
        print(*v, file=sys.stderr)

# エントリーポイント
def main():
    N, Q = parse(int, int)
    edges = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = parse(int1, int1)
        edges[a] += [b]
        edges[b] += [a]
    vals = [0] * N
    for _ in range(Q):
        p, x = parse(int1, int)
        vals[p] += x

    counter = [0] * N
    que = [(0, 0)]
    alr = [False] * N
    while que:
        v, x = que.pop()
        alr[v] = True
        counter[v] += x + vals[v]
        for n in edges[v]:
            if not alr[n]:
                que.append((n, counter[v]))

    for v in counter:
        print(v)

if __name__ == '__main__':
    args = iter(sys.stdin.read().split("\n"))
    main()