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

from collections import defaultdict
N = int(input())
g = [[] for i in range(N)]

for i in range(N-1):
    a,b = list(map(int,input().split()))
    a,b = a-1,b-1
    g[a] += [b]
    g[b] += [a]
    
def bfs(g, st):
    queue = [st]
    distances = [-1 for i in range(N)]
    distances[st] = 0
    
    while queue:
        node = queue.pop(0)
        for h in g[node]:
            if distances[h] == -1:
                distances[h] = distances[node] + 1
                queue += g[node]

    return distances

dB = bfs(g, 0)
dW = bfs(g, N-1)

B, W = 0, 0
for i in range(N):
    if dB[i] <= dW[i]:
        B += 1
    else:
        W += 1
print("Fennec" if B > W else "Snuke")

### FIXED CODE ###

from collections import defaultdict
N = int(input())
g = [[] for i in range(N)]
 
for i in range(N-1):
    a,b = list(map(int,input().split()))
    a,b = a-1,b-1
    g[a] += [b]
    g[b] += [a]
    
def bfs(g, st):
    queue = [st]
    distances = [-1 for i in range(N)]
    distances[st] = 0
    
    while queue:
        node = queue.pop(0)
        for h in g[node]:
            if distances[h] == -1:
                distances[h] = distances[node] + 1
                queue += [h]
 
    return distances
 
dB = bfs(g, 0)
dW = bfs(g, N-1)
 
B, W = 0, 0
for i in range(N):
    if dB[i] <= dW[i]:
        B += 1
    else:
        W += 1
print("Fennec" if B > W else "Snuke")
### BUGGY CODE ###

S = input()
Q = int(input())
ans = S

for i in range(Q):
    Q_i = list(input().split())
    if Q_i[0] == "1":
        ans = ans[::-1]
    else:
        if Q_i[1] == "1":
            ans = Q_i[2] + ans
        else:
            ans = ans + Q_i[2]

print(ans)


### FIXED CODE ###

S = input()
Q = int(input())
revers_count = 0
mae = ""
ushiro = ""

for i in range(Q):
    Q_i = list(input().split())
    if Q_i[0] == "1":
        revers_count += 1
    else:
        if (Q_i[1] == "1" and revers_count % 2 == 0) or (Q_i[1] == "2" and revers_count % 2 == 1):
            mae = Q_i[2] + mae
        else:
            ushiro = ushiro + Q_i[2]

ans = mae + S + ushiro

if revers_count % 2 == 1:
    ans = ans[::-1]

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

s=list(map(int,input()))
an=0
i=0

if len(s) < 2:
    print("0")
    exit()

while 1:
    if s[i]+s[i+1]==1:
        an+=2
        del s[i:i+2]
        i=0
    else:
        i+=1
    if i+1 == len(s) or len(s)==0:
        print(an)
        exit()

### FIXED CODE ###

s=list(map(int,input()))
print(min(s.count(0),s.count(1))*2)
### BUGGY CODE ###

n, k = map(int, input().split())
A = [*map(int, input().split())]
for i in range(k):
    B = [0]*n
    for j in range(n):
        l = max(0, j-A[j])
        r = j + A[j] + 1
        B[l] += 1
        if r <= n-1: B[r] -= 1
    is_same = True
    for j in range(n-1):
        B[j+1] = B[j+1] + B[j]
        if B[j+1] != n: is_same = False
    if is_same: break
    A = B
print(*B,sep=' ')


### FIXED CODE ###

n,k = map(int,input().split())
A=[*map(int,input().split())]
for i in range(k):
    B = [0]*n
    for j in range(n):
        d = A[j] # 強さ
        l = max(0, j-d) # 範囲
        r = j+d+1 # 範囲
        B[l] += 1
        if r <= n-1: B[r] -= 1
    is_same = True
    for j in range(n-1):
        B[j+1] = B[j+1] + B[j]
        if B[j+1] != n: is_same = False
    # print(B)
    if is_same: break
    A = B
# print(B)
print(*B,sep=' ')
### BUGGY CODE ###

# -*- coding: utf-8 -*-

from decimal import *
import numpy as np


getcontext().prec = 6

L = int(input())
L = Decimal(L)

x=y=z=0
x = Decimal(x)
y = Decimal(y)
z = Decimal(z)


p = 0.01
p = Decimal(p)

maxV = 0

for x in np.arange(p,L+1,p):
    for y in np.arange(p,L+1,p):
        z = L-(x+y)

        V = x*y*z
    
        if maxV < V:
            maxV = V


print(maxV)

### FIXED CODE ###

L = int(input())

x=y=z=0

x=y=z=L/3

V = x*y*z




print(V)
### BUGGY CODE ###

S = input()
ans = 0
listmod = [0]*2019
for i in range(1,len(S)+1):
    if(i == 1):
        T = int(S[-1])
        listmod[T] = 1
        mod2 = T
    else:
        T = int(S[-i])
        mod1 = (T*10**(i-1)%2019 + mod2)%2019
        listmod[mod1] += 1
        mod2 = mod1
for i in range(2019):
    if(i == 0):
        ans += listmod[0]
    else:
        n = listmod[i]
        ans += int((n-1)*n/2)
print(ans)

### FIXED CODE ###

S = input()
ans = 0
nd = 1
mod1 = 0
listmod = [0]*2019
for i in S[::-1]:
    mod1 = (int(i)*nd + mod1)%2019
    listmod[mod1] += 1
    nd = (nd*10)%2019
for i in range(2019):
    n = listmod[i]
    if(i == 0):
        if(n == 1):
            ans += 1
        elif(n >= 2):
            ans += ((n+1)*n)//2
    else:
        if(n > 1):
            ans += ((n-1)*n)//2
print(ans)
### BUGGY CODE ###

import copy
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    answer = 0
    del_A = copy.copy(A)
    del_A.remove(A[i])
    answer += abs(del_A[0])
    for j in range(1, N-1):
        answer += abs(del_A[j] - del_A[j-1])
    answer += abs(del_A[-1])
    print(answer)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
all = abs(A[0]) + abs(A[N-1])
for i in range(1, N):
    all += abs(A[i] - A[i-1])

for i in range(N):
    answer = all
    if i == 0:
        prev = 0
    else:
        prev = A[i-1]
    if i == N-1:
        next = 0
    else:
        next = A[i+1]
    curr = A[i]
    if prev > curr and curr < next:
        if prev >= next:
            answer -= abs(curr - next) * 2
        else:
            answer -= abs(curr - prev) * 2
    elif prev < curr and curr > next:
        if prev >= next:
            answer -= abs(curr - prev) * 2
        else:
            answer -= abs(curr - next) * 2
    print(answer)
### BUGGY CODE ###

n = int(input())
s = input()
q = int(input())
#k = list(map(int, input().split()))
for ki in map(int, input().split()):
    D=M=DM=C=0
    for i, c in enumerate(s):
        if c == "D":
            D += 1
        elif c == "M":
            M += 1
            DM += D
        if i >= ki:
            j = i-ki
            if s[j] == "D":
                D -= 1
                DM -= M
            elif s[j] == "M":
                M -= 1
        if c == "C":
            C += DM
    print(C)


### FIXED CODE ###

# コピペ https://atcoder.jp/contests/dwacon5th-prelims/submissions/7670569
# 自分の https://atcoder.jp/contests/dwacon5th-prelims/submissions/7822126
# とほぼ変わらないのに自分のものはTLEするので検証
n=int(input())
s=input()
q=int(input())
for i in list(map(int,input().split())):
    a=0
    v=[0,0,0]
    for j in range(n):
        if s[j]=="D":
            v[0]+=1
        elif s[j]=="M":
            v[1]+=1
            v[2]+=v[0]
        if j>=i:
            if s[j-i]=="D":
                v[0]-=1
                v[2]-=v[1]
            elif s[j-i]=="M":
                v[1]-=1
        if s[j]=="C":
            a+=v[2]
    print(a)
### BUGGY CODE ###

n = int(input())
s = ["".join(sorted(input())) for _ in range(n)]

count = 0
for i in range(n):
  base = s[i]
  num = sum([base==j for j in s[i+1:]])
  count += num
  
print(count)

### FIXED CODE ###

n = int(input())
s = ["".join(sorted(input())) for _ in range(n)]

d = {i:0 for i in set(s)}
for i in s:
  d[i] += 1
  
count = 0

for i in d.values():
  count += i*(i-1)//2
  
print(count)
### BUGGY CODE ###

n = int(input())
l = 0
r = n-1
print(0)
s = str(input())
if s == 'Vacant':
    exit()
else:
    sl = s
print(n-1)
s = str(input())
if s == 'Vacant':
    exit()
else:
    sr = s

while l+1 < r:
    c = (l+r)//2
    print(c)
    s = str(input())
    if s == 'Vacant':
        exit()
    else:
        if s == sl:
            l = c
            sl = s
        else:
            r = c
            sr = s

### FIXED CODE ###

def main():
    n = int(input())

    def q(i):
        print(i, )
        s = str(input())
        if s == 'Vacant':
            exit()
        else:
            return s

    x = q(n-1)
    x = q(0)

    def ok(m):
        if m == 0:
            return False
        else:
            if (m%2 == 0 and q(m) != x) or (m%2 == 1 and q(m) == x):
                return True
            else:
                return False

    l = 0
    r = n-1
    while l+1 < r:
        c = (l+r)//2
        if ok(c):
            r = c
        else:
            l = c

if __name__ == '__main__':
    main()
### BUGGY CODE ###

mod=10**9+7
N,M=map(int,input().split())
S=[int(i) for i in input().split()]
T=[int(i) for i in input().split()]
dp=[[0 for j in range(M)] for i in range(N)]
ans=[[0 for j in range(M+1)] for i in range(N+1)]
for i in range(N+1):
    ans[i][0]=1
for j in range(M+1):
    ans[0][j]=1
for i in range(N):
    for j in range(M):
        if S[i]==T[j]:
            dp[i][j]=ans[i][j]
        else:
            dp[i][j]=0
        ans[i+1][j+1]=dp[i][j]+ans[i+1][j]+ans[i][j+1]-ans[i][j]
        ans[i+1][j+1]%=mod
print(ans[N][M])


### FIXED CODE ###

mod=10**9+7
N,M=map(int,input().split())
S=[int(i) for i in input().split()]
T=[int(i) for i in input().split()]
dp=[[0 for j in range(M)] for i in range(N)]
ans=[[0 for j in range(M+1)] for i in range(N+1)]
for i in range(N+1):
    ans[i][0]=1
for j in range(M+1):
    ans[0][j]=1
for i in range(N):
    for j in range(M):
        if S[i]==T[j]:
            dp[i][j]=ans[i][j]
        else:
            dp[i][j]=0
        ans[i+1][j+1]=dp[i][j]+ans[i+1][j]+ans[i][j+1]-ans[i][j]
        ans[i+1][j+1]%=mod
print(ans[N][M])
### BUGGY CODE ###

N = int(input())
alist = [int(input()) for i in range(N)]
### 三角形が成立しない場合を数える
alist.sort(reverse=True) #大きい方からチェックするとS/2に早く到達しやすい
MOD = 998244353
asum = [0]
for i in range(N):
    asum += [asum[-1] + alist[i]]
S = asum[-1]
Sharf = S / 2

#dptableA[i番目までは振り分けた][Rの合計] -> そこからR>=S/2となる数
dptableA = [{} for i in range(N+1)]
#dptableB[i番目までは振り分けた][Rの合計] -> そこからR=G=S/2, B=0となる数
dptableB = [{} for i in range(N+1)]

def ddp(cur_N, R): #(retA: R>=S/2となる数, retB: R=G=S/2,B=0の数)を返す
    if R in dptableA[cur_N]: #DPテーブルにある
        return dptableA[cur_N][R], dptableB[cur_N][R]
    if cur_N == N: #末端
        retA = 1 if R >= Sharf else 0
        retB = 1 if R == Sharf else 0
        return retA, retB
    if R >= Sharf: #R>=S/2はこれ以降のパターン全てR>=S/2
        #となるので残りの要素をRGBどこに割り振っても良い
        retA = pow(3, N-cur_N, MOD)
        retB = 1 if R == Sharf else 0 #特にR=S/2の時はR=G=S/2にできる
        return retA, retB
    if (asum[cur_N] - R) > Sharf: #Rじゃない方がS/2に到達
        return 0, 0 # R < S/2が決まる
    
    #そうではない場合は計算が必要
    ai = alist[cur_N]
    #aiをRGBのどれかに振り分ける
    retA_R, retB_R = ddp(cur_N+1, R+ai) #Rに振り分けた場合
    retA_GB, retB_GB = ddp(cur_N+1,R) #Rに入れなかった場合
    retA_GB = retA_GB * 2 %MOD #GBで2通りあるので2倍
    retA = (retA_R + retA_GB) % MOD
    retB = (retB_R + retB_GB) % MOD
    dptableA[cur_N][R] = retA
    dptableB[cur_N][R] = retB
    return retA, retB

retA, retB = ddp(0,0)
#全体 - (ある辺がS/2以上) + (2辺がS/2)
ans = (pow(3, N, MOD) - retA*3 + retB*3) % MOD
print(ans)

### FIXED CODE ###

N = int(input())
alist = [int(input()) for i in range(N)]
import numpy as np
### 三角形が成立しない場合を数える
alist.sort(reverse=False) #大きい方からチェックするとS/2に早く到達しやすい
MOD = 998244353
asum = [0]
for i in range(N):
    asum += [asum[-1] + alist[i]]
S = asum[-1]
Sharf = S / 2

#dptableA[i番目までは振り分けた][Rの合計] -> そこからR>=S/2となる数
dptableA = np.zeros((N+1, S+1), dtype=np.int) #[[0 for i in range(S+1)] for j in range(N+1)]
dptableA[N, int(np.ceil(Sharf)):] = 1
#dptableB[i番目までは振り分けた][Rの合計] -> そこからR=G=S/2, B=0となる数
dptableB = np.zeros((N+1, S+1), dtype=np.int) #[[0 for i in range(S+1)] for j in range(N+1)]
if S %2 == 0:
    dptableB[N, int(Sharf)] = 1 

#dpの計算をまとめて行う
for i in range(N, 0, -1): #後ろから見ていく
    n = i - 1
    an = alist[n]
    asn = asum[n]
    dptableA[n, 0:asn+1] = (2*dptableA[n+1, 0:asn+1] + dptableA[n+1, an:an+asn+1])%MOD
    #dptableA[n] = [(2*dptableA[n+1][k]+dptableA[n+1][k+alist[n]]) % MOD for k in range(asum[n]+1)]
    dptableB[n, 0:asn+1] = (dptableB[n+1, 0:asn+1] + dptableB[n+1, an:an+asn+1])%MOD
    #dptableB[n] = [(dptableB[n+1][k]+dptableB[n+1][k+alist[n]]) %MOD for k in range(asum[n]+1)]
retA, retB = dptableA[0,0], dptableB[0,0]
#全体 - (ある辺がS/2以上) + (2辺がS/2)
ans = (pow(3, N, MOD) - retA*3 + retB*3) % MOD
print(ans)
### BUGGY CODE ###

def main():
    from collections import Counter
    from bisect import bisect
    import sys
    input = sys.stdin.buffer.readline

    _ = int(input())
    A = [int(i) for i in input().split()]

    ans = 0
    A.sort(reverse=True)
    c = Counter(A)
    bi = [2**i for i in range(1, 31)]

    for b in A:
        a = (bi[bisect(bi, b)]) - b
        if a == b:
            ans += c[b]//2
            c[b] %= 2
        else:
            if a in c.keys():
                cur = min(c[a], c[b])
                ans += cur
                c[b] -= cur
                c[a] -= cur
        # print(a, b, c, ans)

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    from collections import Counter
    import sys
    input = sys.stdin.buffer.readline

    _ = int(input())
    A = [int(i) for i in input().split()]

    ans = 0
    A.sort(reverse=True)
    c = Counter(A)

    for b in A:
        if c[b] == 0:
            continue
        a = (2 ** b.bit_length()) - b
        if a == b:
            cur = c[b]//2
        else:
            cur = min(c[a], c[b])
        ans += cur
        c[b] -= cur
        c[a] -= cur
        # print(a, b, c, ans)

    print(ans)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

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

while all(i%2==0 for i in a ):
  A = [i//2 for i in a]
  cnt+=1

print(cnt)


### FIXED CODE ###

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

while all(i%2==0 for i in A):
  A=[i//2 for i in A]
  cnt+=1
print(cnt)
### BUGGY CODE ###

from bisect import *
import numpy

a = input()
a = input().split()
# a = [1, 3, -4, 2, 2, -2]
# a = [1, -1, 1, -1, 1, -1, 1]
# a = [1, -2, 3, -4, 5]
a = [int(i) for i in a]
a = numpy.array(a)
b = numpy.cumsum(a)

cnt = len(b) - numpy.count_nonzero(b)

idx = numpy.argsort(b)
c = list(numpy.sort(b))

for xi, x in enumerate(c):
    i = bisect_left(c, x)
    if i == len(c) or (i == 0 and c[0] != x):
        continue
    j = bisect_right(c, x)
    if j == 0 or (j == len(c) and c[-1] != x):
        continue
    for n in range(i, j):
        if idx[n] > idx[xi]:
            cnt += 1
print(cnt)


### FIXED CODE ###

import numpy
from collections import Counter

_ = input()
a = numpy.array(list(map(int, input().split())))

s = numpy.cumsum(a)
s = numpy.concatenate(([0], s))
ans = 0

for i in Counter(s).values():
    ans += i * (i - 1) // 2
print(ans)
### BUGGY CODE ###

x,y,z,k=map(int,input().split())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
c=[int(x) for x in input().split()]

t=list()
for i in range(x):
  for j in range(y):
    t.append(a[i]+b[j])

s=list()
t.sort(reverse=True)
for i in range(min(k,x*y)):
  for j in range(z):
    s.append(t[i]+c[j])

s.sort(reverse=True)

for i in range(k):
  print(s[i])


### FIXED CODE ###

x,y,z,k=map(int,input().split())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
c=[int(x) for x in input().split()]

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

s=list()

for l in range(x):
  if l>k:
    break 
  for m in range(y):
    if l*m>k:
      break
    for n in range(z):
      if l*m*n>k:
        break
      s.append(a[l]+b[m]+c[n])
 
s.sort(reverse=True)
for i in range(k):
  print(s[i])
### BUGGY CODE ###

num = []
num = [int(i) for i in input().split()]

gate = []

for temp in range(num[1]):
    temp = []
    temp = [int(i) for i in input().split()]
    gate.append(temp)

check = [0] * num[0]

for temp in gate:
    while temp[0] <= temp[1]:
        check[temp[0]-1] += 1
        temp[0] += 1

print(check.count(num[1]))

### FIXED CODE ###

import sys
input = sys.stdin.readline
num = []
num = [int(i) for i in input().split()]

syou = []
dai = []

for temp in range(num[1]):
    suuzi = []
    suuzi = [int(i) for i in input().split()]
    syou.append(suuzi[0])
    dai.append(suuzi[1])

result= min(dai) - max(syou) + 1
if result > 0:
    print(result)
else:
    print(0)
### BUGGY CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

def is_prime3(q,k=50):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1

if __name__ == "__main__":
    list = input().split(" ")
    N = int(list[0])
    M = int(list[1])
    if is_prime3(M):
        print(1)
        exit()
    for i in range(M):
        if M%(N+i) == 0:
            print(int(M/(N+i)))
            exit()
        if M/(N+i) < 2:
            print(1)
            exit()


### FIXED CODE ###


#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

if __name__ == "__main__":
    list = input().split(" ")
    N = int(list[0])
    M = int(list[1])
    list = []
    for i in range(1,int(math.sqrt(M)+1)):
        if M%i == 0:
            list.append(i)
    for i in range(len(list)):
        list.append(int(M/list[i]))
    print(max([i for i in list if i <= M // N]))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

for i in range(n):
    c = sorted(a,reverse = True)
    if c[0] == a[i]:
        b = c[1]
    else:
        b = c[0]
    print(b)

### FIXED CODE ###

import sys
input = sys.stdin.readline

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

c = sorted(a,reverse = True)

for i in range(n):
    if c[0] == a[i]:
        b = c[1]
    else:
        b = c[0]
    print(b)
### BUGGY CODE ###

import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

MAX_N = 110000

memo = [-1 for _ in range(MAX_N)]
def rec(n):
    if n == 0: return 0
    if memo[n] != -1: return memo[n]

    res = n

    pow6 = 1
    while pow6 <= n:
        res = min(res, rec(n-pow6)+1)
        pow6 *= 6
    pow9 = 1
    while pow9 <= n:
        res = min(res, rec(n-pow9)+1)
        pow9 *= 9
    memo[n] = res
    return res


N = iin()
print(rec(N))



### FIXED CODE ###

max_n = 100000

N = int(input())

dp = [N for _ in range(N+1)]
dp[0] = 0
for n in range(1, N+1):
    for pow6 in range(n+1):
        if 6 ** pow6 <= n:
            dp[n] = min(dp[n], dp[n - 6 ** pow6] + 1)
        else:
            break

    for pow9 in range(n+1):
        if 9 ** pow9 <= n:
            dp[n] = min(dp[n], dp[n - 9 ** pow9] + 1)
        else:
            break
print(dp[N])
### BUGGY CODE ###

X=int(input())

Xkon=X**0.2
if(Xkon==int(Xkon)):
    print(str(0)+" "+str(int(-Xkon)))
    #break
else:
    m=-10
    while m<0:
        A=X+(m**5)
        check=(A**0.2)
        # print(type(check))
        if(type(check)!=complex):
            if(check==int(check)):
                AnsA=-check
                AnsB=-m
                print(str(int(AnsB))+" "+str(int(AnsA)))
                break
            else:
                pass
        else:
            m=m+1
    n=1
    while n<10:
        A=X+(n**5)
        check=(A**0.2)
        if(check==int(check)):
            AnsA=check
            AnsB=n
            print(str(int(AnsB)+" "+str(int(-AnsA))))
            break
        else:
            n=n+1


### FIXED CODE ###

X=int(input())

for A in range(-1000,1000):
    for B in range (-1000,1000):
        if(A**5-B**5==X):
            print(A,B)
            break
    else:
        continue
    break
### BUGGY CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))
b = [0]*n
t = 0
for i in range(k,n+1):
    x = 1
    for aj in a[i-k:i]:
        x *= aj
    if i == k:
        t = x
        continue
    else:
        if t < x:
            print("Yes")
        else:
            print("No")
        t = x

### FIXED CODE ###

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

wa = [0]
for i in range(n):
    wa.append(wa[i]+a[i])

t = wa[k]-wa[0]
for i in range(k+1,n+1):
    if t < wa[i]-wa[i-k]:
        print("Yes")
    else:
        print("No")
    t = wa[i]-wa[i-k]
    # print(wa[i]-wa[i-k],t)
### BUGGY CODE ###

#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    for i in range(K):
        dm = [0]*N
        for x in range(N):
            dm[max(x - A[x],0)]+=1
            if x+A[x]+1<N:
                dm[x+A[x]+1]+=-1
        for j in range(1,N):
            dm[j]=dm[j-1]+dm[j]
        A[:] = dm[:]
    print(*A)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    for i in range(min(K,50)):
        dm = [0]*N
        for x in range(N):
            dm[max(x - A[x],0)]+=1
            if x+A[x]+1<N:
                dm[x+A[x]+1]+=-1
        for j in range(1,N):
            dm[j]=dm[j-1]+dm[j]
        A[:] = dm[:]
    print(*A)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

import numpy as np
N,Q = list(map(int, input().split(" ")))
v_list = np.zeros(N+1, dtype=np.int)
dic_tree = {}
for i in range(N):
    dic_tree[i+1] = [] 

for i in range(N-1):
    a, b = list(map(int, input().split(" ")))
    dic_tree[a].append(b)
        
for i in range(Q):
    p, x = list(map(int, input().split(" ")))
    
    # v_list[dic_tree[p]] += x # Too Heavy...
    v_list[p] += x

for i in range(N):
    v_list[dic_tree[i+1]] += v_list[i+1]
    if i > 0:
        print(" ", end='') 
    print(v_list[i+1], end='')
    

### FIXED CODE ###

from collections import deque

N,Q = list(map(int, input().split()))
tre = [[] for _ in range(N)]
val = [0] * N
for i in range(N-1):
    a,b = list(map(int, input().split()))
    tre[a-1].append(b-1)
    tre[b-1].append(a-1)

for i in range(Q):
    p,x = list(map(int, input().split()))
    val[p-1] += x

stack = deque([0])
visited = [False] * N
visited[0] = True
while stack:
    cur = stack.pop()
    for target in tre[cur]:
        if visited[target]:
            continue
        visited[target] = True
        stack.append(target)
        val[target] += val[cur]

print(*val)