Harryxun/stf_run huggingface dataset:
n = int(input())
k = int(input())
number = []
while n:
    number.append(n%10)
    n//=10

from math import factorial
def comb(n,k):
    if n>=k:
        return int(factorial(n)/(factorial(k)*factorial(n-k)))
    else:
        return 0


t = len(number)
t1 = len(number) - 1
#if t>k:
   # ans = (9**k)*comb(t1,k) + (9**(k-1))*(number[t1]-1)*comb(t1,k-1)
#else:
 #   ans = (9**(k-1))*(number[t1]-1)*comb(t1,k-1)



ans = 0
def calc(a,k):
    t = len(a)
    t1 = len(a) - 1
    if k<1:
        return 0
    else:
        if a[t1]>0: #and t>1:
            ans = (9**k)*comb(t1,k) + (9**(k-1))*(a[t1]-1)*comb(t1,k-1)
        #elif a[t1]>0 and t==1:
           # ans = a[t1]
        else:
            ans = 0
        ans+=calc(a[:(t-1)],k-1)
        return ans
ans += calc(number,k)
if ans>=0:
    if number[-k]>=1:
        print(ans+1)
    else:
        print(ans)
else:
    print(0)

### FIXED CODE ###

from math import factorial
def comb(n,k):
    if n>=k:
        return int(factorial(n)/(factorial(k)*factorial(n-k)))
    else:
        return 0

n = int(input())
k = int(input())
number = []
while n:
    number.append(n%10)
    n//=10

t = len(number)
t1 = len(number) - 1

if t>=k:
    ans = 0
    def calc(a,k):
        t = len(a)
        t1 = len(a) - 1
        if k<1 or t == 0:
            return 0
        else:
            if a[t1]>0:
                ans = (9**k)*comb(t1,k) + (9**(k-1))*(a[t1]-1)*comb(t1,k-1)
                ans+=calc(a[:(t-1)],k-1)
            else:
                ans = 0
                ans+=calc(a[:(t-1)],k)
            if a[-k]>=1 and k == 1:
               ans+=1
            return ans
    ans += calc(number,k)
else:
    ans = 0
print(ans)
H,W,K = map(int,input().split())
A = [0]*H
for i in range(H):
    A[i] = input()
s = 10000
for i in range(2**(H-1)):
    count = 0
    B = [0]*H
    for j in range(H-1):
        if (i >> j & 1):
            B[j] = 1
            count += 1
    C = [0]*(count + 1)
    for j in range(W):
        a = [0]*(count + 1)
        n = 0
        for k in range(H):
            a[n] += int(A[k][j])
            C[n] += int(A[k][j])
            if B[k] == 1:
                n += 1      
        if max(C) > K:
            count += 1
            C[:] = a[:]
    if s > count:
        s = count
print(s)

### FIXED CODE ###

N,M = map(int,input().split())
print(N*(N-1)//2+(M*(M-1))//2)
S = input()
num = 0
for i in range(len(S))
	if S[i] == '+':
    	num = num + 1
    else:
    	num = num - 1
print(num)

### FIXED CODE ###

S = input()
num = 0
for i in range(len(S)):
    if S[i] == '+': num = num + 1
    else : num = num -1
print(num)
a,b,c,=list(input()),list(input()),list(input())
d=a[0]
e=0
a.remove(d)
while True:
    if eval(d)==[]:
        break
    e=eval(d)[0]
    eval(d).remove(e)
    d=e
print(str.upper(e))

### FIXED CODE ###

a,b,c,=list(input()),list(input()),list(input())
d=a[0]
e=0
a.remove(d)
while True:
    if eval(d)==[]:
        break
    e=eval(d)[0]
    eval(d).remove(e)
    d=e
print(str.upper(d))
N = int(input())

X = [0] * N
Y = [0] * N


X[0],Y[0] = map(int,input().split(" "))
ev = (X[0] + Y[0])%2
flg = False
for i in range(N-1):
    X[i+1],Y[i+1] = map(int,input().split(" "))
    if(X[i+1] + Y[i+1] ) % 2 != ev:
        flg = True

if flg:
    print(-1)
    exit(0)

if ev == 1:
    m =  39
else:
    m = 40

stop = "LR"

print(m)
d = [ 1 for i in range(m) ]
print(*d)
for i in range(N):
    need = (abs(X[i])+abs(Y[i]))
    s = stop * (m - need)
    if X[i] < 0:
        s += ("L" * abs(X[i]))
    else:
        s += ("R" * abs(X[i]))
    if Y[i] < 0:
        s += ("D" * abs(Y[i]))
    else:
        s += ("U" * abs(Y[i]))
    print(s)






### FIXED CODE ###

N = int(input())
X,Y = [0]*N,[0]*N
U,V = [0]*N,[0]*N
mod = [0] * N
for i in range(N):
    X[i],Y[i] = map(int,input().split(" "))
    mod[i] = (X[i] + Y[i]) % 2
    U[i],V[i] = (X[i]+Y[i]),(X[i]-Y[i])

l = len(list(filter(lambda x: x == 1,mod)))

if l != 0 and l != N:
    print(-1)
    exit(0)

# 偶数
if l == 0:
    d = [ 1 << i for i in range(38,-1,-1) ] + [1]

else:
    d = [ 1 << i for i in range(39,-1,-1) ]

ans = []
for i in range(N):
    move = []
    curU,curV = 0,0
    for step in d:
        if curU <= U[i] and curV <= V[i]:
            curU += step
            curV += step
            move.append('R')

        elif curU > U[i] and curV <= V[i]:
            curU -= step
            curV += step
            move.append('D')

        elif curU <= U[i] and curV > V[i]:
            curU += step
            curV -= step
            move.append('U')

        elif curU > U[i] and curV > V[i]:
            curU -= step
            curV -= step
            move.append('L')

    ans.append(move)

print(len(d))
print(*d)
for i in range(N):
    print("".join(ans[i]))
from bisect import bisect_left

N = int(input())

AB = [tuple(map(int, input().split())) for _ in range(N)]
ALL = []
ALL_append = ALL.append
for a, b in AB:
    ALL_append(a)
    ALL_append(b)

ALL.sort()
dic = dict()
for i, x in enumerate(ALL):
    dic[x] = i

lst1 = [0] * (2 * N + 1)
lst2 = [0] * (2 * N + 1)

for a, b in AB:
    lst1[dic[a]] += 1
    lst2[dic[b]] -= 1

for i in range(2 * N):
    lst1[i + 1] += lst1[i]
    lst2[2 * N - 1 - i] += lst2[2 * N - i]

# print (lst1)
# print (lst2)

if N % 2 == 1: #奇数 -->一意に決まる時
    left = bisect_left(lst1, N // 2 + 0.5)
    right = bisect_left(lst2, -((N) // 2) - 0.5) - 1
    # print (left, right)
    upper = ALL[right]
    lower = ALL[left]
    print (upper - lower + 1)
else:
    left = bisect_left(lst1, N // 2 - 0.5)
    right = bisect_left(lst2, -(N // 2) - 0.5)
    # print (left, right)
    upper = ALL[right]
    lower = ALL[left]
    print (upper - lower + 1)
    




### FIXED CODE ###

N = int(input())

A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()

if N % 2 == 1:
    ans = B[N // 2] - A[N // 2] + 1
    print (ans)
else:
    a = (A[N // 2 - 1] + A[N // 2])
    b = (B[N // 2 - 1] + B[N // 2])
    print (b - a + 1)
S = input()
for _ in len(S):
  print('x')

### FIXED CODE ###

s = input()
print('x' * len(s))
s=input

a=s.find('A')
z=s.rfind('Z')

print(z-a)


### FIXED CODE ###

s=input()

a=s.find('A')
z=s.rfind('Z')

print(z-a+1)
H,W = map(int, input().split())
As = []
for i in range(H):
    As.append(list(map(int, input().split())))
diffs = []
for i in range(H):
    bs = list(map(int, input().split()))
    diffs.append([a-b for a,b in zip(As[i],bs)])
max_d = 0
for i in range(H):
    for j in range(W):
        max_d = max(max_d,abs(diffs[i][j]))

M = max_d*(H+W)

# print(M)
# (i,j)において、偏りがkになることがあるか
diff_s = abs(diffs[0][0])
# 初期値
dp = [[[False]*M for i in range(W)] for j in range(H)]
dp[0][0][diff_s] = True
# もらうDP
for i in range(H):
    for j in range(W):
        # 行方向
        if i+1 < H:
            d = abs(diffs[i+1][j])
            for k in range(M):
                x = dp[i][j][k]
                if x:
                    dp[i+1][j][d+k] = x
                    dp[i+1][j][abs(d-k)] = x
        # 列方向
        if j+1 < W:
            d = abs(diffs[i][j+1])
            for k in range(M):
                x = dp[i][j][k]
                if x:                
                    dp[i][j+1][d+k] = x
                    dp[i][j+1][abs(d-k)] = x
        # print(i,j,diffs[i][j],dp)

ans = 0
for i,b in enumerate(dp[i][j]):
    if b:
        print(i)
        exit()

### FIXED CODE ###

M = 6400*4
mid = M//2
INF = 10**18

H,W = map(int, input().split())
As = []
for i in range(H):
    As.append(list(map(int, input().split())))
diffs = []
for i in range(H):
    bs = list(map(int, input().split()))
    diffs.append([abs(a-b) for a,b in zip(As[i],bs)])

# bitset高速化
# 初期値
dp = [[0]*W for j in range(H)]
dp[0][0] = 1 << (mid+diffs[0][0]) #プラスマイナス考慮して、下駄をはかせる
for i in range(H):
    for j in range(W):
        # 行方向
        if i+1 < H:
            d = diffs[i+1][j]
            dp[i+1][j] |= dp[i][j] >> d  
            dp[i+1][j] |= dp[i][j] << d  
        # 列方向
        if j+1 < W:
            d = diffs[i][j+1]
            dp[i][j+1] |= dp[i][j] >> d
            dp[i][j+1] |= dp[i][j] << d

ans = INF
for i in range(M):
    if dp[H-1][W-1] >> i & 1:
        # print(i-mid)
        ans = min(ans, abs(i-mid))
print(ans)
"""
あなたは、X 円を持ってケーキとドーナツを買いに出かけました。
あなたはまずケーキ屋で 1 個 A 円のケーキを 1 個買いました。 次に、ドーナツ屋で 1 個 B 円のドーナツをできるだけたくさん買いました。
これらの買い物のあと手元に残っている金額は何円ですか。
"""

def buying_sweets(money,p_cake,p_dounuts):
    t_money  = money - p_cake
    c_dounuts = t_money // p_dounuts
    p_after_money = t_money - (c_dounuts * p_dounuts)
    return p_after_money
N = input()
a = [input() for i in range(N)]
money = a[1]
p_cake = a[2]
p_dounuts = a[3]
print(buying_sweets(money,p_cake,p_dounuts))

### FIXED CODE ###

"""
あなたは、X 円を持ってケーキとドーナツを買いに出かけました。
あなたはまずケーキ屋で 1 個 A 円のケーキを 1 個買いました。 次に、ドーナツ屋で 1 個 B 円のドーナツをできるだけたくさん買いました。
これらの買い物のあと手元に残っている金額は何円ですか。
"""

def buying_sweets(money,p_cake,p_dounuts):
    t_money  = money - p_cake
    c_dounuts = t_money // p_dounuts
    p_after_money = t_money - (c_dounuts * p_dounuts)
    return p_after_money

money = int(input())
p_cake = int(input())
p_dounuts = int(input())
print(buying_sweets(money,p_cake,p_dounuts))
a,b = map(int, input().split())
if(a<9 && b<9):
  print("Yay!")
else:
  print(":(")

### FIXED CODE ###

a,b = map(int, input().split())
if(a<9 and b<9):
    print("Yay!")
else:
    print(":(")
a, b = input().split()

c = a*b / 2

if c == 0:
  print("Even")

else:
  print("Odd")
    

### FIXED CODE ###

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

c = i[0] * i[1]

ans = 'Even' if c % 2 == 0 else 'Odd'
print(ans)
s = input()
s = s + "1"
k = int(input())
ans = 0
lis = []
tem = 1
for i in range(len(s)-1):
  if s[i] == s[i+1]:
    tem += 1
  else:
    lis.append(tem)
    tem = 1
if s[0] == s[-2]:
  t = lis[0]+lis[-1]
  for i in range(1,len(lis)-1):
    if item % 2 == 0:
      ans += item//2
    else:
      ans += (item-1)//2
  ans*= k
  if t%2 == 0:
    ans += (k-1)*t//2
  else:
    ans += (k-1)*(t-1)//2
  if lis[0]%2 == 0:
    ans += (k-1)*lis[0]//2
  else:
    ans += (k-1)*(lis[0]-1)//2
  if lis[-1]%2 == 0:
    ans += (k-1)*lis[-1]//2
  else:
    ans += (k-1)*(lis[-1]-1)//2
else:
  for item in lis:
    if item % 2 == 0:
      ans += item//2
    else:
      ans += (item-1)//2
  ans *= k
  
print(ans)

### FIXED CODE ###

s = input()
s = s + "1"
k = int(input())
ans = 0
lis = []
tem = 1
for i in range(len(s)-1):
  if s[i] == s[i+1]:
    tem += 1
  else:
    lis.append(tem)
    tem = 1
if s[0] == s[-2]:
  t = lis[0]+lis[-1]
  for i in range(1,len(lis)-1):
    if lis[i] % 2 == 0:
      ans += lis[i]//2
    else:
      ans += (lis[i]-1)//2
  ans*= k
  if t%2 == 0:
    ans += (k-1)*t//2
  else:
    ans += (k-1)*(t-1)//2
  if lis[0]%2 == 0:
    ans += lis[0]//2
  else:
    ans += (lis[0]-1)//2
  if lis[-1]%2 == 0:
    ans += lis[-1]//2
  else:
    ans += (lis[-1]-1)//2
else:
  for item in lis:
    if item % 2 == 0:
      ans += item//2
    else:
      ans += (item-1)//2
  ans *= k
if len(lis) == 1:
  anse = (len(s)-1)*k
  if anse%2 == 0:
    ans = anse//2
  else:
    ans =(anse-1)//2
print(ans)
n, m = map(int, input())
if n >= 2:
  if m >= 2:
    print((n-2) * (m-2)) 
  else:
    print((n-2) * m)
else:
  if m >= 2:
    print(n * (m-2)) 
  else:
    print(n * m) 

### FIXED CODE ###

n, m = map(int, input().split())
if n >= 2:
  if m >= 2:
    print((n-2) * (m-2)) 
  else:
    print((n-2) * m)
else:
  if m >= 2:
    print(n * (m-2)) 
  else:
    print(n * m)
n = int(input())
a = input().split()

money = 1000
stock = 0
pivot = []
flag = 0

for i in range(n):
    pivot.append(int(a[i+1]) - int(a[i]))

pivot.append(-1)
pivot.append(-1)

i=0

for j in range(n):
    if(pivot[j]>0):
        i = j
        break
    else:
        flag = -1

if(flag != -1):
    stock = int(money//int(a[i]))
    money = int(money%(int(a[i])))

i+=1
if(flag != -1):
    while(i<n):
        if(i==n-1):
            if(pivot[i]>0):
                money = money + stock*int(a[i+1])
                stock = 0
            break

        elif(pivot[i]<0):
            while(pivot[i+1]<=0 and flag != -1):
                if(i==n-2):
                    flag = -1
                i+=1
            if(flag != -1):
                stock = int(money//int(a[i+1]))
                money = int(money%(int(a[i+1])))
                i+=1
        else:
            while(pivot[i+1]>=0 and flag != -1):
                if(i==n-2):
                    flag = -1
                i+=1
            money = money + stock*int(a[i+1])
            stock = 0
            i+=1

print(money)


### FIXED CODE ###

n = int(input())
a = input().split()

money = 1000
stock = 0
pivot = []
upflag = 0
dnflag = 1

if(int(a[1]) - int(a[0]) > 0): # initial
    stock = int(money // (int(a[0])))
    money = int(money % (int(a[0])))
    upflag = 1
    dnflag = 0

for i in range(n-2): # i=0,1,,,,n-3 (for n=7, n-3=4)
    if(int(a[i+1]) == int(a[i])):
        if((int(a[i+2]) - int(a[i+1]) < 0) and upflag == 1): # i+1 is local max so that to sell stock
            money = money + stock * (int(a[i+1]))
            stock = 0
            upflag = 1
            dnflag = 0
        elif((int(a[i+2]) - int(a[i+1]) > 0) and dnflag == 1): # i+1 is local min so that to sell stock
            stock = int(money // (int(a[i+1])))
            money = int(money % (int(a[i+1])))
            upflag = 0
            dnflag = 1

    elif(int(a[i+1]) - int(a[i]) > 0):
        upflag = 1
        if(int(a[i+2]) - int(a[i+1]) < 0): # i+1 is local max so that to sell stock
            money = money + stock * (int(a[i+1]))
            stock = 0
            upflag = 0

    elif(int(a[i+1]) - int(a[i]) < 0):
        dnflag = 1
        if(int(a[i+2]) - int(a[i+1]) > 0): # i+1 is local min so that to buy stock
            stock = int(money // (int(a[i+1])))
            money = int(money % (int(a[i+1])))
            dnflag = 0

if(int(a[n-1]) - int(a[n-2]) > 0): # sell @ final
    money = money + stock * (int(a[n-1]))
elif(int(a[n-1]) - int(a[n-2]) == 0):
    if(upflag == 1):
        money = money + stock * (int(a[n-1]))

print(money)
n, k = map(int, input().split())
s = input()
memo = []
c = 0
ps = ''
lens = len(s) - 1
b = 0
if s[0] == '1':
    b = 1

for i in range(lens + 1):
    if s[i] != ps:
        memo.append(c)
        c = 1
        ps = s[i]
        if i == lens:
            memo.append(1)
        continue
    if i == lens:
        memo.append(c+1)
    c += 1
    ps = s[i]
sum = 0
if  len(memo) < k * 2 + b + 1:
    print(sum(memo))
    else:
    sum = sum(memo[: k * 2 + b + 1])
    temp = [sum]
    memo.append(0)
    # print(memo)
    # print(len(memo))
    for i in range(0, len(memo) - 2 * k  - 1, 2):
        sum = sum - memo[i] - memo[i + 1] + memo[i + 2 * k  + 1] + memo[i + 2 * k + 2]
        temp.append(sum)
    # print(temp)
    print(max(temp))


### FIXED CODE ###

n, k = map(int, input().split())
s = input()
memo = []
c = 0
ps = ''
lens = len(s) - 1
b = 0
if s[0] == '1':
    b = 1

for i in range(lens + 1):
    if s[i] != ps:
        memo.append(c)
        c = 1
        ps = s[i]
        if i == lens:
            memo.append(1)
        continue
    if i == lens:
        memo.append(c+1)
    c += 1
    ps = s[i]

if  len(memo) < k * 2 + b + 1:
    print(sum(memo))
else:
    sumi = 0
    sumi = sum(memo[: k * 2 + b + 1])
    temp = [sumi]
    memo.append(0)
    # print(memo)
    # print(len(memo))
    for i in range(b, len(memo) - 2 * k  - 1, 2):
        last = 0
        if i + 2 * k + 2 <= len(memo) - 1:
            last = memo[i + 2 * k + 2]
        sumi = sumi - memo[i] - memo[i + 1] + memo[i + 2 * k  + 1] +last
        temp.append(sumi)
    # print(temp)
    print(max(temp))
import math
A, B = map(int, input().split())

GCD = math.gcd(A, B)



def primes_dict(n):
    #
    prime_list = []
    non_prime_list = []
    k_list = []
    number_dict = {
        i: None for i in reversed(range(n + 1))}
    #
    del number_dict[0]
    del number_dict[1]
    while True:
        # get prime
        prime, _ = number_dict.popitem()
        if A % prime == 0 and B % prime == 0:
            prime_list.append(prime)
        if prime * prime > n:
            break

        # get non primes
        non_prime_list.append(prime * prime)
        while True:
            k, _ = number_dict.popitem()
            k_list.append(k)
            if prime * k > n:
                break
            non_prime_list.append(prime * k)

        while k_list:
            number_dict[k_list.pop()] = None

        # delete non prime
        while non_prime_list:
            del number_dict[non_prime_list.pop()]

    while number_dict:
        prime, _ = number_dict.popitem()
        if A % prime == 0 and B % prime == 0:
            prime_list.append(prime)

    return prime_list

if GCD == 1:
    print(1)
else:
    print(len(primes_dict(GCD))+1)

### FIXED CODE ###

import collections
import math

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


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
     # divisors.sort()
    return divisors



def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

A_div = set(make_divisors(A))
B_div = set(make_divisors(B))
common_div = (A_div & B_div)

cnt = 1
for c in common_div:
    if is_prime(c):
        cnt += 1

print(cnt)
a=input()
b=input()


for i in range(len(a)):
  print(a[i]+b[i],end="")

### FIXED CODE ###

a=input()
b=input()

if len(a)==len(b):
  for i in range(len(a)):
    print(a[i]+b[i],end="")
else:
  k=""
  for i in range(len(a)-1):
    k+=a[i]+b[i]
  print(k+a[-1])
def count_l(d,n):
	maxim = 0
	if n > 0:
		for t in wa_l(d,n-1):
			maxim = max(t[0]+d[t[1]],maxim)
	return(maxim)

def count_r(d,n):
	maxim = 0
	if n > 0:
		for t in wa_r(d,n-1):
			maxim = max(t[0]+d[N-1-t[1]],maxim)
	return(maxim)			
		

def wa_l(d,n):
	if n == 0:
		return([[0,0]])
	if n == 1:
		return([[d[0],1]])
	if n == 2:
		return([[0,1],[d[0]+d[1],2]])
	if n > 2:
		a = []
		for j in wa_l(d,n-2):
			j[1] += 1
			a.append(j)
		for j in wa_l(d,n-1):
			j[0] += d[j[1]]
			j[1] += 1
			a.append(j)
		return(a)

def wa_r(d,n):
	if n == 0:
		return([[0,0]])
	if n == 1:
		return([[d[N-1],1]])
	if n == 2:
		return([[0,1],[d[N-1]+d[N-2],2]])
	if n > 2:
		a = []
		for j in wa_r(d,n-2):
			j[1] += 1
			a.append(j)
		for j in wa_r(d,n-1):
			j[0] += d[N-1-j[1]]
			j[1] += 1
			a.append(j)
		return(a)

def l_r(d,n):
	maxim = 0
	for x in range(n+1):
		maxim = max(count_r(d,x)+count_l(d,n-x),maxim)
	print(maxim)

N, q= map(int,input().split())
p = list(map(int,input().split()))

l_r(p,q)

### FIXED CODE ###

import sys
inputs = sys.stdin.readline
N, K= map(int,inputs().split())
V = list(map(int,inputs().split()))

maxim = 0
if K <= 2*N - 1:
	for i in range(0,K+1):
		for j in range(i+1):
			if j == i:
				a = V[:j] + [0]
			else:
				a = V[:j] + V[j-i:] + [0]
			a.sort()
			b = a.index(0)
			if b <= K - i:
				maxim = max(sum(a[b:]),maxim)
			else:
				maxim = max(sum(a[K-i:]),maxim)
else:
	V.append(0)
	V.sort()
	maxim = sum(V[V.index(0):])
print(maxim)
n = int(input())
t_now = 0
x_now = 0
y_now = 0
flag = True
for _ in range(n):
    t, x, y = map(int, input().split())
    if t < abs(x - x_now) or t < abs(y - y_now) or (y == y_now and x == x_now):
        print('No')
        flag = False
        break
    t_now = t
    x_now = x
    y_now = y
if flag:
    print('Yes')


### FIXED CODE ###

a,b = map(int, input().split())
if (a*b) % 2 == 0:
	print('Even')
else:
	print('Odd')
a = input()
b = int(a)
c = list(a)
t = int(a[0])
#print(t,a.count("9"))
if t != 9  and a.count("9") == len(a)-1:
    r = t+(len(a)-1)*9
elif a.count("9") != len(a):
    t -= 1
    r = t+(len(a)-1)*9
if b<9:
    r = b
else: b == 9
    r = 9
    
print(r)

### FIXED CODE ###

a = input()
b = int(a)
c = list(a)
t = int(a[0])
r = t+(len(a)-1)*9
#print(t,a.count("9"))
if t != 9  and a.count("9") == len(a)-1:
    r = t+(len(a)-1)*9
elif a.count("9") != len(a):
    t -= 1
    r = t+(len(a)-1)*9
if b<9:
    r = b
elif b == 9:
    r = 9
    
print(r)
n, a, b = map(int, input().split())
s = ""
b_cnt = 0
while len(s) + (a + b) <= n:
    s += "b"*a + "r"*b
    b_cnt += 1
rest = n - len(s)
ans = a * b_cnt + rest
print(ans)

### FIXED CODE ###

n, a, b = map(int, input().split())
div, rest =divmod(n, (a + b))
#div, rest
ans = a * div
if rest >= a:
    ans += a
else:
    ans += rest
print(ans)
import sys
from math import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
li = list(map(int,input().split()))
mst = li[0]
for i in range(1, n):
    if li[i] >= mst:
        mst = li[i]
    elif li[i] != mst - 1:
        print("No")
        exit(1)
print("Yes")



### FIXED CODE ###

import sys
from math import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
li = na()
mst = li[0]
flag = "Yes"
for i in range(n):
    if li[i] >= mst:
        mst = li[i]
    elif li[i] != mst - 1:
        flag = "No"
        break
print(flag)
n,m=map(int,input().split())
ans=1
for i in range(1,m**0.5+1):
  if m%i==0:
    if i>=n:
      ans=max(ans,m//i)
    elif m//i>=n:
      ans=max(ans,i)
print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
ans=1
for i in range(1,int(m**0.5)+1):
  if m%i==0:
    if i>=n:
      ans=max(ans,m//i)
    elif m//i>=n:
      ans=max(ans,i)
print(ans)
S = input()
count1=1
count2=0
for i in range(4):
  if S[i] == S[0] :
    count1++
  else:
    count2++
    
if count2==2 and count1 ==2:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

S = input()
l =[S[0]]
for i in S:
  if i not in l:
    l.append(i)
if len(l)==2:
  count1=0
  for i in range(4):
    for j in range (4):
      if S[i]==S[j]:
        count1+=1
  if count1 ==8:
    print("Yes")
  else:
    print("No")
else:
  print("No")
n = [input(i) for i in input().split()]
n.sort(reverse=True)
print(n[0]*10*n[1]+n[2])

### FIXED CODE ###

n = [int(i) for i in input().split()]
n.sort(reverse=True)
print(n[0]*10+n[1]+n[2])
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

a,b,c,x,y = I()
p = []
for i in range(10**5+1):
    cash = 2*c*i+a*max(0,x-i)+B*max(0,y-i)
    c.append(cash)

print(min(p))


### FIXED CODE ###

import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

a,b,c,x,y = I()
p = []
for i in range(10**5+1):
    cash = 2*c*i+a*max(0,x-i)+b*max(0,y-i)
    p.append(cash)

print(min(p))
A, B = map(int, input().split())
if A-2*B > 0:
    print(A-2*B)
else:
    print('0')

### FIXED CODE ###

S = input()
day = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
print(7-day.index(S))