Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python3
import sys
from functools import lru_cache

def to_bit(s):
    r = 0
    for i in s:
        r |= 1 << (i - 1)
    return r

def main():
    N, M = map(int, input().split())
    a, c = [], []
    cd = {}
    ALL = (1 << N) - 1
    tall = 0
    FAIL = (10 ** 3) * (10 ** 5) + 1
    for i in range(M):
        t, _ = map(int, input().split())
        a.append(t)
        cc = to_bit(map(int, input().split()))
        c.append(cc)
        tall |= cc
        cd[cc] = min(cd.get(cc, FAIL), t)

    if tall != ALL:
        print(-1)
        return

    @lru_cache(maxsize=None)
    def helper(i, opened):
        if opened == ALL:
            return 0
        if i == M:
            return FAIL
        while opened | c[i] == opened:
            i += 1
            if i == M:
                return FAIL
        return min(a[i] + helper(i + 1, opened | c[i]),
                   helper(i + 1, opened))

    print(helper(0, 0))


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3

def main():
    N, M = map(int, input().split())
    cd = {}
    FAIL = (10 ** 3) * (10 ** 5) + 1
    for _ in range(M):
        ai, _ = map(int, input().split())
        ci = sum(1 << (int(i) - 1) for i in input().split())
        keys = list(cd.keys())
        for i in keys:
            cd[i | ci] = min(cd.get(i | ci, FAIL), cd[i] + ai)
        cd[ci] = min(cd.get(ci, FAIL), ai)
    print(cd.get((1 << N) - 1, -1))


if __name__ == '__main__':
    main()
array = input().split()
if (int(array[0]) > int(array[1]) and int(array[1]) > int(array[2]):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

#
# 2b
#

def main():
    a, b, c = map(int, input().split())
    if a < b < c:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
from collections import Counter, defaultdict

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

memo = defaultdict(int)
for d in D:
    memo[d] += 1

for i in range(m):
    ti = T[i]
    if ti not in memo:
        print("NO")
        exit()
    if memo[ti] == 0:
        print("NO")
        exit()
    memo[ti] -= 1

print("YES")

### FIXED CODE ###

from collections import Counter, defaultdict

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

memo = defaultdict(int)
for d in D:
    memo[d] += 1

for i in range(M):
    ti = T[i]
    if ti not in memo:
        print("NO")
        exit()
    if memo[ti] == 0:
        print("NO")
        exit()
    memo[ti] -= 1

print("YES")
N, K = map(int, input().split())
dic = {}
ans = []
uniq = []
etc = []
def calc_ans(ans):
    x = 0
    tmp = 0
    for i in range(K):
      tmp += ans[i][0]
      x += ans[i][1]
    return tmp + (x * x)

for i in range(N):
    l = list(map(int, input().split()))
    if dic.get(l[0]):
        dic[l[0]].append(l[1])
    else:
        dic[l[0]] = [l[1]]
if N <= K:
    ans = 0
    for i in dic.keys():
        ans += sum(dic[i])
    ans += len(dic.keys()) * len(dic.keys())
    print(ans)
    exit()
for t in dic.keys():
    dic[t].sort(reverse=True)
    uniq.append((dic[t][0], t))
uniq.sort(reverse=True)
for i in range(K):
  ans.append((uniq[i][0], 1))
  for n in dic[uniq[i][1]][1:]:
      if n <= uniq[K-1][0]:
          break
      etc.append((n, 0))
etc.sort(reverse=True)
ans_res = calc_ans(ans)
for n in etc:
    ans[-1] = n
    tmp_res = calc_ans(ans)
    if ans_res > tmp_res:
        print(ans_res)
        exit()
    else:
        ans_res = tmp_res
        ans.sorted(reverse=True)
print(ans_res)

### FIXED CODE ###

N,K = map(int,input().split())
td = [[int(i) for i in input().split()] for _ in range(N)]
td.sort(key=lambda x:x[1],reverse=True)
ans = 0
ls = set()
dl = []
for i in range(K):
    ans += td[i][1]
    if not td[i][0] in ls:
        ls.add(td[i][0])
    else:
        dl.append(td[i][1])
ans = ans + len(ls)**2
res = ans
for i in range(K,N):
    if not dl:
        break
    if td[i][0] in ls:
        continue
    ans += len(ls)*2+1
    ans += td[i][1]
    ans -= dl[-1]
    del dl[-1]
    res = max(res,ans)
    ls.add(td[i][0])
print(res)
import numpy as np
from numpy.compat import long

n = int(input())
a = list(map(long ,input().split()))
p = np.prod(a)

if len(str(p))>=19:
    print("-1")
else:
    print(p)

### FIXED CODE ###

a,b = map(int ,input().split())
print(a*b)
n=int(inptu())
l=[int(i) for i in input().split()]
f=[0 for i in range(n)]
s=set(l)
for i in s:
  f[i-1]=l.count(i)
print(*f)

### FIXED CODE ###

n=int(input())

f=[0 for i in range(n)]
for i in input().split():
  f[int(i)-1]+=1
print(*f)
a,b=map(int,input())

e=0
t=0

for i in range(1,100):
	if a<=i*0.08<a+1:
		e=i
	if b<=i*0.1<b+1:
		t=i
	if e==t:
		print(e)
        
print(-1)

### FIXED CODE ###

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

for i in range(2000):
    if int(i * 0.08) == A and int(i * 0.1) == B:
        print(i)
        exit()
print(-1)
def bellman_ford(n, edges, s, distance=None):
    if distance != None:
        d = distance.copy()
    else :
        d = [float('inf')] * n
        d[s] = 0
    
    loop_cnt = 0
    while True:
        loop_cnt += 1
        update = False
        for i in range(len(edges)):
            e = edges[i]
            if d[e[0]] != float('inf') and d[e[1]] > d[e[0]] + e[2]:
                d[e[1]] = d[e[0]] + e[2]
                update = True

        if not update or loop_cnt > n: break
    return d

n, m = map(int, input().split())
edges = []
for _ in range(m):
    a, b, c = map(int, input().split())
    edges.append((a-1, b-1, -c))

dist = bellman_ford(n, edges, 0)
test = bellman_ford(n, edges, 0, dist)

if dist[n-1] != test[n-1]:
    print("inf")
else :
    print(-dist[n-1])

### FIXED CODE ###

def bellman_ford(n, edges, s, distance=None):
    if distance != None:
        d = distance[:]
    else :
        d = [float('inf')] * n
        d[s] = 0
    
    loop_cnt = 0
    while True:
        loop_cnt += 1
        update = False
        for i in range(len(edges)):
            e = edges[i]
            if d[e[0]] != float('inf') and d[e[1]] > d[e[0]] + e[2]:
                d[e[1]] = d[e[0]] + e[2]
                update = True

        if not update or loop_cnt > n: break
    return d

n, m = map(int, input().split())
edges = []
for _ in range(m):
    a, b, c = map(int, input().split())
    edges.append((a-1, b-1, -c))

dist = bellman_ford(n, edges, 0)
test = bellman_ford(n, edges, 0, dist)

if dist[n-1] != test[n-1]:
    print("inf")
else :
    print(-dist[n-1])
N = int(input())
mochi = []
for i in range(N):
  a = int(input())
  if not a in mochi:
    mochi.append(a)
    
mochi.sorted()
print(len(mochi))

### FIXED CODE ###

N = int(input())
mochi = []
for i in range(N):
  a = int(input())
  if not a in mochi:
    mochi.append(a)
    
mochi.sort()
print(len(mochi))
import collections
import math
a, b = input().split()
A = int(a)
B = int(b)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


GCB = math.gcd(A, B)

C = collections.Counter(prime_factorize(GCB))

print(len(C) + 1)



### FIXED CODE ###

import collections
import fractions
a, b = input().split()
A = int(a)
B = int(b)


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


GCB = fractions.gcd(A, B)

C = collections.Counter(prime_factorize(GCB))

print(len(C) + 1)
a, b = map(int(input().split()))
if b % a == 0:
    print(a+b)
else:
    print(b-a)

### FIXED CODE ###

a, b = map(int, input().split())
if b % a == 0:
    print(a+b)
else:
    print(b-a)
n,x=map(int,input().split())
d=0
cnt=0
l=list(map(int,input().split()))
while(d<=x):
  cnt+=1
  d+=l[cnt-1]
  if cnt>n+1:
    cnt=n+1
    break
print(cnt)

### FIXED CODE ###

n,x=map(int,input().split())
d=0
cnt=0
l=list(map(int,input().split()))
while(d<=x):
  cnt+=1
  if cnt==n+1:
    break
  d+=l[cnt-1]
print(cnt)
import numpy as np

H, W, M = map(int, input().split())
h_t = [0]*H
w_t = [0]*W
t = np.zeros((H, W))
for i in range(M):
    h, w = map(int, input().split())
    t[h-1][w-1] = 1
    h_t[h-1]+=1
    w_t[w-1]+=1
h_max = max(h_t)
h_max_list = [i for i, v in enumerate(h_t) if v == h_max]
w_max = max(w_t)
w_max_list = [i for i, v in enumerate(w_t) if v == w_max]

for h in h_max_list:
    for w in w_max_list:
        if t[h][w] == 0:
            print(h_max + w_max)
            exit()
print(h_max + w_max - 1)

### FIXED CODE ###

import numpy as np

H, W, M = map(int, input().split())
h_t = [0]*H
w_t = [0]*W
t = {}
for i in range(M):
    h, w = map(int, input().split())
    t[(h-1, w-1)] = 1
    h_t[h-1]+=1
    w_t[w-1]+=1
h_max = max(h_t)
h_max_list = [i for i in range(len(h_t)) if h_t[i] == h_max]
w_max = max(w_t)
w_max_list = [i for i in range(len(w_t)) if w_t[i] == w_max]

for h in h_max_list:
    for w in w_max_list:
        if (h, w) not in t:
            print(h_max + w_max)
            exit()
print(h_max + w_max - 1)
# coding:utf-8

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

def kaijo(n):
    if n==1:
        return 1
    return n*kaijo(n-1)

# 引数として、nかmのうちの小さい方の数字を受け取る
def count(n,m):
    return kaijo(n)*kaijo(m)

if n-m==-1 or n-m==1:
    result=count(n,m)
    amari=result%(10**9+7)
    print amari
elif n-m==0:
    result=count(n,m)
    result*=2
    amari=result%(10**9+7)
    print amari
else:
    print "0"

### FIXED CODE ###

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

mod=10**9+7

def kaijo(n):
    result=1
    for i in range(2,n+1):
        result*=i
        if result>mod:
            result=result%mod
    return result
    
def count(n,m):
    return kaijo(n)*kaijo(m)

if n-m==-1 or n-m==1:
    result=count(n,m)
    amari=result%mod
    print amari
elif n-m==0:
    result=count(n,m)
    result*=2
    amari=result%mod
    print amari
else:
    print 0
import sys
S = input()
S = S.split("er")



for s in S:
    if s not in {'asedream', 'dream', 'as'}:
        if s != '':
            print("NO")
            sys.exit()
    else:
        flag = False
    if s == "":
        if flag:
            print("NO")
            sys.exit()
        flag = True

print("YES")


### FIXED CODE ###

import sys
S = input()[::-1]
ls = ["maerd", "remaerd", "esare", "resare"]
n = 0
while n != len(S):
    flag = False
    for i in ls:
        tmp_n = len(i)
        if S[n:n+tmp_n] == i:
            n += len(i)
            flag = True
            break
    if not flag:
        print("NO")
        sys.exit()
print("YES")
a = list(map(int,input().split()))
if a[0] <=8 and a[1] <=8:
  print("Yay!")
else:
  print(:()

### FIXED CODE ###

a = list(map(int,input().split()))
if a[0] <=8 and a[1] <=8:
  print("Yay!")
else:
  print(":(")
x,y=input().split()
if x=="A":
    x=10
if x=="B":
    X=11
if x=="C":
    x=12
if x=="D":
    x=13
if x=="E":
    x=14
if x=="F":
    x=15
if y=="A":
    y=10
if y=="B":
    y=11
if y=="C":
    y=12
if y=="D":
    y=13
if y=="E":
    y=14
if y=="F":
    y=15
if x<y:
    print("<")
elif x>y:
    print(">")
elif x==y:
    print("=")

### FIXED CODE ###

x,y=input().split()
lis=["A","B","C","D","E","F"]
for i in range(6):
    if x==lis[i]:x=i+10
    if y==lis[i]:y=i+10
if x<y:print("<")
elif x>y:print(">")
elif x==y:print("=")
a,b,c=[int(i) for i in input().split()]                                                                  2 flag=(abs(b-c)%2)==0

if flag:
	print("Alice")
else:
	print("Borys")

### FIXED CODE ###

a,b,c=[int(i) for i in input().split()]
if abs(b-c)%2==0:
	print("Alice")
else:
	print("Borys")
P  = 0
if A > B:
  P = A
else:
  P = B
if C > D:
  P = P + C
else:
  P = P + D
  
print(P)

### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
D = int(input())

print(min(A,B)+min(C,D))
n, m = [int(x) for x in input().split()]
nac = 0
nwa = 0
past_ac = {}
for i in range(m):
    p, s = [x for x in input().split()]
    d = p + s
    if (p + 'AC') in past_ac:
        next
    else:
        if s == 'WA':
            past_ac[d] = 1 if d not in past_ac else past_ac[d] + 1
        else:
            past_ac[d] = 1
            nac += 1
            nwa += past_ac[p + 'WA']
print(nac, nwa)

### FIXED CODE ###

n, m = [int(x) for x in input().split()]
nac = 0
nwa = 0
past = {}
for i in range(m):
    p, s = [x for x in input().split()]
    d = p + s
    if (p + 'AC') in past:
        next
    else:
        if s == 'WA':
            past[d] = 1 if d not in past else past[d] + 1
        else:
            past[d] = 1
            nac += 1
            nwa += 0 if (p + 'WA') not in past else past[p + 'WA']
print(nac, nwa)
[N,L] = [int(x) for x in input().split()]
A = {}
ANS = {}
count = 0
for i,x in enumerate(input().split()):
    i = int(i)
    x = int(x)
    if x in A : A[x] += [i]
    else : A[x] = [i]
for i in sorted(A) :
    for j in A[i] :
        for k in range(L) :
            if j + k not in ANS :
                ANS[j+k] = i
                count += 1
    if count > N + 2 : break

if L == 1 :
    for i in range(L-1,N-1) : print(ANS[i], end=" ")
    print(ANS[N-1])
else :
    for i in range(L-1,N-1) : print(ANS[i], end=" ")
    print(ANS[N-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
n,m=map(int,input().split())
s=[0]*n
t=[0]*n
for i in range(m):
    a,b=map(str,input().split())
    a,
    a=int(a)-1
    if not s[a]:
        if b=="WA":
            t[a]+=1
        else:
            s[a]=1
print(sum(s),sum(t[i] for i in range(n)if s[a]))

### FIXED CODE ###

n,m=map(int,input().split())
s=[0]*n
t=[0]*n
for i in range(m):
    a,b=map(str,input().split())
    a,
    a=int(a)-1
    if not s[a]:
        if b=="WA":
            t[a]+=1
        else:
            s[a]=1
print(sum(s),sum(t[i] for i in range(n)if s[i]))
A, B, C, D = map(int, input().split())
value = min(B, D) - max(A, C)
print(value if value > 0 else "0")



### FIXED CODE ###

# list: ソート済配列
# n: 参照番号
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a*b//gcd(a, b)

N = int(input())
T = [int(input()) for i in range(N)]
ans = 1

for i in range(N):
    ans = lcm(ans, T[i])

print(ans)
N, K = map(int, input().split())
S = list(input())
S[K] = S[K].lower()
print(S[i] for i in range(N))

### FIXED CODE ###

N, K = map(int, input().split())
S = list(input())
S[K -1] = S[K - 1].lower()
print(''.join(S))
n = int(input())
l = list(map(int, input().split()))
freq = [0] * (10**5 + 5)
for i in l: freq[i] -= -1
count = 0
for i in range(10**5 + 5):
    if freq[i] >= 2:
        temp = (freq[i] * (freq[i] - 1)) // 2
        count += temp
for i in l:
    if freq[i] == 1: print(count)
    else:
        temp = freq[i] - 1
        if temp == 1: print(count - 1)
        else:
            yoyo = ((freq[i] * (freq[i] - 1)) // 2) - ((temp * (temp - 1)) // 2)
            print(count - yoyo)

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
freq = [0] * (2 * (10**5) + 5)
for i in l: freq[i] -= -1
count = 0
for i in range(2 * (10**5) + 5):
    if freq[i] >= 2:
        temp = (freq[i] * (freq[i] - 1)) // 2
        count += temp
for i in l:
    if freq[i] == 1: print(count)
    else:
        temp = freq[i] - 1
        if temp == 1: print(count - 1)
        else:
            yoyo = ((freq[i] * (freq[i] - 1)) // 2) - ((temp * (temp - 1)) // 2)
            print(count - yoyo)
import sys
input = sys.stdin.readline
import bisect
n,m = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
#Query = []
#for _ in range(m):
#    b,c = map(int,input().split())
#    Query.append([c,b])
#Query.sort(reverse=True)
Query = [list(map(int,input().split())) for _ in range(m)]
Query = sorted(Query, key=lambda x:(x[1], x[0]), reverse=True)
ans = 0
for b,c in Query:
    #b,c = Query[i][1],Query[i][0]
    #b,c = Query[i][0],Query[i][1]
    if A[0] >= c:
        break
    else:
        #A.sort()
        index = bisect.bisect_left(A,c)
        ans += sum(A[index:])
        if b <= index:
            #for i in range(b):
            #    A[i] = c
            A = A[b:index].extend([c for i in range(b)])
        else:
            #for i in range(index):
            #    A[i] = c
            A = [ c for i in range(index)]
    #print(A)
print(ans + sum(A))

### FIXED CODE ###

a,b = map(int,input().split())
if a >= 13:
    ans = b
elif 6 <= a <= 12:
    ans = b//2
else:
    ans = 0
print(ans)
import sys
K = int(input())
A, B = map(int, input().split())

for i in range(1000):
    s = K * i
    if A <= s <= B:
        print("OK")
        sys.exit()
print("NG")

### FIXED CODE ###

X = int(input())
x = 100
i = 0
while x < X:
    x += x//100 
    i += 1

print(i)
c = input()

if c == "a" or c == "i" or c == "u" ro c == "e" or c == "o":
  print("vowel")
else:
  print("consonant")

### FIXED CODE ###

c = input()

if c == "a" or c == "i" or c == "u" or c == "e" or c == "o":
  print("vowel")
else:
  print("consonant")
N = int(input())
a = list(map(int,input().split()))
count = N
for i in range(N):
	for j in range(N):
		if a[i]%a[j] ==0 and i!= j:
			count = count -1
			break
print(count)

### FIXED CODE ###

x = list(map(int,input().split()))
print(x.index(0)+1)
n = int(input())

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

m = int(input())

drink_num_time = []
drink_time = []

for i in range(m):
    drink_num_time.append(list(map(int,input().split())))

normal_time = sum(time_list)


for i in range(m):
    drink_time.append(normal_time+drink_num_time[i][1]-time_list[i])

for i in range(m):
    print(drink_time[i])


### FIXED CODE ###

n = int(input())

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

m = int(input())

drink_num_time = []
drink_time = []

for i in range(m):
    drink_num_time.append(list(map(int,input().split())))

normal_time = sum(time_list)


for i in range(m):
    drink_time.append(normal_time+drink_num_time[i][1]-time_list[(drink_num_time[i][0])-1])

for i in range(m):
    print(drink_time[i])
W,H,x,y =map(int ,raw_input().split())
i = 0
if x*2 == W and y +2 ==H:
    i = 1
print float(W*H)/2,i

### FIXED CODE ###

W,H,x,y =map(int ,raw_input().split())
i = 0
if x*2 == W and y*2 ==H:
    i = 1
print float(W*H)/2,i
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]

INF = 10 ** 9


def dfs(cursor, a, b, c):  # cursor:カーソル a,b,c:現在の竹の長さ
    if cursor == N:  # cursorが最後まで行ったら終了する。
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) &gt; 0 else INF
    # abs(a - A) + abs(b - B) + abs(c - C) - 30 でなぜ30を減じているのかというと、
    # dfs(0,0,0)
    # dfs(0,0,0,0)で始まる以上、最初に選ばれるa,b,cを決定する際にもコストが10増加してしまうからである。
    # また、全探索を行う中で、a,b,cの初期値が0,0,0である以上、a,b,cのどれかが0のまま終了する場合が存在する。
    # この場合はa,b,cに竹が対応してないと言えるため、解にはならない、そこで三項演算子を利用して
    # その場合についてコストをINFとしている

    # 以下は4**Nで展開される再起処理となる。
    # カーソルの当たっている竹に対して、(A or B or Cに合成する) or (合成しない)の場合に分ける
    no_compound_pattern = dfs(cursor+1, a, b, c)
    compound_a_pattern = dfs(cursor+1, a + L[cursor], b, c)+10
    compound_b_pattern = dfs(cursor+1, a, b + L[cursor], c)+10
    compound_c_pattern = dfs(cursor+1, a, b, c + L[cursor])+10

    # 結果的に以下の値が返るのはそれぞれのパターンのコストが決定されてからなので
    # 以下のコードは最終的なコストの最小値
    return min(no_compound_pattern, compound_a_pattern, compound_b_pattern, compound_c_pattern)


print(dfs(0, 0, 0, 0))


### FIXED CODE ###

N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]

INF = 10 ** 9

def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))
N=int(input())
K=int(input())

n=str(N)
n_digi=len(n)

import math

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)


if n_digi < K:
    print(0)

else:
    ans=0
    
    if n_digi>K:
        ans += permutations_count(n_digi-1,K)*9
    
    keta1=int(n[0])
    nokori=n[1:]
    
    if keta1 != 1 and K!=1:
        ans += (keta1-1)*ermutations_count(n_digi-2,K-1)*9
        
    elif keta1 != 1 and K==1:
        ans += (keta1-1)
        
    elif K==1 and int(nokori)==0:
        ans += 1
        
    else:
        noko_list = list(nokori)
        aa=1
        bb=sum(noko_list)
        for j in noko_list:
            aa *=j
             
        ans += aa-bb*(K-1)
        
            
        




### FIXED CODE ###

from functools import lru_cache

N=int(input())
K=int(input())
 
@lru_cache(None)
def F(N, K):
    """N以下で0でないものがちょうどK個。0を含める"""
#     assert N >= 0
    if N < 10:
        if K == 0:
            return 1
        if K == 1:
            return N
        return 0
    q,r = divmod(N,10)
    ret = 0
    if K >= 1:
        # 1の位が nonzero
        ret += F(q, K-1) * r
        ret += F(q-1, K-1) * (9-r)
    # 1の位が zero
    ret += F(q, K)
    return ret
 
# F(100, 1), F(25, 2), F(314159, 2)
 
print(F(N, K))
n,m = map(int,input().split())
a = list(range(m+2))
a[0] = -1
a[m+1] = n+1
ans = 1
for i in range(m):
  a[i+1] = int(input())
for i in range(m+1):
  if a[i]+1 == a[i+1]:
    ans = 0
  else:
    x = a[i+1]-a[i]-1
    ans = int(ans * 1/(5**0.5) * (((1+(5**0.5))/2)**x - ((1-(5**0.5))/2)**x))%1000000007

if m == 0:
    x = a[m+1]-a[i]-1
    ans = int(1/(5**0.5) * (((1+(5**0.5))/2)**x - ((1-(5**0.5))/2)**x))%1000000007

print(ans)


### FIXED CODE ###

n,m = map(int,input().split())
b = [] 
for i in range(n+1):
  if i == 0 or i == 1:
    b.append(1)
  else:
    b.append(b[i-2]+b[i-1])

ans = 1
if m != 0:
  a = list(range(m))
  for i in range(m):
    a[i] = int(input())
    if i == 0:
      ans = ans*b[a[i]-1]%1000000007
    else:
      if a[i] == a[i-1]+1:
        ans = 0
      else:
        ans = ans*b[a[i]-a[i-1]-2]%1000000007
  ans = ans*b[n-a[m-1]-1]%1000000007
  print(ans)
else:
  print(b[n]%1000000007)
N,M = map(int,inuput().split())
A = list(map(int,input().split()))

total = 0
for i in range(M):
  total += A[i]
  
if N - total >= 0:
  print(N - total)
  
else:
  print("-1")

### FIXED CODE ###

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

total = 0
for i in range(M):
  total += A[i]
  
if N - total >= 0:
  print(N - total)
  
else:
  print("-1")
a = input()
b = input()
s = a*b
l = 2*a + 2*b
print(s,l)

### FIXED CODE ###

a,b = map( int,raw_input().split() )
print a*b, 2*(a+b)
N = int(input())
S = list(map(int, input().split()))

S.sort()

parent = [S.pop()]
rest = S
for _ in range(N):
	n_parent = []
	n_rest = []

	for p in parent[::-1]:
		while rest:
			x = rest.pop()
			if x < p:
				next_parent.append(x)
				break
			else:
				next_rest.append(x)
	parent += next_parent
	parent.sort()
	rest = rest + next_rest[::-1]

if len(parent) == (2**N):
	pritn("Yes")
else:
	print('No')



### FIXED CODE ###

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

S.sort()

parent = [S.pop()]
rest = S
for _ in range(N):
	n_parent = []
	n_rest = []

	for p in parent[::-1]:
		while rest:
			x = rest.pop()
			if x < p:
				n_parent.append(x)
				break
			else:
				n_rest.append(x)
	parent += n_parent
	parent.sort()
	rest = rest + n_rest[::-1]

if len(parent) == (2**N):
	print("Yes")
else:
	print('No')
x, y = map(int, input().split())
while x > 0 :
    x, y = y, x % y
print(x)

### FIXED CODE ###

x, y = map(int, input().split())
while y > 0 :
    x, y = y, x % y
print(x)