Harryxun/stf_run huggingface dataset:
import math
n = int(input())
a = list(map(int, input().split()))

mx = 0
for i in range(n):
    popped = a.pop(i)
    g = a[0]
    for aa in a[1:]:
        g = math.gcd(g, aa)
    a.insert(i, popped)
    mx = max(mx, g)
print(mx)

### FIXED CODE ###

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

mx = 0
gd_pos = [] # 0からiまでのgcd
gd_pos.append(a[0])
for i in range(1, n):
    gd_pos.append(fractions.gcd(gd_pos[i-1], a[i]))
gd_neg = [] # 末尾からiまでのgcd
gd_neg.append(a[-1])
a_rev = a[::-1]
for i in range(1, n):
    gd_neg.append(fractions.gcd(gd_neg[i-1], a_rev[i]))

def popped_g(i):
    if i == 0: return gd_neg[n-2]
    elif i == n-1: return gd_pos[n-2]
    else:
        return fractions.gcd(gd_pos[i-1], gd_neg[n-i-2])

ans = [popped_g(i) for i in range(n)]
print(max(ans))
n,time=(map(int,input().split()))
c=[]
t=[]
for i in range(n):
    C,T=map(int,input().split())
    c.append(C)
    t.append(T)
#print(c)
#print(t)
if min(t)>time:
    print("TLE")
else:
    p=[]
    j=0
    for i in range(len(t)):
        if t[i]>time:
            p.append(i)
            j=i
            del c[i]
    #print(c)
    if len(c)==1:
        print(c[0])
    elif len(c)==2:
        if c[0]>=c[1]:
            print(c[1])
        else:
            print(c[0])
    else:
        print(min(c))

### FIXED CODE ###

n,time=(map(int,input().split()))
c=[]
t=[]
for i in range(n):
    C,T=map(int,input().split())
    c.append(C)
    t.append(T)
#print(c)
#print(t)
if min(t)>time:
    print("TLE")
else:
    for i in range(len(t)):
        if t[i]>time:
            c[i]=max(c)


    #print(c)
    if len(c)==1:
        print(c[0])
    elif len(c)==2:
        if c[0]>=c[1]:
            print(c[1])
        else:
            print(c[0])
    else:
        print(min(c))
pi = 3.14159265359 
r = int(input()) 
area = r*r*pi 
length = 2*r*pi

print('{:.6f}'.format(area),'{:.6f}'.format(length))


### FIXED CODE ###

pi = 3.14159265359 
r = float(input()) 
area = r*r*pi 
length = 2*r*pi 

print('{:.6f}'.format(area),'{:.6f}'.format(length))
#93b
a,b,k=map(int,input().split())
ans=[]

if abs(a-b)<=k:
    for _ in range(b-a+1):
        print(a+i)
    exit()
else:
    for i in range(k):
        ans.append(a+i)
        
    for i in range(k):
        ans.append(b-k+i+1)
       
ans=set(ans)
for i in ans:
    print(i)

### FIXED CODE ###

#93b
a,b,k=map(int,input().split())
c=min(a+k,b)
for i in range(a,c):print(i)
for i in range(max(c,b-k+1),b+1):print(i)
n = int(input())
a = []
b = []
c = 0
for _ in range(n):
  a.append(int(input()))
for _ in range(n):
  b.append(int(input()))
for i in range(0,n):
  if a[i] > b[i]:
    c = c + a[i] - b[i]
  else:
    continue
    
print(c)

### FIXED CODE ###

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

for i in range(0,n):
  if a[i] > b[i]:
    c = c + a[i] - b[i]
  else:
    continue
    
print(c)
N, M=map(int, input().split())
sum = 0
for n in range(N):
 arr = list(map(int, input().split()))
 sum = sum(arr)
 print(" ".join(arr) + " " + sum)

### FIXED CODE ###

N, M=map(int, input().split())
s_row = [0 for x in range(M+1)]
for n in range(N):
 arr = list(map(int, input().split()))
 arr.append(sum(arr))
 s_row = [x+y for x,y in zip(s_row, arr)]
 print(" ".join([str(x) for x in arr]))
print(" ".join([str(x) for x in s_row]))
s = list(input())
a = (len(s) - 1)/2
b = s[:a]
c = b[::-1]
if b == c:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

s = list(input())
s_reverse = s[::-1]
a = int((len(s) - 1)/2)
b = s[:a]
c = b[::-1]
if b == c and s == s_reverse:
  print('Yes')
else:
  print('No')
from sys import stdin

n = int(stdin.readline().rstrip())
h = list(map(int, stdin.readline().rstrip().split(' ')))

if n == 1:
    print("Yes")
    exit()
for i in range(n-1, -1, -1):
    if h[i] - h[i+1] == 1:
        h[i] -= 1
    elif h[i] - h[i+1] > 1:
        print("No")
        exit()
print("Yes")

### FIXED CODE ###

from sys import stdin

n = int(stdin.readline().rstrip())
h = list(map(int, stdin.readline().rstrip().split(' ')))

if n == 1:
    print("Yes")
    exit()
for i in range(n-2, -1, -1):
    if h[i] - h[i+1] == 1:
        h[i] -= 1
    elif h[i] - h[i+1] > 1:
        print("No")
        exit()
print("Yes")
import numpy as np
N,K = map(int,input().split())
list = []
for i in range(N):
 list.append(int(input()))
list = sorted(list);
print(min(h[i+K-1] - h[i] for i in range(N-K+1)))

### FIXED CODE ###

import numpy as np
N,K = map(int,input().split())
list = []
for i in range(N):
 list.append(int(input()))
list = sorted(list);
print(min(list[i+K-1] - list[i] for i in range(N-K+1)))
a , b =input().split()
 
if a <= b:
	for i in b:
    print(a*int(b))
 
else:
	for v in a:
	print(b*int(a))

### FIXED CODE ###

a , b =input().split()
 
if a <= b:
    print(a*int(b))
else:
	print(b*int(a))
N = int(input())
import numpy as np

A = list(map(int, input().split()))
dp = np.zeros((N,N))
for i in range(N):
  tmp = [0]*(A[i]-1)+[1]+[0]*(N-A[i])
  tmp = np.array(tmp)
  dp[i] = tmp+dp[i-1]

dp = np.array(dp)
ans = []
for i in range(N):
  if i > 0 and i < N-1:
    tmp = dp[N-1] - dp[i] + dp[i-1]
    tmp = tmp*(tmp-1)/2
    tmp = tmp[tmp>0]
    ans.append(tmp.sum())
  if i == 0:
    tmp = dp[N-1] - dp[i]
    tmp = tmp*(tmp-1)/2
    tmp = tmp[tmp>0]
    ans.append(tmp.sum())
  if i == N-1:
    tmp = dp[N-2]
    tmp = tmp*(tmp-1)/2
    tmp = tmp[tmp>0]
    ans.append(tmp.sum())
for i in ans:
  print(int(i))

### FIXED CODE ###

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

from collections import defaultdict
c = defaultdict(int)
cm = set()
c2 = list()
num = 0
for i in range(N):
  c[A[i]] += 1
  cm.add(A[i])
for i in list(cm):
  num += c[i]*(c[i]-1)//2
for i in range(N):
  ans = num - c[A[i]] + 1
  c2.append(ans)

for cs in c2:
  print(cs)
from collections import defaultdict
d0 = defaultdict(int)
d1 = defaultdict(int)
N=int(input())
v=list(map(int,input().split()))
for i in range(N):
    if i%2==0:
        d0[v[i]]+=1
    else:
        d1[v[i]]+=1
D0=sorted(d0.items(), key=lambda x:x[1],reverse=True)
D1=sorted(d1.items(), key=lambda x:x[1],reverse=True)
if (D0[0][1]+D1[0][1])==len(v) and D0[0][0]==D1[0][0]:
    print(len(v)//2)
else:
    i0=0
    i1=0
    while i0<=len(D0) or i1<=len(D1):
        if D0[i0][0]!=D1[i1][0]:
            print(len(v)-D0[i0][1]-D1[i1][1])
            break
        else:
            if D0[i0][1]>D1[i1][1]:
                i1+=1
            elif D0[i0][1]<D1[i1][1]:
                i0+=1
            else:
                if (len(D0)-1-i0)>0 and (len(D1)-1-i1)>0:
                    if D[i0+1][1]>D[i1+1][1]:
                        i0+=1
                    else:
                        i1+=1
                elif (len(D0)-1-i0)==0 :
                    i1+=1
                elif (len(D1)-1-i1)==0:
                    i0+=1



### FIXED CODE ###

from collections import defaultdict
d0 = defaultdict(int)
d1 = defaultdict(int)
N=int(input())
v=list(map(int,input().split()))
for i in range(N):
    if i%2==0:
        d0[v[i]]+=1
    else:
        d1[v[i]]+=1
D0=sorted(d0.items(), key=lambda x:x[1],reverse=True)
D1=sorted(d1.items(), key=lambda x:x[1],reverse=True)
if (D0[0][1]+D1[0][1])==len(v) and D0[0][0]==D1[0][0]:
    print(len(v)//2)
else:
    i0=0
    i1=0
    while i0<=len(D0) or i1<=len(D1):
        if D0[i0][0]!=D1[i1][0]:
            print(len(v)-D0[i0][1]-D1[i1][1])
            break
        else:
            if D0[i0][1]>D1[i1][1]:
                i1+=1
            elif D0[i0][1]<D1[i1][1]:
                i0+=1
            else:
                if (len(D0)-1-i0)>0 and (len(D1)-1-i1)>0:
                    if D0[i0+1][1]>D1[i1+1][1]:
                        i0+=1
                    else:
                        i1+=1
                elif (len(D0)-1-i0)==0 :
                    i1+=1
                elif (len(D1)-1-i1)==0:
                    i0+=1
s=input()
res=0
for i in range(len(s)+1):
    for j in range(i+1,len(s)+1):
       
        if set(list(s[i:j]))|{'A','G','C','T'}=={'A','G','C','T'}:
            cnt=len(s[i:j])
        if res<cnt:
            res=cnt

print(res)

### FIXED CODE ###

s=input()

res=0
for i in range(len(s)+1):
    for j in range(i+1,len(s)+1):
        cnt=0
        for x in s[i:j]:
            if x not in ['A','G','C','T']:
                break
            cnt+=1
        if res<cnt:
            res=cnt

print(res)
res = []
for digit in range(1,16):
    if digit<=3:
        for i in range(2,11):
            res.append(10**(digit-1)*i-1)
    elif 4<=digit<=12:
        for i in range(11,(digit-2)*10):
            res.append(i*10**(digit-2)-1)
        for i in range(digit-2,11):
            res.append(i*10**(digit-1)-1)
    else:
        for i in range(11,101):
            res.append(i*10**(digit-2)-1)
for i in range(int(input())):
    print(res[i])


### FIXED CODE ###

res = []
for digit in range(1,16):
    if digit<=3:
        for i in range(2,11):
            res.append(10**(digit-1)*i-1)
    elif 4<=digit<=12:
        for i in range(11,(digit-2)*10):
            res.append(i*10**(digit-2)-1)
        for i in range(digit-2,11):
            res.append(i*10**(digit-1)-1)
    elif digit==15:
        for i in range(101,110):
            res.append(i*10**(digit-3)-1)
        for i in range(11,101):
            res.append(i*10**(digit-2)-1)
    else:
        for i in range(11,101):
            res.append(i*10**(digit-2)-1)
for i in range(int(input())):
    print(res[i])
import itertools
N=int(input())
L=list(map(int,input().split()))
data=list(set(L))
S=list(itertools.permutations(data, 2))
ans=[]
for s in S:
  p=0
  for i in range(N):
    if i%2==0:
      if s[0]==L[i]:
        p=p
      else:
        p=p+1
    else:
      if s[1]==L[i]:
        p=p
      else:
        p=p+1
  ans.append(p)
print(min(ans))
        
  

### FIXED CODE ###

import collections
N=int(input())
L=list(map(int,input().split()))
E=[i for i in L[::2]]
O=[i for i in L[1::2]]
e = collections.Counter(E).most_common()
o = collections.Counter(O).most_common()
if e[0][0] != o[0][0]:
    print(N - e[0][1] - o[0][1])
else:
    if len(e) == 1 or len(o) == 1:
        print(N // 2)
    else:
        a = N - e[1][1] - o[0][1]
        b = N - e[0][1] - o[1][1]
        print(min(a, b))
n = list(map(int, input().split()))
N = n[0]
K = n[1]

d = list(map(int, input().split()))

num = [i for i in range(1,10)]

dd = []

for i in d:
  num.remove(i)

total = 1000*min(num)
print(total)

### FIXED CODE ###

N,K=map(int,input().split())
D=list(map(int,input().split()))
def solve():
  for i in range(10*N+2):
    if i>=N:
      s=str(i)
      for j in range(len(s)):
        if int(s[j]) in D: break
      else:
        print(i)
        return 0
 
solve()
MOD = 998244353 
N = int(input())
D = [int(x) for x in input().split()]
lst = [0] * (N)
for d in D:
    lst[d] += 1
if (lst[0] == 1):
    pos0 = lst.index(0)
    if (len(set(lst[pos0+1:]))>1):
        print(0)
    else:
        ans = 1
        for i in range(N-1):
            ans *= pow(lst[i], lst[i+1], MOD)
        print(ans)
else:
    print(0)


### FIXED CODE ###

MOD = 998244353 
N = int(input())
D = [int(x) for x in input().split()]
zero = 0 
for d in D:
    zero += (d == 0)
if (D[0] != 0 or zero != 1):
    print(0)
else:
    lst = [0] * (N)
    for d in D:
        lst[d] += 1
    first0 = False
    for i in range(N):
        if (lst[i] != 0 and first0):
            print(0)
            exit()
        elif (lst[i] ==0):
            first0 = True
    ans = 1
    for i in range(N-1):
        ans *= lst[i] ** lst[i+1]
        ans %= MOD
    print(ans)
import sys
a,b,c,d = input()
pm = ['+','-']
for pm1 in PM:
    for pm2 in PM:
        for pm3 in PM:
            ans = a+pm1+b+pm2+c+pm3+d
            if eval(ans) == 7:
                print(ans+'=7')
                sys.exit()

### FIXED CODE ###

import itertools

a,b,c,d = input()
pm = ['+','-']
for pm1,pm2,pm3 in itertools.product(pm,repeat=3):
    ans = a+pm1+b+pm2+c+pm3+d
    if eval(ans) == 7:
        print(ans+'=7')
        break
dat =list(input().split())

for i in dat:
	i = int(i)

dat.sort(reverse=True)

asum = 0
bsum = 0

for i in range(len(dat)):
         asum = asum + dat[i]
		
print(asum)

### FIXED CODE ###

n = int(input())
dat = list(input().split())

dat = list(map(int,dat))

dat.sort(reverse=True)

asum = 0
bsum = 0

for i in range(n):
	if i % 2 == 0:
		asum = asum + dat[i]
	else:
		bsum = bsum + dat[i]
		
print(asum-bsum)
a,b,c=input().split()
a=int(a)
b=int(b)
if b=="+":
  print(a+b)
else:print(a-b)

### FIXED CODE ###

a,b,c=input().split()
a=int(a)
c=int(c)
if b=="+":
  print(a+c)
else:print(a-c)
n=int(input())

ans=0

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

b=a.sorted()

cnt=0
for i,v in enumerate(a):
    if i%2 != (b.index(b))%2:
        cnt+=1
print(cnt//2)

### FIXED CODE ###

n=int(input())

ans=0

a=[]
b=[]

for _ in range(n):
    x=int(input())
    a.append(x)
    b.append(x)
b.sort()

dic={}
for i,v in enumerate(b):
    dic[v]=i%2

cnt=0
for i,v in enumerate(a):
    if i%2 != dic[v]:
        cnt+=1
print(cnt//2)
N = int(input())
a = [0] + [int(input()) for _ in range(N)]
x = 1
visited = set([1])
answer = 0

while True:
  x = A[x]
  if x in visited:
    answer = -1
    break
  visited.add(x)
  answer += 1
  if x == 2:
    break
    
print(answer)


### FIXED CODE ###

N = int(input())
a = [int(input()) for i in range(N)]
now = a[0]
count = 1
c = 0
for i in range(10**6):
    if now != 2:
        count += 1
        now = a[now - 1]
    else:
        print(count)
        c = 1
        break
if c == 0:
    print(-1)
a=input().split()

a=[float(p) for p in a]

c=a*b*100
print (c//100)



### FIXED CODE ###

a=input().split()

b=int(a[0])
lst=list(a[1])

del lst[-3]

c=""
for i in lst:
    c=c+i
c=int(c)

print (int(b*c//100))
# -*- coding: utf-8 -*-

#入力
n = int(input())

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

result = 'YES'

#処理
for i in range(n):
    for j in range(n):
        if j == i:
            continue
        else:
            if A[i] == A[j]:
                result = 'NO'
                
                goto .end


label.end
#出力
print(result)

    


### FIXED CODE ###

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

#入力
S, T = map(str, input().split())
A, B = map(int, input().split())
U = str(input())

#処理
if S == U:
    A -= 1
else:
    B -= 1

#出力
print('{} {}'.format(A, B))
n = int(input())
a = input().split()
alist = set()
adic = {}
for i in a:
    if int(i) in alist:
        adic[int(i)] = adic[int(i)] + 1
    else:
        alist.add(int(i))
        adic[int(i)] = 1

q = int(input())
ans = []

for i in range(q):
    s = input().split()
    b = int(s[0])
    c = int(s[1])
    if b in alist:
        if not(c in alist):
            adic[c] = 0
            alist.add(c)
        adic[c] = adic[c] + adic[b]
        adic[b] = 0
        su = 0
        for j in adic:
            su += j * adic[j]
    ans.append(su)

print(ans)

### FIXED CODE ###

n = int(input())
a = input().split()
alist = set()
adic = {}
su = 0

for i in a:
    su += int(i)
    if int(i) in alist:
        adic[int(i)] = adic[int(i)] + 1
    else:
        alist.add(int(i))
        adic[int(i)] = 1

q = int(input())
ans = []

for i in range(q):
    s = input().split()
    b = int(s[0])
    c = int(s[1])
    if b in alist:
        if not(c in alist):
            adic[c] = 0
            alist.add(c)
        adic[c] = adic[c] + adic[b]
        su = su + (c * adic[b]) - (b * adic[b])
        adic[b] = 0

    ans.append(su)
for i in range(len(ans)):
    print(ans[i])
a,b,c = map(int,input())
if a==b:
  print(c)
elif b==c:
  print(a)
else:
  print(b)
  

### FIXED CODE ###

a,b,c = map(int,input().split())
print(a if b==c else b if a==c else c)
t=input()
a,*b,c=t
print(a+len(b)+c)

### FIXED CODE ###

t=input()
a,*b,c=t
print(a+str(len(b))+c)
S=input()
if S="ABC":
  print("ARC")
elif S="ARC":
  print("ABC")

### FIXED CODE ###

S=input()
if S=="ABC":
  print("ARC")
elif S=="ARC":
  print("ABC")
from  itertools import combinations
n,c=map(int,input().split())
d=[list(map(int,input().split())) for _ in range(c)]
c=[list(map(int,input().split())) for _ in range(n)]
a=[[0]*c for _ in range(3)]
for i in range(n):
	for j in range(n):
		a[(i+j)%3][c[i][j]-1]+=1
ans=10**9
for v in combinations(c,3):
	tmp=0
	for i in range(3):
		for j in range(30):
			tmp+=a[i][j]*c[j][v[i]]
	ans=min(ans,tmp)
print(ans)

### FIXED CODE ###

from itertools import permutations
n,C=map(int,input().split())
d=[list(map(int,input().split())) for _ in range(C)]
c=[list(map(int,input().split())) for _ in range(n)]
a=[[0]*C for _ in range(3)]
for i in range(n):
	for j in range(n):
		a[(i+j)%3][c[i][j]-1]+=1
ans=10**9
for v in permutations(range(C),3):
	tmp=0
	for i in range(3):
		for j in range(C):
			tmp+=a[i][j]*d[j][v[i]]
	ans=min(ans,tmp)
print(ans)
import numpy as np
N, X, D = map(int, input().split())

if not D:
  if not X:
    print(1)
  else:
    print(N+1)

else:
  num_dict = dict()
  ans = 0
  for i in range(N+1):
    left_num = int(i*X/D) + int(i*(i-1)/2)
    right_num = int(i*X/D) + int(i*(2*N-1-i)/2)
    judge_num = i*X%D
    if not judge_num in num_dict:
      num_dict[judge_num] = [(left_num,right_num)]
    else:
      num_dict[judge_num].append((left_num,right_num))

  for j,k in num_dict.items():
    if D < 0:
      min_num = min(k, key=lambda x:x[1])[1]
      max_num = max(k, key=lambda x:x[0])[0]
      abs_min_num = abs(min_num)
      abs_max_num = abs(max_num)
      num_lis = np.zeros((abs_max_num+abs_min_num+1))
      for l in k:
        num_lis[l[1]+abs_min_num:l[0]+abs_min_num+1] += 1
    else:
      min_num = min(k, key=lambda x:x[0])[0]
      max_num = max(k, key=lambda x:x[1])[1]
      abs_min_num = abs(min_num)
      abs_max_num = abs(max_num)
      num_lis = np.zeros((abs_max_num+abs_min_num+1))
      for m in k:
        num_lis[m[0]+abs_min_num:m[1]+abs_min_num+1] += 1
    ans += np.count_nonzero(num_lis > 0)
    
  print(ans)

### FIXED CODE ###

import numpy as np
N, X, D = map(int, input().split())

if not D:
  if not X:
    print(1)
  else:
    print(N+1)

else:
  num_dict = dict()
  ans = 0
  for i in range(N+1):
    left_num = int(i*X/D) + int(i*(i-1)/2)
    right_num = int(i*X/D) + int(i*(2*N-1-i)/2)
    judge_num = i*X%D
    if not judge_num in num_dict:
      num_dict[judge_num] = [(left_num,right_num)]
    else:
      num_dict[judge_num].append((left_num,right_num))

  for j,k in num_dict.items():
    new_k = sorted(k)
    L = new_k[0][0]
    R = new_k[0][1]
    for l in new_k:
      if l[0] <= R <= l[1]:
        R = l[1]
      elif R < l[0] and R < l[1]:
        ans += R-L+1
        L, R = l[0], l[1]
    ans += R-L+1
    
  print(ans)
treat = input()

acc = 0
hugs = 0

for i in len(treat):
	if treat[acc] = treat[len(treat) - acc]:
		acc = acc + 1
	else:
		hugs = hugs + 1
		acc = acc + 1

### FIXED CODE ###

treat = input()

acc = 0
hugs = 0

for i in range(len(treat) // 2):
	if treat[acc] == treat[len(treat) - 1 - acc]:
		acc = acc + 1
	else:
		hugs = hugs + 1
		acc = acc + 1

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


if n == 1 or w == 1: 
    ans = 1
elif n % 2 == 0 or w % 2 == 0:
    ans = int((n * w) / 2.)

else:
    ans = int((n * w) / 2.) + 1

print(ans)

### FIXED CODE ###

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


if n == 1 or w == 1: 
    ans = 1
elif n % 2 == 0 or w % 2 == 0:
    ans = int((n * w) / 2.)

else:
    ans = int((n * w) / 2.) + 1

print(ans)
s = input()
ans = False
def dfs(now, length):
  global ans
  if len(now) >= length:
    if now == s:
      ans = True
    return
  
  dfs(now + 'dream', length)
  dfs(now + 'dreamer', length)
  dfs(now + 'erase', length)
  dfs(now + 'eraser', length)

dfs('', len(s))

if ans:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

s = input()[::-1]
l = ["dream", "dreamer", "erase", "eraser"]
start = 0

for i in range(len(l)):
  l[i] = l[i][::-1]
  
def f():
  i = 0
  j = 0
  while j <= len(s):
    can = False
    for d in l:
      if s[i:i+len(d)] == d:
        i += len(d)
        can = True

    if i == len(s) and can == True:
      return 'YES'

    if can == False:
      return 'NO'
    j += 1

  return 'YES'

print(f())
a = int(input())
b = int(input())
if a<b:
    print("a<b")
elif a>b:
    print("a>b")
elif a==b:
    print("a==b")


### FIXED CODE ###

a,b = input().split()
a = int(a)
b = int(b)
if a < b:
    print("a < b")
elif a > b:
    print("a > b")
else:
    print("a == b")
import sys
from collections import Counter
m = Counter(sys.stdin.readlines().lower())
for i in 'abcdefghijklmnopqrstuvwxyz':
    print(i, ":", m[i])


### FIXED CODE ###

import sys
from collections import Counter
m = Counter(sys.stdin.read().lower())
for i in 'abcdefghijklmnopqrstuvwxyz':
    print(i, ":", m[i])
N, L = map(int, input().split())

# 元々の味
s = (N-1)*(2*L+N-1) // 2
l = [abs(s - (L+i)) for i in range(N)]
m = min(l)
print(s - (L + [l.index(m)]))

### FIXED CODE ###

N, L = map(int, input().split())
 
s = N*(2*L+N-1) // 2
l = [abs(L+i) for i in range(N)]

print(s - (L+l.index(min(l))))
A = int(input())
B = int(input())

S = (A-1)*(B-1)
print(S)

### FIXED CODE ###

A,B = (int(i) for i in input().split())

S = (A-1)*(B-1)
print(S)
def Teleport(i,P):
    if(i==K):
        return print(P)
    else:
        Teleport(i+1,T[P-1])



N,K=(int(x) for x in input().split())
T=list((int(x) for x in input().split()))

Teleport(1,T[0])



### FIXED CODE ###

S=input()

T=input()
if(S==T[:-1]):
    print("Yes")
else:
    print("No")
import sys
c = 1
for i in sys.stdin.readline() :
    if (int(i) == 0) :
        break
    else :
        print("Case " + str(c) + ":" + " " + str(i))
        c = c + 1

### FIXED CODE ###

import sys
c = 1
for i in sys.stdin.readlines() :
    if i.strip() == "0" :
        break
    else :
        print("Case " + str(c) + ":" + " " + str(i.strip()))
        c = c + 1
A,B = map(int,input().split())
if A>B:
    print('GREATER')
elif A<B:
    print('LESS')
else:
    print('EQUAL')

### FIXED CODE ###

A=int(input())
B = int(input())
if A>B:
    print('GREATER')
elif A<B:
    print('LESS')
else:
    print('EQUAL')
# 解説を見た

def solve(N, t, a, g) -> int:
    def calc_dist(init):
        dist = [-1] * N
        dist[init] = 0

        def _calc_dist(curr):
            for next_ in g[curr]:
                if dist[next_] != -1:
                    continue
                dist[next_] = dist[curr] + 1
                _calc_dist(next_)

        _calc_dist(init)
        return dist

    dist_a = calc_dist(a)
    dist_t = calc_dist(t)

    return max(dist_a[v] for v in range(N) if dist_t[v] < dist_a[v]) - 1


if __name__ == '__main__':
    N, t, a = map(int, input().split())
    t -= 1
    a -= 1

    g = tuple(set() for _ in range(N))
    for _ in range(N - 1):
        u, v = (int(x) - 1 for x in input().split())
        g[u].add(v)
        g[v].add(u)

    print(solve(N, t, a, g))

# 青木君からの距離 > 高橋君からの距離 となる頂点Xが目的地の候補
# 青木君と高橋君の共通祖先からの距離は等しいので、
# 共通祖先への距離は、 青木君 > 高橋君 となり、高橋君は必ずXに到達できる
# Xに着いた高橋君は、手前の頂点とXとを行ったり来たりする
# a-t->at-: aが一歩進んだときに高橋君に会う(-は無人のマス目)
# at: tが手前の頂点に移動したときに青木君に会う
# いずれも手前の頂点まで青木君が移動したときにゲームが終わる
# どのXを選んでも、Xの手前でゲームが終わるので、青木君から最も遠いXを選ぶのが最善
# 頂点X: 追いつめられる位置=葉


### FIXED CODE ###

# 解説を見た

def solve(N, t, a, g) -> int:
    import sys

    sys.setrecursionlimit(10 ** 7)

    def calc_dist(init):
        dist = [-1] * N
        dist[init] = 0

        def _calc_dist(curr):
            for next_ in g[curr]:
                if dist[next_] != -1:
                    continue
                dist[next_] = dist[curr] + 1
                _calc_dist(next_)

        _calc_dist(init)
        return dist

    dist_a = calc_dist(a)
    dist_t = calc_dist(t)

    return max(dist_a[v] for v in range(N) if dist_t[v] < dist_a[v]) - 1


if __name__ == '__main__':
    N, t, a = map(int, input().split())
    t -= 1
    a -= 1

    g = tuple(set() for _ in range(N))
    for _ in range(N - 1):
        u, v = (int(x) - 1 for x in input().split())
        g[u].add(v)
        g[v].add(u)

    print(solve(N, t, a, g))

# 青木君からの距離 > 高橋君からの距離 となる頂点Xが目的地の候補
# 青木君と高橋君の共通祖先からの距離は等しいので、
# 共通祖先への距離は、 青木君 > 高橋君 となり、高橋君は必ずXに到達できる
# Xに着いた高橋君は、手前の頂点とXとを行ったり来たりする
# a-t->at-: aが一歩進んだときに高橋君に会う(-は無人のマス目)
# at: tが手前の頂点に移動したときに青木君に会う
# いずれも手前の頂点まで青木君が移動したときにゲームが終わる
# どのXを選んでも、Xの手前でゲームが終わるので、青木君から最も遠いXを選ぶのが最善
# 頂点X: 追いつめられる位置=葉