Buggy python submission (verdict: Runtime Error):
import numpy as np

N, Q = map(int, input().split())
Child = [[] for _ in range(N)]
X = np.zeros(N, np.int64)
Y = np.zeros(N, np.int64)
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    Child[a].append(b)
for _ in range(Q):
    p, x = map(int, input().split())
    p -= 1
    X[p] += x


def dfs(u, k):
    Y[u] += k
    for v in Child[u]:
        dfs(v, k + X[v])


dfs(0, X[0])
print(' '.join(str(y) for y in Y))


Fixed submission:
N, Q = map(int, input().split())
graph = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

C = [0] * (N + 1)
for _ in range(Q):
    p, x = map(int, input().split())
    C[p] += x

se = set([1])
stack = [1]
while stack:
    # print(C)
    x = stack.pop()
    for y in graph[x]:
        if y in se:
            continue
        stack.append(y)
        se.add(y)
        # 親x, 子y
        C[y] += C[x]

print(' '.join(str(i) for i in C[1:]))

Buggy python submission (verdict: Runtime Error):
import numpy as np

N, Q = map(int, input().split())
Child = np.zeros((N, N), np.bool)
X = np.zeros(N, np.int64)
Y = np.zeros(N, np.int64)
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    Child[a, b] = True
for _ in range(Q):
    p, x = map(int, input().split())
    p -= 1
    X[p] += x


def dfs(u, k):
    Y[u] += k
    for v, flag in enumerate(Child[u, :]):
        if flag:
            dfs(v, k + X[v])


dfs(0, X[0])
print(' '.join(str(y) for y in Y))


Fixed submission:
N, Q = map(int, input().split())
graph = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

C = [0] * (N + 1)
for _ in range(Q):
    p, x = map(int, input().split())
    C[p] += x

se = set([1])
stack = [1]
while stack:
    # print(C)
    x = stack.pop()
    for y in graph[x]:
        if y in se:
            continue
        stack.append(y)
        se.add(y)
        # 親x, 子y
        C[y] += C[x]

print(' '.join(str(i) for i in C[1:]))

Buggy python submission (verdict: Runtime Error):
import numpy as np

N, Q = map(int, input().split())
Child = np.zeros((N, N), np.bool)
X = np.zeros(N, np.int32)
Y = np.zeros(N, np.int32)
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    Child[a, b] = True
for _ in range(Q):
    p, x = map(int, input().split())
    p -= 1
    X[p] += x


def dfs(u, k):
    Y[u] += k
    for v in range(N):
        if Child[u, v]:
            dfs(v, k + X[v])


dfs(0, X[0])
print(' '.join(str(y) for y in Y))


Fixed submission:
N, Q = map(int, input().split())
graph = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

C = [0] * (N + 1)
for _ in range(Q):
    p, x = map(int, input().split())
    C[p] += x

se = set([1])
stack = [1]
while stack:
    # print(C)
    x = stack.pop()
    for y in graph[x]:
        if y in se:
            continue
        stack.append(y)
        se.add(y)
        # 親x, 子y
        C[y] += C[x]

print(' '.join(str(i) for i in C[1:]))