Harryxun/stf_run huggingface dataset:
import sys
sys.setrecursionlimit(10**5)

N,Q=map(int,input().split())
tree=[[] for i in range(N)]

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

point=[0]*N

def search(p,add):
  if p>=N:
    return
  else:
    point[p]=point[p]+add
    for j in range(len(tree[p])):
      search(tree[p][j],add)

for i in range(Q):
  p,x=map(int,input().split())
  p=p-1
  search(p,x)
  
print(*point)


### FIXED CODE ###

N,Q=map(int,input().split())
tree={}
for i in range(N-1):
  a,b=map(int,input().split())
  if (a-1) in tree:
    tree[a-1].append(b-1)
  else:
    tree[a-1]=[b-1]
  if (b-1) in tree:
    tree[b-1].append(a-1)
  else:
    tree[b-1]=[a-1]

point=[0]*N

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

ans=[0]*N
stack=[]
stack.append([0,0,-1])
while len(stack)>0:
  nodes=stack.pop()
  node=nodes[0]
  sump=nodes[1]
  parent=nodes[2]
  sump=sump+point[node]
  ans[node]=sump
  if node in tree:
      childs=tree[node]
      for child in childs:
        if child!=parent:
          stack.append([child,sump,node])

print(*ans)
#B
a = int(input())
b = int(input())
if b == 1:
    print(0)
elif a >= b:
    print(1)
else:
    print((b-a)//a + 2)

### FIXED CODE ###

#B
import math
a,b = map(int,input().split())

k = math.ceil((b-1)/(a-1))

if b == 1:
    print(0)
elif a == b:
    print(1)
else:
    print(k)
[a,op,b]=list(input().split())
siki=a+op+b
	print(eval(siki))

### FIXED CODE ###

[a,op,b]=list(input().split())
siki=a+op+b
print(eval(siki))
s = input() #sys.stdin.readlineは最後が改行
n=len(s)
ch = 0
ans = 0
left=0
right=n-1
while left!=right:
    if s[left] == s[right]:
        left+=1
        right-=1
    else:
        if s[left] == 'x':
            ans+=1
            left+=1
        elif s[right] =='x':
            ans+=1
            right-=1
        else:
            print(-1)
            exit()
print(ans)



### FIXED CODE ###

s = input() #sys.stdin.readlineは最後が改行
n=len(s)
ch = 0
ans = 0
left=0
right=n-1
while left<right:
    if s[left] == s[right]:
        left+=1
        right-=1
    else:
        if s[left] == 'x':
            ans+=1
            left+=1
        elif s[right] =='x':
            ans+=1
            right-=1
        else:
            print(-1)
            exit()
print(ans)
N = int(input())
L = [int(i) for i in input().split()]
M = max(L)
A = min(L)
Z_L = list()
for i in range(A, M):
  ZZ = 0
  for j in range(N):
    Z =  pow(L[j] - i, 2)
    ZZ += Z
  Z_L.append(ZZ)
print(min(Z_L))

### FIXED CODE ###

N = int(input())
L = [int(i) for i in input().split()]
M = max(L)
A = min(L)
Z_L = list()
for i in range(A, M + 1):
  ZZ = 0
  for j in range(N):
    Z =  pow(L[j] - i, 2)
    ZZ += Z
  Z_L.append(ZZ)
print(min(Z_L))
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, K = map(int, input().split())
S = list(input())
S = [int(i) for i in S]

L = [0]
R = [0]

for i in range(N):
	if S[i] == 0:
		if i == N - 1:
			L.append(i + 1)
		elif S[i + 1] == 1:
			L.append(i + 1)
	if S[N - i -1] == 0:
		if i == N - 1:
			R.append(i + 1)
		elif S[N - i -2] == 1:
			R.append(i + 1)

ans = 0
M = len(L) - K

if M <= 0:
	ans = N
	
for i in range(M):
	tmp = N - L[i] - R[M - i - 1]
	if tmp > ans:
		ans = tmp

print(ans)


### FIXED CODE ###

#import sys
#input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, K = map(int, input().split())
S = list(input())
S = [int(i) for i in S]

L = [0]
R = [0]

for i in range(N):
	if S[i] == 0:
		if i == N - 1:
			L.append(i + 1)
		elif S[i + 1] == 1:
			L.append(i + 1)
	if S[N - i -1] == 0:
		if i == N - 1:
			R.append(i + 1)
		elif S[N - i -2] == 1:
			R.append(i + 1)

ans = 0
M = len(L) - K

if M <= 0:
	ans = N
	
for i in range(M):
	tmp = N - L[i] - R[M - i - 1]
	if tmp > ans:
		ans = tmp

print(ans)
import string


def count_changes(s, k, pool, prev=None):
    if k == 0:
        return 0, None, None
    t = s * k
    count = 0
    i = 0
    for cur in t:
        if cur == prev:
            count += 1
            prev = pool[i]
            i = (i + 1) % length
        else:
            prev = cur
    return count, i, prev


if __name__ == '__main__':
    s = input()
    k = int(input())
    s_set = set(s)
    if len(s) == len(s_set):
        return 0
    pool = list(set(string.ascii_lowercase) - s_set)
    length = len(pool)
    if k <= 2:
        print(count_changes(s, k, pool)[0])
    else:
        base_count, i, prev = count_changes(s, 3, pool)
        d, rest = divmod(k, 3)
        print(base_count * d + count_changes(s, rest, pool, prev)[0])

### FIXED CODE ###

def count_changes(s, k, prev=None):
    count = 0
    for _ in range(k):
        for cur in s:
            if cur == prev:
                count += 1
                prev = None
            else:
                prev = cur
    return count, prev


if __name__ == '__main__':
    s = input()
    k = int(input())
    if len(set(s)) == 1:
      print((len(s) * k) // 2)
      exit()
    if k <= 10 ** 8:
        print(count_changes(s, k)[0])
    else:
        base_count, prev = count_changes(s, 3)
        d, rest = divmod(k, 3)
        res = base_count * d
        if rest:
            res += count_changes(s, rest, prev)[0]
        elif s[0] == prev:
            res += (d - 1)
        print(res)
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
ls = [x+1 for x in range(N)]
candidates = [str(x) for x in ls if "7" in str(x) and "5" in str(x) and "3" in str(x))
count = 0
for _ in range len(candidates):
    candlist = list(candidates)
    ls2 = [x for x in candlist if x != "7" and x != "5"and x != "3"]
    if ls2 is False:
        count += 1

print(count)


### FIXED CODE ###

#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    ret =1 if all (s.count(c) > 0 for c in '753') else 0
    for c in '753':
        ret += dfs (s+c)
    return ret

print(dfs('0'))
n,m=map(int,input().split())
l=list(input().split() for _ in range(m))
l=sorted(l,key=lambda x:x[0])
import itertools
lll=[]
for (k,g) in itertools.groupby(l,key=lambda x:x[0]):
    lll.append(list(g))
a=0
w=0
for i in range(len(lll)):
    for j in lll[i]:
        if j[1]=="AC":
            a+=1
            w+=lll[i].index(j)
            break
print(a,w)

### FIXED CODE ###

print(chr(ord(input())+1))
#%%
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())

print(A[K - 1])

#%%
from decimal import *
getcontext().prec = 20

a, b, c = map(int, input().split())

sqrt_ab = Decimal(a).sqrt() + Decimal(b).sqrt()
sqrt_c = Decimal(c).sqrt()

if sqrt_ab < sqrt_c:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

from decimal import *
getcontext().prec = 20

a, b, c = map(int, input().split())

sqrt_ab = Decimal(a).sqrt() + Decimal(b).sqrt()
sqrt_c = Decimal(c).sqrt()

if sqrt_ab < sqrt_c:
    print('Yes')
else:
    print('No')
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

n, x, y = map(int, input().split())
ma = [[0]*n for _ in range(n)]
for i in range(n-1):
    ma[i][i+1] = 1
    ma[i+1][i] = 1

ma[x-1][y-1] = 1
ma[y-1][x-1] = 1
a = csr_matrix(ma)
b = shortest_path(a)
ans = [0]*(n-1)
for i in range(n):
  l = b[i]
  for num in l:
    if num != 0:
    	ans[int(num)-1] += 1

for i in ans:
  print(i//2)

### FIXED CODE ###

n, x, y = map(int, input().split())
ans = [0 for _ in range(n)]
for i in range(1, n+1):
    for j in range(i+1, n+1):
        ans[min(j-i, abs(i-x)+abs(j-y)+1)] += 1


for i in range(1, n):
    print(ans[i])
N,M=(int(x) for x in input().split())

if N===M:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

N,M=(int(x) for x in input().split())

if N==M:
    print('Yes')
else:
    print('No')
N,K=map(int, raw_input().split())
S=raw_input()

if "0" not in S:
	print len(S)
	quit()

L=[]
for i,x in enumerate(S):
	if i==0:
		cnt=1
	else:
		if prev==x:
			cnt+=1
		else:
			L.append(cnt)
			cnt=1
	prev=x
else:
	L.append(cnt)	


LSUM=[0]
for x in L:
	LSUM.append(LSUM[-1]+x)


#print "L :::: ",L
#print "LSUM  :::: ",LSUM

lsum_len=len(LSUM)

#print "lsum_len  :::: ",lsum_len

h=2*K+1

ans=0
if S[0]=="1":
	for l in range(0,lsum_len-h,2):
		r=l+h
		ans=max(ans, LSUM[r]-LSUM[l])
else:
	ans=max(ans, LSUM[2*K]-LSUM[0])
	for l in range(1,lsum_len-h,2):
		r=l+h
		ans=max(ans, LSUM[r]-LSUM[l])
	
	ans=max(ans, LSUM[lsum_len-1]-LSUM[lsum_len-1-2*K])
print ans
		

### FIXED CODE ###

N,K=map(int, raw_input().split())
S=raw_input()

if "0" not in S:
	print len(S)
	quit()
L=[]
if S[0]=="0": L.append(0)
for i,x in enumerate(S):
	if i==0:
		cnt=1
	else:
		if prev==x:
			cnt+=1
		else:
			L.append(cnt)
			cnt=1
	prev=x
else:
	L.append(cnt)

if S[-1]=="0": L.append(0)

LSUM=[0]
for x in L:
	LSUM.append(LSUM[-1]+x)

K=min(K,len(L)/2)

ans=0
len_lsum=len(LSUM)
for l in range(0,len_lsum,2):
	r=l+2*K+1
	if r < len_lsum:
		ans=max(ans , LSUM[r]-LSUM[l])

print ans
N = int(input())
nums = list(map(int, input().split()))

first = None
start = nums[0]
next = None

lists = nums[:]
for index, num in enumerate(lists):
    lists.pop(index)
    if start ^ num in lists:
        next = num
        first = start

# print(start, next)

if next == None:
    print("No")
else:
    while len(nums) > 1:
        if start ^ next in nums:
            nums.remove(start)
            nums.remove(next)
            next2 = start ^ next
            start = next
            next = next2
            # print(nums)
            # print(start, next)
        else:
            print("No")
            break

    if len(nums) <= 1:
        if start ^ next == first:
            print("Yes")  
        else:
            print("No")


### FIXED CODE ###

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

result = 0

for num in nums:
    result ^= num

if result == 0:
    print('Yes')
else:
    print('No')
N = input()
len_N = len(N)
N = int(N)
count = 0

for i in range(len_N):
  count += N[i]
if count%9 == 0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N = input()
len_N = len(N)
count = 0

for i in range(len_N):
  count += int(N[i])
if count%9 == 0:
  print("Yes")
else:
  print("No")
n,m=map(int,input().split())
if m==0:
    print(0,0)
    exit()
l=[]
for i in range(m):
    x,y=input().split()
    l.append([int(x),y])
l=sorted(l,key=lambda x:x[0])
ac=0
wa=0
tmp=0
t=[0]*(n+1)

for i in range(m):
    if tmp==l[i][0]:
        continue
    if l[i][1]=="WA":
        wa+=1
    elif l[i][1]=="AC":
        ac+=1
        tmp=l[i][0]
print(ac,wa)

### FIXED CODE ###

n,m=map(int,input().split())
p=[];s=[]
if m==0:
    print(0,0)
    exit()
for i in range(m):
    x,y=input().split()
    p.append(int(x))
    s.append(y)
ac=0
wa=0
t=[0]*(n+1)
wf=[0]*(n+1)
for i in range(m):
    if t[p[i]]>=1:
        continue
    elif s[i]=="WA":
        wf[p[i]]+=1
    elif s[i]=="AC":
        t[p[i]]+=1
        ac+=1
        wa+=wf[p[i]]
print(ac,wa)
while True:
    y,x = [int(i) for i in input().split()]
    if y and x == 0:
        break
    for i in range(y):
        print('#'*x)
    print()

### FIXED CODE ###

while True:
    y,x = [int(i) for i in input().split()]
    if y == 0:
        break
    for i in range(y):
        print('#'*x)
    print()
A,B,C = map(int,input().split())
if A%2==1 or B%2==1 or C%2==1:
    cnt = 0
elif A==B and A==C:
    cnt = -1
else:
    a = 0
    while A%2==0:
        A //= 2
        a += 1
    b = 0
    while B%2==0:
        B //= 2
        b += 1
    c = 0
    while C%2==0:
        C //= 2
        c += 1
    cnt = min(a,b,c)
if [a,b,c].count(cnt)<3:
    print(cnt)
else:
    print(cnt+1)

### FIXED CODE ###

A,B,C = map(int,input().split())
if A%2==1 or B%2==1 or C%2==1:
    print(0)
elif A==B and A==C:
    print(-1)
else:
    a = 0
    while A%2==0:
        A //= 2
        a += 1
    b = 0
    while B%2==0:
        B //= 2
        b += 1
    c = 0
    while C%2==0:
        C //= 2
        c += 1
    cnt = min(a,b,c)
    if [a,b,c].count(cnt)<3:
        print(cnt)
    else:
        print(cnt+1)
str = input()
max = 0
count = 0
for chr in str:
	if chr == 'A' or chr == 'C' or chr == 'G' or chr == 'T':
		count += 1
		if count > max:
        	max = count
	else:
		count = 0
print('{}'.format(max))

### FIXED CODE ###

str = input()
max = 0
count = 0
for chr in str:
    if chr == 'A' or chr == 'C' or chr == 'G' or chr == 'T':
        count += 1
        if count > max:
            max = count
    else:
        count = 0
print('{}'.format(max))
# ABC064D - Insertion
def main():
    # count shortages on both sides -> restore
    N = int(input())
    S = input().rstrip()
    l, r = i.count("("), i.count(")")
    ans = "(" * max(0, r - l) + i + ")" * max(0, l - r)
    print(ans)
    


if __name__ == "__main__":
    main()

### FIXED CODE ###

# ABC064D - Insertion
# https://www.hamayanhamayan.com/entry/2017/06/10/224823
def main():
    N = int(input())
    S = input().rstrip()
    cnt, pre = 0, 0
    for i in S:
        if i == "(":
            cnt += 1
        else:
            cnt -= 1
            if cnt < 0:
                pre = max(pre, abs(cnt))
    S = "(" * pre + S
    cnt = 0
    for i in S:
        if i == "(":
            cnt += 1
        else:
            cnt -= 1
    S += ")" * cnt
    print(S)
    


if __name__ == "__main__":
    main()
n, k = map(int,input().split())
s = input()
sento = 0
ketu = 0
tmp = '1'
zeroichi = []
cnt = 0

for i in range(n):
    if tmp == s[i]:
        cnt += 1
    else:
        zeroichi.append(cnt)
        cnt = 1
        tmp = s[i]

zeroichi.append(cnt)

if len(zeroichi)%2 == 0:
    zeroichi.append(0)

if len(zeroichi) == 1:
    zeroichi.append(0)
    zeroichi.append(0)

i = 0
ans = 0
ans_list = []
j = 0
right = 1+k*2
left = 0

while i != right:
    ans += zeroichi[i]
    i += 1

ans_list.append(ans)

while right != len(zeroichi):
    ans -= zeroichi[left]
    ans -= zeroichi[left+1]
    ans += zeroichi[right]
    ans += zeroichi[right+1]
    ans_list.append(ans)
    left += 2
    right += 2

print(max(ans_list))


### FIXED CODE ###

n, k = map(int,input().split())
s = input()
sento = 0
ketu = 0
tmp = '1'
zeroichi = []
cnt = 0

for i in range(n):
    if tmp == s[i]:
        cnt += 1
    else:
        zeroichi.append(cnt)
        cnt = 1
        tmp = s[i]

zeroichi.append(cnt)

if len(zeroichi)%2 == 0:
    zeroichi.append(0)

if len(zeroichi) == 1:
    zeroichi.append(0)
    zeroichi.append(0)

i = 0
ans = 0
ans_list = []
j = 0
right = min(1+k*2,len(zeroichi))
left = 0

while i != right:
    ans += zeroichi[i]
    i += 1

ans_list.append(ans)

while right != len(zeroichi):
    ans -= zeroichi[left]
    ans -= zeroichi[left+1]
    ans += zeroichi[right]
    ans += zeroichi[right+1]
    ans_list.append(ans)
    left += 2
    right += 2

print(max(ans_list))
s = input()

if 'RRR' in s:
  ans == 3
elif 'RR' in s:
  ans = 2
elif 'R' in s:
  ans = 1
else:
  ans = 0

print(str(ans))

### FIXED CODE ###

s = input()

if 'RRR' in s:
  print(3)
elif 'RR' in s:
  print(2)
elif 'R' in s:
  print(1)
else:
  print(0)
import bisect
from collections import deque

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

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

wq = deque(sorted(work))

paytree = deque([])

ans = 0

for day in range(M + 1):
    while len(wq) > 0 and wq[0][0] <= day:
        bisect.insort_right(paytree,wq.popleft()[1])
    if len(paytree) > 0:
        ans += paytree.pop()

print(ans)

### FIXED CODE ###

import heapq
from collections import deque

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

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

wq = deque(sorted(work))

paytree = []

ans = 0

for day in range(M + 1):
    while len(wq) > 0 and wq[0][0] <= day:
        heapq.heappush(paytree, wq.popleft()[1] * (-1))
    if len(paytree) > 0:
        ans -= heapq.heappop(paytree)

print(ans)
import numpy as np
from scipy.sparse.csgraph import floyd_warshall



n = int(input())
matrix = np.zeros((n, n))
for i in range(n-1):
    a, b, c = map(int, input().split())
    matrix[a-1][b-1] = c
    matrix[b-1][a-1] = c
min_span_matrix = floyd_warshall(matrix, directed=False,
                                 return_predecessors=False)
q, k = map(int, input().split())
for i in range(q):
    x, y = map(int, input().split())
    print(min_span_matrix[x-1][k-1] + min_span_matrix[k-1][y-1])


### FIXED CODE ###

from collections import deque
import sys
sys.setrecursionlimit(10 ** 9)


n = int(input())
query = [[] for i in range(n)]
for i in range(n-1):
    a, b, c = map(int, input().split())
    query[a-1].append((b-1, c))
    query[b-1].append((a-1, c))
q, k = map(int, input().split())
stack = deque([(k-1, 0, -1)])
dist = [0] * n
while stack:
    now, cnt, per = stack.pop()
    lis = query[now]
    dist[now] = cnt
    for nx, c in lis:
        if nx == per:
            continue
        if c != 0:
            stack.append((nx, cnt+c, now))
for i in range(q):
    x, y = map(int, input().split())
    print(dist[x-1] + dist[y-1])
n = int(input())
a = list(map(int,input().split()))
dict = {}
ans = 0

for i in range(n):
  if a[i] not in dict:
    dict[a[i]] = 1
  else:
    dict[a[i]] += 1

l = sorted(dict.items())
l += [(-1,0),(-2,0)]

for j in range(len(l)-2):
  if l[i][0]+1 == l[i+1][0] and l[i][0]+2 == l[i+2][0]:
     ans = max(ans,l[j][1]+l[j+1][1]+l[j+2][1])
  elif l[i][0]+1 == l[i+1][0] and l[i][0]+2 != l[i+2][0]:
     ans = max(ans,l[j][1]+l[j+1][1])
  elif l[i][0]+1 != l[i+1][0] and l[i][0]+2 != l[i+2][0]:
     ans = max(ans,l[j][1])
   
  
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
dict = {}
ans = 0

for i in range(n):
  if a[i] not in dict:
    dict[a[i]] = 1
  else:
    dict[a[i]] += 1

l = sorted(dict.items())
l += [(-1,0),(-2,0)]

for j in range(len(l)-2):
  if l[j][0]+1 == l[j+1][0] and l[j][0]+2 == l[j+2][0]:
     ans = max(ans,l[j][1]+l[j+1][1]+l[j+2][1])
  elif l[j][0]+1 == l[j+1][0] and l[j][0]+2 != l[j+2][0]:
     ans = max(ans,l[j][1]+l[j+1][1])
  elif l[j][0]+1 != l[j+1][0] and l[j][0]+2 != l[j+2][0]:
     ans = max(ans,l[j][1])
   
  
print(ans)
n=int(input())
    buff=set()
    for i in range(n):
        a=int(input())
        if a in buff:
            buff.remove(a)
        else:
            buff.add(a)
     
    print(len(buff))

### FIXED CODE ###

n=int(input())
buff=[]
ans=1
for i in range(n):
    buff.append(input())

a=sorted(buff)

for i in range(1,n):
    if a[i] == a[i-1]:
        a[i-1]= -1
        a[i]= -1
        if ans>0:
            ans -= 1
    else:
        ans += 1

print(ans)
n,m=map(int,input().split())
l=[[] for i in range(n)]
for i in range(m):
    p,y=input().split()
    l[int(p)-1].append(y.zfill(6)+str(i).zfill(6))
for i in range(n):
    l[i].sort()
s=[0]*m
for i in range(n):
    for j in range(len(l[i])):
        s[int(l[i][j][6:12])]=str(i+1).zfill(6)+str(j+1).zfill(6)
for i in s:
    print(i)

### FIXED CODE ###

n,m=map(int,input().split())
l=[[] for i in range(n)]
for i in range(m):
    p,y=input().split()
    l[int(p)-1].append(y.zfill(10)+str(i).zfill(6))
for i in range(n):
    l[i].sort()
s=[0]*m
for i in range(n):
    for j in range(len(l[i])):
        s[int(l[i][j][10:16])]=str(i+1).zfill(6)+str(j+1).zfill(6)
for i in s:
    print(i)
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
from typing import NamedTuple
from fractions import gcd

NN = 202020
MOD = 10**9+7
INF = float("inf")

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

def bfs(start, player):
    que = deque([(start, -1, 0)])
    while que:
        node, par, dst = que.popleft()
        # print(node, par, dst)
        if len(graph[node]) == 1:
            # print(player, node)
            dst_dict[player][node] = dst

        for nxt in graph[node]:
            if nxt == par:
                continue
            que.append((nxt, node, dst+1))


dst_dict = [{}, {}]
bfs(u, 0)
bfs(v, 1)
# print(dst_dict[0], dst_dict[1])

max_time = 0
for k in dst_dict[0]:
    if dst_dict[0][k] < dst_dict[1][k]:
        max_time = max(max_time, dst_dict[1][k]-1)

print(max_time)



### FIXED CODE ###

from collections import defaultdict, Counter, namedtuple, deque

NN = 202020
MOD = 10**9+7
INF = float("inf")

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


def bfs(start, player):
    que = deque([(start, -1, 0)])
    while que:
        node, par, dst = que.popleft()
        # print(node, par, dst)
        if len(graph[node]) == 1:
            # print(player, node)
            dst_dict[player][node] = dst

        for nxt in graph[node]:
            if nxt == par:
                continue
            que.append((nxt, node, dst+1))


dst_dict = [{}, {}]
bfs(u, 0)
bfs(v, 1)
# print(dst_dict[0], dst_dict[1])

max_time = 0
for k in dst_dict[0]:
    if dst_dict[0][k] < dst_dict[1][k]:
        max_time = max(max_time, dst_dict[1][k]-1)

print(max_time)
import math
HW = input().split()
H = int(HW[0])
W = int(HW[1])
print(math.ceil(H*W/2))


### FIXED CODE ###

K = int(input())
x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(x[K-1])
# -*- coding: utf-8 -*-
     
    #input
    import numpy as np
    [X,Y,Z,K] = list(map(int,input().split()))
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    C = list(map(int,input().split()))
     
    D = np.zeros(X*Y*Z+5)
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)
     
    #make list
    for i in range(min(K,X)):
        for j in range(min((K//(i+1))+1,Y)):
            for k in range(min(((K//(i+1))+1)//(j+1),Z)):
                    D.append(A[i]+B[j]+C[k])
    D.sort(reverse=True)
    for i in range(K):
        print(int(D[i]))

### FIXED CODE ###

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

#input
import numpy as np
[X,Y,Z,K] = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

D = []
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

#make list
for i in range(min(K,X)):
    for j in range(min((K//(i+1))+1,Y)):
        for k in range(min(((K//(i+1))+1)//(j+1),Z)):
                D.append(A[i]+B[j]+C[k])
D.sort(reverse=True)
for i in range(K):
    print(int(D[i]))
x, n = list(map(int, input().split()))
if not n:
  print(x) 
else:
  l = list(map(int, input().split()))
  dic = {} 
  for ll in l: dic[ll] = 1
  i = 1
  while true:
    if not dic.get(x-i,0):
      print(x-i)
      break
    elif not dic.get(x+i, 0):
      print(x+i) 
      break
    i+=1

### FIXED CODE ###

l = list(map(int, input().split()))
print(l.index(0) + 1)
x = input()
k = input()

if x <= k*500:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

k, x = input().split()

if int(x) <= int(k)*500:
    print("Yes")
else:
    print("No")