Harryxun/stf_run huggingface dataset:
def main():
    n1 = int(input())
    if n1 > 100000:
        return 
    li1 = [int(x) for x in input().split()]
    if len(l1) > 10**9:
        return 
    n2 = int(input())
    if n1 > 50000:
        return 
    li2 = [int(x) for x in input().split()]
    if len(l2) > 10**9:
        return
    count = 0

    for l in li2:
        if binary_search(li1, l):
            count += 1

    print(count)


def binary_search(li, x):
    if len(li) == 0:
        return False
    
    mid = len(li)//2
    
    k = li[mid]
    if k == x:
        return True
    elif k > x:
        li = li[:mid]
    else:
        li = li[mid+1:]
        
    return binary_search(li, x)

if __name__=='__main__':
    main()


### FIXED CODE ###

import array

def main():
    n1 = int(input())
    li1 = array.array('l', [int(x) for x in input().split()])
    n2 = int(input())
    li2 = array.array('l', [int(x) for x in input().split()])
    count = 0

    for l in li2:
        if binary_search(li1, l):
            count += 1

    print(count)


def binary_search(li, x):
    if len(li) == 0:
        return False
    
    mid = len(li)//2
    
    k = li[mid]
    if k == x:
        return True
    elif k > x:
        li = li[:mid]
    else:
        li = li[mid+1:]
        
    return binary_search(li, x)

if __name__=='__main__':
    main()
n,m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()

dis=[]
res=0
if n>m: 
    print(0)
else:
    for i in range(len(x)-1):
        dis[i] = x[i+1] - x[i]

    dis.sort()

    for j in range(n-1):
        res += dis[j]

    print(sum(dis) - res)

### FIXED CODE ###

n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
d = [x[i] - x[i-1] for i in range(1, m)]
d.sort()
print(sum(d[:m-n]) if m >= n else 0)
N, A ,B = map(int, input().split())
res = 0

for n in N:
  if A <= int(s) <= B for s in str(n):
    res += n
    
print(res)

### FIXED CODE ###

N, A, B = map(int, input().split())
res = 0
for i in range(N+1):
    if A <= sum([int(s) for s in str(i)]) <= B:
        res += i
print(res)
import math
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))
AA = [a//2 for a in A]
#print(AA)

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

l = 1
for i in range(len(AA)):
    l = lcm(l, AA[i])
amari = l % 2
if amari == 1:
    ans = M // l
    print((ans+1)//2)
else:
    print(0)

### FIXED CODE ###


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

def gcd(x, y):
    if x < y:
        x, y = y, x
    while x % y != 0:
        x, y = y, x % y
    return(y)

def lcm(x, y):
    ans = (x * y) // gcd(x, y)
    return(ans)
l = 1
cnt = [0 for i in range(len(A))]
for i in range(len(A)):
    a = A[i]
    l = lcm(l, a)
    count = 0
    while True:
        if a % 2 == 0:
            a //= 2
            count += 1
        else:
            cnt[i] = count
            break
count = cnt[0]
flag = True
for i in range(len(A)):
    if cnt[i] != count:
        flag = False
        break
if flag:
    l = l // 2
    ans = M // l
    print((ans+1)//2)
else:
    print(0)
a,b,c=map(int,input().split())
for i in range(1,b+1):
  if (i*a)%b==c:
    print('YES')
    break
print('NO')
a,b,c=map(int,input().split())
for i in range(b):
  if (i*a)%b==c:
    print('YES')
    break
print('NO')
提出情報

### FIXED CODE ###

a,b,c=map(int,input().split())
ans='NO'
for i in range(1,b+1):
  if (i*a)%b==c:
    ans='YES'
    break
print(ans)
# coding: utf-8
def is_unique(seq):
    return len(seq) == len(set(seq))
 
 
def main():
    n = int(input())
 
    w = []
    for i in range(n):
        w.append(input())
 
    for i in range(n-1):
        if w[i][-1] != w[i + 1][0] and not is_unique(w)::
            return 'No'
        else:
            return 'Yes'
 
if __name__ == '__main__':
    main()

### FIXED CODE ###

# coding: utf-8
 
 
def is_unique(seq):
    return len(seq) == len(set(seq))
 
 
def main():
    n = int(input())
    shiri = True
 
    w = []
    for i in range(n):
        w.append(input())
 
    for i in range(n-1):
        if w[i][-1] != w[i + 1][0]:
            shiri = False
            break
 
    if not is_unique(w):
        shiri = False
 
    if shiri:
        print('Yes')
    else:
        print('No')
 
 
if __name__ == '__main__':
    main()
n,k=map(int,input().split())
count=0
while int(m)!=0:
    int(m)= n/k
    n=int(m)
    count += 1
print(count)

### FIXED CODE ###

n,k=map(int,input().split())
count=0
while n !=0:
    n //= k
    count += 1
print(count)
h,w=map(int,input().split())
a=[]
for i in range(h):
    a.append(list(input()))
j=0
lis=[]
while j<len(a):
    if '#' not in set(a[j]):
        a.remove(a[j])
    j+=1
for k in range(len(a)):
    for l in range(w):
        if a[k][l]=='.':
            c=0
            while c<len(a):
                if a[c][l]!='.':
                    break
                if c==len(a)-1 and l not in set(lis):
                    lis.append(l)
                c+=1
ans=''
#print(lis)
tmp=0

for o in range(len(lis)):
    tmp=lis[o]
    for s in range(len(a)):
        del a[s][tmp]
for q in range(len(a)):
    for e in range(len(a[0])):
        ans+=a[q][e]
    print(ans)
    ans=''


### FIXED CODE ###

h,w=map(int,input().split())
a=[]
for i in range(h):
    a.append(list(input()))
j=0
lis=[]
l=[]
count=0
for i in range(h):
    for j in range(w):
        if a[i][j]!='.':
            break
        if j==w-1:
            l.append(i)
x=0
while x<len(l):
    del a[l[x]-count]
    count+=1 
    x+=1
#print(a)
for k in range(len(a)):
    for l in range(w):
        if a[k][l]=='.':
            c=0
            while c<len(a):
                if a[c][l]!='.':
                    break
                if c==len(a)-1 and l not in set(lis):
                    lis.append(l)
                c+=1
ans=''
#print(lis)
tmp=0
count=0
for o in range(len(lis)):
    tmp=lis[o]
    for s in range(len(a)):
        del a[s][tmp-count]
    count+=1    
for q in range(len(a)):
    for e in range(len(a[0])):
        ans+=a[q][e]
    print(ans)
    ans=''
N = int(input())
if N == 1:
  print('Hello World')
elif:
  A,B = int(input())
  print(A+B)

### FIXED CODE ###

N = int(input())
if N == 1:
  print('Hello World')
else:
  A = int(input())
  B = int(input())
  print(A+B)
N, i = list(map(int, input().split()))
print(n + 1 - i)


### FIXED CODE ###

n, i = list(map(int, input().split()))
print(n - i + 1 )
s1=input()
l=len(s1)
h=(l-1)//2
k1=s1[:h]
k2=s1[h+1:]
if k1==k2:
    a=(l-1)//2
    s3=s1[:a]
    if a%2!=0:
        h2=(a-1)//2
        j1=s3[:h2]
        j2=s3[h2+1:]
        if j1==j2:
            b=(l+3)/2
            b2=l-b+1
            s4=s1[:b2]
            h3=(b2-1)//2
            f1=s3[:h3]
            f2=s3[h3+1:]
            if f1==f2:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    else:
        h2=a/2
        j1=s3[:h2]
        j2=s3[h2+1:]
        if j1==j2:
            b=(l+3)/2
            b2=l-b+1
            s4=s1[:b2]
            h3=(b2-1)//2
            f1=s3[:h3]
            f2=s3[h3+1:]
            if f1==f2:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
else:
    print("No")

### FIXED CODE ###

s = list(input())
n = len(s)
flag = 0
for i in range(n//2):
    if s[i] != s[n-i-1]:
        flag = 1
if flag == 0:
    s2 = s[:(n-1)//2]
    n2 = len(s2)
    for i in range(n2//2):
        if s2[i] != s2[n2-i-1]:
            flag = 1
#print(n, n2, s, s2)
if flag == 0:
    if flag == 0:
        s2 = s[(n+3)//2-1:]
        n2 = len(s2)
    for i in range(n2//2):
        if s2[i] != s2[n2-i-1]:
            flag = 1
#print(s2)
if flag == 0:
    print("Yes")
else:
    print("No")
N = int(input())
S = list(map(int,input().split()))
S.sort(reverse = True)
for i in range(N):
    for i in range(2**i):
        if S[i] <= S[i+2**i]:
            print("No")
            exit()
print("Yes")

### FIXED CODE ###

N = int(input())
S = list(map(int,input().split()))
S.sort(reverse=True)
slime = [S[0]]
S[0] = -1
for i in range(N):
    slime.sort(reverse = True)
    S.sort(reverse=True)
    ai = 0
    for j in range(2**i):
        while S[ai] != -1:
            if slime[j] > S[ai]:
                slime.append(S[ai])
                S[ai] = -1
                ai += 1
                break
            ai += 1
    if len(slime) < 2**(i+1):
        print("No")
        exit()
print("Yes")
a,b,c = (int, raw_input().split())
n = [a,b,c]
x = n.sort()
print x

### FIXED CODE ###

a,b,c = map(int, raw_input().split())
n = [a,b,c]
n.sort()
for i in n:
    print i,
from math import factorial
n=int(input())
count=0
d={}
for i in range(n):
  b=list(input())
  b.sort()
  c=str(b)
  if c in d.keys():
    d[c]+=1
  else:
    d[c]=1
for i in d.values():
  if i>1:
    count+=factorial(i)/factorial(2)/factorial(i-2)
print(int(count))

### FIXED CODE ###

n=int(input())
count=0
d={}
for i in range(n):
  b=list(input())
  b.sort()
  c=str(b)
  if c in d.keys():
    d[c]+=1
  else:
    d[c]=1
for i in d.values():
  count+=i*(i-1)/2
print(int(count))
n, m = map(int, input().split())

adj = [[] for i in range(n)]

for i in range(m):
    s, t = map(int, input().split())
    adj[s].append(t)
    adj[t].append(s)

isVisited = [False] * n

CC = [None] * n

import sys
sys.setrecursionlimit(100000)

def dfs(u, group):
    isVisited[u] = True
    CC[u] = group
    for v in adj[u]:
        if not isVisited[v]:
            dfs(v, group)

def makeCC(group):
    for i in range(n):
        if not isVisited[i]:
            dfs(i, group)
            group += 1

def isConnected(v1, v2):
    if CC[v1] == CC[v2]:
        print('yes')
    else:
        print('no')


makeCC(0)


q = int(input())

for i in range(q):
    s, t = map(int, input().split())
    isConnected(s, t)

### FIXED CODE ###

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

adj = [[] for i in range(n)]

for i in range(m):
    s, t = map(int, input().split())
    adj[s].append(t)
    adj[t].append(s)

groups = [None] * n


def dfs(u, group_num):
    path = []
    path.append(u)
    groups[u] = group_num
    while path:
        u = path[-1]
        if adj[u]:
            v = adj[u].pop(0)
            if not groups[v]:
                groups[v] = group_num
                path.append(v)
        else:
            path.pop()


g_n = 1
for i in range(n):
    if not groups[i]:
        dfs(i, g_n)
        g_n += 1

def isConnected(v1, v2):
    if groups[v1] == groups[v2]:
        print('yes')
    else:
        print('no')


q = int(input())

for i in range(q):
    s, t = map(int, input().split())
    isConnected(s, t)
n=int(input())
a=int(input())
b=int(input())

if n==2:
  print(a+b)
else:
  print("Hello World")

### FIXED CODE ###

n=int(input())

if n==2:
  a=int(input())
  b=int(input())
  print(a+b)
else:
  print("Hello World")
import sys

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

if N % 2 != 0:
    if A[0] == 0:
        a = A[1:]
        j = 1
        for i in range(0, N//2 + 1, 2):
            if a[i] == a[i+1] == 2*j:
                j += 1
            else:
                print(0)
                sys.exit()
        print((2**(N//2)) % (10**9+7))
        
    else:
        print(0)
else:
    j = 1
    k = 0
    for i in range(0, N//2 + 1, 2):
        if A[k] == A[k+1] == 2*j -1:
            j += 1
            k += 2
        else:
            print(0)
            sys.exit()
    print((2**(N//2)) % (10**9+7))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = 1
if N % 2 == 0:
    if len(A) != 2*len(set(A)):
        ans = 0
else:
    if A.count(0) == 1:
        A.remove(0)
        if len(A) != 2*len(set(A)):
            ans = 0
    else:
        ans = 0
if ans == 0:
    print(0)
else:
    print((2**(N//2))%(10**9+7))
import math
import collections
n = int(input())
a = list(map(int, input().split()))
ans=0
x=[a[0]]
for i in range(1,n):
    x.append(a[i]+x[i-1])
c = collections.Counter(x)
for i in c.items():
	if i[1]>=2:
        ans+=math.factorial(i[1]-1)
print(ans)

### FIXED CODE ###

def com(x,y):
    a=1
    b=1
    y=min(y,x-y)
    for i in range(x,x-y,-1):
        a*=i
    for i in range(1,y+1):
        b*=i
    return a//b

n=int(input())
a=list(map(int,input().split()))
b=[a[0]]
for i in range(1,n):
    b.append(b[-1]+a[i])
from collections import Counter
c=Counter(b)
d=list(c.items())
ans=0
for t in d:
    if t[0]==0:
        ans+=com(t[1]+1,2)
    elif t[1]>1:
        ans+=com(t[1],2)
print(ans)
import math
n = int(input())
a = [int(i) for i in input().split()]
a = sorted(a)
flag = False
for i in range(1,n):
    if math.gcd(a[i],a[0])==1:
        flag = True
mn = 10**9
if not flag:
    for i in range(1,n):
        mn = min(mn,math.gcd(a[0],a[i]))
print(1 if flag else mn)

### FIXED CODE ###

import fractions

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

for i in range(1,n):
    if i==1:
        ko = fractions.gcd(a[1],a[0])
    else:
        ko = fractions.gcd(ko,a[i])
print(ko)
n = int(input())
a = list(map(int,input().split()))
x = min(3000,gcd(a[i] for i in range(n)))
m = [0]*x

for i in range(x):
    for j in a:
        m[i] += m%j

print(max(m))


### FIXED CODE ###

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

print(sum(a)-n)
s = int(input())
if (s[:4] == 2019 and s[5] == 0 and s[6] <= 4) or (s[:4] < 2019):
    print("Heisei")
else:
    print("TBD")

### FIXED CODE ###

s = input()
 
if s <= '2019/04/30':
    print('Heisei')
else:
    print('TBD')
x = 10000
i = 1
while x:
    x = input()
    if x == 0:
        break
    print("Case {}: {}".format(i, x))
    i += 1

### FIXED CODE ###

x = 10000
i = 1
while x:
    x = input()
    if x == "0":
        break
    print("Case {}: {}".format(i, x))
    i += 1
n = int(input())
l = list(map(int ,input().split(" ")))
count = 0
while True:
  for i in range(n):
    if l[i]%2 == 0:
      l[i] = l[i]//2
    else:
      print(count)
      exit()
  count += 1

### FIXED CODE ###

print(input().count("1"))
N,L=map(int,input())
S=sorted(list(map(int,input())))
ans = ""
for x in S:
  ans += x
print(ans)

### FIXED CODE ###

N,L=map(int,input().split())
S=[input() for i in range(N)]
S.sort()
print(*S,sep="")
# -*- coding: utf-8 -*-

import sys
import math

for line in sys.stdin:
    a, b = map(int, raw_input().split())
    print math.log10(a+b)+1

### FIXED CODE ###

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

import sys

for line in sys.stdin:
    a, b = map(int, line.split())
    print len(str(a+b))
X = int(input())

for a in range(-118, 119):
  for b in range(-118, 119):
    Y = a ** 5 - b ** 5
    if Y == X:
      A = a
      B = b
      break
      
print(A, B)

### FIXED CODE ###

X = int(input())

for a in range(-500, 500):
  for b in range(-500, 500):
    Y = a ** 5 - b ** 5
    if Y == X:
      A = a
      B = b
      break
      
print(A, B)
N,K = map(int,input().split())
x = [int(i) for i in input().split()]
ans = 0

if  0 in x:
    K-=1
    x.pop(0)

if K > 0:
    ansp,ansm,anso,border = 1e8,1e8,1e8,0
    while border < N and x[border] < 0:
        border += 1
    
    if N - border >= K: ansp = x[border+K-1]
    if border >= K: ansm = -x[border-K+1]
    
    if border!=0 and border!=N-1:
        xn = sorted(x,key = lambda x: abs(x))[:K]
        if xn[-1] > 0:
            pmax,mmax,i = xn[-1],0,2
            while i <= K and xn[-i] > 0:
                i += 1
            if i <= K:  mmax = xn[-i]
            anso = pmax - 2*mmax
        else:
            mmax,i = xn[-1],2
            while i <= K and xn[-i] < 0:
                i += 1
            if i <= K:  pmax = xn[-i]
            anso = 2*pmax - mmax
    
    ans = min(ansp,ansm,anso)

print(ans)
        

### FIXED CODE ###

N,K = map(int,input().split())
x = [int(i) for i in input().split()]
ans = 1e10

for i in range(N-K+1):
    l,r = x[i],x[i+K-1]
    if l < 0 and r <= 0: temp = -l
    elif l >= 0 and r > 0:   temp = r
    else:
        if -l < r:    temp = 2*(-l) + r
        else:    temp = -l + 2*r  
    
    if ans > temp:  ans = temp

print(ans)
import collections from deque
dq = deque()
num = int(input())

for i in range(num):
    order = imput().split()

    if com[0] == 'insert':
        dq.appendleft(com[1])
    elif com[0] == 'deleteFirst':
        dq.popleft()
    elif com[0] == 'deleteLast':
        dq.pop()
    else:
        if com[1] in dq:
            dq.remove(com[1])

print(' '.join(dq))

### FIXED CODE ###

from collections import deque
import sys

dq = deque()
num = int(sys.stdin.readline())
line = sys.stdin.readlines()

for i in range(num):

    order = line[i].split()

    if order[0] == 'insert':
        dq.appendleft(order[1])
    elif order[0] == 'deleteFirst':
        dq.popleft()
    elif order[0] == 'deleteLast':
        dq.pop()
    else:
        if order[1] in dq:
            dq.remove(order[1])

print(' '.join(dq))
N=int(input())
dst = []
dst.append(input().split())

max_ = 0
for i in range(N-2):
    if dst[0][i] >= dst[0][i+1]:
        count += 1
        if count > max_:
            max_ = count
    else:
        count = 0
print(max_)

### FIXED CODE ###

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

cmax = 0
count = 0
for i in range(N-1):
    if dst[i] >= dst[i+1]:
        count += 1
        if count > cmax:
            cmax = count
    else:
        count = 0
        
print(cmax)
N,A=[int(N),int(A)]
if A >= (N%500):
  print('Yes')
else:
  print('no')


### FIXED CODE ###

N=int(input())
A=int(input())
if A >= (N%500):
  print('Yes')
else:
  print('No')
a = input()
if .join(sorted(a))=="abc":
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a = input()
if "".join(sorted(a))=="abc":
  print("Yes")
else:
  print("No")
import math
from sys import stdin, stdout

def main():
	arr = [int(x) for x in stdin.readline().split()]
	H, A = arr
    count = 0
    while H > 0:
      H -= A
      count += 1
    stdout.write(count)
    
if __name__ == "__main__":
  main()


### FIXED CODE ###

import math
from sys import stdin, stdout
 
def main():
	arr = [int(x) for x in stdin.readline().split()]
	H, A = arr
	count = 0
	while H > 0:
		H -= A
		count += 1
	stdout.write(str(count))
    
if __name__ == "__main__":
	main()
N, K = map(int, input().split())
H = map(int, input().split())
H = H[:-K]
print(sum(H))

### FIXED CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
if K != 0:
    H = H[:-K]
print(sum(H))
S,T = input().split()
ptint(T+S)

### FIXED CODE ###

S,T = input().split()
print(T+S)
N = int(input())
d = [int(input()) for i in range(N)]
sum = 0
for i in range(N):
    if i > 0:
        for j in range(i):
            sum = sum + d[i] * d[j]
print(sum)

### FIXED CODE ###

A, B = map(int, input().split())
if A - 2 * B < 0 or A-2*B == 0:
    print(0)
else:
    print(A - 2 * B)
x=int,input()

for v in range(x):
 print(case i : v)

### FIXED CODE ###

i = 1

while True:

 x=int(input())
 if x==0:
  break
 print("Case {0}: {1}".format(i,x))
 i+=1
N = int(input())
A = list(map(int,input().split()))

X1by2 = 0
for i in range(N):
  if i%2 ==0:
    X1by2 += A[i]
  else:
    X1by2 -= A[i]

X = []

X.append(X1by2)
for i in range(1,len(A)):
  X.append((A[i]-X1by2/2)*2)

print(" ".join(repr(int(e)) for e in X))


### FIXED CODE ###

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

train = N*A
taxi = B

if train>=taxi:
  print(taxi)
else:
  print(train)
X = int(input())
Y = int(input())
Z = int(input())

A = Z
B = X
C = Y

print(f"{A} {B} {C}")

### FIXED CODE ###

X,Y,Z = map(int,input().split())
print(Z ,X ,Y)
N,K = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
minTotalCostList = [0 for i in range(N)]
minTotalCostList[0] = 0
for i in range(1,N) :
	for j in range(1,K+1) :
		if j == 1 :
			minTotalCostList[i] = (abs(h[i] - h[i-j]) + minTotalCostList[i-j] )
		elif j > i or minTotalCostList[i] == 0 :
			break
		else :
			minTotalCostList[i] = min(minTotalCostList[i], (abs(h[i] - h[i-j]) + minTotalCostList[i-j] ))

print(minTotalCostList[N-1])

### FIXED CODE ###

N = int(input())
h = [int(i) for i in input().split()]
minToatalCostList = [0 for i in range(N)]

for i in range(N) :
	if i > 1 :
		minToatalCostList[i] = min( abs(h[i] - h[i-1]) + minToatalCostList[i-1], abs(h[i] - h[i-2]) + minToatalCostList[i-2] )
	elif i == 1:
		minToatalCostList[i] = abs(h[i] - h[i-1])
	else :
		minToatalCostList[i] = 0

print(minToatalCostList[N-1])
def solve(left, right):
    if right - left >= 2019:
        return 0
    l_mod = left % 2019
    r_mod = right % 2019
    if r_mod < l_mod:
        return 0
    ans = 2019
    for i in range(l_mod, r_mod + 1):
        for j in range(i + 1, r_mod + 1):
            ans = min(ans, i * j % 2019)
    return ans
 L, R = map(int, input().split())
 print(solve(L, R))


### FIXED CODE ###

L,R = map(int,input().split())
l = L
m = (L *(L + 1)) % 2019
while l < min (R, L + 2019):
  r = l + 1
  while r <= min (R, L + 2019):
  	n = (l * r) % 2019 
  	m = min(m,n)
  	r = r + 1
  l = l + 1
print(m)
n =int(input())
v =list(map(int ,input().split()))
c =list(map(int ,input().split()))
a =[]
if n ==1:
    print(0)
    
else:
    for i in range(n):
        for j in range(n):
            x =v[i] +v[j]
            y =c[i] +c[j]
            if not v[i] == v[j]:
                if not c[i] == c[j]:
                    a.append(x-y)
    print(max(a))  

### FIXED CODE ###

n =int(input())
v =list(map(int ,input().split()))
c =list(map(int ,input().split()))
ans =0
for i,j in zip(v,c):
    ans += max(0 ,i-j)
print(ans)
N,R = input(int,split())
if N <= 9:
  R -= 100*(10-R)
print(R)

### FIXED CODE ###

N,R = map(int,input().split())
if N <= 9:
  R += 100*(10-N)
print(R)
def dps(no, fno, d, hen, D, MD, P):
    D[no] = d
    P[no] = fno
    maxd = d
    for h in hen[no]:
        if h == fno:
            continue
        maxd = max(maxd, dps(h, no, d + 1, hen, D, MD, P))
    MD[no] = maxd
    return maxd


def main():
    import my_method
    N, u, v = map(int, my_method.input().split())
    hen = {}
    for i in range(N - 1):
        A, B = map(int, my_method.input().split())
        if A in hen.keys():
            hen[A].append(B)
        else:
            hen[A] = [B]
        if B in hen.keys():
            hen[B].append(A)
        else:
            hen[B] = [A]
    DEPTH = [-1 for i in range(N + 1)]
    MAX_DEPTH = [-1 for i in range(N + 1)]
    Parent = [-1 for i in range(N + 1)]
    dps(v, -1, 0, hen, DEPTH, MAX_DEPTH, Parent)
    ans = DEPTH[u]
    p = u
    for i in range((DEPTH[u] + 1) // 2 - 1):
        p = Parent[p]
        ans = max(ans, MAX_DEPTH[p])
    print(ans - 1)

if __name__ == '__main__':
    main()


### FIXED CODE ###

def dps_rec(no, fno, d, hen, D, MD, P):
    D[no] = d
    P[no] = fno
    maxd = d
    for h in hen[no]:
        if h == fno:
            continue
        maxd = max(maxd, dps_rec(h, no, d + 1, hen, D, MD, P))
    MD[no] = maxd
    return maxd

def dps_stc(no, fno, d, hen, D):
    stack = [(no, fno, d)]
    while not stack == []:
        t = stack.pop()
        D[t[0]] = t[2]
        for h in hen[t[0]]:
            if h == t[1]:
                continue
            stack.append((h, t[0], t[2] + 1))

def main():
    N, u, v = map(int, input().split())
    hen = {}
    for i in range(N - 1):
        A, B = map(int, input().split())
        if A in hen.keys():
            hen[A].append(B)
        else:
            hen[A] = [B]
        if B in hen.keys():
            hen[B].append(A)
        else:
            hen[B] = [A]
    DEPTH_A = [-1 for i in range(N + 1)]
    DEPTH_T = [-1 for i in range(N + 1)]
    dps_stc(v, -1, 0, hen, DEPTH_A)
    dps_stc(u, -1, 0, hen, DEPTH_T)
    ans = 0
    for a, t in zip(DEPTH_A, DEPTH_T):
        if a > t:
            ans = max(ans, a - 1)

    print(ans)


if __name__ == '__main__':
    main()