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

n = int(input())
a = list(map(int,input().split()))
ans = []
for i in a:
    ans.append(i)
    ans = ans[::-1]
let = ""
for j in ans:
    let += str(j) + " "
print(let[:-1])

### FIXED CODE ###

n = int(input())
a = list(input().split())
ans = ' '.join(a[::-2])
if n % 2 == 0:
    ans += " " + ' '.join(a[::2])
else:
    ans += " " + ' '.join(a[1::2])
print(ans)
### BUGGY CODE ###

ans = {}

roop = input()
for k in range(roop):
    str1 = raw_input()
    str2 = raw_input()
    len1 = len(str1)
    len2 = len(str2)
    
    for i in xrange (-1, len1):
        for j in xrange(-1, len2):
            if(i == -1 or j == -1):
                ans[i, j] = 0
            else:   
                if(str1[i] == str2[j]):
                    ans[i, j] = ans[i - 1, j - 1] + 1
                else:
                    ans[i, j] = max(ans[i - 1, j], ans[i, j - 1])
    print ans[len(str1) - 1, len(str2) - 1]

### FIXED CODE ###

def LCS():
    str1 = raw_input()
    str2 = raw_input()
    
    after = [0] * (len(str2) + 1)
    
    for i in xrange(1, len(str1) + 1):
        before = after + []
        for j in xrange(1, len(str2) + 1):
             if str1[i - 1] == str2[j - 1]:
                 after[j] = before[j - 1] + 1
             elif after[j - 1] > before[j]: #this is equal to 'max(after[j - 1], before[j])'
                 after[j] = after[j - 1]
    return after[j]

n = input()
for k in xrange(n):
    print LCS()
### BUGGY CODE ###

a,b,n=map(int,input().split())
max=0
for i in range(1,n+1):
    if a%b*i%b!=0:
        ans=a*i//b -a*(i//b)
        if max<ans:
            max=ans

print(max)

### FIXED CODE ###

# a,b,n=map(int,input().split())
# max=0
# for i in range(1,n+1):
#     if a%b*i%b<i%b:
#         ans=a*i//b -a*(i//b)
#         if max<ans:
#             max=ans

# print(max)

a,b,n=map(int,input().split())
max=0

if b>n:
    x=n
    ans=(a*x)//b -a*(x//b)

else:
    x=b-1
    ans=(a*x)//b -a*(x//b)

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

import math
def main():

    N = int(input())

    d = dict()
    for i in range(1, N+1):d[i] = 0

    v = int(math.sqrt(N))
    for i in range(1, v+1):
        p = i
        while p <= N:
            d[p] += 1
            if p//i > v and p//i > i:
                d[p] += 1
            p += i
    ans = 0
    for i in range(1, N+1):
        ans += i * d[i]
    return ans

if __name__ == '__main__':
    print(main())


### FIXED CODE ###

import math
import collections
def main():

    N = int(input())
    d = dict()
    for i in range(1, N+1):
        d[i] = 0

    ans = 0
    for i in range(1, N+1):
        p = N//i
        ans += p * (p+1)//2 * i
    return ans

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

import re


def main(S=None):
    if not S:
        S = input()
    count = 0
    s_len = len(S)
    for candidate_len in range(4, s_len+1):
        for i in range(s_len):
            if i+candidate_len > s_len:
                break
            if int(S[i:i+candidate_len]) % 2019 == 0:
                count += 1
    print(count)


if __name__ == "__main__":
    # main("1817181712114")
    # main("14282668646")
    main()


### FIXED CODE ###

def main(S=None):
    if not S:
        S = input()
    r = [0]*2019
    r[0] = 1
    tmp = 0
    base = 1
    for s in S[::-1]:
        s = int(s) * base
        base *= 10
        base %= 2019
        tmp += s
        tmp %= 2019
        r[tmp] += 1
    count = 0
    for v in r:
        count += v*(v-1)//2
    print(count)
    return count


if __name__ == "__main__":
    # assert main("1817181712114") == 3
    # assert main("14282668646") == 2
    # assert main("2119") == 0
    main()
### BUGGY CODE ###

n = int(input())
s = [input() for _ in range(n)]

march = 'MARCH'

h = []
for x in s:
  if x[0] in march:
    h.append(x[0])

ans = 0
import itertools
for com in itertools.combinations(h, r=3):
  for x in com:
    if not x[0] in march:
      break
  if len(com) == len(set(com)):
    ans += 1

print(ans)


### FIXED CODE ###

n = int(input())
s = [input() for _ in range(n)]

march='MARCH'
h = []
for x in s:
  if x[0] in march:
    h.append(x[0])

d = {}
for c in march:
  d[c]=0

for x in h:
  d[x] += 1

ans=0
import itertools
for com in itertools.combinations(d.values(), r=3):
  pro=1
  for x in com:
    pro *= x
  ans+=pro

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

class BIT:
    def __init__(self, n):
        self.array = [0] * (n + 1)
        self.size = n

    def sum(self, i):
        s = 0
        tmp = i
        while tmp > 0:
            s += self.array[tmp]
            tmp -= tmp & -tmp
        return s

    def add(self, i, x):
        tmp = i + 1
        while tmp <= self.size:
            self.array[tmp] += x
            tmp += tmp & -tmp


n, q = map(int, input().split())
*C, = map(lambda x: int(x) - 1, input().split())
P = [0] * n
N = [None] * n
for i in range(n)[::-1]:
    if P[C[i]]:
        N[i] = P[C[i]]
    P[C[i]] = i
F = [0] * n
B = BIT(n)
for i in range(n):
    if F[C[i]] == 0:
        B.add(i, 1)
        F[C[i]] = 1
XY = [tuple(map(int, input().split())) for j in range(q)]
ids = list(range(q))
ids.sort(key=lambda j: XY[j][0])
a = 0
lst = [0] * q
for j in ids:
    x, y = XY[j]
    for i in range(a, x - 1):
        if N[i]:
            B.add(N[i], 1)
    a = x - 1
    lst[j] = B.sum(y) - B.sum(x - 1)
print(*lst, sep="\n")


### FIXED CODE ###

import sys
input = sys.stdin.readline


class BIT:
    def __init__(self, n):
        self.array = [0] * (n + 1)
        self.size = n

    def sum(self, i):
        s = 0
        tmp = i
        while tmp > 0:
            s += self.array[tmp]
            tmp -= tmp & -tmp
        return s

    def add(self, i, x):
        tmp = i + 1
        while tmp <= self.size:
            self.array[tmp] += x
            tmp += tmp & -tmp


def main():
    n, q = map(int, input().split())
    *C, = map(lambda x: int(x) - 1, input().split())
    P = [0] * n
    N = [None] * n
    for i in range(n)[::-1]:
        if P[C[i]]:
            N[i] = P[C[i]]
        P[C[i]] = i
    F = [0] * n
    B = BIT(n)
    for i in range(n):
        if F[C[i]] == 0:
            B.add(i, 1)
            F[C[i]] = 1
    XY = [tuple(map(int, input().split())) for j in range(q)]
    ids = list(range(q))
    ids.sort(key=lambda j: XY[j][0])
    a = 0
    lst = [0] * q
    for j in ids:
        x, y = XY[j]
        for i in range(a, x - 1):
            if N[i]:
                B.add(N[i], 1)
        a = x - 1
        lst[j] = B.sum(y) - B.sum(x - 1)
    print(*lst, sep="\n")


main()
### BUGGY CODE ###

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

ws = []
vs = []

for i in range(n):
  a, b = map(int, input().split())
  ws.append(a)
  vs.append(b)

dp = [0] * (w + 1)

for i in range(n):
  for j in reversed(range(w + 1)):
    if j + ws[i] <= w:
      dp[j + ws[i]] = max(dp[j + ws[i]], dp[j] + vs[i])
      
print(dp[w])

### FIXED CODE ###

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

ws = [0] * n
vs = [0] * n

for i in range(n):
  a, b = map(int, input().split())
  ws[i] = a
  vs[i] = b
  
dp = [0] * (w + 1)

for i in range(n):
  for j in range(w, -1, -1):
    if j + ws[i] <= w:
      dp[j + ws[i]] = max(dp[j + ws[i]], dp[j] + vs[i])
      
print(dp[w])
### BUGGY CODE ###

N, K = map(int, input().split())
S = []

for i in range(K):
  s = list(map(int, input().split()))
  S.append(s)
  
DP = [0]*N
DP[0] = 1

#print(DP)

for i in range(1,N):
  T = 0
  for s in S:
    l = max(0,i-s[1])
    r = max(0,i-s[0]+1)
    T += sum(DP[l:r])
  DP[i] = T
  #print(DP)
  
print(DP[-1]%998244353)

### FIXED CODE ###

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

L = []
R = []

for _ in range(K):
  l, r = map(int, input().split())
  L.append(l)
  R.append(r)
  
dp = [0]*(N+5)
dp[1] = 1

for i in range(2, N+1):
  dp[i] = dp[i-1]
  for j in range(K):
    if i-L[j] >= 0:
      dp[i] += dp[i-L[j]]
    if i-R[j]-1 >= 0:
      dp[i] -= dp[i-R[j]-1]
    dp[i] %= 998244353
    
print((dp[N]-dp[N-1])%998244353)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = 0
while len(A) > 0:
  ans += A[1]
  A = A[2:-1]
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = 0
for i in range(1, 2*N, 2):
  ans += A[i]
print(ans)
### BUGGY CODE ###

from heapq import heapify, heappop, heappush

def dijkstra(start,node,edge):
    d = [2*10**5] * node
    m = [0]*node
    d[start] = 0
    q = [0]
    heapify(q)
    
    while(len(q) != 0):
      i = heappop(q)
      for j in edge[i]:
        if(d[j] > d[i]+1):
          d[j] = d[i] + 1
          heappush(q, j)
          m[j] = i+1
    return m

def main():
    N,M = map(int, input().split())
    
    E = [[] for _ in [0]*N]
    for i in range(M):
      a,b = (int(x) for x in input().split())
      E[a-1].append(b-1)
      E[b-1].append(a-1)

    m = dijkstra(0, N, E)
    print("Yes")
    # for i in range(1,N):
    #   print(m[i]+1)
    print("\n".join(map(str, m[1:])))

if __name__ == '__main__':
    main()


### FIXED CODE ###

from heapq import heapify, heappop, heappush

def dijkstra(start,node,edge):
    d = [2*10**5] * node
    m = [0]*node
    d[start] = 0
    q = [(0,0)]
    heapify(q)
    
    while(len(q) != 0):
      ci, i = heappop(q)
      di = d[i]
      for j in edge[i]:
        if(d[j] > di+1):
          d[j] = di + 1
          heappush(q, (di+1,j))
          m[j] = i+1
    return m

def main():
    N,M = map(int, input().split())
    
    E = [[] for _ in [0]*N]
    for i in range(M):
      a,b = (int(x) for x in input().split())
      E[a-1].append(b-1)
      E[b-1].append(a-1)

    m = dijkstra(0, N, E)
    print("Yes")
    print("\n".join(map(str, m[1:])))

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

import numpy as np
s=list(input())
n=len(s)
dp=np.zeros((n+1,13),np.int64)
mod=pow(10,9)+7
if s[-1]=='?':
  dp[1][:10]=1
else:
  dp[1][int(s[-1])]=1
for i in range(2,n+1):
  if s[-i]=='?':
    for j in range(10):
      if (j*pow(10,i-1))%13==0:
        dp[i]+=dp[i-1]
      else:
        dp[i][(j*pow(10,i-1))%13:]+=dp[i-1][:-(j*pow(10,i-1))%13]
        dp[i][:(j*pow(10,i-1))%13]+=dp[i-1][-(j*pow(10,i-1))%13:]
  else:
    j=int(s[-i])
    if (j*pow(10,i-1))%13==0:
      dp[i]+=dp[i-1]
    else:
      dp[i][(j*pow(10,i-1))%13:]+=dp[i-1][:-(j*pow(10,i-1))%13]
      dp[i][:(j*pow(10,i-1))%13]+=dp[i-1][-(j*pow(10,i-1))%13:]
  dp[i]%=mod
print(dp[n][5])
#print(dp)

### FIXED CODE ###

def main():
  s=list(input())
  n=len(s)
  dp=[0]*13
  mod=pow(10,9)+7
  if s[-1]=='?':
    dp=[1]*10+[0]*3
  else:
    dp[int(s[-1])]=1
  p_dp=[0]*13
  for i in range(2,n+1):
    if s[-i]=='?':
      for j in range(10):
        a=(j*pow(10,i-1,13))%13
        for k in range(13):
          p_dp[(a+k)%13]+=dp[k]
    else:
      j=int(s[-i])
      a=(j*pow(10,i-1,13))%13
      for k in range(13):
        p_dp[(a+k)%13]+=dp[k]
    
    for k in range(13):
      p_dp[k]%=mod
    dp=[k for k in p_dp]
    p_dp=[0]*13
  print(dp[5])

if __name__=='__main__':
  #import datetime
  #print(datetime.datetime.now())
  main()
  #print(datetime.datetime.now())
### BUGGY CODE ###

from functools import lru_cache
from heapq import heappop, heappush
import sys
input = sys.stdin.readline
H, W, K = map(int, input().split())
x1, y1, x2, y2 = map(lambda x: int(x)-1, input().split())
S = [input()[:-1] for _ in [0]*H]

dirs = [(-1, 0), (0, -1), (0, 1), (1, 0)]

@lru_cache(None)
def f(x, y):
    return abs(x-x2)+abs(y-y2)

INF = 1<<30
D = [[INF]*W for _ in [0]*H]

q = []
heappush(q, (f(x1, x2), 0, x1, y1))
while q:
    h, d, x, y = heappop(q)
    if d >= D[x][y]:
        continue
    D[x][y] = d

    for sgn in (1, -1):   
        for dx in range(1, K+1):
            _x = x+dx*sgn
            if _x < 0 or _x >= H or S[_x][y] == '@':
                break
            if d+1 >= D[_x][y]:
                continue
            heappush(q, (d+f(_x, y), d+1, _x, y))

        for dy in range(1, K+1):
            _y = y+dy*sgn
            if _y < 0 or _y >= W or S[x][_y] == '@':
                break
            if d+1 >= D[x][_y]:
                continue
            heappush(q, (d+f(x, _y), d+1, x, _y))

ans = D[x2][y2]
print(-1 if ans == INF else ans)

### FIXED CODE ###

from heapq import heappop, heappush
import sys
input = sys.stdin.readline
H, W, K = map(int, input().split())
x1, y1, x2, y2 = map(lambda x: int(x)-1, input().split())
S = [input()[:-1] for _ in [0]*H]

def geth(x, y, z):
    return (x*W+y)*4+z

def push(x, y, z, d):
    h = geth(x, y, z)
    if D[h] <= d:
        return
    D[h] = d
    heappush(q, (d, h))

INF = 10**10
MAX = H*W*4
D = [INF]*MAX
dirs = [(-1, 0), (0, -1), (1, 0), (0, 1)]

q = []
for z in range(4):
    heappush(q, (0, geth(x1, y1, z)))

while q:
    d, h = heappop(q)
    z = h % 4
    x, y = divmod((h//4), W)

    if d > D[h]:
        continue
    D[h] = d

    for _z, (dx, dy) in enumerate(dirs):
        if _z == z:
            _x, _y = x+dx, y+dy
            if 0 <= _x < H and 0 <= _y < W and S[_x][_y] == '.':
                push(_x, _y, z, d+1)
        else:
            _h = geth(x, y, _z)
            _d = (d+K-1)//K*K
            push(x, y, _z, _d)

g = geth(x2, y2, 0)
ans = min(D[g:g+4])
if ans == INF:
    print(-1)
else:
    ans = (ans-1+K)//K
    print(ans)
### BUGGY CODE ###

S=input()
N=len(S)
#dp?
ans=0
for l in range(N-4):
    r=l+4
    on=False
    while r<N:
        X=int(S[l:r+1])
        if int(X)%(2019)==0:
            ans+=1
            if not on:
                add=r-l+1
                on=True
        if on:
            r+=add
        else:
            r+=1
print(ans)

### FIXED CODE ###

S=input()
N=len(S)
R=[0]*(N+1)
mul=1
for i in range(1,N+1):
    R[-(i+1)]=(((int(S[-i])*mul))%(2019)+R[-i])%2019
    mul*=10
    mul%=2019
#print(R)
L=[0]*2019
for r in R:
    L[r]+=1
ans=0
for l in L:
    if l>=2:
        ans+=l*(l-1)//2
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
check = 0
for i in set(a):
  if n%2 == 1:
    if i == 0 and a.count(i) == 1:
      pass
    elif i%2 == 0 and a.count(i) == 2:
      pass
    else:
      print(0)
      exit()
  else:
    if i%2 == 1 and a.count(i) == 2:
      pass
    else:
      print(0)
      exit()

print(2**(n//2))

### FIXED CODE ###

m = 10**9+7
n = int(input())
a = list(map(int, input().split()))
check = True
if n%2 == 0:
    if 0 in a or len(set(a)) != n//2:
      check = False
else:
    if len([0 for i in a if i==0]) != 1 or len(set(a)) != n//2+1:
      check = False
      
if check:
  print(2**(n//2)%m)
else:
  print(0)
### BUGGY CODE ###

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

# 入力された文字列
string = input()

# 最大処理数。100000以下なら文字列長。
max = min(len(string), 100000)

raw_length = len(string)
# 削除した文字数
del_count = 0

# 削除があった場合True
del_flg = True

# 削除文字がなくなるまでループする
while del_flg:
    del_flg = False
    target = ['01', '11']
    before_length = len(string)
    string = string.replace('01', '')
    string = string.replace('10', '')
    after_length = len(string)
    
    if before_length != after_length:
        del_flg = True

new_length = len(string)
del_count = (raw_length - new_length)

print(del_count)

### FIXED CODE ###

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

string = input()

red_count  = string.count('0')
blue_count = string.count('1')

print(min(red_count, blue_count) * 2)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
MOD = 1000000007
SUM = 0
for i in range(N-1):
    j=i+1
    for j in range(i+1,N):
        SUM += A[i] * A[j] % MOD
print(SUM % MOD)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
MOD = 1000000007
S = sum(A) % MOD
ans = 0

for x in A:
    S -= x
    S %= MOD
    ans += S * x
    ans %= MOD
ans %= MOD
print(ans)
### BUGGY CODE ###

# coding: utf-8
# Your code here!

n,a,b = input().rstrip().split(' ')

n = int(n)
a = int(a)
b = int(b)

x =  [a,b]
count = 0
ti = 1

for d in range(1,n+1):
    if d in x:
        ti = (ti*(n-d+1))/d
        continue
        
    ti = (int((ti*(n-d+1))/d))%(10**9+7)
    #print(ti)
   
    count +=  ti
    count = count%(10**9+7)
   
count = count%(10**9+7)
print(count)

### FIXED CODE ###

# coding: utf-8
# Your code here!
mo = 10**9+7

def C(n,a):
  d = 1
  u = 1
  for i in range(n-a+1,n+1):
    d *= i
    d %= mo
  for j in range(1,a+1):
    u *= j
    u %= mo
  return d*(pow(u,mo-2,mo))

n,a,b = map(int,input().split())
p = pow(2,n,mo) - 1

print((p-C(n,a)-C(n,b))%mo)
### BUGGY CODE ###

import numpy as np

N = int(input())
x_list = np.array(sorted(list(map(int, input().split())), reverse=True))

count = 0
for i, xi in enumerate(x_list):
  if np.sum(xi%x_list==0) == 1:
      count += 1
print(count)

### FIXED CODE ###

N = int(input())
a_list = sorted(list(map(int, input().split())))
a_max = a_list[-1]

count = [0] * (a_max+1)

for a in a_list:
  for j in range(a, a_max+1, a):
    count[j] += 1
  
ans = 0
for a in a_list:
  if count[a] == 1:
    ans += 1
print(ans)
### BUGGY CODE ###


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

nowlen = N // 2
flag = False
while True:

    if nowlen == 0:
        break

    dic = {}

    for i in range(N - nowlen + 1):

        if S[i:i+nowlen] not in dic:
            dic[S[i:i+nowlen]] = i

        elif i - dic[S[i:i+nowlen]] >= nowlen:
            flag = True
            break

    if flag:
        break

    
    nowlen -= 1



print (nowlen)
        


### FIXED CODE ###


N = int(input())

S = input()
CS = S

ans = 0

for i in range(N):

    now = 0
    for j in range(N):

        if S[j] == CS[j]:
            now += 1
        else:
            ans = max(ans, min(i,now) )
            now = 0

    ans = max( ans , min(i,now) )

    CS = " "+CS

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

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

dp = [10 ** 9] * n
dp[0] = 0

for i in range(1, n):
    k_max = min(i, k)
    for j in range(1, k_max+1):
        dp[i] = min(dp[i], abs(h[i] - h[i-j]) + dp[i-j])
print(dp[n-1])

### FIXED CODE ###

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

dp = [10 ** 9] * n
dp[0] = 0

for i in range(1, n):
    k_max = min(i, k)
    for j in range(1, k_max+1):
        dp[i] = min(dp[i], abs(h[i] - h[i-j]) + dp[i-j])
print(dp[n-1])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10000000)
n,k= map(int,input().split())
mxScore = set()
items= []
for i in range(n):
    w,v = map(int,input().split())
    items.append([w,v])
def factory(item,weight,value):
    if item==n or weight==k:
        mxScore.add(value)
    else:
        w, v = items[item]
        factory(item + 1,weight, value)
        if weight+w<=k:
            factory(item+1,weight+w,value+v)
factory(0,0,0)
print(max(mxScore))

### FIXED CODE ###

n,k = map(int,input().split())
mx = 100000
dp = [[k+1 for _ in range(mx+1)]for _ in range(n+1)]
dp[0][0]=0
for i in range(1,n+1):
    dp[i][0]= 0
    w,v = map(int,input().split())
    for j in range(v):
        dp[i][j]= dp[i-1][j]
    for j in range(v,mx+1):
        next = w+dp[i-1][j-v]
        if next<=k:
            dp[i][j]= min(next,dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
for i in range(mx,-1,-1):
    if dp[n][i]<=k:
        print(i)
        break
### BUGGY CODE ###

from sys import stdin
N,Q=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
data=[]
for i in range(Q):
    data.append([int(x) for x in stdin.readline().rstrip().split()])
for j in data:
    print(S[j[0]-1:j[1]].count("AC"))

### FIXED CODE ###

from sys import stdin
N,Q=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
acc=[0]*N
cnt=0
flag=0
for index,i in enumerate(list(S)):
    if i == "C" and flag == 1:
        cnt+=1
        flag=0
    if i != "C":
        flag=0
    if i == "A":
        flag=1
    acc[index]=cnt
for j in range(Q):
    n1,n2=[int(x) for x in stdin.readline().rstrip().split()]
    print(acc[n2-1]-acc[n1-1])
### BUGGY CODE ###

import math
N= int(input())
c=list(str(input()))
#N=4
#c=['W', 'W', 'R', 'R']
#c.reverse()
#print(c)


num=0
for i in reversed(range(N)):
    if c[i]=='R' :
        for u in (range(i)):
            if c[u]=='W':
                c[u]='y'
                c[i]='W'
                num+=1
                break
            
#print(c)
print(num)

### FIXED CODE ###

N= int(input())
c=list(str(input()))
#N=4
#c=['W', 'W', 'R', 'R']
#c.reverse()
#print(c)

t1=t2=True

n1=0
n2=0
num=0
while t1:
    t2=True
    if not 0<=N-1-n1<=N-1:
        t1=False
    if c[N-1-n1]=='W':
        n1+=1
        continue
    else:
        while t2:
            if c[n2]=='W':
                if n2<N-1-n1:
                    c[N-1-n1]='W'
                    c[n2]='R'
                    num+=1
                    t2=False
                    continue
                else:
                    t1=False 
            n2+=1
            if not 0<=n2<=N-1:
                t1=False
                t2=False
print(num)
### BUGGY CODE ###

inp = input().split(" ")
N = int(inp[0])
K = int(inp[1])

arr = {}
keys = []

def bin_insert(arr, n, lo, hi):
	if lo == hi:
		return arr[:lo] + [n] + arr[lo:]
	mid = (hi+lo) // 2
	if n > arr[mid]:
		return bin_insert(arr, n, mid+1, hi)
	else:
		return bin_insert(arr, n, lo, mid)
	

for i in range(N):
	inp = input().split(" ")
	a = int(inp[0])
	b = int(inp[1])
	try:
		arr[a] += b
	except KeyError:
		arr[a] = b
		keys = bin_insert(keys, a, 0, len(keys))

for i in keys:
	K -= arr[i]
	if K <= 0:
		print(i)
		break

### FIXED CODE ###

nk = input().split(' ')
n = int(nk[0])
k = int(nk[1])

arr = []

for i in range(0, n):
	ab = input().split(' ')
	arr.append((int(ab[0]), int(ab[1])))

arr = sorted(arr)

pos = 0
while True:
	if k > arr[pos][1]:
		k -= arr[pos][1]
	else:
		print(arr[pos][0])
		break
	pos += 1
### BUGGY CODE ###

import sys
import itertools
input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def dfs(N, L, s):
    depth = [-1] * N

    stack = [(0, s)]
    while stack:
        d, p = stack.pop()
        depth[p] = d

        for q in L[p]:
            if depth[q] != -1:
                continue
            stack.append((d + 1, q))
    return depth

    
def main():
    N, u, v = read_values()
    u -= 1
    v -= 1
    L = [set() for _ in range(N)]
    for _ in range(N - 1):
        A, B = read_values()
        A -= 1
        B -= 1
        L[A].add(B)
        L[B].add(A)
    
    depth_A = dfs(N, L, v)

    res = 0
    stack = [(0, u)]
    while stack:
        d, p = stack.pop()
        if d == depth_A[p]:
            res = max(res, d)
            continue

        for q in L[p]:
            if depth_A[q] == d:
                res = max(res, d)
                continue
            
            stack.append((d + 1, q))
    
    print(res)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N, u, v = read_values()
    u -= 1
    v -= 1
    F = [set() for _ in range(N)]
    for _ in range(N - 1):
        a, b = read_index()
        F[a].add(b)
        F[b].add(a)

    D = [-1] * N
    S = deque()
    S.append((0, v))
    D[v] = 0
    while S:
        c, p = S.popleft()
        for q in F[p]:
            if D[q] != -1:
                continue
            D[q] = c + 1
            S.append((c + 1, q))

    E = [-1] * N
    S.append((0, u))
    E[u] = 0
    while S:
        c, p = S.popleft()
        for q in F[p]:
            if E[q] != -1  or D[q] < c + 1:
                continue
            E[q] = c + 1
            S.append((c + 1, q))
    
    res = 0
    for i in range(N):
        if E[i] < 0:
            continue
        res = max(res, D[i])
    print(res - 1)


if __name__ == "__main__":
    main()