Buggy python submission (verdict: Time Limit Exceeded):
#input()を速い方にしないとTLEになる

import sys
sys.setrecursionlimit(10**7) #再帰関数の呼び出し制限
input = sys.stdin.readline

def dfs(v,p): #点vについての処理。p：vの親
    if (p != -1): res[v] += res[p]
    
    for e in edges[v]:
        if (e == p): continue
        dfs(e,v)
#--------------------------------
N, Q = map(int, input().split())
edges = [[] for _ in range(N+1)]
for i in range(N-1):
    a,b = map(int, input().split())
    edges[a].append(b)
    edges[b].append(a)

res = [0]*(N+1) #点数リスト
for i in range(Q): #点数リストに初期値を格納
    p,x = map(int, input().split())
    res[p] += x

dfs(1,-1)
print(*res[1:])


Fixed submission:
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,Q = LI()
ab = [LI() for _ in [None]*(N-1)]
px = [LI() for _ in [None]*(Q)]
ans = [0]*(N+1) #1_index
graph = [collections.deque() for _ in [None]*(N+1)] #1_index
for a,b in ab:
        graph[a].append(b)
        graph[b].append(a)
for p,x in px:
    ans[p] += x
seen = [0]*(N+1) #1_index
stack = []
def dfs():
    seen[1] = 1
    stack.append(1)
    while stack:
        s = stack.pop()
        if not graph[s]:
            continue
        for j in range(len(graph[s])):
            g_NO = graph[s].popleft()
            if seen[g_NO]:
                continue
            seen[g_NO] = 1
            stack.append(g_NO)
            ans[g_NO] += ans[s]
dfs()
print(*ans[1:])

Buggy python submission (verdict: Time Limit Exceeded):
#input()を速い方にしないとTLEになる

import sys
sys.setrecursionlimit(10**7) #再帰関数の呼び出し制限
input = sys.stdin.readline

def dfs(v,p): #点vについての処理。p：vの親
    if (p != -1): res[v] += res[p]
    
    for e in edges[v]:
        if (e == p): continue
        dfs(e,v)
#--------------------------------
N, Q = map(int, input().split())
edges = [[] for _ in range(N+1)]
for i in range(N-1):
    a,b = map(int, input().split())
    edges[a].append(b)
    edges[b].append(a)

px = [list(map(int, input().split())) for _ in range(Q)]

res = [0]*(N+1) #点数リスト
for i in range(Q): #点数リストに初期値を格納
    p,x = px[i]
    res[p] += x

dfs(1,-1)
print(*res[1:])


Fixed submission:
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,Q = LI()
ab = [LI() for _ in [None]*(N-1)]
px = [LI() for _ in [None]*(Q)]
ans = [0]*(N+1) #1_index
graph = [collections.deque() for _ in [None]*(N+1)] #1_index
for a,b in ab:
        graph[a].append(b)
        graph[b].append(a)
for p,x in px:
    ans[p] += x
seen = [0]*(N+1) #1_index
stack = []
def dfs():
    seen[1] = 1
    stack.append(1)
    while stack:
        s = stack.pop()
        if not graph[s]:
            continue
        for j in range(len(graph[s])):
            g_NO = graph[s].popleft()
            if seen[g_NO]:
                continue
            seen[g_NO] = 1
            stack.append(g_NO)
            ans[g_NO] += ans[s]
dfs()
print(*ans[1:])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7) #再帰関数の呼び出し制限

def dfs(v,p): #点vについての処理。p：vの親
    if (p != -1): res[v] += res[p]
    
    for e in edges[v]:
        if (e == p): continue
        dfs(e,v)
#--------------------------------
N, Q = map(int, input().split())
edges = [[] for _ in range(N+1)]
for i in range(N-1):
    a,b = map(int, input().split())
    edges[a].append(b)
    edges[b].append(a)
#print(edges)
px = [list(map(int, input().split())) for _ in range(Q)]

res = [0]*(N+1) #点数リスト
for i in range(Q): #点数リストに初期値を格納
    p,x = px[i]
    res[p] += x

dfs(1,-1)
print(*res[1:])


Fixed submission:
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,Q = LI()
ab = [LI() for _ in [None]*(N-1)]
px = [LI() for _ in [None]*(Q)]
ans = [0]*(N+1) #1_index
graph = [collections.deque() for _ in [None]*(N+1)] #1_index
for a,b in ab:
        graph[a].append(b)
        graph[b].append(a)
for p,x in px:
    ans[p] += x
seen = [0]*(N+1) #1_index
stack = []
def dfs():
    seen[1] = 1
    stack.append(1)
    while stack:
        s = stack.pop()
        if not graph[s]:
            continue
        for j in range(len(graph[s])):
            g_NO = graph[s].popleft()
            if seen[g_NO]:
                continue
            seen[g_NO] = 1
            stack.append(g_NO)
            ans[g_NO] += ans[s]
dfs()
print(*ans[1:])

Buggy python submission (verdict: Runtime Error):
def dfs(v,p): #点vについての処理。p：vの親
    if (p != -1): res[v] += res[p]
    
    for e in edges[v]:
        if (e == p): continue
        dfs(e,v)
#--------------------------------
N, Q = map(int, input().split())
edges = [[] for _ in range(N+1)]
for i in range(N-1):
    a,b = map(int, input().split())
    edges[a].append(b)
    edges[b].append(a)
#print(edges)
px = [list(map(int, input().split())) for _ in range(Q)]

res = [0]*(N+1) #点数リスト
for i in range(Q): #点数リストに初期値を格納
    p,x = px[i]
    res[p] += x

dfs(1,-1)
print(*res[1:])


Fixed submission:
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,Q = LI()
ab = [LI() for _ in [None]*(N-1)]
px = [LI() for _ in [None]*(Q)]
ans = [0]*(N+1) #1_index
graph = [collections.deque() for _ in [None]*(N+1)] #1_index
for a,b in ab:
        graph[a].append(b)
        graph[b].append(a)
for p,x in px:
    ans[p] += x
seen = [0]*(N+1) #1_index
stack = []
def dfs():
    seen[1] = 1
    stack.append(1)
    while stack:
        s = stack.pop()
        if not graph[s]:
            continue
        for j in range(len(graph[s])):
            g_NO = graph[s].popleft()
            if seen[g_NO]:
                continue
            seen[g_NO] = 1
            stack.append(g_NO)
            ans[g_NO] += ans[s]
dfs()
print(*ans[1:])