Harryxun/stf_run huggingface dataset:
n = int(input())
a = [int(input()) for i in range(n)]

m = max(a)

for i in range(n):
    if m >= a[i]:
        print(m)
    else:
        b = a[i]
        a.remove(b)
        print(max(a))
        a.insert(i,b)

### FIXED CODE ###

r = int(input())

print(3*(r**2))
nq = input().split()
n, q = int(nq[0]), int(nq[1])
s = list(input())
r_li = []
l_li = []
t_li = []
ac_li = []
for i in range(q):
    rl = input().split()
    l_li.append(int(rl[0]))
    r_li.append(int(rl[1]))
count = 0
i = 0
while True:
    if i == n:
        t_li.append(count)
        break
    else:
        if s[i] == "A":
            if s[i + 1] == "C":
                t_li.append(count)
                count += 1
                t_li.append(count)
                i += 2
            else:
                t_li.append(count)
                i += 1
        else:
                i += 1
                t_li.append(count)
for i in range(q):
    print(t_li[r_li[i] - 1] - t_li[l_li[i] - 1])









### FIXED CODE ###

nq = input().split()
n, q = int(nq[0]), int(nq[1])
s = list(input())
r_li = []
l_li = []
t_li = []
for i in range(q):
    rl = input().split()
    l_li.append(int(rl[0]))
    r_li.append(int(rl[1]))
count = 0
i = 0
while True:
    if i == n:
        break
    else:
        if s[i] == "A":
            if i == n - 1:
                i += 1
                t_li.append(count)
            else:
                if s[i + 1] == "C":
                    t_li.append(count)
                    count += 1
                    t_li.append(count)
                    i += 2
                else:
                    t_li.append(count)
                    i += 1
        else:
            i += 1
            t_li.append(count)
for i in range(q):
    print(t_li[r_li[i] - 1] - t_li[l_li[i] - 1])
n = int(input())
if n == 1:
	print(0)
else:
	vals = list(map(int, input().split()))
    costs = list(map(int, input().split()))
 
	total = 0
	for v, c in zip(vals, costs):
    	resale = v - c
        if resale > 0:
        	total += resale
    print(total)

### FIXED CODE ###

n = int(input())
vals = list(map(int, input().split()))
costs = list(map(int, input().split()))

if n == 1:
    print(0)
else:
    total = 0
    for v, c in zip(vals, costs):
        resale = v - c
        if resale > 0:
            total += resale
    print(total)
h,w,k = map(int, input().split())
s = []
Nm = [[0]*w for i in range(h)]
nm = 1
Q = []
empty =[]
for i in range(h):
    si = input()
    s.append(si)
    berry = False
    for j in range(w):
        if si[j]=="#":
            berry = True
            Nm[i][j]=nm
            nm+=1
            Q.append((i,j))
    if not berry:
        empty.append(i)

for i,j in Q:#横に伸ばす
    for t in range(j+1,w):
        if Nm[i][t]==0:
            Nm[i][t]=Nm[i][j]
        else:
            break
    for t in range(j-1,-1,-1):
        if Nm[i][t]==0:
            Nm[i][t]=Nm[i][j]
        else:
            break
for i in empty:#縦下に伸ばす
    for j in range(w):
        Nm[i][j] = Nm[i-1][j]
if 0 in empty:#下から延ばす必要がある場合
    j = 0
    while empty[j]==j:
        j+=1
    for t in range(j):
        for s in range(w):
            Nm[t][s] = Nm[j][s]

for i in range(h):
    print(*Nm[i])


    

### FIXED CODE ###

h,w,k = map(int, input().split())
s = []
Nm = [[0]*w for i in range(h)]
nm = 1
Q = []
empty =[]
for i in range(h):
    si = input()
    s.append(si)
    berry = False
    for j in range(w):
        if si[j]=="#":
            berry = True
            Nm[i][j]=nm
            nm+=1
            Q.append((i,j))
    if not berry:
        empty.append(i)

for i,j in Q:#横に伸ばす
    for t in range(j+1,w):
        if Nm[i][t]==0:
            Nm[i][t]=Nm[i][j]
        else:
            break
    for t in range(j-1,-1,-1):
        if Nm[i][t]==0:
            Nm[i][t]=Nm[i][j]
        else:
            break
if not empty:
    for i in range(h):
        print(*Nm[i])
    exit()
j=0###
if 0 in empty:#下から延ばす必要がある場合
    j = 0
    while empty[j]==j:
        j+=1
        if j<len(empty):
            continue
        else:
            break
    for t in range(j):
        for s in range(w):
            Nm[t][s] = Nm[j][s]
#print(j)
for i in empty[j:]:#縦下に伸ばす
    for j in range(w):
        Nm[i][j] = Nm[i-1][j]

for i in range(h):
    print(*Nm[i])
from itertools import permutations

while True:
	n = input()
	k = input()
	if n == k == 0:
		break
	nums = [raw_input().strip() for i in xrange(n)]
	result = set(["".join(p) for p in permutations(nums, k)])
	print(len(result))

### FIXED CODE ###

import sys
from itertools import permutations
 
def main():
	while True:
		line = raw_input()
		if line == "0 0": break
		n = int(line)
		k = input()
		nums = [raw_input().strip() for i in xrange(n)]
		result = set(["".join(p) for p in permutations(nums, k)])
		print (len(result))

if __name__ == '__main__':
	sys.exit(main())
import sys
for n in sys.stdin: print len([None for a in range(10) for b in range(10) for c in range(10) for d in range(10) if a+b+c+d == N])

### FIXED CODE ###

import sys
for n in sys.stdin: print len([None for a in range(10) for b in range(10) for c in range(10) for d in range(10) if a+b+c+d == int(n)])
n,m = map(int, input().split())
a=[]
for i in range(n):
    a.append(tuple(map(int, input().split())))

memo = {}
def f(a, s, fn):
    global m
    l = len(a)
    if s >= m or l == 0:
        return 0
    if (l,s) in memo:
        return memo[(l,s)]
    elif len(a) == 1:
        return max(0, fn(a[0]))
    else:
        return max(f(a[1:], s, fn), fn(a[0]) + f(a[1:], s+1, fn))

ans = []
ans.append(f(a,0, lambda x: x[0]+x[1]+x[2]))
memo.clear()
ans.append(f(a,0, lambda x: x[0]+x[1]-x[2]))
memo.clear()
ans.append(f(a,0, lambda x: x[0]-x[1]+x[2]))
memo.clear()
ans.append(f(a,0, lambda x: x[0]-x[1]-x[2]))
memo.clear()
ans.append(f(a,0, lambda x: -x[0]+x[1]+x[2]))
memo.clear()
ans.append(f(a,0, lambda x: -x[0]+x[1]-x[2]))
memo.clear()
ans.append(f(a,0, lambda x: -x[0]-x[1]+x[2]))
memo.clear()
ans.append(f(a,0, lambda x: -x[0]-x[1]-x[2]))
memo.clear()
print(max(ans))


### FIXED CODE ###

n,m = map(int, input().split())
a=[]
for i in range(n):
    a.append(tuple(map(int, input().split())))

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

def f(fn):
    global dp, a
    for i in range(1,m+1):
        for j in range(i,n+1):
            if j == i:
                dp[i][j] = sum(map(fn, a[:j]))
            else:
                dp[i][j] = max(dp[i][j-1], dp[i-1][j-1] + fn(a[j-1]))

ans = []
f(lambda x: x[0]+x[1]+x[2])
ans.append(dp[m][n])
f(lambda x: x[0]+x[1]-x[2])
ans.append(dp[m][n])
f(lambda x: x[0]-x[1]+x[2])
ans.append(dp[m][n])
f(lambda x: x[0]-x[1]-x[2])
ans.append(dp[m][n])
f(lambda x: -x[0]+x[1]+x[2])
ans.append(dp[m][n])
f(lambda x: -x[0]+x[1]-x[2])
ans.append(dp[m][n])
f(lambda x: -x[0]-x[1]+x[2])
ans.append(dp[m][n])
f(lambda x: -x[0]-x[1]-x[2])
ans.append(dp[m][n])

print(max(ans))
a,b,c = map(int, input().split())
if b − a == c − b:
  print("YES"):
else:
  print("NO")
 


### FIXED CODE ###

a,b,c = map(int, input().split())
if (b - a) == (c - b):
  print("YES")
else:
  print("NO")
#/usr/bin/env python3

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

adj = [[] for _ in range(N)]

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

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

def dfs(node, parent):
    for child in adj[node]:
        if child == parent: continue
        values[child] += values[node]
        dfs(child, node)

dfs(0, -1)

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

### FIXED CODE ###

#/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)

def input():
    return sys.stdin.readline()

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

adj = [[] for _ in range(N)]

for _ in range(N - 1):
    a, b = map(int, input().split())
    a, b = (a - 1, b - 1)
    adj[a].append(b)
    adj[b].append(a)
    
values = [0 for _ in range(N)]
    
for _ in range(Q):
    p, x = map(int, input().split())
    values[p - 1] += x

def dfs(node, parent):
    for child in adj[node]:
        if child == parent: continue
        values[child] += values[node]
        dfs(child, node)

dfs(0, -1)

print(" ".join(map(str, values)))
from itertools import*
from numpy import*
def section_sum(numbers,separate):
    sep1=array(numbers[separate:],dtype=int)
    sep2=array(numbers[:-separate],dtype=int)
    sep3=sum(numbers[:separate])
    return insert(sep3+cumsum(sep1-sep2),0,sep3)
    
    
n,k,a=open(0).read().split()
n,k=int(n),int(k)
ar=[len(list(v))for k,v in groupby(a)]

#print(ar)
if n<=k:
    print(sum(ar)-1)
else:
    ar2=[i-1 for i in ar]
    s=cumsum(ar2[::2])
    t=cumsum(ar2[1::2])
    mae=[0]+[t[i//2] if i%2 else s[i//2] for i in range(len(ar))]+[0,0,0]
    p=cumsum(ar2[::2][::-1])[::-1]
    q=cumsum(ar2[1::2][::-1])[::-1]
    usiro=[0]+[q[i//2] if i%2 else p[i//2] for i in range(len(ar))]+[0,0,0]
#    print(mae,usiro)
#    print([[[kk,kk+2*k+2],mae[kk],usiro[kk+2*k+2],vv] for kk,vv in enumerate(section_sum(ar,k*2+1))])
    print(max(mae[kk]+usiro[kk+2*k+2]+vv for kk,vv in enumerate(section_sum(ar,k*2+1)))-1)

### FIXED CODE ###

from itertools import*

a,b=map(int,input().split())
s=input()
n=[len(list(v)) for k,v in groupby(s)]
print(min(sum(n)-len(n)+min(len(n)-1,b)*2,a-1))
r=int(input())
if r>=2800:
  print('AGC')
 elif r>=1200:
  print('ARC')
 else:
  print('ABC')


### FIXED CODE ###

r=int(input())
if r>=2800:
	print('AGC')
elif r>=1200:
	print('ARC')
else:
	print('ABC')
import math
def myfunc(N):
    math.floor(N/2)
    
myfunc(N)

### FIXED CODE ###

import math
N = input()
n = int(N)
print(math.ceil(n/2))
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N,x = LI()
    if x == 1 or x == N-1:
        print('No')
        return

    ans = [0] * (2*N-1)
    ans[N-2] = x-1
    ans[N-1] = x
    ans[N] = x+1

    j = N+1
    for i in range(1,2*N):
        if i < x-1 or i > x+1:
            ans[j] = i
            j += 1
            if j >= 2 * N - 1:
                j = 0
    print('Yes')
    print(*ans,sep='\n')


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N,x = LI()
    if x == 1 or x == 2*N-1:
        print('No')
        return

    ans = [0] * (2*N-1)
    ans[N-2] = x-1
    ans[N-1] = x
    ans[N] = x+1

    j = N+1
    for i in range(1,2*N):
        if i < x-1 or i > x+1:
            ans[j] = i
            j += 1
            if j >= 2 * N - 1:
                j = 0
    print('Yes')
    print(*ans,sep='\n')


if __name__ == '__main__':
    main()
scores=[]
def depth(now,score,d):
    global scores
    if d[now]:
        for i in d[now]:
            depth(i,score+1,d)
    else:
        scores.append(score)


N,M=map(int,input().split())
d=[[] for i in range(N)]
for i in range(M):
    x,y=map(int,input().split())
    d[x-1].append(y-1)

Max=0
for i in range(N):
    depth(i,0,d)
    if scores and max(scores)>Max:
        Max=max(scores)
    scores.clear()
print(Max)

### FIXED CODE ###

import numpy as np
import sys
sys.setrecursionlimit(100000)
N,M=map(int,input().split())
d=[[] for i in range(N)]
for i in range(M):
    x,y=map(int,input().split())
    d[x-1].append(y-1)
dp=[0 for i in range(N)]

def depth(now,score,d):
    global dp
    if dp[now]==0 or not(dp[now]):
        if d[now]:
            _score=[]
            for i in d[now]:
                _score.append(depth(i,score+1,d)-score)
            dp[now]=max(_score)
        else:
            return score

        return dp[now]+score

    else:
        return dp[now]+score



Max=0
for i in range(N):
    m=depth(i,0,d)
    if  m>Max:            
        Max=m
print(Max)
N=int(input())
S=input()
if N%2!=0:
    print('No')
	exit()
    
if S[0:N//2]==S[N//2:N]:
	print('Yes')
else:
	print('No')

### FIXED CODE ###

N=int(input())
S=input()
if N%2!=0:
    print('No')
else:
    if S[0:N//2]==S[N//2:N]:
        print('Yes')
    else:
        print('No')
def resolve():
	w, h, n = map(int, input().split())
	r = [[True]*w for _ in range(h)]
	for _ in range(n):
		ix, iy, a = map(int, input().split())
		if a == 1:
			for row in r:
				row[:ix] = [False]*ix
		elif a == 2:
			for row in r:
				row[ix:] = [False]*ix if ix > 0 else [False]*w
		elif a == 3:
			for i in range(iy):
				for j in range(w):
					r[i][j] = False
		else:
			for i in range(iy, h):
				for j in range(w):
					r[i][j] = False
	ans = 0

	for row in r:
		for i in row:
			if i:
				ans += 1
	print(ans)
resolve()

### FIXED CODE ###

def resolve():
	w, h, n = map(int, input().split())
	r = [[True]*w for _ in range(h)]
	for _ in range(n):
		ix, iy, a = map(int, input().split())
		if a == 1:
			for i in range(h):
				for j in range(ix):
					r[i][j] = False
		elif a == 2:
			for i in range(h):
				for j in range(ix, w):
					r[i][j] = False
		elif a == 3:
			for i in range(iy):
				for j in range(w):
					r[i][j] = False
		else:
			for i in range(iy, h):
				for j in range(w):
					r[i][j] = False
	ans = 0

	for row in r:
		for i in row:
			if i:
				ans += 1
	print(ans)
resolve()
s = input()
N = len(s)
s_trim = ''.join([c for c in s if c != 'x'])
N_trim = len(s_trim)

def check_anagram():
    for i in range(N_trim):
        j = N_trim - 1 - i
        if s_trim[i] != s_trim[j]:
            return False
    return True

def solve():
    if not check_anagram():
        return -1

    # Center of anagram
    pr = N_trim // 2
    pl = pr
    if N_trim % 2 == 0:
        pl -= 1

    xl = 0
    tl = 0
    while xl < N:
        if s[xl] != 'x':
            assert s[xl] == s_trim[tl]
            if tl == pl:
                break
            tl += 1
        xl += 1

    if N_trim % 2 == 1:
        xr = xl
    else:
        xr = xl + 1
        while s[xr] == 'x':
            xr += 1

    cost = 0
    while True:
        assert s[xl] == s_trim[pl]
        assert s[xr] == s_trim[pr]
        assert s[xl] == s[xr]
        # assert s_trim[pl] == s_trim[pr]
        if s_trim[pl] != s_trim[pr]:
            while True: pass
        pl -= 1; pr += 1
        while True:
            xl -= 1; xr += 1
            if not (xl >= 0 and xr < N and s[xl] == 'x' and s[xr] == 'x'):
                break
        while xl >= 0 and s[xl] == 'x':
            cost += 1
            xl -= 1
        while xr < N and s[xr] == 'x':
            cost += 1
            xr += 1
        if pl < 0 and pr >= N_trim and xl < 0 and xr >= N:
            return cost

print(solve())


### FIXED CODE ###

s = input()
N = len(s)
s_trim = ''.join([c for c in s if c != 'x'])
N_trim = len(s_trim)

def check_anagram():
    for i in range(N_trim):
        j = N_trim - 1 - i
        if s_trim[i] != s_trim[j]:
            return False
    return True

def solve():
    if not check_anagram():
        return -1
    if N_trim == 0:
        return 0
    # Center of anagram
    pr = N_trim // 2
    pl = pr
    if N_trim % 2 == 0:
        pl -= 1

    xl = 0
    tl = 0
    while xl < N:
        if s[xl] != 'x':
            # assert s[xl] == s_trim[tl]
            if tl == pl:
                break
            tl += 1
        xl += 1

    if N_trim % 2 == 1:
        xr = xl
    else:
        xr = xl + 1
        while s[xr] == 'x':
            xr += 1

    cost = 0
    while True:
        # assert s[xl] == s_trim[pl]
        # assert s[xr] == s_trim[pr]
        # assert s[xl] == s[xr]
        # assert s_trim[pl] == s_trim[pr]
        pl -= 1; pr += 1
        while True:
            xl -= 1; xr += 1
            if not (xl >= 0 and xr < N and s[xl] == 'x' and s[xr] == 'x'):
                break
        while xl >= 0 and s[xl] == 'x':
            cost += 1
            xl -= 1
        while xr < N and s[xr] == 'x':
            cost += 1
            xr += 1
        if pl < 0 and pr >= N_trim and xl < 0 and xr >= N:
            return cost

print(solve())
w ,h ,x ,y ,r = input().split(' ')
if int(x) < int(w) - int(r):
elif int(x) > int(r):
elif int(y) < int(h) - int(r):
elif int(y) > int(r):
	print("Yes")
else:
	print("No")

### FIXED CODE ###

w ,h ,x ,y ,r = input().split(' ')
if int(x) <= int(w) - int(r) and int(x) >= int(r) and int(y) <= int(h) - int(r) and int(y) >= int(r):
	print("Yes")
else:
	print("No")
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
A = sorted([int(i) for i in input().split()])
F = sorted([int(i) for i in input().split()], reverse = True)
 
P = [A[i]*F[i] for i in range(n)]
 
def b(p):
    result = 0
    for i in range(n):
        result += A[i] - p / F[i]
    return result
 
if sum(A) <= k: print('0')
else: 
    left = 0
    right = max(P)
    middle = (left + right) / 2
    bm = b(middle)
    while right - left > 1:
        
        if bm > k: left = middle
        else: right = middle
        
        middle = (left + right) / 2
        bm = b(middle)
    
    if b(int(left)) == k: print(int(left))
    elif: b(int(right)) <= k: print(int(right))
    else: print(int(right) + 1)

### FIXED CODE ###

# -*- coding: utf-8 -*-
 
n, k = map(int, input().split())
A = [int(i) for i in input().split()]
A.sort(reverse = True)
F = [int(i) for i in input().split()]
F.sort()
"""
n = 11
k = 14
A = [1,1,2,3,3,4,5,5,5,6,9]
F = [9,9,8,8,7,6,4,3,3,2,2]
"""

 
P = [A[i]*F[i] for i in range(n)]
sum_A = sum(A)
 
def b(p):
    result = 0
    for i in range(n):
        if P[i] > p:
            r = (P[i] - p) // F[i]
            if P[i] - r * F[i] > p:
                r += 1
            result += r
    return result
 
if sum_A <= k: print('0')
else: 
    left = 0
    right = max(P)
    middle = int((left + right) / 2)
    bm = b(middle)
    
    
    
    while right - left > 1:
        
        if bm > k: left = middle
        else: right = middle
            
        middle = int((left + right) / 2)
        bm = b(middle)
 
    if b(left) <= k: print(left)
    else: print(right)
import math

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

p = 0
for i in range(N):
    p += 1/N * (1/2) ** max(0, math.ceil(math.log2(K/(i+1))))

print(p)

### FIXED CODE ###

import math

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

p = 0
for i in range(N):
    p += 1/N * (1/2) ** max(0, math.ceil(math.log2(K/(i+1))))

print(p)
N = int(input())
def sieve(n, s):
    num = [True]*n
    num[0] = num[1] = False
    for i in range(2,int(n**0.5)+1):
        if num[i]:
            for j in range(i**2, n, i):
                num[j] = False
    return [i for i in range(2,n) if num[i] and i > s]
print(sieve(N*2, N)[0])

### FIXED CODE ###

S, T = input().split()
print(T + S)
X, N = map(int, input().split())
p = list(map(int, input().split()))

if N == 0:
    ans = X
else:
    for i in range(N):
        if not X - i in p:
            ans = X - i
            break
        elif not X + i in p:
            ans = X + i
            break

print(ans)

### FIXED CODE ###

X, N = map(int, input().split())
p = list(map(int, input().split()))

ans = X
for i in range(N+1):
    if not X - i in p:
        ans = X - i
        break
    elif not X + i in p:
        ans = X + i
        break

print(ans)
from sys import stdin

i = stdin.readline().strip()
d = datetime.date.fromisoformat("-".join(i.split("/")))
print("Heisei" if d < datetime.date.fromisoformat("2019-04-30") else "TBD")

### FIXED CODE ###

from sys import stdin
 
i = stdin.readline().strip()
d = tuple(map(int, i.split("/")))
print("Heisei" if d <= (2019,4,30) else "TBD")
import queue
N, Q = map(int, input().split())

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

points = [0]*N
PX = [list(map(int, input().split())) for _ in range(Q)]
for px in PX:
    points[px[0]-1] += px[1]


def dfs(v, par):
    for nv in edges[v]:
        if nv == par:
            continue
        points[nv] += points[v]
        dfs(nv, v)

dfs(0, -1)

print(*points)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
N, Q = map(int, input().split())

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

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

def dfs(v, par):
    for nv in edges[v]:
        if nv == par:
            continue
        points[nv] += points[v]
        dfs(nv, v)

dfs(0, -1)

print(*points)
from itertools import product
 
H, W = map(int, input().split())
 
a = [ list(map(int, input().split())) for _ in range(H) ]
 
output = ''
direction = -1
idou = 0
last_i = 0
last_j = 0
count = 0
j = -1
for i in range(H):
    direction *= -1
    j += direction
    for _ in range(W):
        if idou == 1:
            count += 1
            output += '{} {} {} {}\n'.format(last_i+1, last_j+1, i+1, j+1)
        if (a[i][j] + idou) % 2 == 1:
            idou = 1
        else:
            idou = 0
        last_i = i
        last_j = j
        j += direction
 
output = str(count) + '\n' + output.strip()
print(output)

### FIXED CODE ###

A, B = map(int, input().split())

if A * B % 2 == 1:
    print('Yes')
else:
 print('No')
S=input()
T=input()
differnce=0
for i in range(len(S)):
  if S[i]!=T[i]:
    difference+=1
print(difference)

### FIXED CODE ###

S=input()
T=input()
difference=0
for i in range(len(S)):
  if S[i]!=T[i]:
    difference+=1
print(difference)
# F - LIS on Tree
import bisect

INF = 10**10

n = int(input())
a = list(int(x) for x in input().split())
g = [[] for _ in range(n)]
for i in range(n-1):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    g[u].append(v)
    g[v].append(u)

def dfs(now, par):
    idx = bisect.bisect_left(dp, a[now])    
    tmp = dp[idx]
    dp[idx] = a[now]
    #print(dp)
    #print('now',now)
    # 親のLIS以上であれば、その値で更新
    if ans[par] <= idx:
        ans[now] = idx
    # そうでなければ親のLISを引き継ぐ
    else:
        ans[now] = ans[par]

    for i in g[now]:
        #print('i',i)
        if i!=par:
            # 次にみる頂点と、自分（親）の情報を渡す
            dfs(i, now)
    dp[idx] = tmp

ans = [0] * n
dp = [-INF] + [INF] * n
dfs(0,-1)
for a in ans:
    print(a)

### FIXED CODE ###

# F - LIS on Tree
import bisect
import sys
sys.setrecursionlimit(10**7)

INF = 10**18

n = int(input())
a = list(int(x) for x in input().split())
g = [[] for _ in range(n)]
for _ in range(n-1):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    g[u].append(v)
    g[v].append(u)

def dfs(now, par):
    idx = bisect.bisect_left(dp, a[now])    
    tmp = dp[idx]
    dp[idx] = a[now]
    # 親のLIS以上であれば、その値で更新
    if ans[par] <= idx:
        ans[now] = idx
    # そうでなければ親のLISを引き継ぐ
    else:
        ans[now] = ans[par]

    for i in g[now]:
        if i!=par:
            # 次にみる頂点と、自分（親）の情報を渡す
            dfs(i, now)
    dp[idx] = tmp

ans = [0] * n
dp = [-INF] + [INF] * n
dfs(0, -1)
for a in ans:
    print(a)
n,q = int(input().split())
a = []
b = []
for i in range(n-1):
  a1,b1=[int(i) for i in input().split()]
  a.append(a1)
  b.append(b1)
p = []
x = []
for j in range(q):
  p1,x1=[int(j) for j in input().split()]
  p.append(p1)
  x.append(x1)
c = [0]*n
for j in range(q):
  for i in range(n-1):
    if p[j] == a[i]:
      c[a[i]-1] += x[j]
      c[b[i]-1] += x[j]
      for l in range(i,n-1):
        if b[i] == a[l]:
          c[a[l]-1] += x[j]
          c[b[l]-1] += x[j]
print(c)

### FIXED CODE ###

def main():
  import sys
  input = sys.stdin.readline
  from collections import deque
  
  n,q=map(int,input().split())
  ab=[[] for _ in range(n+1)]
  for _ in range(n-1):
    a,b=map(int,input().split())
    ab[a].append(b)
    ab[b].append(a)
  ans=[0]*(n+1)
  for _ in range(q):
    p,x=map(int,input().split())
    ans[p]+=x
  
  l,parent=deque([1]),[0]*(n+1)
  parent[1]=1
  while l:
    x=l.popleft()
    for i in ab[x]:
      if parent[i]:
        continue
      l.append(i)
      ans[i]+=ans[x]
      parent[i]=1
      
  print(*ans[1:])
if __name__=='__main__':
  main()