Harryxun/stf_run huggingface dataset:
paper = [[0 for _ in range(14)] for _ in range(14)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

while True:
    try:
        x, y, s = map(int, input().split())
    except EOFError:
        break
    x += 2
    y += 2
    paper[x][y] += 1
    for i in range(4):
        paper[x + dx[i]][y + dy[i]] += 1
    if s >= 2:
        for i in range(4):
            paper[x + dx[i] + dx[(i + 1) % 4]][y + dy[i] + dy[(i + 1) % 4]] += 1
    if s >= 3:
        for i in range(4):
            paper[x + 2 * dx[i]][y + 2 * dy[i]] += 1

paper = paper[2:12]
for i in range(10):
    paper[i] = paper[i][2:12]
print(sum(paper[i].count(0) for i in range(10)))
print(max(paper[i][j] for i in range(10) for j in range(10)))

### FIXED CODE ###

paper = [[0 for _ in range(10)] for _ in range(10)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

def paint(x, y):
    if 0 <= x <= 9 and 0 <= y <= 9:
        paper[x][y] += 1

while True:
    try:
        x, y, s = map(int, input().split(","))
    except EOFError:
        break
    if x == y == s == -1:
        break
    paint(x, y)
    for i in range(4):
        paint(x + dx[i], y + dy[i])
    if s >= 2:
        for i in range(4):
            paint(x + dx[i] + dx[(i + 1) % 4], y + dy[i] + dy[(i + 1) % 4])
    if s >= 3:
        for i in range(4):
            paint(x + 2 * dx[i], y + 2 * dy[i])

print(sum(paper[i].count(0) for i in range(10)))
print(max(paper[i][j] for i in range(10) for j in range(10)))
import math
o, b = map(int, input().split())
def pi(a):
    s= 0
    a+=1
    p = math.log2(a)
    p = int(p)
    b_q =1
    q = 2
    ans =0
    ans += (t//2)%2

    for i in range(1,p+1):
        b_q = q

        q*=2
        t = a%(q)
        ans += b_q*(max(0,t-b_1)%2)
    return ans
print((pi(b)^pi(o))^o)


### FIXED CODE ###

import math
o, b = map(int, input().split())
def pi(a):
    s= 0
    a+=1
    p = math.log2(a)
    p = int(p)
    qq=1
    q = 2
    ans =0
    t = 0
    t = a//2
    ans += t%2

    for i in range(1,p+1):
        qq = q

        q*=2
        t = a%(q)
        ans += qq*(max(0,t-qq)%2)
    return ans
print((pi(b)^pi(o))^o)
a,p = map(int,input().split()
print(int((a*3+p)/2))

### FIXED CODE ###

a,p = map(int,input().split())
print(int((a*3+p)/2))
N,Q = [int(i) for i in input().split()] #N個の頂点、Q回の操作
aaabbb = [[int(i) for i in input().split()] for j in range(N-1)] #木の辺
pppxxx = [[int(i) for i in input().split()] for j in range(Q)] #操作

tree = [[] for i in range(N+1)]

for a,b in aaabbb:
    tree[a].append(b)

#print(tree)

counter = [0 for i in range(N+1)]

for p,x in pppxxx:
    counter[p] += x

#print(counter)

def dfs(pos):
    for next_pos in tree[pos]:
        counter[next_pos] += counter[pos]
        dfs(next_pos)

dfs(1)

#print(counter)

print(" ".join([str(i) for i in counter[1:]]))


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N,Q = [int(i) for i in input().split()] #N個の頂点、Q回の操作
aaabbb = [[int(i) for i in input().split()] for j in range(N-1)] #木の辺
pppxxx = [[int(i) for i in input().split()] for j in range(Q)] #操作

tree = [[] for i in range(N+1)]

for a,b in aaabbb:
    tree[a].append(b)
    tree[b].append(a)

#print(tree)

counter = [0 for i in range(N+1)]

for p,x in pppxxx:
    counter[p] += x

#print(counter)

def dfs(pos,parent,add):
    counter[pos] += add
    for next_pos in tree[pos]:
        if not next_pos == parent:
            dfs(next_pos,pos,counter[pos])

dfs(1,0,0)

#print(counter)

print(" ".join([str(i) for i in counter[1:]]))
n=int(input())
m=list(map(int,input().split()))
for i in range(n):
  a=0
  for m[i]>1:
    m[i]//=2
    a+=1
  if a>2:
    a=2
  m[i]=a
if m.count(2)>m.count(1):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n=int(input())
m=list(map(int,input().split()))
for i in range(n):
  a=0
  while m[i]%2==0:
    m[i]//=2
    a+=1
  if a>2:
    a=2
  m[i]=a
if m.count(2)>=m.count(0):
  print("Yes")
elif m.count(0)==0:
  print("Yes")
elif m.count(1)==0 and m.count(2)>=m.count(0)-1:
  print("Yes")
else:
  print("No")
H, W, h, w = (int(i) for i in input().split())

def whiecells(H, W, h, w):
	ans = H * W - (h*W + w*(H-h))
	return ans

print(ans)


### FIXED CODE ###

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

ans = H * W - (h*W + w*(H-h))
print(ans)
X, N = map(int, input().split())
try:
  p = list(map(int, input().split()))
except:
  p = []


l = [0]*X

for i in range(N):
  l[abs(p[i] - X)] += 1

#print(p.index(9))
if N == 0:
  print(X)
else:
  for i in range(N):
    if i == 0:
      if l[0] == 1:
        continue
      else:
        print(X)
        break
    else:
      if l[i] == 0:
        print(X-i)
        break
      elif l[i] == 1:
        try:
          p_index = p.index(X-i)
          print(X+i)
        except:
          print(X-i)
        break

### FIXED CODE ###

X, N = map(int, input().split())
try:
  p = list(map(int, input().split()))
except:
  p = []


l = [0]*200

for i in range(N):
  l[abs(p[i] - X)] += 1

#print(p.index(9))

if N == 0:
  print(X)
else:
  for i in range(N+1):
    if i == 0:
      if l[0] == 1:
        continue
      else:
        print(X)
        break
    else:
      if l[i] == 0:
        print(X-i)
        break
      elif l[i] == 1:
        try:
          p_index = p.index(X-i)
          print(X+i)
        except:
          print(X-i)
        break
import sys
from scipy.sparse.csgraph import dijkstra, csgraph_from_dense, shortest_path
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N = int(readline())
INF = float('inf')
graph = [[INF] * (N + 1) for _ in range(N + 1)]
for i in range(N + 1):
    graph[i][i] = 0

for _ in range(N - 1):
    a, b, c = map(int, readline().split())
    graph[a][b] = c
    graph[b][a] = c

Q, K = map(int, readline().split())
graph = csgraph_from_dense(graph, null_value=INF)
distance = shortest_path(graph, indices=K)

xy = map(int, read().split())
for x, y in zip(xy, xy):
    print(int(distance[x] + distance[y]))

### FIXED CODE ###

import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 6)


def main():
    N = int(readline())
    edge = [[] for _ in range(N + 1)]

    for _ in range(N - 1):
        a, b, c = map(int, readline().split())
        edge[a].append((b, c))
        edge[b].append((a, c))

    Q, K = map(int, readline().split())

    distance = [None] * (N + 1)


    def measure_distance(v, d):
        distance[v] = d
        for vv, dd in edge[v]:
            if distance[vv] is not None:
                continue
            measure_distance(vv, d + dd)


    measure_distance(K, 0)

    xy = map(int, read().split())
    for x, y in zip(xy, xy):
        print(distance[x] + distance[y])


if __name__ == '__main__':
    main()
n=raw_input()
A=map(int,raw_input.split())
q=raw_input()
m=map(int,raw_input.split())

def solve(c, m):
  if m == 0:
    return 1
  if c >= n or sum(A)<m:
    return 0
  res = solve(c + 1, m) or solve(c + 1, m - A[c])
  return res

for i range(0,q):
  if solve(0,m[i])==1:
    print yes
  else:
    print no

### FIXED CODE ###

n=int(raw_input())
A=map(int, raw_input().split())
q=int(raw_input())
m=map(int, raw_input().split())

def solve(j, m):
  if m == 0:
    return 1
  if j >= n or m > sum(A):
    return 0
  res = solve(j + 1, m) or solve(j + 1, m - A[j])
  return res

for i in range(0,q):
  if solve(0,m[i]):
    print "yes"
  else:
    print "no"
ans = 0
for i in range(5):
  if int(input()) == 0:
    ans = i+1
print(ans)  

### FIXED CODE ###

a = list(map(int, input().split()))
for i in range(5):
  if a[i] == 0:
    print(i+1)
N.M = map(int,input().split())
C = [0] * (M+1)
for i in range(N):
    K = list(map(int, input().split()))
    for k in range(len(k)):
        C[K[k]] += 1
count = 0

for c in C:
    if c == N:
        count += 1

print(count)

### FIXED CODE ###

N,M = map(int,input().split())
C = [0] * (M+1)
for i in range(N):
    K = list(map(int, input().split()))
    for k in range(len(K)):
        if k != 0:
            C[K[k]] += 1
count = 0

for c in C:
    if c == N:
        count += 1

print(count)
import sys
input = sys.stdin.readline
h, w, d = map(int, input().split())
a = {}
l = list(range(1, h * w + 1))
for i in range(h):
  for j, x in enumerate(input().split()):
    a[int(x)] = (i, j)
memo = {}
def calc(s):
  tmp = 0
  memo[a[s]] = 0
  for Xc, Xn in zip(l[s::d], l[s+d::d]):
    xc, yc = a[Xc]
    xn, yn = a[Xn]
    tmp += abs(xc - xn) + abs(yc - yn)
    memo[a[Xn]] = tmp
for i in range(d):
  calc(i+1)
for _ in range(int(input())):
  l, r = map(int, input().split())
  print(memo[a[r]] - memo[a[l]])

### FIXED CODE ###

import sys
input = sys.stdin.readline
h, w, d = map(int, input().split())
a = {}
l = list(range(1, h * w + 1))
for i in range(h):
  for j, x in enumerate(input().split()):
    a[int(x)] = (i, j)
memo = {}
def calc(s):
  tmp = 0
  memo[a[s+1]] = 0
  for Xc, Xn in zip(l[s::d], l[s+d::d]):
    xc, yc = a[Xc]
    xn, yn = a[Xn]
    tmp += abs(xc - xn) + abs(yc - yn)
    memo[a[Xn]] = tmp
for i in range(d):
  calc(i)
for _ in range(int(input())):
  l, r = map(int, input().split())
  print(memo[a[r]] - memo[a[l]])
a,b=input().split()
c,c = b.split(".")
print(int(a)*int(b)+int(a)*int(c)//100)

### FIXED CODE ###

from decimal import Decimal
a,b = input().split()
a = Decimal(a)
b = Decimal(b)
print(int(a*b))
X = int(input())
p = 1e9

n = 1
C = [0]
while n**5 < p:
    C.append(n)
    n += 1

for i in C:
    for j in C:
        if i**5 + j**5 == X:
            a, b = i, -j
            break
        elif i**5 - j**5 == X:
            a, b = i, j
            break

print(a, b)

### FIXED CODE ###

X = int(input())

def check():
    for i in range(1000):
        for j in range(1000):
            if i**5 + j**5 == X:
                print(i, -j)
                return
            elif i**5 - j**5 == X:
                print(i, j)
                break

check()
s = input()
dic = {}
flag = False

for key in s:
  if key not in dic:
    dic[key] = 0
  dic[key] += 1

for k, v in dic.items():
  if v >= len(s)/2:
    answ = k
    flag = True
    
if flag == False:
  print(-1, -1)

start = s.find(answ)+1
end = s.rfind(answ)+1
print(start, end)

### FIXED CODE ###

def solve(s):
  for i in range(len(s)-1):
    if s[i] == s[i+1]:
      return '{0} {1}'.format(i+1, i+2)
  for i in range(len(s)-2):
    if s[i] == s[i+2]:
      return '{0} {1}'.format(i+1, i+3)
  return '{0} {1}'.format(-1, -1)

print(solve(input()))
l = map(int ,raw_input().split() )
for i in range(0,1):
  a='Odd'
  if l[i]% 2 = 0:
    a = 'Even'
print(a)


### FIXED CODE ###

a, b = map(int, input().split())
if (a*b) % 2:
    print("Odd")
else:
    print("Even")
n = int(input())
prices = []
for i in range(0,n):
    prices[i] = int(input())

coupon = max(prices) / 2

total = sum(prices) - coupon
print(total)

### FIXED CODE ###

n = int(input())
prices = []
for i in range(0,n):
    prices.append(int(input()))
    
coupon = max(prices) // 2
    
total = sum(prices) - coupon
print(total)
import numpy as np
N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))
A.sort()
A = A[::-1]

# B, Cで出てくる数字全部並べて最後にsortしてAの数だけ取れば良さそう？
D = []
for _ in range(M):
    b, c = map(int, input().split())
    tmp = [c for _ in range(b)]
    D.extend(tmp)
D = np.array(D)
D.sort()
print(D)
print(A)
print(np.maximum(D, A))
print(np.maximum(D, A).sum())


### FIXED CODE ###

import numpy as np
N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))
A.sort()

# B, Cで出てくる数字全部並べて最後にsortしてAの数だけ取れば良さそう？
BC = []
for _ in range(M):
    b, c = map(int, input().split())
    BC.append((b, c))
BC = sorted(BC, key=lambda x: -x[1])

D = []
n = 0
for b, c in BC:
    if n + b >= N:
        while len(D) < N:
            D.append(c)
        break
    else:
        for i in range(b):
            D.append(c)
        n += b

while len(D) < N:
    D.append(0)

print(np.maximum(D, A).sum())
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

N = int(input())
A = np.array([int(x) for x in input().split()],dtype=np.int64)

"""
F_2 上の線形代数。基本変形で簡単な基底を得る。
"""

xor = np.bitwise_xor.reduce(A)

A = np.concatenate([np.array([1<<i for i in range(60) if xor&(1<<i)],np.int64),A])

for k in range(60,-1,-1):
    bit = 1<<k
    one = (A&bit != 0)
    i = np.where(one & (A < (1<<(k+1))))[0]
    if len(i) == 0:
        continue
    i = i[0]
    x = A[i]
    A[one] ^= x
    A[i] = x

A = A[A != 0]
A.sort()
A = A[::-1]

red = np.bitwise_xor.reduce(A)
blue = red^xor
answer = red + blue
print(answer)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

N = int(input())
A = np.array([int(x) for x in input().split()],dtype=np.int64)

"""
F_2 上の線形代数。基本変形で簡単な基底を得る。
"""

xor = np.bitwise_xor.reduce(A)

A = np.concatenate([np.array([1<<i for i in range(60) if xor&(1<<i)],np.int64),A])

for k in range(60,-1,-1):
    bit = 1<<k
    one = (A&bit != 0)
    i = np.where(one & (A < (1<<(k+1))))[0]
    if len(i) == 0:
        continue
    i = i[0]
    x = A[i]
    A[one] ^= x
    A[i] = x

A = A[A != 0]
A.sort()
A = A[::-1]

if len(A) > 0:
	red = np.bitwise_xor.reduce(A)
else:
    red = 0
blue = red^xor
answer = red + blue
print(answer)
import math

N = int(input())
X = list(map(int, input().split()))
cen = sorted(X)[-(sorted(len(X)/2))]
sum = 0
all = True
for a in X:
    sum = sum + a
    for c in X:
            all = False
ans = 0
for b in X:
    ans = ans + (b-cen)**2
if all == True:
    ans = 0
    print(ans)
else:
    print(ans)


### FIXED CODE ###

N = int(input())
X = list(map(int, input().split()))
sum = 0
all = True
for a in X:
    sum = sum + a
C = int(sum / N + 0.5)
ans = 0
for b in X:
    ans = ans + (b-C)**2
print(ans)
n = int(input())
s = [input() for i in range(n)]

l = [s.count(i) for i in s]
d = {i:j for i,j in zip(s, l)}
m = max(l)

d = {i:j for i, j in zip(s, l)}
ans = [i for i in d if d[i] == m]
sorted(ans)

for i in ans:
    print(i)

### FIXED CODE ###

a = {int(i) for i in input().split()}
if len(a) == 2:
    print("Yes")
else:
    print("No")
import math

n = int(input())

ans = 0

while True:
    a = int(math.log(n,9))
    b = int(math.log(n,6))
    if a == b == 0:
        ans += n
        break
    else:
        if 9 ** a >= 6 ** b:
            n -= 9 ** a
            ans += 1
        else:
            n -= 6 ** b
            ans += 1

print(ans)

### FIXED CODE ###

import math

n = int(input())

dp = [float('inf') for _ in range(n+1)]
dp[0] = 0
dp[1] = 1

for i in range(1,n+1):
    tmp = float('inf')
    tmp6, tmp9 = 1,1
    while tmp6 <= i:
        if dp[i-tmp6]+1 < tmp:
            tmp = dp[i-tmp6] + 1
        tmp6 *= 6
    while tmp9 <= i:
        if dp[i-tmp9] + 1 < tmp:
            tmp = dp[i-tmp9] + 1
        tmp9 *= 9
    dp[i] = tmp

'''
    for j in range(int(math.log(i,6))+1):
        if dp[i-6**j]+1 < tmp:
            tmp = dp[i-6**j] + 1
    for j in range(int(math.log(i,9))+1):
        if dp[i-9**j]+1 < tmp:
            tmp = dp[i-9**j]+1
'''
    #dp[i] = tmp

print(dp[n])
import copy

T = input()
copy_T = copy.copy(T)
ans, ans_T = 0, ''

def do_T():
    global ans, ans_T, T
    tmp = T.index('?')

    T = change_T(T, tmp, 'P')
    if '?' in T: do_T()
    if not '?' in T:
        var = T.count('PD') + T.count('D')
        if ans < var: 
            ans_T = copy.copy(T)
            ans = max(ans, var)

    T = change_T(T, tmp, 'D')
    if '?' in T: do_T()
    if not '?' in T:
        var = T.count('PD') + T.count('D')
        if ans < var: 
            ans_T = copy.copy(T)
            ans = max(ans, var)

def change_T(s, index, char):
    var = list(s)
    var[index] = char
    return ''.join(var)

do_T()
print(ans_T)

### FIXED CODE ###

T = input()
print(T.replace('?', 'D'))
from collections import Counter

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

ac = Counter(a)

cur_a = 0
cur_c = 0
res = 0
for a,c in ac.items():
	if c < 2:
		break
	if c >= 4:
		res = max(res,a*a)
	if cur_c == c
		res = max(res,cur_a*a)
		cur_a = max(cur_a,a)
	else:
		cur_a = a
		cur_c = c

print(res)

### FIXED CODE ###

from collections import Counter

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

ac = Counter(a)

cur_a = 0
res = 0
# print(ac)
for a,c in ac.items():
	# print(a,c)
	if c < 2:
		continue
	else:
		res = max(res,cur_a*a)
		cur_a = max(cur_a,a)
		if c >= 4:
			res = max(res,a*a)
	# print(cur_a,res)
print(res)
n = input()
l = list(map(int, input().split()))
 
if l.count(0)+ l.count(1) == len(l):
    print("Yes")
else:
    l1 = l[1:]+[0]
    print(l1)
    d = [i-j for (i,j) in zip(l1, l)][:-1] ##dは差分のリスト
    print(d)
    if -2 in d:
        print("No")
    else:
        s = ''.join(map(str, d)) ## dを文字列にする
        spl = s.split("-1") ##-1でdを区切る
        print(spl)
        if "" not in spl:
            print("Yes")
        else:
            if spl[-1] == "" and spl[-2] != "" and spl[-2] != "0" and "" not in spl[:-1]:
                print("Yes")
            else:
                if "" in spl:
                    print("No")
                else:
                    y = [int(i) for i in spl]
                    print(y)
                    if 0 in y:
                        print("No")
                    else:
                        print("Yes")

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
if n == 1:
    print("Yes")
else:
    l1 = l[1:]+[0]
    d = [i-j for (i,j) in zip(l1, l)][:-1]
    t = [i for i in d if i <= -2]
    if len(t) >= 1:
        print("No")
    else:
        if -1 not in d or d.count(-1)==1:
            print("Yes")
        else:
            p = d.index(-1)
            d = d[p+1:]
            s = ''.join(map(str, d))
            spl = s.split("-1") 
            if "" in spl[:-1]:
                print("No")
            else:
                if spl[-1] == "":
                    spl = [s for s in spl if s != '']
                    y = [int(i) for i in spl]
                    if 0 not in y:
                        print("Yes")
                    else:
                        print("No")
                else:
                    y = [int(i) for i in spl]
                    if 0 in y[:-1]:
                        print("No")
                    else:
                        print("Yes")
N, M = map(int, input().split())
d = dict([list(map(int, input().split()))[::-1] for i in range(N)])
d = sorted(d.items(), key=lambda x: x[1])
c = p = i = 0

while c < M:
    if c + d[i][0] <= M:
        c += d[i][0]
        p += d[i][1] * d[i][0]
        i += 1
    else:
        p += d[i][1] * (M - c)
        print(c)
        break

print(p)


### FIXED CODE ###

N, M = map(int, input().split())
d = [list(map(int, input().split())) for i in range(N)]
d.sort(key=lambda x:(x[0],x[1]))

c = p = i = 0

while c < M:
    if c + d[i][1] <= M:
        c += d[i][1]
        p += d[i][0] * d[i][1]
        i += 1
    else:
        p += d[i][0] * (M - c)
        break

print(p)
def unite(par, i, j):
    j = get_par(par, j)
    par[j] = get_par(par, i)

def get_par(par, p):
    while par[p] != None:
        p = par[p]
    return par[p]

N = int(input())
points = []
edges = []
for i in range(N):
    x,y = map(int, input().split())
    points.append([x,y,i])
points.sort()
for i in range(N-1):
    edges.append((abs(points[i][0] - points[i+1][0]), points[i][2], points[i+1][2]))
points.sort(key=lambda x:x[1])
for i in range(N-1):
    edges.append((abs(points[i][1] - points[i+1][1]), points[i][2], points[i+1][2]))
edges.sort(key=lambda x:x[0], reverse=True)

par = [None] * N
cost = 0
count = 0
points.sort()
while count < N - 1:
    c, i, j = edges.pop()
    if get_par(par, i) == get_par(par, j):
        continue
    unite(points, i, j)
    cost += c
    count += 1
print(cost)


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

def unite(i, j):
    j = get_par(j)
    par[j] = get_par(i)
    return

def get_par(p):
    if par[p] is None:
        return p
    par[p] = get_par(par[p])
    return par[p]

N = int(input())
points = []
edges = []
for i in range(N):
    x,y = map(int, input().split())
    points.append([x,y,i])
points.sort()
for i in range(N-1):
    edges.append((abs(points[i][0] - points[i+1][0]), points[i][2], points[i+1][2]))
points.sort(key=lambda x:x[1])
for i in range(N-1):
    edges.append((abs(points[i][1] - points[i+1][1]), points[i][2], points[i+1][2]))
edges.sort(key=lambda x:x[0], reverse=True)

par = [None] * N
cost = 0
count = 0
points.sort()
while count < N - 1:
    c, i, j = edges.pop()
    if get_par(i) == get_par(j):
        continue
    unite(i, j)
    cost += c
    count += 1
print(cost)
def f(s,t,k):
 n=len(s)
 a=max(t,int(s[0]))
 z=0
 if k>n:z=0
 elif a==0:z=f(s[1:],t,k)
 elif k==1:z=a+(n-1)*9
 else:
  if k-1<=n:z+=f(s[1:],9,k)
  z+=(a-1)*f(s[1:],9,k-1)
  z+=f(s[1:],t,k-1)
 return z
print(f(input(),0,int(input())))


### FIXED CODE ###

def f(s, t, k):
 n = len(s)
 if k > n: return 0
 a = max(t, int(s[0]))
 if a == 0: return f(s[1:], t, k)
 if k == 1: return a + (n - 1) * 9
 z = 0
 if k - 1 <= n: z += f(s[1:], 9, k)
 z += (a - 1) * f(s[1:], 9, k - 1)
 z += f(s[1:], t, k - 1)
 return z

s = input()
k = int(input())
print(f(s, 0, k))
a,b,c,d = map(int, input().split())
print(a*b if a*b > d*c els

### FIXED CODE ###

a,b,c,d = map(int, input().split())
if a*b < c*d:
    a,b = c,d
print(a*b)
w = input()

f = True
for i in renge(len(w)):
  if w.count(w[i]) % 2 == 1:
    print("No")
    f = False
if f:
  print("Yes")

### FIXED CODE ###

w = input()

f = True
for i in range(len(w)):
  if w.count(w[i]) % 2 == 1:
    print("No")
    f = False
    break
if f:
  print("Yes")
a= int(input())
b= int(input())
c= int(input())

if a == b == c:
	print(1)

if (a==b and b!=c) or (b==c and a!=b) or (a==c and b!=a):
	print(2)

else:
	print(3)

### FIXED CODE ###

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

if a == b == c:
    print(1)

elif (a==b and b!=c) or (b==c and a!=b) or (a==c and b!=a):
    print(2)

else:
    print(3)
FUCKOFF

### FIXED CODE ###

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

ans = float('inf')
sum_A = sum(A)
hoge = 0


for i in range(N-1):
  hoge = hoge + A[i]
  ans = min(ans,abs(sum_A - (hoge*2)))

print(ans)
a=int(input())
b=int(input())
c=a*b
print(c)

### FIXED CODE ###

a, b = map(int, input().split())
print(a*b)
# -*- coding: utf-8 -*-

n = int(raw_input())
for i in range(n):
    A, B, C = [], [0], [0]
    A = map(int, raw_input().split())
    for i in range(10):
        if num[i] > A[0]:
            A.insert(0, num[i])
        elif num[i] > B[0]:
            B.insert(0, num[i])
        else:
            break
    if len(A) + len(B) == 12:
        print "YES"
    else:
        print "NO"

### FIXED CODE ###

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

n = int(raw_input())
for i in range(n):
    A, B, C = [], [0], [0]
    A = map(int, raw_input().split())
    for i in range(10):
        if A[i] > B[0]:
            B.insert(0, A[i])
        elif A[i] > C[0]:
            C.insert(0, A[i])
        else:
            break
    if len(B) + len(C) == 12:
        print "YES"
    else:
        print "NO"