Harryxun/stf_run huggingface dataset:
S = str(input())
ans = set()

def dfs(i, j):
    if int(S[i:j+1])%2019 == 0:
        ans.add((i, j))
    if j == len(S)-1:
        return

    dfs(i, j+1)
    dfs(i+1, j+1)

if len(S) < 4:
    print(0)

else:
    dfs(0, 3)
    print(len(ans))

### FIXED CODE ###

s=input()
n=len(s)
mod=2019
d=0
p=1
ml=[0]*mod
for i in range(1,n+1):
  k=int(s[-i])
  d+=p*k
  d%=mod
  ml[d]+=1
  p*=10
  p%=mod
ans=0
for i in ml:
  ans+=i*(i-1)//2
print(ans+ml[0])
N,K = map(int,input().split())
P = list(map(int,input().split()))
T = [0]*N

for i in range(N):
    P[i] = (1 + P[i])/2

for i in range(1,N):
    P[i] += P[i-1]

for i in range(K,N):
    T[i] = P[i] - P[i-K]

T = T[K:]

print(max(T))

### FIXED CODE ###

N,K = map(int,input().split())
P = list(map(int,input().split()))
T = [0]*N

for i in range(N):
    P[i] = (1 + P[i])/2

if N == K:
    print(sum(P))

else:
    for i in range(1,N):
        P[i] += P[i-1]

    for i in range(K,N):
        T[i] = P[i] - P[i-K]

    T = T[K:]

    print(max(T))
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    h, n, w <= 3500
    4*h*n*w/(h*n+n*w+h*w) = N
    n*w+h*w = (n+h)*w = k*h*n  => k = (n+h)*w/(h*n)

    4hnw/(k+1)hn=4w/(k+1) = N
    """
    N = read_int()
    for w in range(1, 3501):
        if (4*w)%N == 0:
            k = (4*w)//N-1
            for n in range(1, 3501):
                if k*n-w > 0 and (n*w)%(k*n-w) == 0:
                    h = n*w//(k*n-w)
                    if h > 0:
                        return h, n, w


if __name__ == '__main__':
    print(*solve())


### FIXED CODE ###



def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    h, n, w <= 3500
    4/N = 1/h+1/n+1/w
    1/h = 4/N-1/n-1/w = 4nw-Nw-Nn / Nnw
    """
    N = read_int()
    for w in range(1, 3501):
        for n in range(1, 3501):
            if (4*n*w-N*w-N*n) != 0 and (N*n*w)%(4*n*w-N*w-N*n) == 0:
                h = (N*n*w)//(4*n*w-N*w-N*n)
                if h > 0:
                    return h, n, w


if __name__ == '__main__':
    print(*solve())
A, B =int(input()), float(input())
print(int(A*B))

### FIXED CODE ###

from decimal import *

A, B = input().split()
print(int(Decimal(A)*Decimal(B)))
import math
def check1(N):
    n = int(math.log10(N))
    return 9*n+(N//(10**n))
def check2(N):
    n = int(math.log10(N))
    return n*(n-1)/2*81+(N//(10**n)-1)*n*9+check1(N%(10**n))
def check3(N):
    n = int(math.log10(N))
    summ = 0
    for i in range(n):
        summ += i*(i-1)/2
    return summ*729+(N//(10**n)-1)*n*(n-1)/2*81+check2(N%(10**n))
def main():
    N = int(input())
    K = int(input())
    if K == 1:
        print(int(check1(N)))
    elif K == 2:
        print(int(check2(N)))
    elif K == 3:
        print(int(check3(N)))        
main()

### FIXED CODE ###

import math
def check1(N):
    if N == 0:
        return 0
    n = int(math.log10(N))
    return 9*n+(N//(10**n))
def check2(N):
    if N == 0:
        return 0
    n = int(math.log10(N))
    return n*(n-1)/2*81+(N//(10**n)-1)*n*9+check1(N%(10**n))
def check3(N):
    if N == 0:
        return 0
    n = int(math.log10(N))
    summ = 0
    if n >= 3:
        for i in range(n):
            summ += i*(i-1)/2
    return summ*729+(N//(10**n)-1)*n*(n-1)/2*81+check2(N%(10**n))
def main():
    N = int(input())
    K = int(input())
    if K == 1:
        print(int(check1(N)))
    elif K == 2:
        print(int(check2(N)))
    elif K == 3:
        print(int(check3(N)))
        
main()
N = int(input())
colors = list(map(int, input().split()))
if len(set(colors)) == 3:
  print('Three')
else:
  print('Four')

### FIXED CODE ###

N = int(input())
colors = list(input().split())
if len(set(colors)) == 3:
    print('Three')
else:
    print('Four')
import fractions
 
n = int(input())
a = [int(value) for value in input().split(" ")]
 
from_right_gcd = []
from_left_gcd = []
 
# 左から
for index in range(a.__len__):
    if index == 0:
        from_left_gcd.append(a[index])
        continue
    from_left_gcd.append(fractions.gcd(from_left_gcd[index - 1], a[index]))
 
# 右から
for index in range(a.__len__ - 1, -1, -1):
    if index == a.__len__ - 1:
        from_right_gcd.append(a[index])
        continue
    from_right_gcd.append(fractions.gcd(from_right_gcd[a.__len__ - index - 1 - 1], a[index]))
 
maybe_answer_list = []
 
for index in range(a.__len__):
    if index == 0:
        maybe_answer_list.append(from_right_gcd[a.__len__ - 1 - 1])
        continue
    if index == a.__len__ - 1:
        maybe_answer_list.append(from_left_gcd[index - 1])
        continue
    maybe_answer_list.append(fractions.gcd(from_left_gcd[index - 1], from_right_gcd[a.__len__ - index - 1 - 1]))
 
print(max(maybe_answer_list))

### FIXED CODE ###

import fractions
# import math
from functools import reduce
 
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
 
n = int(input())
a = [int(value) for value in input().split(" ")]

from_right_gcd = []
from_left_gcd = []

# 左から
for index in range(len(a)):
    if index == 0:
        from_left_gcd.append(a[index])
        continue
    from_left_gcd.append(fractions.gcd(from_left_gcd[index - 1], a[index]))

# 右から
for index in range(len(a) - 1, -1, -1):
    if index == len(a) - 1:
        from_right_gcd.append(a[index])
        continue
    from_right_gcd.append(fractions.gcd(from_right_gcd[len(a) - index - 1 - 1], a[index]))

maybe_answer_list = []

for index in range(len(a)):
    if index == 0:
        maybe_answer_list.append(from_right_gcd[len(a) - 1 - 1])
        continue
    if index == len(a) - 1:
        maybe_answer_list.append(from_left_gcd[index - 1])
        continue
    maybe_answer_list.append(fractions.gcd(from_left_gcd[index - 1], from_right_gcd[len(a) - index - 1 - 1]))

print(max(maybe_answer_list))
#!/usr/bin/env python
# -*- conding: utf-8 -*-
import numpy as np

N, M = map(int, input().split())
A = []
B = []
for i in range(N):
    A_i, B_i = map(int, input().split())
    A.append(A_i)
    B.append(B_i)

min_value_index_list = np.argsort(A)

cnt = 0
result = 0
for i in range(N):
    cnt += B[min_value_index_list[i]]
    if M - cnt >= 0:
        result += A[min_value_index_list[i]] * B[min_value_index_list[i]]
        goal = M - cnt
    else:
        result += A[min_value_index_list[i]] * goal
        break
print(result)


### FIXED CODE ###

N,M = map(int,input().split())
li = [list(map(int,input().split())) for i in range(N)]
li=sorted(li,key=lambda x: x[0])
m_sum=0
for i in li:
	buy=min(M,i[1])
	m_sum+=i[0]*buy
	M-=buy
print(m_sum)
w,h,x,y = map(int, input().split())

if w%x == 0 and h%y == 0:
  print(w*h/2, 1)
else:
  print(w*h/2, 0)

### FIXED CODE ###

w,h,x,y = map(int, input().split())

t = w * h / 2

if x == w/2 and y == h/2:
  print(t, 1)
else:
  print(t, 0)
from itertools import *
from collections import *
h,w=map(int,input().split())
s=[[False]*w for i in range(h)]
for i in range(h):
    t=list(input())
    for j in range(w):
        
        if t[j]==".":
            s[i][j]=True
def dp(i,j):
    if s[i][j]:
        return l(i,j)+r(i,j)+d(i,j)+u(i,j)-6
    else:
        return 0
def l(i,j):
    if s[i][j]:
        if j==0:
            return 1
        else:
            return l(i,j-1)+1
    else:
        return 0
def r(i,j):
    if s[i][j]:
        if j==w-1:
            return 1
        else:
            return l(i,j+1)+1
    else:
        return 0
def d(i,j):
    if s[i][j]:
        if i==h-1:
            return 1
        else:
            return d(i+1,j)+1
    else:
        return 0
def u(i,j):
    if s[i][j]:
        if i==0:
            return 1
        else:
            return u(i-1,j)+1
    else:
        return 0
ans=0
for i in range(h):
    for j in range(w):
        if dp(i,j)>ans:
            ans=dp(i,j)
print(ans)

### FIXED CODE ###

from collections import deque

h, w = list(map(int, input().split()))

s = [list(input()) for _ in range(h)]

yo = [[0] * w for _ in range(h)]
q = deque([])
c = 0

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            q.append((i, j))
            c += 1
        
        if s[i][j] == "#" or j == w-1:
            while len(q) > 0:
                x, y = q.pop()
                yo[x][y] = c
            c = 0



m = 0

c = 0
for j in range(w):
    for i in range(h):
        if s[i][j] == ".":
            q.append((i, j))
            c += 1

        if s[i][j] == "#" or i == h-1:
            while len(q) > 0:
                x, y = q.pop()
                m = max(m, yo[x][y] + c - 1)
            c = 0
print(m)
S = input()

if len(S) == 2:
    print(S)
elif len(S) == 3:
    str_list = list(reversed(S))
    new_str = ''.join(list(reversed(org_str)))
    print(new_str)

### FIXED CODE ###

S = input()

if len(S) == 2:
    print(S)
elif len(S) == 3:
    #str_list = list(reversed(S))
    new_str = ''.join(list(reversed(S)))
    print(new_str)
n = int(input())
a = [int(input()) for i in range(n)]

for i in a[::-1]:
    print(i)


### FIXED CODE ###

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

print(' '.join(map(str, reversed(a))))
from sys import stdin
input = stdin.readline
N,T = map(int,input().split())
prices = list(map(int,input().split()))
last = 10000000000
highestTally = [prices[-1]]
for price in prices[-2:-N-1:-1]:
    highestTally.append(max(highestTally[-1],price))
highestTally.reverse()

biggestJump=0
sellingPriceForBiggestJump=0
count=0
for index,price in enumerate(prices):
    if index==N-1:
        break
    bestSellingPrice = highestTally[index+1]
    jump = bestSellingPrice-price
    if jump>biggestJump:
        biggestJump = jump
        sellingPriceForBiggestJump = bestSellingPrice
        count=1
    elif jump==biggestJump:
        if bestSellingPrice!=sellingPriceForBiggestJump:
            sellingPriceForBiggestJump = bestSellingPrice
            count+=1
if T//2>=count:
    print(count)
else:
    print(int(T//2))


### FIXED CODE ###

line = input()
s = len(line)
last = line[0]
count = 0
for letter in line:
    if letter!=last:
        last = letter
        count+=1
print(count)
import numpy as np
def main():
    [N,W]=input().split(" ")
    N=int(N)
    W=int(W)
    inputset=[]
    for i in range(N):
        [vi,wi]=input().split(" ")
        inputset.append([int(vi),int(wi)])

    graph=np.zeros([N+1,W+1])

    '''for i in range(N):
        for j in range(W+1):
            if(inputset[i][1]>j):
                graph[i+1,j]=graph[i,j]
            else:
                rest=j-inputset[i][1]
                choosevalue=graph[i,rest]+inputset[i][0]
                nonchoosevalue=graph[i,j]
                if(choosevalue>nonchoosevalue):
                    graph[i+1,j]=choosevalue
                else:
                    graph[i+1,j]=nonchoosevalue'''

    print(13)

main()

### FIXED CODE ###

def main():
    [N,W]=input().split(" ")
    N=int(N)
    W=int(W)
    inputset=[]
    for i in range(N):
        [vi,wi]=input().split(" ")
        inputset.append([int(vi),int(wi)])

    graph=[]
    for i in range(N+1):
        graph.append([])
        for j in range(W+1):
            graph[i].append(0)

    for i in range(N):
        for j in range(W+1):
            if(inputset[i][1]>j):
                graph[i+1][j]=graph[i][j]
            else:
                rest=j-inputset[i][1]
                choosevalue=graph[i][rest]+inputset[i][0]
                nonchoosevalue=graph[i][j]
                if(choosevalue>nonchoosevalue):
                    graph[i+1][j]=choosevalue
                else:
                    graph[i+1][j]=nonchoosevalue

    print(graph[N][W])

main()
SA=input()
SB=input()
SC=input()

A_rest=len(SA)
B_rest=len(SA)
C_rest=len(SA)
next='a'

while(1):
    if next=='a':
        A_rest-=1
       	if A_rest<0:
           	break
        next=SA[len(SA)-A_rest]
    elif next=='b':
        B_rest-=1
       	if B_rest<0:
           	break
        next=SB[len(SB)-B_rest]
    else:
        C_rest-=1
       	if C_rest<0:
           	break
        next=SC[len(SC)-C_rest]

if A_rest<0:
    print('A')
elif B_rest<0:
    print('B')
else:
    print('C')

### FIXED CODE ###

SA=input()
SB=input()
SC=input()

A_rest=len(SA)
B_rest=len(SB)
C_rest=len(SC)
next='a'

while(1):
    if next=='a':
       	if A_rest==0:
            print('A')
            exit()
        next=SA[len(SA)-A_rest]
        A_rest-=1
    elif next=='b':
       	if B_rest==0:
            print('B')
            exit()
        next=SB[len(SB)-B_rest]
        B_rest-=1
    else:
       	if C_rest==0:
            print('C')
            exit()
        next=SC[len(SC)-C_rest]
        C_rest-=1
n=int(input())
tmp=2
ans=0
Flag=True
while Flag:
    tmp+=1
    iterator=product(range(3),repeat=tmp)
    for idxs in iterator:
        num=''.join(map(str,idxs))
        num753=str(num).replace('0', '3').replace('1', '5').replace('2', '7')
        if '7' in num753 and '5' in num753 and '3' in num753:
            if int(num753)<=n:
                ans+=1
            else:
                Flag=False
                break
print(ans)

### FIXED CODE ###

from itertools import product
n=int(input())
tmp=2
ans=0
Flag=True
while Flag:
    tmp+=1
    iterator=product(range(3),repeat=tmp)
    for idxs in iterator:
        num=''.join(map(str,idxs))
        num753=str(num).replace('0', '3').replace('1', '5').replace('2', '7')
        if '7' in num753 and '5' in num753 and '3' in num753:
            if int(num753)<=n:
                ans+=1
            else:
                Flag=False
                break
print(ans)
n,q = map(int, input().split())

g = [[] for _ in range(n)]
for i in range(n-1):
    a,b = [int(i) for i in input().split()]
    g[a-1].append(b-1)
    g[b-1].append(a-1)

add = [0]*n
for _ in range(q):
    p,x = [int(i) for i in input().split()]
    add[p-1] += x

ans = [0]*n
 
def dfs(v,p,value): #p: parent of v
    value += add[v]
    ans[v] = value
    for c in g[v]:
        if c == p: continue
        dfs(c,v,value)

dfs(0,-1,0)
 
print(*ans)

### FIXED CODE ###

import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,q = map(int, input().split())
ABPX = list(map(int,read().split()))
AB = iter(ABPX[:n+n-2])
PX = iter(ABPX[n+n-2:])

tree = dict()
for a,b in zip(AB,AB):
  if a in tree: tree[a].add(b)
  else: tree[a] = {b}
  if b in tree: tree[b].add(a)
  else: tree[b] = {a}

opr = {i+1:0 for i in range(n)}
for p,x in zip(PX,PX):
  opr[p] += x

stack = [1]
parent = [0] * (n+1)
ans = [0]*n
while stack:
  x = stack.pop()
  ans[x-1] += opr[x]
  for y in tree[x]:
    if y == parent[x]: continue
    parent[y] = x
    stack.append(y)
    ans[y-1] += ans[x-1]

print(*ans)
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
V = []
W = []
for _ in range(n):
    v, w = LI()
    V.append(v)
    W.append(w)

q = I()
vl = []
maxL = 0
for _ in range(q):
    v, l = LI()
    maxL = max(maxL, l)
    vl.append([v,l])

m = int(math.sqrt(n))
dp = [[0]*(maxL + 1) for _ in range(m + 1)]

for i in range(1, m+1):
    for j in range(maxL+1):
        if j < W[i-1]:
            dp[i][j] = dp[i//2][j]
        else:
            dp[i][j] = max(dp[i//2][j],dp[i//2][j-W[i-1]] + V[i-1])

for i in range(q):
    v, L = vl[i]
    if v <= m:
        print(dp[v][L])
        continue
    x = v.bit_length() - m.bit_length()
    ret = 0
    for j in range(1 << x):
        weight_sum = 0
        value_sum = 0
        tmp = v
        for k in range(x):
            if j >> k & 1:
                weight_sum += W[tmp - 1]
                value_sum += V[tmp - 1]
            tmp //= 2
        if weight_sum > L:
            continue
        value_sum += dp[tmp][L - weight_sum]
        ret = max(ret, value_sum)
    print(ret)


### FIXED CODE ###

#!/usr/bin/env python3

def main():
    import sys
    def I(): return int(sys.stdin.readline())
    def LI(): return list(map(int,sys.stdin.readline().split()))

    n = I()
    V = []
    W = []

    maxL = 10**5
    m = min(n, 1 << 10)
    dp = [[0]*(maxL + 1)]
    
    for i in range(n):
        v, w = LI()
        if i <= m:
            d_ = dp[(i+1)>>1][:]
            for j in range(w, maxL+1)[::-1]:
                d_[j] = max(d_[j], d_[j - w] + v)
            dp.append(d_)
        V.append(v)
        W.append(w)
    
    q = I()
    for i in range(q):
        v, L = LI()
        if v <= m:
            print(dp[v][L])
            continue
        cnt = 0
        v_ = []
        w_ = []
        while v > m:
            v_.append(V[v-1])
            w_.append(W[v-1])
            v >>= 1
            cnt += 1
        ret = dp[v][L]
        v_tmp = [0] * (1 << cnt)
        w_tmp = [0] * (1 << cnt)
        for b in range(1, 1 << cnt):
            lsb = b & -b
            l = lsb.bit_length()
            w_t = w_tmp[b - lsb] + w_[l-1]
            w_tmp[b] = w_t
            if w_t <= L:
                v_t = v_tmp[b - lsb] + v_[l-1]
                v_tmp[b] = v_t
                ret = max(ret, v_t + dp[v][L - w_t])
        print(ret)
    return

if __name__ == "__main__":
    main()
[N,K] = list(map(int,input().split()))
R = N-K
if N==K:
    print(1)
    for i in range(2,K+1):
        print(0)
elif K == 1:
    print(int((N-K+1)%(10**9+7)))
else:
    print(int((N-K+1)%(10**9+7)))
    for i in range(2,K+1):
        if i>R+1:
            print(0)
            continue
        C1 = 1
        bo = i-1
        shi = K-1
        while bo!=0:
            C1 *= shi/bo
            shi += -1
            bo += -1
        R2 = R - (i-1)
        C2 = 1
        bo = i
        shi = R2+i
        while bo!=0:
            C2 *= shi/bo
            shi += -1
            bo += -1
        print(int((C1*C2)%(10**9+7)))

### FIXED CODE ###

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

MAXN = 2000+5
p = 10**9+7
MOD = p
f = [1]
for i in range(MAXN):
    f.append(f[-1] * (i+1) % MOD)
def nCr(n, r, mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

for i in range(1,K+1):
    if (i>R+1) or (i-1>B-1):
        print(0)
    else:
        X = nCr(R+1, i, mod=p)
        Y = nCr(B-1, i-1, mod=p)
        print(X*Y%p)
N, A, B = map(int, input().split())
if (B - A) % 2 == 0:
    print((B - A) // 2)
else:
    if B - A == 1: 
        print(min(N-A, B-1))
    elif A == 1 or B == N:
        print((B - A - 1) // 2 + 1)
    else:
        print(min((A-1)+1+(B-2-1)//2), (N-B)+1+(N-A-2)//2)

### FIXED CODE ###

N, A, B = map(int, input().split())
if (B - A) % 2 == 0:
    print((B - A) // 2)
else:
    print(min(A-1, N-B)+1+(B-A-1)//2)
#coding: utf-8

import sys

def keitai(n1,n2):
    li1 = ['.', ',', '!', '?'] 
    li2 = ['a','b','c']
    li3 = ['d','e','f']
    li4 = ['g','h','i']
    li5 = ['j','k','l']
    li6 = ['m','n','o']
    li7 = ['p','q','r','s']
    li8 = ['t','u','v']
    li9 = ['w','x','y','z']
    li = [li1,li2,li3,li4,li5,li6,li7,li8,li9]
    lis = li[n1 - 1]
    n2 = n2 % len(li)
    a = lis[n2 - 1]
    return a

for line in sys.stdin:
    a = str(line)
    num = 0
    for i in len(a):
        if int(a[i]) == 0:
            print keitai(b,num),
        else:
            num = num + 1
            b = int(a[i])
    print ''

### FIXED CODE ###

#coding: utf-8
 
n = int(raw_input())
 
def keitai(n1,n2):
    li1 = ['.', ',', '!', '?',' '] 
    li2 = ['a','b','c']
    li3 = ['d','e','f']
    li4 = ['g','h','i']
    li5 = ['j','k','l']
    li6 = ['m','n','o']
    li7 = ['p','q','r','s']
    li8 = ['t','u','v']
    li9 = ['w','x','y','z']
    li = [li1,li2,li3,li4,li5,li6,li7,li8,li9]
    lis = li[n1 - 1]
    n2 = n2 % len(lis)
    a = lis[n2 - 1]
    return a
 
for k in range(n):
    a = str(raw_input())
    num = 0
    string = ''
    for i in range(len(a)):
        if int(a[i]) == 0:
            if num != 0:
                string = string + keitai(b,num)
                num = 0
            else:
                pass
        else:
            num = num + 1
            b = int(a[i])
    print string
while True:
    input=input().split()
    H=int(input[0])
    W=int(input[1])
    if H==0:
        break
    for i in range(1,H+1):
        if i%2!=0:
            if W%2==0:
                print("#."*(W//2))
            if W%2!=0:
                print("#."*(W//2)+".")
        if i%2==0:
            if W%2==0:
                print(".#"*(W//2))
            if W%2!=0:
                print(".#"*(W//2)+".")
    print()


### FIXED CODE ###

while True:
    s=input().split()
    h=int(s[0])
    w=int(s[1])
    if h==0:
        break
    for i in range(1,h+1):
        if i%2==1:
            if w%2==0:
                print("#."*(w//2))
            else:
                print("#."*(w//2)+"#")
        else:
            if w%2==0:
                print(".#"*(w//2))
            else:
                print(".#"*(w//2)+".")
    print()
A, B, C = map(int,input().split())
if A == B and B != C:
    print('Yes')
elif C == B and C != A:
    print('Yes')
elif A == C and C != B:
    print('Yes')
else('No')


### FIXED CODE ###


A, B, C = map(int,input().split())
if A == B and B != C:
  print('Yes')
elif C == B and C != A:
  print('Yes')
elif A == C and C != B:
  print('Yes')
else:
  print('No')
S=input()
if S = AAA or BBB:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

S=input()
count=0
for i in range(2):
  if S[i]==S[i+1]:
    count+=1
if count==2:
  print("No")
else:
  print("Yes")
a, b, c = map(int, input().split())

d = c - a - b
 
if d > 0 and 4 * a * b > d * d
    print('Yes')
else:
    print('No')

### FIXED CODE ###

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

d = c - a - b
 
if d > 0 and 4 * a * b < pow(d, 2):
    print('Yes')
else:
    print('No')
def main():
    N = input()
    cnt = 9
    len_n = len(N)
    if len_n == 1:
        cnt = int(N)
    elif len_n % 2 == 0:
        len_n -= 1
    else:
        cnt += int(N[1:]) + 1
        len_n -= 2
    while len_n > 1:
        print(f'len_n {len_n} , cnt {cnt}')
        cnt += 10 ** (len_n - 1) * 9
        len_n -= 2
    print(cnt)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N = input()
    cnt = 9
    len_n = len(N)
    if len_n == 1:
        cnt = int(N)
    elif len_n % 2 == 0:
        len_n -= 1
    else:
        cnt += int(N[1:]) + 1
        if int(N[0]) > 1:
            cnt += (int(N[0])-1) * 10 ** (len_n-1)
        len_n -= 2
    while len_n > 1:
        cnt += 10 ** (len_n - 1) * 9
        len_n -= 2
    print(cnt)


if __name__ == '__main__':
    main()
N,u,v = map(int,input().split())
u -= 1
v -= 1
E = [set() for _ in range(N)]
for _ in range(N-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  E[a].add(b)
  E[b].add(a)

DU = [-1 for _ in range(N)]  
DV = [-1 for _ in range(N)]
def dfs(p,c,D):
  D[p] = c
  for q in E[p]:
    if D[q] == -1:
      dfs(q,c+1,D)
dfs(u,0,DU)
dfs(v,0,DV)
#print(DU)
#print(DV)
DX = []
for du,dv in zip(DU,DV):
  DX.append(dv-du)
#print(DX)
#print(max(max(DX)-1,0))
mx = max(DX)
#print(DX.index(mx))
if DU[DX.index(mx)]%2 == 1:
  print(max(mx,0))
else:
  print(max(mx-1,0))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)

N,u,v = map(int,input().split())
u -= 1
v -= 1
E = [set() for _ in range(N)]
for _ in range(N-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  E[a].add(b)
  E[b].add(a)

DU = [-1 for _ in range(N)]  
DV = [-1 for _ in range(N)]
def dfs(p,c,D):
  D[p] = c
  for q in E[p]:
    if D[q] == -1:
      dfs(q,c+1,D)
dfs(u,0,DU)
dfs(v,0,DV)
#print(DU)
#print(DV)
mx = 0
for du,dv in zip(DU,DV):
  if du < dv:
    mx = max(dv,mx)
print(mx-1)