Harryxun/stf_run huggingface dataset:
n,x,y=map(int,input().split())
edge=[]
for i in range(int(n)):
    tmp=[0 if i==j else 1 if abs(i-j)==1 else -1 for j in range(n)]
    edge.append(tmp)
edge[x-1][y-1]=1
edge[y-1][x-1]=1
step=[0 for i in range(n)]#ある歩数の点の選び方をカウントする
def bfs(start,graph,step):
    kyori={}#スタートからある点までの距離をある点をキーとして入れる
    num=0
    Tovis=[start]
    kyori[start]=0
    visited=[]
    while Tovis:
        nex=Tovis.pop(0)
        visited.append(nex)
        for v in range(len(graph[nex])):
            tmp=graph[nex][v]
            if tmp!=-1:
                if v in visited:
                    continue
                if  v in Tovis:
                    continue
                Tovis.append(v)
                kyori[v]=kyori[nex]+1#点ｖまでの距離はその前に通った点までの距離+1
                step[kyori[v]]+=0.5#i->j j->iの二回数えてしまうので
for i in range(n):
    bfs(i,edge,step)
for i in range(1,len(step)):
    print(int(st

### FIXED CODE ###

s=input()

x=1
if s[2]!=s[3]:
    x=0
    
if s[4]!=s[5]:
    x=0
    
        
if x==1:
    print("Yes")
else:
    print("No")
import numpy as np
H, W, D = map(int, input().split())

px, py = np.zeros(H*W+1, dtype=int), np.zeros(H*W+1, dtype=int)
for i in range(H):
    A = map(int, input().split())
    for j in range(W):
        px[A[j]] = i
        py[A[j]] = j

d = np.zeros(H*W+1, dtype=int)
for i in range(D+1, H*W+1):
    d[i]= d[i-D]+abs(px[i]-px[i-D])+abs(py[i]-py[i-D])

Q = int(input())

for i in range(Q):
    L, R = map(int, input().split())
    print(d[R]-d[L])

### FIXED CODE ###

import numpy as np
H, W, D = list(map(int, input().split()))

px, py = [None for i in range(H*W+1)], [None for i in range(H*W+1)]
for i in range(H):
    A = list(map(int, input().split()))
    for j in range(W):
        px[A[j]] = i
        py[A[j]] = j

d = [0 for i in range(H*W+1)]
for i in range(D+1, H*W+1):
    d[i]= d[i-D]+abs(px[i]-px[i-D])+abs(py[i]-py[i-D])

Q = int(input())

for i in range(Q):
    L, R = list(map(int, input().split()))
    print(d[R]-d[L])
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
 a= int(readline())
if a % 2 == 1:
    print(0)
else:
    a //= 2
    ans = 0
    while a:
        a //= 5
        ans += a
    print(ans)

### FIXED CODE ###

def findTrailingZeros(n): 
      
    if (n%2!=0): 
        return 0

    else: 
        ans = 0
        n //= 2
        while (n): 
            ans += n // 5
            n //= 5
  
        return ans 
  
n = int(input())
  
print(findTrailingZeros(n))
n,m=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True)
dic={1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}
dp=[0]*(n+1)
for i in range(n+1):
  for val in arr:
    if i-dic[val]<0:
      continue
    else:
      dp[i]=max(dp[i],dp[i-dic[val]]+1)
ans=''
tmp=n
while tmp>0:
  for val in arr:
    if tmp-dic[val]<0:
      continue
    if dp[tmp]==dp[tmp-dic[val]]+1:
      ans+=str(val)
      tmp-=dic[val]
      break
  else:
    break
last=dic[int(ans[-1])]
cand=[]
for val in arr:
  if dic[val]-last==tmp:
    cand.append(val)
cand=sorted(cand,reverse=True)
ans=ans[:-1]+str(cand[0])
print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True)
dic={1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}
dp=[-1]*(n+1)
dp[0]=0
for i in range(n+1):
  for val in arr:
    if i-dic[val]<0:
      continue
    else:
      dp[i]=max(dp[i],dp[i-dic[val]]+1)
ans=''
tmp=n
while tmp>0:
  for val in arr:
    if tmp-dic[val]<0:
      continue
    if dp[tmp]==dp[tmp-dic[val]]+1 and dp[tmp-dic[val]]!=-1:
      ans+=str(val)
      tmp-=dic[val]
      break
print(ans)
n,m = map(int,input().split())
listA=[] #appendのために宣言が必要
i=0
a=[]
b=[]
c=[]
while True:
    try:
        if(i%2==0):
          i=i+1
          a1,b1=(list(map(int,input().split())))
          a.append(a1)
          b.append(b1)
          #listA.append(list(map(int,input().split())))
        else:
          i=i+1
          c.append(list(map(int,input().split())))	
    except:
        break;
        #または、quit(),os.exit()をして止める。

#print(listA)
print(a)
print(b)
print(*c)
#偶数はa,b
get_=[]
money=[]
kei=0
for i in range(m):
  get_.extend(c[i])
  kei=kei+a[i]
  if(len(list(set(get_)))==n):
    money.append(kei)
  
print(min(money))

### FIXED CODE ###

import math
a=int(input())
if(a%2==0):
  print(0.5000)
else:
  print(math.floor(a/2+1)/a)
N,M = map(int,input().split())
A = list(map(int,input()))
counter = 0

for i in range(M):
    counter += A[i]
    
print(N-counter)


### FIXED CODE ###

N,M = map(int,input().split())
A = list(map(int,input().split()))
counter = 0
for i in range(M):
    counter += A[i]
    
if N - counter>=0:
    print(N-counter)
else:
    print(-1)
s = input()
x, y = map(int, input().split())
dic = {"U": (1, 0), "R": (0, 1), "D": (-1, 0), "L": (0, -1)}
rec = []


def dfs(x1, y1, pos, k):
    if k == len(s):
        if (x1, y1) not in rec:
            rec.append((x1, y1))
        return
    else:
        if s[k] == "F":
            nx, ny = x1 + dic[pos][0], y1 + dic[pos][1]
            dfs(nx, ny, pos, k + 1)
        else:
            if pos == "U" or pos == "D":
                dfs(x1, y1, "R", k + 1)
                dfs(x1, y1, "L", k + 1)
            else:
                dfs(x1, y1, "U", k + 1)
                dfs(x1, y1, "D", k + 1)


dfs(0, 0, "R", 0)
if (y, x) in rec:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

S = input()
x, y = map(int, input().split())

T = S.split("T")
u, v = [len(T[0])], [0]
dp = [u, v]
for i in range(1, len(T)):
    s = set()
    k = len(T[i])
    if i % 2 != 0:
        Q = dp[1]
        for j in Q:
            s.add(j - k)
            s.add(j + k)
        dp = [dp[0], list(s)]
    else:
        Q = dp[0]
        for j in Q:
            s.add(j - k)
            s.add(j + k)
        dp = [list(s), dp[1]]
if x in dp[0] and y in dp[1]:
    print("Yes")
else:
    print("No")
N = int(input())
C_0 = 0
C_1 = 0
C_2 = 0
C_3 = 0
for _ in range(N):
    if input() == 'AC':
        C_0 += 1
    elif input() == 'WA':
        C_1 += 1
    elif input() == 'TLE':
        C_2 += 1
    else:
        C_3 += 1
print('AC x {}'.format(C_0))
print('WA x {}'.format(C_1))
print('TLE x {}'.format(C_2))
print('RE x {}'.format(C_3))

### FIXED CODE ###

N = int(input())
C_0 = 0
C_1 = 0
C_2 = 0
C_3 = 0
for _ in range(N):
    S = input()
    if S == 'AC':
        C_0 += 1
    elif S == 'WA':
        C_1 += 1
    elif S == 'TLE':
        C_2 += 1
    else:
        C_3 += 1
print('AC x {}'.format(C_0))
print('WA x {}'.format(C_1))
print('TLE x {}'.format(C_2))
print('RE x {}'.format(C_3))
H,W = map(int,input().split())
a_list = []
for i in range(H):
    str = input()
    a_list.append(list(str))

def clear(A):
    
    INF = 100000000

    distance = [[INF for i in range(W)] for j in range(H)]

    def bfs():
        queue = []
        already = []

        for i in range(W):
            for j in range(H):
                if A[i][j] == "#":
                    queue.insert(0,(i,j))
                    already.insert(0,(i,j))
                    distance[i][j] = 0

        while len(queue):
            x, y = queue.pop()

            for i in range(0, 4):
                nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]

                if (0 <= nx and nx < W and 0 <= ny and ny < H and \
                    A[nx][ny] == '.' and distance[nx][ny] == INF):
                    queue.insert(0, (nx, ny))
                    already.insert(0, (nx,ny))
                    distance[nx][ny] = distance[x][y] + 1

        max_dis = 0
        for i in range(H):
            max_dis = max(max_dis,max(distance[i]))

        return max_dis

    return bfs()

print (clear(a_list))

### FIXED CODE ###

import numpy
H,W = map(int,input().split())
a_list = []
INF = 10**10
for i in range(H):
    str = input()
    a_list.append([0 if i == "#" else INF for i in list(str)])

a_list = numpy.array(a_list)
for x in range(W-1):
    a_list[:,x+1] = numpy.minimum(a_list[:,x]+1,a_list[:,x+1])
    a_list[:,-x-2] = numpy.minimum(a_list[:,-x-1]+1,a_list[:,-x-2])

for y in range(H-1):
    a_list[y+1,:] = numpy.minimum(a_list[y,:]+1,a_list[y+1,:])
    a_list[-y-2,:] = numpy.minimum(a_list[-y-1,:]+1,a_list[-y-2,:])

print(a_list.max())
n= int(input())
spot = input().split()
ans = []
for i in spot:
    spot.append(int(spot[0]))
    del spot[0]
if n == 1:
    print(0)
else:
    for s in range(min(spot),max(spot)):
        x = 0
        for t in spot:
            x += (s-t)**2
        ans.append(x)
if n != 1:
    ans.sort(reverse=True)
    print(ans[0])

### FIXED CODE ###

n= int(input())
spot = input().split()
ans = []
for i in spot:
    spot.append(int(spot[0]))
    del spot[0]
if n == 1:
    print(0)
else:
    if max(spot)==min(spot):
        ans.append(0)
    for s in range(min(spot),max(spot)):
        x = 0
        for t in spot:
            x += (s-t)**2
        ans.append(x)
if n != 1:
    ans.sort(reverse=False)
    print(ans[0])
I0 = lambda :map(int,input().split())
I1 = lambda :int(input())
I2 = lambda :list(map(int,input().split()))
#####################################################




def dfs(tree,counter,p):
    for i in tree[p]:
        counter[i]+=counter[p]
        dfs(tree,counter,i)

n ,q = I0()
counter = [0]*n
tree = [[] for i in range(n)]
for i in range(n-1):
    a,b=I0()
    tree[a-1].append(b-1)


for i in range(q):
    p,x = I0()
    counter[p-1]+=x
    

dfs(tree,counter,0)


print(*counter)

'''stack = [1]
while stack:
    yy = stack.pop()
    for i in tree[yy]:
        counter[i-1]+=counter[yy-1]
        stack.append(i)'''

### FIXED CODE ###

I0 = lambda :map(int,input().split())
I1 = lambda :int(input())
I2 = lambda :list(map(int,input().split()))
#####################################################


from sys import stdin,setrecursionlimit
#from copy import deepcopy
 
setrecursionlimit(10**6)
input=stdin.readline

def dfs(p,father=-1):
    for i in tree[p]:
        if i == father:
            continue
        counter[i]+=counter[p]
        dfs(i,p)

n ,q = I0()
counter = [0]*n
tree = [[] for i in range(n)]
for i in range(n-1):
    a,b=I0()
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

for i in range(q):
    p,x = I0()
    counter[p-1]+=x
    

dfs(0)

print(*counter)

'''stack = [1]
while stack:
    yy = stack.pop()
    for i in tree[yy]:
        counter[i-1]+=counter[yy-1]
        stack.append(i)'''
5 3
50 100 80 120 80

### FIXED CODE ###

N, K = map(int,input().split())
p = list(map(int,input().split()))
new = sorted(p)
sum = 0
for i in range(K):
  sum += new[i]
print(sum)
n = int(input())
l = []
r = []
for _ in range(n):
  a, b = map(int, input())
  l.append(a)
  r.append(b)
before_sa = 0
for i in range(1, n+1):
  j = 0
  a, b = l[-i], r[-i]
  while True:
    if j == 0 and a % b == 0:
      sa = 0
    elif j == 0 and a % b != 0:
      sa = (a//b + 1) * b - a
    elif j > 0:
      sa = (a//b + j) * b - a
    if before_sa <= sa:
      before_sa = sa
      break
    j += 1
print(before_sa)

### FIXED CODE ###

n = int(input())
l = []
r = []
for _ in range(n):
  a, b = map(int, input().split())
  l.append(a)
  r.append(b)
before_sa = 0
for i in range(1, n+1):
  a, b = l[-i], r[-i]
  a += before_sa
  if a % b == 0:
    continue
  else:
    sa = (a//b + 1) * b - a
    before_sa += sa
print(before_sa)
N = int(input())
S = str(input())

dfs = df[S]

dfs.str.contains("ABC")

### FIXED CODE ###

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

count = 0
for i in range(N-2):
    if S[i]=="A" and S[i+1]=="B" and S[i+2]=="C":
       count+=1
print(count)
a, b, c = map(int, input().split())
if  b−a == c−b:
  print ("YES")
else:
  print ("NO")

### FIXED CODE ###

a,b,c = map(int,input().split())
if b-a == c-b:
    print("YES")
else:
    print("NO")
line1 = input().split()
n = int(line1[0])
k = int(line1[1])

print(min(n % k, abs(n % k - k))

### FIXED CODE ###

line1 = input().split()
n = int(line1[0])
k = int(line1[1])
 
print(min(n % k, abs(n % k - k)))
n= int(input())
d = list(map(int,input().split()))
d.sort()
x=int(n/2)
if d[x] == d[x-1]:
  print(0)
else:
  y = d[x] - d[x-1]

print(y)

### FIXED CODE ###

n= int(input())
d = list(map(int,input().split()))
d.sort()
x=int(n/2)
if d[x] == d[x-1]:
  print(0)
else:
  y = d[x] - d[x-1]
  print(y)
#!/usr/bin/env python3
n, *p = map(int, open(0).read().split())
c = 0
for i in range(n):
    if p[i] == i + 1:
        p[i], p[i+1] = p[i+1], p[i]
        c += 1
print(c)

### FIXED CODE ###

#!/usr/bin/env python3
n, *p = map(int, open(0).read().split())
c = 0
for i in range(n):
    if p[i] == -~i:
        if i == ~-n:
            p[i], p[i-1] = p[i-1], p[i]
        else:
            p[i], p[i+1] = p[i+1], p[i]
        c += 1
print(c)
X, N = map(int,input().split())
if N == 0:
    print(X)
    exit()

p = list(map(int,input().split()))
if p.count(X) == 0:
    print(X)
    exit()


l = list(range(0,102)) #ここの範囲設定が一番難しい部分だと思う
flist = []
for i in range(len(l)):
    if p.count(l[i]) == 0:
        flist.append(l[i])


flist.append(X)
anslist = sorted(flist)
t = anslist.index(X)

dist1 = anslist[t] - anslist[t-1] #Xと1つ前の数字との距離
dist2 = anslist[t+1] - anslist[t] #Xと1つ後ろの数字との距離
    if dist1 <= dist2:
        print(anslist[t-1])
    else:
        print(anslist[t+1])

### FIXED CODE ###

X,N=map(int,input().split())
if N==0:
    print(X)
    exit()

P_ori=list(map(int,input().split()))
if P_ori.count(X)==0:
    print(X)
    exit()


P1=sorted(P_ori)
N=list(range(0,102))
PZ=[]
for i in range(len(N)):
    if P1.count(N[i])==0:
        PZ.append(N[i])

PZ.append(X)
P2=sorted(PZ)
t=P2.index(X)
if P2[t]==P2[0]:
    print(P2[1])
    exit()
elif P2[t]==P2[-1]:
    print(P2[-2])
    exit()
else:
    dist1=abs(P2[t-1]-P2[t])
    dist2=abs(P2[t]-P2[t+1])
    if dist1<=dist2:
        print(P2[t-1])
        exit()
    else:
        print(P2[t+1])
        exit()
print(0)
s=input()   
if s[0]==s[1]:
	print("Bad")
elif s[1]==s[2]:
	print("Bad")
elif s[2]==s[3]:
	print("Bad")
else:
	print(good)

### FIXED CODE ###

s=input()
if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
	print("Bad")
else:
	print("Good")
N, C = map(int, input().split())
 x = []
 v = []
 for i in range(N):
     a, b = map(int, input().split())
     x.append(a)
     v.append(b)

 R = [0] * N
 L = [0] * N
 R2L = 0
 L2R = 0
 for i in range(N):
     R[i] = sum(v[:i+1]) - x[i]
     L[i] = sum(v[-i-1:]) - (C - x[-i-1])
     if i < N - 1:
         R2L = max(R2L, R[i] - x[i] + max(L[:N-1-i]))
         L2R = max(L2R, L[i] - (C - x[-i-1]) + max(R[:N-1-i]))

 print(max(0, max(R), max(L), R2L, L2R))

### FIXED CODE ###

N, C = map(int, input().split())
x = []
v = []
for i in range(N):
    a, b = map(int, input().split())
    x.append(a)
    v.append(b)

R = [0] * N
L = [0] * N
for i in range(N):
    if i == 0:
        R[i] = v[i] - x[i]
        L[N-1-i] = v[N-1-i] - (C - x[N-1-i])
    else:
        R[i] = R[i - 1] + v[i] - (x[i] - x[i - 1])
        L[N-1-i] = L[N-i] + v[N-1-i] - (x[N-i] - x[N-1-i])

Rmax = [0] * N
Lmax = [0] * N
for i in range(N):
    if i == 0:
        Rmax[i] = R[i]
        Lmax[N-1-i] = L[N-1-i]
    else:
        Rmax[i] = max(Rmax[i-1], R[i])
        Lmax[N-1-i] = max(Lmax[N-i], L[N-1-i])

R2L = 0
L2R = 0
for i in range(N-1):
    R2L = max(R2L, R[i] - x[i] + Lmax[i+1])
    L2R = max(L2R, L[i+1] - (C - x[i+1]) + Rmax[i])

print(max(0, max(R), max(L), R2L, L2R))
a = int (input())
b = int (input())

if a*b%2 == 0:
    print('Even')
else:
    print('Odd')

### FIXED CODE ###

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

if a*b % 2 == 0:
    print('Even')
else:
    print('Odd')
a,b,c,d = map(int,input().split())

aoki_new = (a+d-1)/d
taka_new1 = (c+b-1)/b

if aoki_new >= taka_new1:
	print("Yes") #takahasi is loses because its heath is zero first
else:
	print("No")






### FIXED CODE ###

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

if s<w or s==w:
	print("unsafe")
else:
	print("safe")
s = input().split()
stk = []
for i in s:
	if i >= '0' and i <= '9':
		stk.append(int(i))
	else:
		a = stk.pop()
		b = stk.pop()
		if i == '+':
			stk.append(b + a)
		elif i == '-':
			stk.append(b - a)
		else:
			stk.append(b * a)
print(stk.pop())



### FIXED CODE ###

s = input().split()
stk = []
for i in s:
	if i.isdigit():
		stk.append(int(i))
	else:
		a = stk.pop()
		b = stk.pop()
		if i == '+':
			stk.append(b + a)
		elif i == '-':
			stk.append(b - a)
		else:
			stk.append(b * a)
print(stk.pop())
import numpy as np

N, K = map(int, input().split())
A = [int(x) for x in input().split()]

A_past = np.prod(A[:K])

for i in range(N-K):
  A_now = A_past*A[i+K]/A[i]
  if A_now > A_past:
    print("Yes")
  else:
    print("No")
  A_past = A_now



### FIXED CODE ###

N, K = map(int, input().split())
A = [int(x) for x in input().split()]

for i in range(N-K):
  t = A[i+K]/A[i]
  if t > 1:
    print("Yes")
  else:
    print("No")
# input
N = int(input())
L = list(map(int, input().split()))

if max(L) < sum(L) - max(L):
    print("Yes")
else;
    print("No")

### FIXED CODE ###

# input
N = int(input())
L = list(map(int, input().split()))

if max(L) < sum(L) - max(L):
    print("Yes")
else:
    print("No")
a,b = int(input())
if a == 1:
  a += 13
if b == 1:
  b += 13
if a > b:
  print("Alice")
if a < b:
  print("Bob")
if a == b:
  print("Drow")

### FIXED CODE ###

a,b = map(int,input().split())
if a == 1:
  a += 13
if b == 1:
  b += 13
if a > b:
  print("Alice")
if a < b:
  print("Bob")
if a == b:
  print("Draw")
import sys
sys.setrecursionlimit(10**6)
from functools import lru_cache
@lru_cache(maxsize = None)

edges, vertices = map(int, input().split())
dp = [None for _ in range(edges)]

nodes = [[] for _ in range(edges)]

for i in range(vertices):
    start, end = map(int, input().split())
    nodes[end -1].append(start-1)

for i in range(edges):
    if not len(nodes[i]):
        dp[i] = 0
@lru_cache(maxsize = None)
def find(arr):
    if not len(arr):
        return 0
    for x in arr:
        if dp[x] is None:
            dp[x] = find(nodes[x])
    return 1 + max(dp[x] for x in arr)

for i in range(edges):
    dp[i] = find(nodes[i])

print(max(dp))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
edges, vertices = map(int, input().split())
dp = [None for _ in range(edges)]

nodes = [[] for _ in range(edges)]

for i in range(vertices):
    start, end = map(int, input().split())
    nodes[end -1].append(start-1)

for i in range(edges):
    if not len(nodes[i]):
        dp[i] = 0
def find(arr):
    if not len(arr):
        return 0
    for x in arr:
        if dp[x] is None:
            dp[x] = find(nodes[x])
    return 1 + max(dp[x] for x in arr)

for i in range(edges):
    dp[i] = find(nodes[i])

print(max(dp))
N = map(int, input())
n = N // 15
x = 800 * N
y = 200 * n

print(x-y)

### FIXED CODE ###

N = int(input())
n = N // 15
x = 800 * N
y = 200 * n

print(x-y)
import sys
S = list(input())
C_cnt,low,upp = 0,0,0
if S[0] != "A" or S[-1].isupper()
  print("WA")
  sys.exit()
for i in range(1,len(S)-1):
  if S[i] == "C":
    C_cnt += 1
  elif S[i].islower():
    low += 1
  elif S[i].isupper():
    upp += 1
if C_cnt = 1 and low = len(S)-3 and upp = 0:
  print("AC")
else :
  print("WA")

### FIXED CODE ###

import sys
S = list(input())
C_cnt,low,upp = 0,0,0
if S[0] != "A" or S[-1].isupper() or S[1].isupper():
  print("WA")
  sys.exit()
for i in range(2,len(S)-1):
  if S[i] == "C":
    C_cnt += 1
  elif S[i].islower():
    low += 1
  elif S[i].isupper():
    upp += 1
if C_cnt == 1 and low == len(S)-4 and upp == 0:
  print("AC")
else :
  print("WA")
a = int(input('A'))
b = int(input('B'))
k = int(input('K'))

count = 0
kcount = 0
while True:
    count += 1
    if a % count == 0 and b % count == 0:
        print(count)
        kcount += 1
    if k == kcount:
        break

print(count)



### FIXED CODE ###

A,B,K = map(int,input().split())
l = []
for i in range(1,min(A,B)+1):
    if A % i == 0 and B % i == 0:
        l.append(i)
l.reverse()
print(l[K - 1])
a, b = map(int, input().split())

x = a + b
y = a - b
z = a * b

print(max[x, y, z])

### FIXED CODE ###

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

x = a + b
y = a - b
z = a * b

print(max([x, y, z]))
n=int(input())
a=[]
for i in range(n):
  a.appent(int(input))
i=0
count=1
while(1):
  if a[i]==1:
    frag=-1
    break
  elif a[i]==2:
    frag=count
    break
  else:
    i=a[i]-1
    count+=1
print(frag)  

### FIXED CODE ###

n=int(input())
a=[]
for i in range(n):
  a.append(int(input()))
i=0
count=1
frag=-1
for j in range(n):
  if a[i]==2:
    frag=count
    break
  else:
    i=a[i]-1
    count+=1
print(frag)
A, B, C = list(map(int, input().split()))
  
print(max([A+B, A-B, A*B]))


### FIXED CODE ###

A, B = list(map(int, input().split()))
  
print(max([A+B, A-B, A*B]))
def neighbor(N, edges):
    neighbor_list = [[] for _ in range(N)]
    for a, b in edges:
        neighbor_list[a-1] += [b-1]
        neighbor_list[b-1] += [a-1]
        
    return neighbor_list

def paint(N, K, nlist, clist, p2c, combi):
    p2c_next = {}
    for parent in p2c:
        for children in p2c[parent]:
            # childrenに対し、Kからparentの塗られている近接の数を引いた数だけ組み合わせを掛ける
            combi *= (K - 1 - len([t for t in nlist[parent - 1] if clist[t - 1]]))
            clist[children - 1] = True #子供の頂点を塗る
        # 次の世代のリスト
            p2c_next.update({children:[gc for gc in nlist[children - 1] if gc != parent]})
            
    return clist, p2c_next, combi

def paint2(K, nlist, now_num, from_num, case_num):
        mod = 1000000007
        
        if now_num == 0:
            can_use_color = K - 1
        else:
            can_use_color = K - 2
        
        if len(nlist[now_num]) > can_use_color:
            return 0
        
        for child in nlist[now_num]:
            if child == from_num:
                continue
            else:
                case_num *= can_use_color
                can_use_color -= 1
                case_num %= mod
        
        for child in nlist[now_num]:
            if child == from_num:
                continue
            else:
                case_num = paint2(K, nlist, child, now_num, case_num)
        return case_num%mod
            

if __name__ == '__main__':
    N, K = map(int, input().split())
    edges = [None]*(N-1)
    
    for i in range(N-1):
        edges[i] = list(map(int, input().split()))
    
    nlist = neighbor(N, edges)
    
    print(paint2(K, nlist, 0, -1, K))

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

def neighbor(N, edges):
    neighbor_list = [[] for _ in range(N)]
    for a, b in edges:
        neighbor_list[a-1] += [b-1]
        neighbor_list[b-1] += [a-1]
        
    return neighbor_list


def paint(K, nlist, now_num, from_num, case_num):
        mod = 1000000007
        if  from_num == -1:
            can_use_color = K - 1
        else:
            can_use_color = K - 2
        
        if len(nlist[now_num]) - 1 > can_use_color:
            return 0
        
        for child in nlist[now_num]:
            if child == from_num:
                continue
            else:
                case_num *= can_use_color
                can_use_color -= 1
                case_num %= mod
        
        for child in nlist[now_num]:
            if child == from_num:
                continue
            else:
                case_num = paint(K, nlist, child, now_num, case_num)
        return case_num%mod
            

if __name__ == '__main__':
    N, K = map(int, input().split())
    edges = [None]*(N-1)
    
    for i in range(N-1):
        edges[i] = list(map(int, input().split()))
    
    nlist = neighbor(N, edges)


    print(paint(K, nlist, 0, -1, K))
r = range(1, 10)
n = int(input())
a = [None] + [[0] * 10 for _ in r]
for i in r:
  if i <= n:
    a[i][j] += 1
for i in r:
  for j in r:
    k = 1
    while 10 * k * i + j <= n:
      a[i][j] += min(k, (n - j) // 10 - k * i + 1)
      k *= 10
print(sum(a[i][j] * a[j][i] for i in r for j in r))


### FIXED CODE ###

n = int(input())
r = range(1, 10)
a = [[0] * 9 for _ in r]
for i in r:
  if i <= n:
    a[i - 1][i - 1] += 1
for i in r:
  for j in r:
    k = 1
    while 10 * k * i + j <= n:
      a[i - 1][j - 1] += min(k, (n - j) // 10 - k * i + 1)
      k *= 10
print(sum(a[i][j] * a[j][i] for i in range(9) for j in range(9)))