Harryxun/stf_run huggingface dataset:
import queue

H, W = map(int, input().split())
S = [input() for i in range(H)]
q = queue.LifoQueue()
longest_path = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            g = [[999 if S[k][l] == '.' else -1 for l in range(W)] for k in range(H)]
            q.put((i,j))
            g[i][j] = 0
            while not(q.empty()):
                x, y = q.get()
                for nx, ny in [(x+1, y),(x-1, y),(x, y+1),(x, y-1)]:
                    if nx < 0 or nx > H-1 or ny < 0 or ny > W-1: continue
                    if S[nx][ny] == '#': continue
                    if g[nx][ny] > g[x][y] + 1:
                        g[nx][ny] = g[x][y] + 1
                        q.put((nx,ny))
        longest_path = max(longest_path, max(map(max, g)))
print(longest_path)

### FIXED CODE ###

import queue

H, W = map(int, input().split())
S = [input() for i in range(H)]
q = queue.Queue()
longest_path = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            g = [[0 if S[k][l] == '.' else -1 for l in range(W)] for k in range(H)]
            q.put((i,j))
            g[i][j] = 0
            while not(q.empty()):
                x, y = q.get()
                for nx, ny in [(x+1, y),(x-1, y),(x, y+1),(x, y-1)]:
                    if nx < 0 or nx > H-1 or ny < 0 or ny > W-1: continue
                    if g[nx][ny] != 0: continue
                    if nx == i and ny == j: continue
                    g[nx][ny] = g[x][y] + 1
                    q.put((nx,ny))
            '''
            print('===========')
            for line in g:
                print(line)
            '''     
            longest_path = max(longest_path, max(map(max, g)))
print(longest_path)
from sys import stdin
from functools import lru_cache


@lru_cache(maxsize=100)
def f(x, k, d):
    if k == 0:
        return x

    if x == 0:
        if k % 2 == 0:
            return 0
        if k % 2 == 1:
            return d
    if x > 0:
        return f(x-d, k-1, d)
    if x < 0:
        return f(x+d, k-1, d)


if __name__ == '__main__':
    X, K, D = [int(x) for x in stdin.readline().rstrip().split()]
    print(abs(f(X, K, D)))


### FIXED CODE ###

from sys import stdin


def f(x, k, d):
    if k == 0:
        return x

    absX = abs(x)
    tmp = absX // d

    if tmp > k:
        return absX - d * k
    else:
        absX = absX - d * tmp
        k = k - tmp
        if k % 2 == 0:
            return absX
        else:
            return abs(absX - d)


if __name__ == '__main__':
    X, K, D = [int(x) for x in stdin.readline().rstrip().split()]
    print(f(X, K, D))
a,b = input().split
num = int(a+b)
print('Yes' if float(num**0.5) else 'No')

### FIXED CODE ###

import sys
a,b = input().split()
num = int(a+b)
i=1
while(i<=num**0.5):
	if(i**2 == num):
		print('Yes')
		sys.exit()
	i += 1
print('No')
a = int(input())
b = int(input())

if a = b[::-1]:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

a = input()
b = input()

if a == b[::-1]:
  print("YES")
else:
  print("NO")
a = int(raw_input())
b = int(raw_input())
 
if a != 3 && b != 3:
  print(str(3))
else if a != 2 && B != 2:
  print(str(2))
else:
  print(str(1))

### FIXED CODE ###

a = int(input())
b = int(input())
 
if (a != 1 and b != 1):
  print(1)
elif (a != 2 and b != 2):
  print(2)
else:
  print(3)
x,y = int(input().split())
if y % 2 == 1:
    print("No")
elif 2 * x <= y <= 4 * x:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

x,y = map(int, input().split())
if y % 2 == 1:
    print("No")
elif 2 * x <= y <= 4 * x:
    print("Yes")
else:
    print("No")
N, Y = map(int, input().split())
sum = 0
is_exist = False
for i in range(N+1):
  for j in range(N+1):
    for k in range(N+1):
      if i + j + k > N:
        break
      sum = i * 10000 + j * 5000 + k * 1000
      if sum == Y:
        printf(str(i) + " " + str(j) + " " + str(k))
        is_exist = True
        break
if is_exist == False:
  print("-1 -1 -1")

### FIXED CODE ###

def find(n, y):
  for i in range(n+1):
    for j in range(n+1-i):
      if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
        return i, j, n-i-j
  return -1, -1, -1
N, Y = map(int, input().split())
i, j, k = find(N, Y)
print("{} {} {}".format(i, j, k))
from __future__ import division, print_function
from sys import stdin, maxint
 
 
def main():
    num = int(stdin.readline())
 
    y = []
    for _ in xrange(num):
        it = iter(int(s) for s in stdin.readline().split()[1:])
        y.append([(next(it), next(it)) for _ in xrange(next(it))])
 
    weight = [maxint] * num
    weight[0] = 0
    t = set(xrange(1, num))
    index = 0
 
    while t:
        for v, cost in y[index]:
            if v not in t:
                continue
            weight[v] = min(weight[v], cost + weight[index])
 
        index = min(t, key=lambda i: weight[i])
        t.remove(index)
 
    for i, d in enumerate(weight):
        print(i, d)
 
 
main()

### FIXED CODE ###

from __future__ import division, print_function
from sys import stdin, maxint
 
 
def main():
    x = int(stdin.readline())
 
    y = []
    for _ in xrange(x):
        y.append([int(s) for s in stdin.readline().split()])
 
    g = set(xrange(1, x+1))
    index = g.pop()
    h = {index}
    leng = 0
 
    while g:
        minimum = maxint

        for j in h:
            mj = y[j-1]
            for i in g:
                if 0 <= mj[i-1] < minimum:
                    index = i
                    minimum = mj[i-1]

        h.add(index)
        g.remove(index)
        leng += minimum
 
    print(leng)
 
 
main()
A, B, C, D = map(int, input().split())
  areaA = A*B
  areaB = C*D
  result = areaA if (areaA > areaB) else areaB
  print(result)

### FIXED CODE ###

A, B, C, D = map(int, input().split())
areaA = A*B
areaB = C*D
result = areaA if (areaA > areaB) else areaB
print(result)
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    # input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    II = lambda : int(input())

    N = II()
    info = []
    MAXL = 101
    b = [[0] * MAXL for _ in range(MAXL)]

    def vtop(x1,x2,y1,y2,h1):
        ans = h1 + abs(x1-x2) + abs(y1-y2)
        return ans if ans <= 10**9 else 0

    # get info
    info = []
    for i in range(N):
        x,y,h = LMIIS()
        info.append((x,y,h))

    # info = XLMIIS(N)
    if len(info) < N:
        raise Exception()
    elif len(info) > N:
        while True:
            pass

    # init candidates
    for x,y,h in info:
        if h != 0:
            for i in range(MAXL):
                for j in range(MAXL):
                    b[i][j] = vtop(x,j,y,i,h)
        break

    # check
    for x,y,h in info:
        for i in range(MAXL):
            for j in range(MAXL):
                if h == 0:
                    if b[i][j] > vtop(x,j,y,i,h):
                        b[i][j] = 0

                else:
                    if b[i][j] != vtop(x,j,y,i,h):
                        b[i][j] = 0

    # answer
    ansl = []
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] > 0:
                ansl.append((j,i,b[i][j]))
    
    ansl2 = []
    for x0,y0,h0 in ansl:
        f = True
        for x1,y1,h1 in info:
            
            if max(h0-abs(x0-x1)-abs(y0-y1),0) != h1:
                f = False
                break
        if f:
            ansl2.append((x0,y0,h0))
    x,y,h= ansl2[-1]
    print(x,y,h)


if __name__ == '__main__':
    main()

### FIXED CODE ###

#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(input = sys.stdin.readline):
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())

    N = II()
    info = []
    for _ in range(N):
        xi, yi, hi = LMIIS()
        if hi != 0:
            xt, yt, ht = xi, yi, hi
        info.append((xi, yi, hi))

    for Cy in range(101):
        for Cx in range(101):
            H = ht + abs(xt - Cx) + abs(yt - Cy)
            found = True
            for xi, yi, hi in info:
                tmp_h = max(H - abs(Cy-yi) - abs(Cx-xi), 0)
                if tmp_h != hi:
                    found = False
                    break
            if found:
                print('{} {} {}'.format(Cx,Cy,H))
                return



if __name__ == '__main__':
    main()
a, b = map(int, input())
if a*b%2 == 1:
  print('Odd')
else:
  print('Even') 

### FIXED CODE ###

a, b = map(int, input().split())
if a*b%2 == 1:
  print('Odd')
else:
  print('Even')
n = int(input())
a = [map(int,input().split()) for i in range(n)]
b = [i for i in a if i%2==0]
c = [i for i in b if i%3!=0]
d = [i for i in c if i%5!=0]
if len(d)==0:
  print('APPROVED')
else:
  print('DENIED')

### FIXED CODE ###

n = int(input())
try:
  a = list(map(int,input().split()))
  a1 = list(i for i in a if i%2==0)
  a2 = list(i for i in a1 if i%3!=0)
  a3 = list(i for i in a2 if i%5!=0)
except EOFError:
  pass
if len(a3) == 0:
  print('APPROVED')
else:
  print('DENIED')
o=input()
e=input()
ans=""
if len(o)==len(e):
    for i in range(len(e)):
        ans+=o[i]+e[i]
else:
    for j in range(len(e)):
        ans+=o[i]+e[i]
    ans+=o[-1]
print(ans)

### FIXED CODE ###

o=input()
e=input()
ans=""
if len(o)==len(e):
    for i in range(len(e)):
        ans+=o[i]+e[i]
else:
    for j in range(len(e)):
        ans+=o[j]+e[j]
    ans+=o[-1]
print(ans)
A,B,C,D,E,F = map(int,input().split())
concent = 0
ans = []
for one in range(F//(100*A)+1):
    for two in range((F-100*A*one)//(100*B)+1):
        for three in range((F-100*A*one-100*B*two)//C+1):
            for four in range((F-100*A*one-100*B*two-C*three)//D+1):
                water = 100*A*one+100*B*two
                sugar = C*three+D*four
                all = water + sugar
                if all == 0:
                    continue
                if E*water//100 < sugar or all > F:
                    continue
                if concent < 100*sugar/all:
                    concent = 100*sugar/all
                    ans = [all,sugar]
print(str(ans[0])+' '+str(ans[1]))




### FIXED CODE ###

A,B,C,D,E,F = map(int,input().split())
concent = 0
ans = []
for one in range(F//(100*A)+1):
    for two in range((F-100*A*one)//(100*B)+1):
        for three in range((F-100*A*one-100*B*two)//C+1):
            for four in range((F-100*A*one-100*B*two-C*three)//D+1):
                water = 100*A*one+100*B*two
                sugar = C*three+D*four
                all = water + sugar
                if all == 0:
                    continue
                if E*water//100 < sugar or all > F:
                    continue
                if concent < 100*sugar/all:
                    concent = 100*sugar/all
                    ans = [all,sugar]
if len(ans) == 0:
    print(str(100*A)+' '+str(0))
else:
    print(str(ans[0])+' '+str(ans[1]))
my_value = input()
my_value_list = ([int(x) for x in my_value.split()])

count = 0
for i in range(my_value_list[0], my_value_list[1]+1):
    if my_value_list[] % i == 0:
        count += 1

print(count)

### FIXED CODE ###

my_value = input()
my_value_list = ([int(x) for x in my_value.split()])

count = 0
for i in range(my_value_list[0], my_value_list[1]+1):
    if my_value_list[2] % i == 0:
        count += 1

print(count)
/home/hiroya/.pyenv/versions/anaconda3-5.3.1/bin/python /home/hiroya/06_coding/aa.py
2
5 1 1
100 1 1No

Process finished with exit code 0


### FIXED CODE ###

N = int(input())
prevt,prevx,prevy = 0,0,0
for i in range(N):
    t, x, y = map(int,input().split())
    dt,dx,dy = t-prevt,x-prevx,y-prevy
    if dt < dx+dy or (dt-dx-dy)%2 != 0:
        print('No')
        exit()
    prevt,prevx,prevy = t,x,y
print('Yes')
if __name__ == '__main__':
    ken_num, city_num = list(map(int, input().split()))
    data = []
    for i in range(city_num):
        element = list(map(int, input().split())).append(i)
        data.append(element)
    # data = [list(map(int, input().split())).append(i) for i in range(city_num)]

    # ken_num, city_num = 2, 3
    # data = [[1,32,0], [2,63,1],[1,12,2]]

    data = sorted(data, key=lambda x: (x[0], x[1]))

    count = 1
    ken_num = 1
    ans_data = {}

    for i in range(city_num):
        number = data[i][2]
        if data[i][0] != ken_num:
            count = 1
            ken_num = data[i][0]
        chr = "{0:06d}".format(ken_num) + "{0:06d}".format(count)
        ans_data.update({number:chr})
        count += 1

    for i in range(city_num):
        print(ans_data[i])

### FIXED CODE ###

a, b = list(map(int, input().split()))
print(a+int(b/2))
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from math import pi
from bisect import bisect_left
def resolve():
    x1,y1,x2,y2=map(int,input().split())
    if(x1>x2): x1,y1,x2,y2=x2,y2,x1,y1 # x1<=x2
    trans=False
    if(y1>y2):
        y1,y2=10**8-y1,10**8-y2 # y1<=y2
        trans=True

    n=int(input())
    XY=[]
    for i in range(n):
        x,y=map(int,input().split())
        if(trans): y=10**8-y
        if(x1<=x<=x2 and y1<=y<=y2):
            XY.append((x,y))

    d=(x2-x1)+(y2-y1) # マンハッタン
    d*=100

    if(x1==x2 or y1==y2):
        assert(False)
        if(XY): d+=10*pi-20
        print(d)
        return

    # XYのLISを求めて、その個数*(20-5pi)を引けばよい
    XY.sort()
    C=[INF]*(n+1)
    for x,y in XY:
        i=bisect_left(C,y)
        C[i]=y
    k=C.index(INF)
    d-=k*(20-5*pi)
    print(d)
resolve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from math import pi
from bisect import bisect_left
def resolve():
    x1,y1,x2,y2=map(int,input().split())
    if(x1>x2): x1,y1,x2,y2=x2,y2,x1,y1 # x1<=x2
    trans=False
    if(y1>y2):
        y1,y2=-y1,-y2 # y1<=y2
        trans=True

    n=int(input())
    XY=[]
    for i in range(n):
        x,y=map(int,input().split())
        if(trans): y=-y
        if(x1<=x<=x2 and y1<=y<=y2):
            XY.append((x,y))

    d=(x2-x1)+(y2-y1) # マンハッタン
    d*=100
    l=min(x2-x1,y2-y1)

    # XYのLISを求めて、その個数*(20-5pi)を引けばよい
    XY.sort()
    C=[INF]*(n+1)
    for x,y in XY:
        i=bisect_left(C,y)
        C[i]=y
    k=C.index(INF)
    # LISの数が l より大きい時 -> 1回は無駄にしてしまう
    if(k>l):
        d-=(k-1)*(20-5*pi)
        d+=10*pi-20
    else:
        d-=k*(20-5*pi)
    print(d)
resolve()
n = int(input())
mul = 1
for i in range(n):
  ai = int(input())
  mul = mul * ai
  if mul > 10 ** 18:
    print('-1')
    exit()

### FIXED CODE ###

n = int(input())
lst = list(map(int, input().split()))
mul = 1
thr = 10 ** 18
if 0 in lst:
  print('0')
  exit()
for i in range(n):
  mul = mul * lst[i]
  if mul > thr:
    print('-1')
    exit()
print(mul)
Residents = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for l in range(n):
    b ,f ,r ,v  = list(map(int,input().split())
    Residents[b-1][f-1][r-1] += v
for k in range(4):
    for j in range(3):
        print(' '+ ' '.join(map(str,Residents[k][j])))
    print('####################') 


### FIXED CODE ###

Residents = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for l in range(n):
    b ,f ,r ,v  = list(map(int,input().split()))
    Residents[b-1][f-1][r-1] += v
for k in range(4):
    for j in range(3):
        print(' '+ ' '.join(map(str,Residents[k][j])))
    if (k ==3): break
    print('####################')
mod = 10 ** 9 + 7
n, m = map(int, input().split())

f = []
p = 2
while p * p <= m:
    if m % p != 0:
        p += 1
        continue
    c = 0
    while m % p == 0:
        c += 1
        m //= p
    f.append(c)
    p += 1
if m != 1:
    f.append(1)


def comb(a, b):
    ret = 1
    r = min(b, a-b)
    for i in range(a-r+1, a+1):
        ret *= i
    for j in range(1, r+1):
        ret //= j
    return (int)(ret)


ans = 1
for i in f:
    c = 1
    for j in range(i):
        c = c * (n+j) // (j+1)
    ans *= c
print(ans % mod)


### FIXED CODE ###

import collections
s=(str)(input())
t=(str)(input())

s_c=collections.Counter(s)
s_t=collections.Counter(t)
for i in range(len(s_c)):
    if s_c.get(s[i]) != s_t.get(t[i]):
        print("No")
        exit()
print("Yes")
import sys
n = int(input())
d = list(map(int, input().split()))
m = {}
ans = 1

if d[0] != 0:
    print(0)
    sys.exit()

for i in range(n):
    num = d[i]
    if num in m:
        m[num] += 1
    else:
        m[num] = 1

#print(m)
#print(max(m))

#for i in range(1, max(m)+1):
for i in range(0, max(m)):
    if i not in m:
        print(0)
        sys.exit()
    # prevCnt = m[i]
    # curCnt = m[i+1]
    prevCnt = m[i] % 998244353
    curCnt = m[i+1] % 998244353
    # ans *= prevCnt ** curCnt
    ans *= (prevCnt ** curCnt) % 998244353

print(ans % 998244353)







### FIXED CODE ###

import sys
n = int(input())
d = list(map(int, input().split()))
m = {}
ans = 1

if d[0] != 0:
    print(0)
    sys.exit()

if d.count(0) > 1:
    print(0)
    sys.exit()

for i in range(n):
    num = d[i]
    if num in m:
        m[num] += 1
    else:
        m[num] = 1

# if len(m) < n:
#     print(0)
#     sys.exit()

#print(m)
#print(max(m))
maxV = max(m.keys())

#for i in range(1, max(m)+1):
#for i in range(0, max(m)):
for i in range(0, maxV):
    if i not in m or i + 1 not in m:
        print(0)
        sys.exit()
    prevCnt = m[i]
    curCnt = m[i+1]
    # prevCnt = m[i] % 998244353
    #curCnt = m[i+1] % 998244353
    ans *= prevCnt ** curCnt
    #ans *= (prevCnt ** curCnt) % 998244353

print(ans % 998244353)
import numpy as np

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

n0 = 2**int(np.ceil(np.log2(2*Amax - 1)))#Amax+1以上となる最小の2のべき乗数

Afre=np.zeros(n0).astype(int)#パワーの頻度(1~Amax+1)
for i in range(N):
    Afre[A[i]]+=1

#astype(int)は切り捨てなので，rintで四捨五入してから．
S = np.rint(np.fft.irfft(np.fft.rfft(Afre)*np.fft.rfft(Afre))).astype(int)
Scum =S.cumsum()#累積和
bd = N*N-M#上からM個を取り出したい
i=np.searchsorted(Scum,bd)#価値iを生み出せる組みがM個以上ある
#価値iが生み出せる選び方の余分なものを引きたい
remove=((Scum[-1]-Scum[i])-M)*i

ans=0
for j in range(i+1,n0):
    ans+=S[j]*j
print(ans-remove)

### FIXED CODE ###

N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)

#幸福度をX以上増やせる手が何通りあるか？を二分探索．
#左手で握る人は線形探索，右手が二分探索で探す
#最後は累積和で計算

inf = 2*10**5+1
X_top = inf
X_bot = 0 #M手以上の組み合わせが作れる最大値

#幸福度をX以上挙げられる手の通り数ががMになる境界を探す
while X_top - X_bot !=1:  
    X=(X_top+X_bot)//2
    num=0
    
    for i in range(N):
        ok=-1
        ng=N
        h1=A[i]
        
        #右手と左手の合計がXになる境界を探す
        while ng-ok!=1:
            med=(ok+ng)//2
            h2=A[med]
            if h1+h2>=X:
                ok=med
            else:
                ng=med
        num+=ok+1
    
    if num>=M:
        X_bot = X
    else:
        X_top = X
        
ok_list=[0]*N
#各左手に対して何個okなくみがあるか探す
for i in range(N):
        ok=-1
        ng=N
        h1=A[i]
        X = X_bot
        #右手と左手の合計がXになる境界を探す
        while ng-ok!=1:
            med=(ok+ng)//2
            h2=A[med]
            if h1+h2>=X:
                ok=med
            else:
                ng=med
        ok_list[i]=ok

S=[0]*(N+1)
for i in range(N):
    S[i+1]=S[i]+A[i]

ans=0
for i in range(N):
    ans += A[i]*(ok_list[i]+1)+S[ok_list[i]+1]

if sum(ok_list)+N>M:
    ans-=(sum(ok_list)+N-M)*X
print(ans)
while 1:
  n,m,q=map(int,input().split())
  if (n|m|q)==0: break
  
  p=[]
  res=[[_ for _ in range(n)] for _ in range(m)]
  for i in range(q):
    s,b=[[int(c) for c in s] for s in input().split()]
    if i>0:
      for j in range(n):
        s[j]^=p[j]
    for j in range(n):
      for k in range(m):
        if s[j]!=b[k] and j in res[k]:
          res[k].remove(j)
    p=s
  
  table="".join([str(i) for i in range(10)]+[chr(ord("A")+i) for i in range(26)])
  for i in range(m):
    if len(res[i])==1:
      print(table[res[i][0]],sep="",end="")
    else:
      print("?",sep="",end="")
  print()

### FIXED CODE ###

while 1:
  n,m,q=map(int,input().split())
  if (n|m|q)==0: break
  
  p=[]
  res=[{_ for _ in range(n)} for _ in range(m)]
  for i in range(q):
    s,b=[[int(c) for c in s] for s in input().split()]
    if i>0:
      for j in range(n):
        s[j]^=p[j]
    zero={i for i in range(n) if s[i]==0}
    one={i for i in range(n) if s[i]==1}
    for j in range(m):
      if(b[j]==0): res[j]-=one
      if(b[j]==1): res[j]-=zero
    p=s
  
  table="".join([str(i) for i in range(10)]+[chr(ord("A")+i) for i in range(26)])
  for i in range(m):
    if len(res[i])==1:
      print(table[res[i].pop()],sep="",end="")
    else:
      print("?",sep="",end="")
  print()
from sys import stdin
from functools import lru_cache

@lru_cache(None)
def solver(N, K):
    """N以下で0でないものがちょうどK個。0を含める"""
    if N < 10:
        if K == 0:
            return 1
        if K == 1:
            return N
        return 0
    # divmod : 商と余りを両方取れる
    m, r = divmod(N,10)
    ans = 0
        # 1の位が nonzero
        ans += solver(m, K-1) * r
        ans += solver(m-1, K-1) * (9-r)
    ans += solver(m, K)
    return ans


n = int(input())
k = int(input())
print(solver(n,k)


### FIXED CODE ###

from sys import stdin
from functools import lru_cache

@lru_cache(None)
def solver(N, K):
    if N < 10:
        if K == 0:
            return 1
        if K == 1:
            return N
        return 0
    m, r = divmod(N,10)
    ans = 0
    if K >= 1:
        ans += solver(m, K-1) * r
        ans += solver(m-1, K-1) * (9-r)
    ans += solver(m, K)
    return ans


n = int(input())
k = int(input())
print(solver(n,k))
s = input()
t = input()

if len(t) + 1  == len(s) and s in t:
  print(Yes)
  
else :
  print(No)

### FIXED CODE ###

s = input()
t = input()

if s == t[0:-1]:
  
  print('Yes')
  
else:
  print('No')
N = int(input())
A = [int(input()) for i in range(N)]
maxa = max(A)
for i in range(N):
    if maxa == A[i]:
        tmp = A.pop(i)
        print(max(A))
        insert(i,tmp)
    else:
        print(maxa)

### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
maxind = A.index(max(A))
maxa = max(A)
A = sorted(A)
ans = [maxa]*maxind
ans.append(A[-2])
[ans.append(i) for i in [maxa]*(N-maxind-1)]
print(*ans,sep="\n")
from itertools import combinations
n = int(input())
A = tuple(map(int, input().split()))
def solve(m):
    if m in A:
        return "yes"
    for i in range(2, n + 1):
        for C in combinations(A, i):
            if sum(C) == m:
                return "yes"
    return "no"
q = int(input())
for m in map(int, input().split()):
    print(solve(m))



### FIXED CODE ###

n = int(input())
SET1 = {0}
for a in map(int, input().split()):
    for b in tuple(SET1):
        SET1.add(a + b)
input()
for m in map(int, input().split()):
    print('yes' if m in SET1 else 'no')
a=int(input())
s=input()
if a>3200:
  print(s)
else:
  print(red)

### FIXED CODE ###

a=int(input())
s=input()
if a>=2800 and a<3200:
  print('red')
if a>=3200 and a<5000:
  print(s)
import sys
for i in range(N-1):
    l.append(a[i+1]-a[i])
if any(i<=-2 for i in l):
    print("No")
for i in range(N-1):
    total = l[i]
    for k in range(1,N-1):
        if total <=0:
            total += l[k]
            if k == N-2:
                print("No")
                sys.exit()
        else:
            break
print("Yes")

### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
l = []
for i in range(N-1):
    if a[i+1]-a[i] != 0:
        l.append(a[i+1]-a[i])
# print(l)
if any(i<=-2 for i in l):
    print("No")
    exit()
# while 0 in l:
#     l.remove(0)
# # print(l)
for i in range(len(l)-1):
    if l[i] == -1 and l[i+1] == -1:
        print("No")
        exit()
print("Yes")