Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N = int(input())
An = list(map(int, input().split()))
order = []

for i in range(N):
    print( An.index(i+1)+1 ,end=" ")

### FIXED CODE ###

N = int(input())
An = list(map(int, input().split()))
ans = [0] * N

for i, num in enumerate(An):
    ans[num-1] = i+1

print(*ans)
### BUGGY CODE ###

import heapq
initial = 10 ** 15

def di(link_costs, s):
    costs = [initial] * n
    costs[s] = 0
    node_list = []
    serched_node = set()
    heapq.heappush(node_list, (0, s))
    
    while(len(node_list) != 0 and len(serched_node) != n):
        index = heapq.heappop(node_list)[1]
        if index in serched_node:
            continue
        serched_node.add(index)
        link = links[index]
        for j in link:
            if j in serched_node:
                continue
        
            cost = link_costs[index][j]
            newcost =  costs[index] + cost
            if newcost < costs[j]:
                costs[j] = newcost
                heapq.heappush(node_list, (newcost, j))
    return costs
    
n, m, s, t  = list(map(int, input().split()))
s -= 1
t -= 1
links = [set() for _ in range(n)]
links_cost_en = [[initial for _ in range(n)] for __ in range(n)]
links_cost_sn = [[initial for _ in range(n)] for __ in range(n)]

for _ in range(m):
    u, v, a, b  = list(map(int, input().split()))
    links[u-1].add(v-1)
    links[v-1].add(u-1)
    links_cost_en[u - 1][v - 1] = a
    links_cost_en[v - 1][u - 1] = a
    links_cost_sn[u - 1][v - 1] = b
    links_cost_sn[v - 1][u - 1] = b

cost_en_from_s = di(links_cost_en, s)
cost_sn_to_t = di(links_cost_sn, t)
cost_list = [cost_en_from_s[i] + cost_sn_to_t[i] for i in range(n)]
 
ans = [initial] * n
ans[-1] = cost_list[-1]
for i in list(range(n - 1))[::-1]:
    ans[i] = min(ans[i + 1], cost_list[i])
for i in range(n):
    print(initial - ans[i])

### FIXED CODE ###

import heapq
initial_cost = 10 ** 9
initial = 10 ** 15

def di(link_costs, s):
    costs = [initial] * n
    costs[s] = 0
    q = []
    heapq.heappush(q, (0, s))
    
    while(len(q) != 0):
        index_cost, index = heapq.heappop(q)
        if costs[index] < index_cost:
            continue

        for j in link_costs[index]:
            newcost = costs[index] + link_costs[index][j]
            if newcost < costs[j]:
                costs[j] = newcost
                heapq.heappush(q, (newcost, j))
    return costs
    
n, m, s, t  = list(map(int, input().split()))
s -= 1
t -= 1
links_cost_en = [{} for _ in range(n)]
links_cost_sn = [{} for _ in range(n)]

for _ in range(m):
    u, v, a, b  = list(map(int, input().split()))
    u -= 1
    v -= 1
    links_cost_en[u][v] = a
    links_cost_en[v][u] = a
    links_cost_sn[u][v] = b
    links_cost_sn[v][u] = b

cost_en_from_s = di(links_cost_en, s)
cost_sn_to_t = di(links_cost_sn, t)
cost_list = [cost_en_from_s[i] + cost_sn_to_t[i] for i in range(n)]

ans = [initial] * n
ans[-1] = cost_list[-1]
for i in list(range(n - 1))[::-1]:
    ans[i] = min(ans[i + 1], cost_list[i])
for i in range(n):
    print(initial - ans[i])
### BUGGY CODE ###

import sys

input = sys.stdin.readline

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if L[i] + L[j] > L[k]:
                ans += 1
            else:
                break

print(ans)

### FIXED CODE ###

import sys
from bisect import bisect_left
input = sys.stdin.readline

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        search = L[i] + L[j]
        k = bisect_left(L, search)
        ans += k - j - 1
print(ans)
### BUGGY CODE ###

M = int(input())
ans = 0
hoge = 0
for _ in range(M):
    d,c = map(int,input().split())
    while c:
        if c % 2 == 1:
            hoge += d
            ans += 1
            if hoge > 9:
                hoge = (hoge%10)+1
                ans += 1
        c //= 2
        ans += c
        d = d*2
        if d > 9:
            ans += c
            d = d%10+1

print(ans-1)

### FIXED CODE ###

M = int(input())
ans = 0
hoge = 0
for _ in range(M):
    d,c = map(int,input().split())
    while c:
        if c % 2 == 1:
            hoge += d
            ans += 1
            if hoge > 9:
                hoge = (hoge%10)+1
                ans += 1
        c //= 2
        ans += c
        d = d*2
        if d > 9:
            ans += c
            d = d%10+1

print(ans-1)
### BUGGY CODE ###

N = int(input())
A = []
for i in range(N):
    a = int(input())
    A.append(a)
for i in range(N):
    B = A.copy()
    del B[i]
    print(max(B))

### FIXED CODE ###

N = int(input())

m0 = 1
m1 = 1
max_i = []
for i in range(N):
    a = int(input())
    if a > m0:
        m1 = m0
        m0 = a
        max_i = []
        max_i.append(i)
    elif a == m0:
        m1 = a
    elif a > m1:
        m1 = a
for i in range(N):
    if i in max_i:
        print(m1)
    else:
        print(m0)
### BUGGY CODE ###

N=int(input())
a= list(map(int, input().split()))
a.sort()
b=[None]*N
b[0]=a[0]
A=0
for i in range(N-1,0,-1):
  b[1]=a[i]
  for j in range(2,N):
    b[j]=b[j-1]^b[j-2]
    if b[j] not in a:
      break
  else:
    b.sort()
    if a==b:
      A=1
      break
if A==1:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))
t=0
for i in a:
    t=t^i
print("No" if t else "Yes")
### BUGGY CODE ###

n = input()
x = 1
print ''
while 1:
  if x > n:
     break
  if ( x % 3 == 0 ) or ( '3' in str(x) ):
     print x
     x += 1

### FIXED CODE ###

n = input()
ans = '' 
for i in range(3,n+1):
    if i%3 == 0 or '3' in str(i):
        ans += ' ' + str(i)
print ans
### BUGGY CODE ###

from itertools import accumulate
from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
f = [1]*(N+1)


def fact(n):
    for i in range(1, n):
        f[i+1] = f[i]*(i+1)


def comb(n, r):
    return f[n]//(f[r]*f[n-r])


a = accumulate(A)
C = Counter(a)
fact(max(C.values()))

ans = 0
for i, v in C.items():
    if i == 0:
        ans += v
    if v > 1:
        ans += comb(v, 2)
print(ans)


### FIXED CODE ###

from itertools import accumulate
from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))


a = accumulate(A)
C = Counter(a)


def comb(v):
    return (v)*(v-1)//2


ans = 0
for i, v in C.items():
    if i == 0:
        ans += v
    if v > 1:
        ans += comb(v)
print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

while m:
    a[-1] //= 2
    a.sort()
    m -= 1

print(sum(a))


### FIXED CODE ###

import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)

for _ in range(m):
    y = heapq.heappop(a)
    heapq.heappush(a, (-1)*(-y//2))

print(-sum(a))
### BUGGY CODE ###

N = int(input())
listNums = list(map(int,input().split()))
listSadness = []
b = 0
c = 1000000000
for b in range(min(listNums) - N, max(listNums) + N):
    for i in range(len(listNums)):
        listSadness.append(abs(listNums[i] - (b + 1 + i)))
    if sum(listSadness) < c:
        c = sum(listSadness)
    listSadness = []
print(c)

### FIXED CODE ###

# median を import する
from statistics import median

# N と Ai を標準入力
N = int(input())
listNumsAs = list(map(int,input().split()))

# 空のリスト listNumsBs を用意
listNumsBs = []

# listNumAs の各要素から、その (index + 1) の数を引いた (Ai - (i + 1)) をリスト listNumsBs に順番に代入
for index in range(len(listNumsAs)):
    listNumsBs.append(listNumsAs[index] - index - 1)

# listNumsBs を昇順にソートする
listNumsBs.sort()

# listNumsBs の中央値を med に代入する
med = int(median(listNumsBs))

listSadnessA1 = [abs(s - med - N) for s in listNumsBs]
minimumSum = sum(listSadnessA1)

# listNumsBs の中央値 ± N の範囲の変数 b で処理を繰り返す
for b in range(med - 10, med + 10):
    
    # 悲しさ指数のリスト listSadness に (Bi - b) の絶対値の計算結果を順番に代入する
    listSadness = [abs(s - b) for s in listNumsBs]
       
    if sum(listSadness) < minimumSum:
        minimumSum = sum(listSadness)
        listTruthSadness = listSadness
        truthB = b

print(minimumSum)
### BUGGY CODE ###

def make_reverse_index(s):
    idx = dict()

    for pos, c in enumerate(s):
        if c not in idx:
            idx[c] = set()
        idx[c].add(pos)

    return idx

def solve(s, t):
    idx1 = make_reverse_index(s)
    idx2 = make_reverse_index(t)

    for c1, c2 in zip(s, t):
        if idx1[c1] != idx2[c2]:
            return False

    return True

def main():
    s = input()
    t = input()

    if solve(s, t):
        print('Yes')
    else:
        print('No')

main()


### FIXED CODE ###

def make_reverse_index(s):
    idx = dict()

    for pos, c in enumerate(s):
        if c not in idx:
            idx[c] = list()
        idx[c].append(pos)

    return idx

def solve(s, t):
    idx1 = make_reverse_index(s)
    idx2 = make_reverse_index(t)

    for i1 in idx1.values():
        c2 = t[i1[0]]
        i2 = idx2[c2]

        if i1 != i2:
            return False

    return True

def main():
    s = input()
    t = input()

    if solve(s, t):
        print('Yes')
    else:
        print('No')

main()
### BUGGY CODE ###

L = [int(input()) for _ in range(int(input()))]
r = 0
for s in set(L):
    if L.count(s) % 2 == 1:
        r+=1
print(r)

### FIXED CODE ###

S = set()
for _ in range(int(input())):
    A = int(input())
    if A not in S:
        S.add(A)
    else:
        S.remove(A)
print(len(S))
### BUGGY CODE ###

a,b,k=map(int,input().split())
N=[int(i) for i in range(a,b+1)]
Ans=N[:k]+N[-k:]
print(*sorted(set(Ans)),sep="\n")

### FIXED CODE ###

a,b,k=map(int,input().split())
N=[int(i) for i in range(a,min(a+k,b+1))]
M=[int(i) for i in range(max(a,b-k+1),b+1)]
print(*sorted(set(M+N)),sep="\n")
### BUGGY CODE ###

n, m = map(int, input().split())

A = []
for i in range(m):
    A.append(int(input()))
    
dp = [0 for i in range(n + 1)]
dp[0] = 1

for i in range(n+1):
    if not i in A:
        if i >= 2:
            dp[i] += (dp[i-2] + dp[i-1]) % (10 ** 9 + 7)
        elif i == 1:
            dp[i] += dp[i-1] % (10 ** 9 + 7)
            
print(dp[-1] % (10 ** 9 + 7))

### FIXED CODE ###

n, m = map(int, input().split())
mod = 10 ** 9 + 7
A = []
for i in range(m):
    A.append(int(input()))
    
dp = [None for i in range(n + 1)]
dp[0] = 1

for a in A:
    dp[a] = 0
    
for i in range(1,n+1):
    if dp[i] != 0:
        dp[i] = 0
        if i >= 2:
            dp[i] += (dp[i-2] + dp[i-1]) % mod
        elif i == 1:
            dp[i] += dp[i-1] % mod
            
print(dp[-1])
### BUGGY CODE ###

s=input()
ans=len(s)

bef=s
while True:
    aft=bef.replace("ST", "")
    if len(bef)==len(aft):
        break
    bef=aft

print(len(aft))

### FIXED CODE ###

x = input()

s = 0
t = 0
nokori = 0
disappear = 0

for i in x:
    if i == "S":
        s += 1
    else:
        if s > 0:
            disappear += 2
            s -= 1

print(len(x)-disappear)
### BUGGY CODE ###

import queue
from itertools import product

H, W = map(int, input().split())
S= [input() for i in range(H)]

ans=-1

def dfs(start,goal):
    distance=[[-1]*H for j in range(W)]
    li_x=[1,-1,0,0]
    li_y=[0,0,1,-1]
    q = queue.Queue()
    q.put(start)
    distance[start[0]][start[1]]=0

    while not q.empty():
        hoge=q.get()
        x=hoge[0]
        y=hoge[1]
        dis=distance[x][y]

        for i in range(4):
            x1=x+li_x[i]
            y1=y+li_y[i]
            if (0 <=x1 < W and 0 <= y1 < H):
                if distance[x1][y1] == -1:
                    if S[y1][x1]=='.':
                        q.put([x1,y1])
                        distance[x1][y1]=dis+1

    return distance[goal[0]][goal[1]]

for sx,sy,gx,gy in product(range(W),range(H),range(W),range(H)):

                if S[sy][sx]=='.' and S[gy][gx]=='.':
                    re=dfs([sx,sy],[gx,gy])
                    if re > ans:
                        ans=re

print(ans)


### FIXED CODE ###

import queue
from itertools import product

H, W = map(int, input().split())
S= [input() for i in range(H)]

ans=-1

def bfs(start):
    distance=[[-1]*H for j in range(W)]
    li_x=[1,-1,0,0]
    li_y=[0,0,1,-1]
    q = queue.Queue()
    q.put(start)
    distance[start[0]][start[1]]=0

    while not q.empty():
        hoge=q.get()
        x=hoge[0]
        y=hoge[1]
        dis=distance[x][y]

        for i in range(4):
            x1=x+li_x[i]
            y1=y+li_y[i]
            if (0 <=x1 < W and 0 <= y1 < H):
                if distance[x1][y1] == -1:
                    if S[y1][x1]=='.':
                        q.put([x1,y1])
                        distance[x1][y1]=dis+1
    m=[]
    for i in range(W):
        m.extend(distance[i])
    return max(m)

for sx,sy in product(range(W),range(H)):

                if S[sy][sx]=='.':
                    re=bfs([sx,sy])
                    if re > ans:
                        ans=re

print(ans)
### BUGGY CODE ###

import collections
def input_int_list():
    return [int(thing) for thing in input().split(" ")]

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

def nC2(n):
    return n*(n-1)//2



N=int(input())
A_list=input_int_list()
int_count=collections.Counter(A_list)
for i in range(N):
    number=A_list[i]
    int_count[number]=int_count[number]-1
    print(sum([nC2(int_count[i]) for i in int_count]))
    int_count[number]=int_count[number]+1

### FIXED CODE ###

import collections
def input_int_list():
    return [int(thing) for thing in input().split(" ")]

nCr = {}

def nC2(n):
    if n in nCr:
        return nCr[n]
    else:
        val=n*(n-1)//2
        nCr[n]=val
        return val



N=int(input())
A_list=input_int_list()
int_count=collections.Counter(A_list)
the_sum=sum([nC2(int_count[i]) for i in int_count])
for i in range(N):
    number=A_list[i]
    c=int_count[number]
    print(the_sum-c+1)
### BUGGY CODE ###

n = int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
if sum(a_list)<sum(b_list):
    print(-1)
else:
    diff_list = [a_list[i]-b_list[i] for i in range(n)]
    cnt=0
    for diff in diff_list:
        if diff<0:
            cnt+=1
    while min(diff_list)<0:
        M = max(diff_list)
        for i in range(n):
            dif = diff_list[i]
            if dif<0 and M+dif>=0:
                M+=dif
                diff_list[i]=0
            elif M+dif<0:
                break
        cnt+=1
    print(cnt)

### FIXED CODE ###

n = int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
if sum(a_list)<sum(b_list):
    print(-1)
else:
    diff_list = [a_list[i]-b_list[i] for i in range(n)]
    posi_list=[]
    cnt,diff_sum = 0,0
    for diff in diff_list:
        if diff<0:
            cnt+=1
            diff_sum+=diff
        elif diff>0:
            posi_list.append(diff)
    diff_sum*=(-1)
    posi_list.sort(reverse=True)
    i,S=0,0
    while S<diff_sum:
        S+=posi_list[i]
        i+=1
    print(i+cnt)
### BUGGY CODE ###

n = int(raw_input())
ls = []
for i in range(n):
	cmd = raw_input()
	if cmd[0] == "i":
		ls.insert(0,cmd[7:])
	elif cmd[6] == " ":
		try:
			ls.remove(cmd[7:])
		except:
			pass
	elif cmd[6] == "F":
		ls.pop(0)
	else:
		ls.pop(-1)

print " ".join(map(str, ls))

### FIXED CODE ###

n = int(raw_input())
ls = []
bp = 0
for i in range(n):
	cmd = raw_input()
	if cmd[0] == "i":
		ls.append(cmd[7:])
	elif cmd[6] == " ":
		try:
			x = ls[::-1].index(cmd[7:])
			if x!=-1:
				del ls[-x-1]
		except:
			pass
	elif cmd[6] == "F":
		ls.pop()
	else:
		bp += 1

print " ".join(map(str, ls[bp:][::-1]))
### BUGGY CODE ###

import collections
n = int(input())
s=[input() for i in range(n)]
ans = list()

c = collections.Counter(s)
k = c.most_common()[0][1]

if n == 1:
    print(s[0])
elif n >= 2 and len(c.keys()) == 1:
    print(c.most_common()[0][0])
else:
    for i in range(n):
        if k == c.most_common()[i][1]:
            ans.append(c.most_common()[i][0])
        else:
            break

ans = sorted(ans)
[print(i) for i in ans]

### FIXED CODE ###

import collections
n = int(input())
s=[input() for i in range(n)]
ans = list()

c = collections.Counter(s)

m = max(c.values())
for k,v in c.items():
    if v ==m:
        ans.append(k)
ans.sort()
print(*ans,sep="\n")
### BUGGY CODE ###

K,S = [int(i) for i in input().rstrip().split()]

rec = 0
for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x+y+z == S:
        rec += 1
        
print(rec)

### FIXED CODE ###

K,S = [int(i) for i in input().rstrip().split()]

lst_temp = [ int(i) for i in range(K + 1)]

recCnt = 0
for x in lst_temp:
  for y in lst_temp:
    z = S - x - y 
    if z >= 0 and z <= K:
      recCnt += 1
      
print(recCnt)
### BUGGY CODE ###


N = int(input())
A = list(map(int, input().split()))

B = []

for i in range(N):
  B.append(A[i])
  B = B[::-1]
print(*B)

### FIXED CODE ###


N = int(input())
A = list(map(int, input().split()))

B = [0] * N
if N % 2 == 0:
  for i in range(N):
    if i % 2 == 0:
      B[N//2+i//2] = A[i]
    else:
      B[N//2-(i//2+1)] = A[i]
else:
  for i in range(N):
    if i % 2 == 1:
      B[N//2+(i//2+1)] = A[i]
    else:
      B[N//2-(i//2)] = A[i]

print(*B)
### BUGGY CODE ###

import math
a,b,n=map(int,input().split())
max=-2
for i in range(1,n+1):
    s=math.floor(a*i/b)-a*math.floor(i/b)
    if s>max:
        max=s
print(int(max))

### FIXED CODE ###

import math
a,b,n=map(int,input().split())
max=-2
if n<b:
    max=math.floor(a*n/b)
else:
    #b<=n
    max=math.floor(a*(b-1)/b)
    

print(max)
### BUGGY CODE ###

N = int(input())
S = input()

Rs = []
Gs = []
Bs = []
for i, il in enumerate(S):
    if il == 'R':
        Rs.append(i)
    if il == 'G':
        Gs.append(i)
    if il == 'B':
        Bs.append(i)
num = 0
for i in Rs:
    for j in Gs:
        for k in Bs:
            ijk = sorted([i, j, k])
            if (ijk[2] - ijk[1]) != (ijk[1] - ijk[0]):
                num += 1
print(num)


### FIXED CODE ###

N = int(input())
S = input()

Rs = 0
Gs = 0
Bs = 0
for il in S:
    if il == 'R':
        Rs += 1
    if il == 'G':
        Gs += 1
    if il == 'B':
        Bs += 1
num = 0
for i in range(N):
    for step in range(1, N):
        j = i + step
        k = i + 2*step
        if k > N - 1:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            num += 1
print(Rs*Gs*Bs - num)
### BUGGY CODE ###

H, W, N = map(int, input().split())
G = [[0 for w in range(W)] for h in range(H)]
for i in range(N):
  a, b = map(int, input().split())
  for j in range(3):
    for k in range(3):
      if (a - j > 0) and (b - k > 0):
        G[a - j - 1][b - k - 1] += 1
A = [0 for i in range(10)]
for h in range(H - 2):
  for w in range(W - 2):
    A[G[h][w]] += 1
for a in A:
  print(a)

### FIXED CODE ###

from collections import defaultdict
H, W, N = map(int, input().split())
P = [0] * 10
P[0] = (H - 2) * (W - 2)
G = defaultdict(lambda: defaultdict(int))
for i in range(N):
  a, b = map(int, input().split())
  for i in range(max(a - 3, 0), min(a, H - 2)):
    for j in range(max(b - 3, 0), min(b, W - 2)):
      p = G[i][j]
      P[p] -= 1
      P[p + 1] += 1
      G[i][j] += 1
for i in range(10):
  print(P[i])
### BUGGY CODE ###

text = input()

a = int(text.split(' ')[0])
b = int(text.split(' ')[1])
k = int(text.split(' ')[2])

for i in range(a, b + 1):
    if i < a + k or i > b - k:
        print(i)


### FIXED CODE ###

text = input()

a = int(text.split(' ')[0])
b = int(text.split(' ')[1])
k = int(text.split(' ')[2])

t = min(a + k, b + 1)
for i in range(a, t):
    print(i)

if max(b - k + 1, t) < b + 1:
    for i in range(max(b - k + 1, t), b + 1):
        print(i)
### BUGGY CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))

ans = [0]*(n-k+1)
ans[0] = sum(a[0:k])
for i in range(1,n-k+1):
    ans[i] = sum(a[i:k+i])
    if ans[i-1] < ans[i]:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))

for i in range(1,n-k+1):
    if a[k+i-1] > a[i-1]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###


NQ = input().split(' ')
N = int(NQ[0])
Q = int(NQ[1])
candidate_list = []
tree_list = [[]] * N
out_put_list = [0] * N

for i in range(N-1):
    ab = input().split(' ')
    a = int(ab[0])
    b = int(ab[1])
    tree_list[a-1] = tree_list[a-1] + [b-1]

for _ in range(Q):
    px = input().split(' ')
    p = int(px[0])
    x = int(px[1])
    out_put_list[p-1] += x

for i in range(len(tree_list)):
    for num in tree_list[i]:
        out_put_list[num] += out_put_list[i]

print(*out_put_list)

### FIXED CODE ###


NQ = input().split(' ')
N = int(NQ[0])
Q = int(NQ[1])
out_put_list = [0] * N
tree_list = {}
for i in range(N):
    tree_list[i] = []

for i in range(N-1):
    ab = input().split(' ')
    a = int(ab[0]) -1
    b = int(ab[1]) -1
    tree_list[a].append(b)

for _ in range(Q):
    px = input().split(' ')
    p = int(px[0])
    x = int(px[1])
    out_put_list[p-1] += x

for i in range(len(tree_list)):
    for num in tree_list[i]:
        out_put_list[num] += out_put_list[i]

print(*out_put_list)
### BUGGY CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
ans = 0

for i in range(N-K+1):
    expected = sum(map(lambda x: (x + 1) / 2, P[i:i+K]))
    ans = max(ans, expected)

print(ans)

### FIXED CODE ###

from itertools import accumulate

N, K = map(int, input().split())
P = map(int, input().split())
acc_P = list(accumulate(P))
ans = (acc_P[K-1] + K) / 2

for i in range(N-K):
    ans = max(ans, (acc_P[i+K] - acc_P[i] + K) / 2)

print(ans)
### BUGGY CODE ###

a,b,k = map(int,input().split())
for i in range(k):
    if a > 0:
        a-=1
    else:
        b-=1

print(a, b)

### FIXED CODE ###

a,b,k = map(int,input().split())
if a >= k:
    print(a-k, b)
else:
    print(0, max(b+a-k,0))
### BUGGY CODE ###

#import deque
import sys

sys.setrecursionlimit(10**6)

N, Q = map(int, input().split())

Graph = [[] for i in range(N)]
#print(Graph)
for _ in range(N-1):
    a, b = map(int, input().split())
    #print(a, b)
    Graph[a-1].append(b-1)
    Graph[b-1].append(a-1)

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

ans = [0] * N
def dfs(v, u, counter):
    counter += score[v]
    ans[v] = counter
    for c in Graph[v]:
        if c == u:
            continue
        dfs(c, v, counter)

dfs(0, -1, 0)

print(*ans)


### FIXED CODE ###

# 深さ優先探索の問題
import sys

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

N, Q = map(int, input().split())

# 隣接リスト
t = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = [int(i) for i in readline().split()]
    t[a-1].append(b-1)
    t[b-1].append(a-1)

# スコア
s = [0] * N
for _ in range(Q):
    p, x = [int(i) for i in readline().split()]
    #s[p-1] = s[p-1] + x
    s[p-1] += x

ans = [0] * N

# 深さ優先探索
def dfs(v, p, value):
    #value = value + s[v]
    value += s[v]
    ans[v] = value
    for c in t[v]:
        if c == p:
            continue
        dfs(c, v, value)

dfs(0, -1, 0)

print(*ans)
### BUGGY CODE ###

n, k = [int(v) for v in input().split()]
a = [int(v) for v in input().split()]

b = []
for i in range(n):
    s = a[i]
    b.append(s)
    for j in range(i+1, n):
        s += a[j]
        b.append(s)

MAX = 40
ans = 0
for t in range(MAX, 0, -1):
    x = ans + 2 ** (t-1)
    cnt = 0
    for v in b:
        if x & v == x:
            cnt += 1
    if cnt >= k:
        ans = x

print(ans)

### FIXED CODE ###

n, k = [int(v) for v in input().split()]
a = [int(v) for v in input().split()]

b = []
for i in range(n):
    s = a[i]
    b.append(s)
    for j in range(i+1, n):
        s += a[j]
        b.append(s)

MAX = 40
ans = 0
for t in range(MAX, 0, -1):
    x = ans + (1 << (t-1))
    cnt = 0
    for v in b:
        if x & v == x:
            cnt += 1
    if cnt >= k:
        ans = x

print(ans)