Harryxun/stf_run huggingface dataset:
def move(move_count, current, flag):
    for i in range(move_count):
        n_lis.append(num_lis[current+i])
        if flag == n:
            calculate()
            del n_lis[-1]
        else:
            move(move_count, current+i+1, flag+1)
            move_count -= 1
            del n_lis[-1]
            
def calculate():
    print n_lis
    global count
    if sum(n_lis) == s:
        count += 1

while True:
    n, s = map(int, raw_input().split())
    if n == 0 and s == 0:
        break
    num_lis = [0,1,2,3,4,5,6,7,8,9]
    n_lis = []
    count = 0
    move(8,0,1)
    print count

### FIXED CODE ###

def move(move_count, current, flag):
    for i in range(move_count):
        n_lis.append(num_lis[current+i])
        if flag == n:
            calculate()
            del n_lis[-1]
        else:
            move(move_count, current+i+1, flag+1)
            move_count -= 1
            del n_lis[-1]
            
def calculate():
    global count
    if sum(n_lis) == s:
        count += 1

while True:
    n, s = map(int, raw_input().split())
    if n == 0 and s == 0:
        break
    num_lis = [0,1,2,3,4,5,6,7,8,9]
    n_lis = []
    count = 0
    move(10-n+1,0,1)
    print count
h = list(map(int, input().split()))

h.sort()
h.reverse()

print(sum(h[k:]))

### FIXED CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))

h = sorted(h)

h.reverse()

print(sum(h[k:]))
# modular inverse for positive a and b and nCk mod MOD depending on modinv

def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

MOD = 10 ** 9 + 7

N,K = map(int,input().split())

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

Combination = []

for i in range(N):
    if i < K:
        Combination.append(0)
    elif i == K:
        Combination.append(1)
    else:
        Combination.append(Combination[-1] * i * modinv(i - K + 1) % MOD)

ans = 0

for i in range(N):
    ans += a[i] * Combination[i]
    ans -= a[i] * Combination[N - i - 1]
    ans %= MOD

print(ans)

### FIXED CODE ###

# modular inverse for positive a and b and nCk mod MOD depending on modinv

def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

MOD = 10 ** 9 + 7

N,K = map(int,input().split())

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

Combination = []

for i in range(N):
    if i < K - 1:
        Combination.append(0)
    elif i == K - 1:
        Combination.append(1)
    else:
        Combination.append(Combination[-1] * i * modinv(i - K + 1, MOD) % MOD)

        
ans = 0

for i in range(N):
    ans += a[i] * Combination[i]
    ans -= a[i] * Combination[N - i - 1]
    ans %= MOD

print(ans)
= int(input())

print(N * 800 - ((N // 15) * 200))

### FIXED CODE ###

N = int(input())

print(N * 800 - ((N // 15) * 200))
s, t = input().split()
a, b = map(int, input().split())
u = input()
 
if u == s:
  print(s-1,t)
elif u == t:
  print(s, t-1)

### FIXED CODE ###

s, t = input().split()
a, b = map(int, input().split())
u = input()
 
if u == s:
  print(a-1,b)
elif u == t:
  print(a, b-1)
A, B = map(int, input().split())
print( max(A+B A-B, A*B))

### FIXED CODE ###

A, B = map(int, input().split())
print( max(A+B, A-B, A*B))
# -*- coding utf-8 -*-

a,b,x=map(int,input().split())
ans=0

for i in range(a,b+1):
    if i%x==0:
        ans+=1
    else:
        pass
print(ans)


### FIXED CODE ###

# -*- coding utf-8 -*-

x,y,z =list(map(str,input().split()))

print(x[0].upper() + y[0].upper() + z[0].upper())
s=input()
K=int(input())

ans=[]
ans.append(s)
count=0


for i in range(len(s)-1):
 for j in range(i+1):
  cut_s=s[j:j+len(s)-i-1]
  if cut_s not in ans:
   ans.append(cut_s)
    
ans.sort()

answer=ans[K-1]
print(answer)

### FIXED CODE ###

s=input()
K=int(input())
 
ans=[]
ans.append(s)
 
 
for i in range(len(s)):
 for j in range(len(s)-i):
  cut_s=s[i:i+j+1]
  ans.append(cut_s)
  ans=sorted(set(ans))
  if len(ans)>K:
   if cut_s==ans[K]:
     ans.pop()
     break;
   ans.pop()
 
answer=ans[K-1]
print(answer)
n = int(input())
v = list(map(int, input().split()))

v.sort()

mean = v[0]
for i in v:
  mean = (mean + v)/2

  
print(mean)

### FIXED CODE ###

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

v.sort()

mean = v[0]
for i in v:
  mean = (mean + i)/2

  
print(mean)
a,b,c,d = map(int, '1222'.split())

if a + b + c + d == 7:
    print('{a}+{b}+{c}+{d}=7'.format(a,b,c,d))
elif a + b + c - d == 7:
    print('{a}+{b}+{c}-{d}=7'.format(a,b,c,d))
elif a + b - c + d == 7:
    print('{a}+{b}-{c}+{d}=7'.format(a,b,c,d))
elif a + b - c - d == 7:
    print('{a}+{b}-{c}-{d}=7'.format(a,b,c,d))
elif a - b + c + d == 7:    
    print('{a}-{b}+{c}+{d}=7'.format(a,b,c,d))
elif a - b + c - d == 7:       
    print('{a}-{b}+{c}-{d}=7'.format(a,b,c,d))
elif a - b - c + d == 7:     
    print('{a}-{b}-{c}+{d}=7'.format(a,b,c,d))
elif a - b - c - d == 7:    
    print('{a}-{b}-{c}-{d}=7'.format(a,b,c,d))

### FIXED CODE ###

a,b,c,d = map(int, list(input()))

if a + b + c + d == 7:
    print('{}+{}+{}+{}=7'.format(a,b,c,d))
elif a + b + c - d == 7:
    print('{}+{}+{}-{}=7'.format(a,b,c,d))
elif a + b - c + d == 7:
    print('{}+{}-{}+{}=7'.format(a,b,c,d))
elif a + b - c - d == 7:
    print('{}+{}-{}-{}=7'.format(a,b,c,d))
elif a - b + c + d == 7:    
    print('{}-{}+{}+{}=7'.format(a,b,c,d))
elif a - b + c - d == 7:       
    print('{}-{}+{}-{}=7'.format(a,b,c,d))
elif a - b - c + d == 7:     
    print('{}-{}-{}+{}=7'.format(a,b,c,d))
elif a - b - c - d == 7:    
    print('{}-{}-{}-{}=7'.format(a,b,c,d))
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(n)]
cnt = 0

for l in a:
    tmp = 0
    for i in range(m):
        tmp += b[i]*a[i]
    tmp += c
    if tmp > 0:
        cnt += 1

print(cnt)

### FIXED CODE ###

n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(n)]
cnt = 0

for l in a:
    tmp = 0
    for i in range(m):
        tmp += b[i]*l[i]
    tmp += c
    if tmp > 0:
        cnt += 1

print(cnt)
nums = []
val = []
ans = []

while True:
	try:
		nums.append(int(raw_input()))
	break:
		num_list = sorted(list(set(nums)))
		for n in num_list:
			val.append(nums.count(n))
		ans.append(num_list[val.index(max(val))])
		tmp = max(val)
		val.remove(max(val))
		num_list.pop(val.index(tmp))
		while max(val) == tmp:
			ans.append(num_list[val.index(max(val))])
			num_list.pop(val.index(tmp))
			val.remove(max(val))
		for s in ans:
			print s

### FIXED CODE ###

nums = []
val = []
ans = []

while True:
	try:
		nums.append(int(raw_input()))
	except EOFError:
		num_list = sorted(list(set(nums)))
		for n in num_list:
			val.append(nums.count(n))
		ans.append(num_list[val.index(max(val))])
		tmp = max(val)
		val.remove(max(val))
		num_list.pop(val.index(tmp))
		while max(val) == tmp:
			ans.append(num_list[val.index(max(val))])
			num_list.pop(val.index(tmp))
			val.remove(max(val))
		for s in ans:
			print s
		break
A, B = map(int, input().split)
print(A*B)

### FIXED CODE ###

A, B = map(int, input().split())
print(A*B)
N=int(input())
li = list(map(int,input().split()))	
num = {}
for l in li:
    print(num)
    if str(l) not in num  :
        num[l] = 1
    else:
        print("NO")
        break
else:
    print("YES")



### FIXED CODE ###

N=int(input())
li = list(map(int,input().split()))	
num = {}
for l in li:
    if str(l) not in num :
        num[str(l)] = 1
    elif num[str(l)]==1:
        print("NO")
        break
else:
    print("YES")
X,Y,Z,K=map(int,input().split())

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

r=[]
out=[]

for i in range(X):
    for j in range(Y):
        r.append(A[i]+B[j])

r.sort(reverse=True)

for i in range(K):
    for j in range(Z):
        out.append(r[i]+C[j])

out.sort(reverse=True)

for i in range(K):
    print(out[i])


### FIXED CODE ###

X,Y,Z,K=map(int,input().split())
     
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
     
r=[]
out=[]
     
for i in range(X):
    for j in range(Y):
        r.append(A[i]+B[j])
     
r.sort(reverse=True)
     
if len(r)>K:
    for i in range(K):
        for j in range(Z):
            out.append(r[i]+C[j])
else:
    for i in range(len(r)):
        for j in range(Z):
           out.append(r[i]+C[j])
     
out.sort(reverse=True)
     
for i in range(K):
    print(out[i])
import math
while 1:
	n = int(raw_input())
	if n == 0:
		break
	count = 0
	for p in range(n+1,2*n+1):
		for d in range(2, int(math.sqrt(p)) + 1):
			if p != d and p % d == 0:
				break
		else:
			count += 1
	print count

### FIXED CODE ###

import math
MAX = 123456
def sieve (n):
	prime = [0,0]
	prime += [1 for i in range(n-1)]
	ub = math.sqrt(n) + 1
	d = 2
	while d <= ub:
		if prime[d] == 0:
			d += 1
			continue
		prod = 2
		while d * prod <= n:
			prime[d*prod] = 0
			prod += 1
		d += 1
	return prime
prime = sieve(2 * MAX)
while 1:
	n = int(raw_input())
	if n == 0:
		break
	print sum(prime[n+1:2*n+1])
N = int(input())

if N == 1:
    print(Hello World)
else:
    AB = int(input()) for _ in range(2):
    print(sum(AB))


### FIXED CODE ###

N = int(input())

if N == 1:
    print('Hello World')
else:
    AB = [int(input()) for _ in range(2)]
    print(sum(AB))
n = int(input())
total = 0
for i in range(len(str(n))):
  total += str(n)[i]
if N%total == 0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n = int(input())
total = 0
for i in range(len(str(n))):
  total += int(str(n)[i])
if n%total == 0:
  print('Yes')
else:
  print('No')
from collections import deque

D = deque(map(int,input()))

leading_zeros = 0
while D[-1] == 0:
  D.pop()
  leading_zeros += 1

# (10-x) ways: (0,x)-(9-x,9) -> (-x, x)
# (x) ways:    (10-x,0)-(9,x-1) -> (10-x, -10 + x)

def solve(D):
  r = 1
  while len(D) > 1:
    h,t = D.popleft(), D.pop()
    c = h + t

    if -1 <= c <= 0:
      r *= 10-t
      D[0] += c*10
    elif 9 <= c <= 10:
      r *= t
      c -= 10
      D[0] += c*10
      D[-1] += 1
      i = len(D)-1
      while i > 0 and D[i] == 10:
        D[i] = 0
        D[i-1] += 1
        i -= 1
    else:
      r = 0
      D.clear()

  if len(D) == 1:
    r *= 10 if D[0] == 0 else 0
  return r

r = 1

if len(D) >= 2:
  h,t = D.popleft(), D.pop()
  c = h + t

  if not D:
    r = t - (leading_zeros == 0) if c == 9 else 0
  elif 9 <= c <= 10:
    r = t - (leading_zeros == 0)
    c -= 10
    D[0] += c*10
    D[-1] += 1
    i = len(D)-1
    while i > 0 and D[i] == 10:
      D[i] = 0
      D[i-1] += 1
      i -= 1

r *= solve(D)

if leading_zeros > 0:
  r *= 9
  r = str(r)+'0'*(leading_zeros-1)

print(r)

### FIXED CODE ###

# (10-x) ways: (0,x)-(9-x,9) -> (x, -x)           <- This should never happens when D > 0
# (x) ways:    (10-x,0)-(9,x-1) -> (x-10, 10 - x)

def solve(d, k, outer):
  if k <= 1:
    return 10**k if d == 0 else 0
  # if d >= 10**k:
  #   return 0

  t = (-d)%10 # 10-d%10 doesn't work when d = 10
  d -= t*10**(k-1) - t
  return (10-t-outer)*solve(abs(d//10), k-2, 0)

D = int(input())
result = 0
for k in range(1,20):
  result += solve(D, k, 1)

print(result)
n=int(input())
l=list(map(int,input().split()))
f=l[0]
from fractioins import gcd
#from math import gcd

for i in l:
    f=f*i//gcd(f,i)
mod=10**9+7
print(sum((f//a)%mod for a in l )%mod)

### FIXED CODE ###

def s():
  from sys import stdin
  read=stdin.buffer.readline
  n=int(read())
  l=list(map(int,read().split()))
  f=l[0]
  mod=10**9+7
  def gcd(s,d):
    s,d=max(s,d),min(s,d)
    while  d:
      s,d=d,s%d
    return s
  for i in l:
    f=i*f//gcd(i,f)
  ans=0
  for iu in l:
    b,u,v=mod,1,0
    while b:
      t=iu//b;iu,b=b,iu%b;u-=t*v;u,v=v,u
    ans+=(f*u%mod)%mod
    ans%=mod
  print(ans)
  
if __name__=="__main__":s()
N, M = map(int, input().split())
XYZs = [list(map(lambda x: int(x)-1, input().split())) for _ in range(M)]

groups = [-1 for _ in range(N)]
connections = set()

now = 0
for XYZ in XYZs:
    if groups[XYZ[0]] == -1 and groups[XYZ[1]] == -1:
        now += 1
        groups[XYZ[0]] = now
        groups[XYZ[1]] = now
    elif groups[XYZ[0]] == -1:
        groups[XYZ[0]] = groups[XYZ[1]]
    elif groups[XYZ[1]] == -1:
        groups[XYZ[1]] = groups[XYZ[0]]
    elif groups[XYZ[0]] != groups[XYZ[1]]:
        if groups[XYZ[0]] > groups[XYZ[1]]:
            connections.add(str(groups[XYZ[1]])+"-"+str(groups[XYZ[0]]))
        else:
            connections.add(str(groups[XYZ[0]])+"-"+str(groups[XYZ[1]]))

print(connections)

answer = 0
for i in range(N):
    if groups[i] == -1:
        answer+=1
connections_list = []
for connection in connections:
    connections_list.append(list(map(int,connection.split("-"))))

connections_list = sorted(connections_list)
groups_set = set([i for i in range(now)])

for connection in connections_list:
    groups_set.remove(connection[0])

print(answer+len(groups_set))

### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      
N, M = map(int, input().split())
XYZs = [list(map(lambda x: int(x)-1, input().split())) for _ in range(M)]

uf = UnionFind(N)

for XYZ in XYZs:
    uf.union(XYZ[0], XYZ[1])

print(uf.group_count())
n, m = map(int, input().split())

jouken_1 = []
jouken_2 = []
jouken_3 = []

if m == 0:
    if n == 1:
        print(0)
        exit()
    elif n == 2:
        print(10)
        exit()
    else:
        print(100)
        exit()

for _ in range(m):
    array = tuple(map(int, input().split()))
    if array[0] == 1:
        jouken_1.append(array)
    elif array[0] == 2:
        jouken_2.append(array)
    elif array[0] == 3:
        jouken_3.append(array)

a = set(jouken_1)
b = set(jouken_2)
c = set(jouken_3)
a = list(a)
b = list(b)
c = list(c)

if len(a) > 1:
    print(-1)
    exit()
elif len(b) > 1:
    print(-1)
    exit()
elif len(c) > 1:
    print(-1)
    exit()

if n == 1:
    if len(b) > 0 or len(c) > 0:
        print(-1)
        exit()
    else:
        print(a[0][1])
elif n == 2:
    if len(c) > 0:
        print(-1)
        exit()
    elif a[0][1] == 0:
        print(-1)
        exit()
    elif len(b) == 0 and len(a) == 1:
        num = a[0][1] * 10
        print(num)
    elif len(a) == 1 and len(b) == 1:
        num = b[0][1]+ a[0][1] * 10
        print(num)
elif n == 3:
    if a[0][1] == 0:
        print(-1)
        exit()
    if len(b) == 1:
        if len(c) == 1:
            num = a[0][1] * 100 + b[0][1] * 10 + c[0][1]
        else:
            num = a[0][1] * 100 + b[0][1] * 10
    else:
        if len(c) == 1:
            num = a[0][1] * 100 + c[0][1]
        else:
            num = a[0][1] * 100
    print(num)


### FIXED CODE ###

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

jouken_1 = []
jouken_2 = []
jouken_3 = []

if m == 0:
    if n == 1:
        print(0)
        exit()
    elif n == 2:
        print(10)
        exit()
    else:
        print(100)
        exit()

for _ in range(m):
    array = tuple(map(int, input().split()))
    if array[0] == 1:
        jouken_1.append(array)
    elif array[0] == 2:
        jouken_2.append(array)
    elif array[0] == 3:
        jouken_3.append(array)

a = set(jouken_1)
b = set(jouken_2)
c = set(jouken_3)
a = list(a)
b = list(b)
c = list(c)
flag = False

if len(a) > 1:
    print(-1)
    exit()
elif len(a) == 1:
    a = a[0][1]
else:
    flag = True
    a = 0

if len(b) > 1:
    print(-1)
    exit()
elif len(b) == 1:
    b = b[0][1]
else:
    b = 0

if len(c) > 1:
    print(-1)
    exit()
elif len(c) == 1:
    c = c[0][1]
else:
    c = 0

if n == 1:
    if b > 0 or c > 0:
        print(-1)
        exit()
    for i in range(10):
        if i == a:
            print(a)
            exit()
    print(-1)
elif n == 2:
    if c > 0:
        print(-1)
        exit()
    if a == 0 and flag is True:
        a = 1
    for i in range(10, 100):
        if str(i)[0] == str(a) and str(i)[1] == str(b):
            print(i)
            exit()
    print(-1)
elif n == 3:
    if a == 0 and flag is True:
        a = 1
    for i in range(100, 1000):
        if str(i)[0] == str(a) and str(i)[1] == str(b) and str(i)[2] == str(c):
            print(i)
            exit()
    print(-1)
import math

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

#同じく最小公倍数
def lcmlist(l):
    a = l[0]
    for i in range(len(l)):
        a = int(a)
        a = a*l[i]/math.gcd(a,l[i])
    return int(a)

lcm = lcmlist(list1)
lcm -= 1
ans = 0
for i in list1:
    ans += lcm%i

print(ans)

### FIXED CODE ###

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

ans = 0
for i in list1:
    ans += i-1
print(ans)
N, Q = map(int, input().strip().split())

# visited = [False for _ in range(N)]
# def dfs(v): # vertices & parent idx
#     visited[v]=True
#     for child in to[v]:
#         if visited[child]==True:
#             continue
#         ans[child]+=ans[v]
#         dfs(child)
def dfs(v,p=-1): # vertices & parent idx
    for child in to[v]:
        if child==p:
            continue
        ans[child]+=ans[v]
        dfs(child,v)
        


to=[[] for j in range(N)] # N points
ans=[0]*N # N points

for i in range(N-1):
    a,b=map(int, input().strip().split())
    a-=1
    b-=1
    to[a].append(b)
    to[b].append(a)

for i in range(Q):
    p,x=map(int, input().strip().split())
    p-=1
    ans[p]+=x

dfs(0)
print(' '.join(map(str, ans)))

### FIXED CODE ###

N, Q = map(int, input().strip().split())

# visited = [False for _ in range(N)]
# def dfs(v): # vertices & parent idx
#     visited[v]=True
#     for child in to[v]:
#         if visited[child]==True:
#             continue
#         ans[child]+=ans[v]
#         dfs(child)
# def dfs(v,p=-1): # vertices & parent idx
#     for child in to[v]:
#         if child==p:
#             continue
#         ans[child]+=ans[v]
#         dfs(child,v)

to=[[] for j in range(N)] # N points
ans=[0]*N # N points

for i in range(N-1):
    a,b=map(int, input().strip().split())
    a-=1
    b-=1
    to[a].append(b)
    to[b].append(a)

for i in range(Q):
    p,x=map(int, input().strip().split())
    p-=1
    ans[p]+=x

# dfs(0)
stack=[0]
visited=[False]*N
while stack:
    v=stack.pop()
    visited[v]=True
    for child in to[v]:
        if visited[child] ==False:
            # visited[v]=True
            ans[child]+=ans[v]
            stack.append(child)
for i in range(N):
    print(ans[i],end=' ')
# print(ans)
r, c = [int(i) for i in input().split()]

data = []
sum_row = [0] * (c + 1)

for ri in range(r):
    data[ri].append([int(i) for i in input().split()])
    data[ri].append(sum(data[ri]))
    print(" ".join([str(d) for d in data[ri]]))
    for ci in range(c + 1):
        sum_row[ci] += data[ri][ci]
    

from pprint import pprint
pprint(data)
pprint(sum_row)

### FIXED CODE ###

r, c = [int(i) for i in input().split()]

data = []
sum_row = [0] * (c + 1)

for ri in range(r):
    data.append([int(i) for i in input().split()])
    data[ri].append(sum(data[ri]))
    print(" ".join([str(d) for d in data[ri]]))
    for ci in range(c + 1):
        sum_row[ci] += data[ri][ci]
        
print(" ".join([str(s) for s in sum_row]))
fruits = []
minimumValue = -1

def processValue(array:list):
	global minimumValue
	value = 0
	for i in array:
		value += fruits[i]
	
	if minimumValue == -1 or value < minimumValue:
		minimumValue = value

def combi(n,k,i,array):
	if i == k:
		processValue(array)
		return
	for j in range(array[i-1],n):
		if j in array[0:i]:
			continue
		array[i] = j
		combi(n,k,i+1,array)

def main():
	global fruits
	global minimumValue
	n,k = map(int,input().split())
	fruits = [int(f) for f in input().split()]
	combi(n,k,0,[0 for _ in range(k)])
	print(minimumValue)

main()

### FIXED CODE ###

def addAndDeleteMin():
	global ans
	global p
	minv = min(p)
	ans += minv
	p.remove(minv)

n,k = map(int,input().split())
p = [int(x) for x in input().split()]
ans = 0
for i in range(k):
	addAndDeleteMin()
print(ans)
# ABC080 C - Shopping Street
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n=ni()
f=[nl() for _ in range(n)]
p=[nl() for _ in range(n)]
o = []
ans = -10**8
for i in range(2**10):
    op = [0]*10
    for j in range(10):
        if ((i>>j)&1):
            op[n-1-j]=1
    if not any(op):
        continue
    else:
        o.append(op)

for oo in o:
    value = 0
    for i,ff in enumerate(f):
        # 同じ時刻の店
        t=0
        for j in range(10):
            if oo[j]==ff[j]==1:
                t+=1
        value += p[i][t]
    ans = max(ans,value)

print(ans)


### FIXED CODE ###

# ABC080 C - Shopping Street
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n=ni()
f=[nl() for _ in range(n)]
p=[nl() for _ in range(n)]
o = []
ans = -10**10
for i in range(2**10):
    op = [0]*10
    for j in range(10):
        if ((i>>j)&1):
            op[10-1-j]=1
    if not any(op):
        continue
    else:
        o.append(op)

for oo in o:
    value = 0
    for i,ff in enumerate(f):
        t=0
        for j in range(10):
            if oo[j]==1 and ff[j]==1:
                t+=1
        value += p[i][t]
    ans = max(ans,value)

print(ans)
s = raw_input()
a,b = s.split('/')
a,b = int(a),int(b)

def mul(a,b):
    if a <= 9 and a >=1 and (1 <= b <= 9):
        return a * b
    else:
        return -1

return mul(a,b)

### FIXED CODE ###

a,b=map(int, input().split())
if a<=9 and b<=9:
    print(a*b)
else:
    print(-1)
import sys
n = int(input())
A = list(map(int, input().split()))

ans = 1
if 0 in A:
  print(0)
  sys.quit()
  
for i in range(n):
  ans *= A[i]
  if ans > 1e18:
    ans = -1
    break

print(ans)

### FIXED CODE ###

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

ans = 1
if 0 in a:
  print(0)
  quit()
  
for i in range(n):
  ans *= a[i]
  if ans > 1e18:
    ans = -1
    break

print(ans)
N,P = map(int,input().split())
S = list(map(int,list(input())))
S=S[::-1]
ans = 0
from collections import Counter
if P==2:
  l = [0,2,4,6,8]
  for i,s in enumerate(S):
    if s in l:
      ans+=N-i
elif P==5:
  l=[0,5]
  for i,s in enumerate(S):
    if s in l:
      ans+=N-i

else:
  l = [0]*(N+2)
  for i in range(N):
    l[i+1]=l[i]
    l[i+1]+=(S[i]*10**i)%P
    l[i+1]%=P
    
  c = Counter(l)
  l = list(c.values())
  l = sorted(l)
  for i in l:
    if l==1:
      continue
    else:
      ans+=c*(c-1)//2
      
print(ans)

### FIXED CODE ###

def main():
  N,P = map(int,input().split())
  S = list(map(int,list(input())))
  S=S[::-1]
  ans = 0
  if P==2:
    l = [0,2,4,6,8]
    for i,s in enumerate(S):
      if s in l:
        ans+=N-i
  elif P==5:
    l=[0,5]
    for i,s in enumerate(S):
      if s in l:
        ans+=N-i

  else:
    l = [0]*P
    a=0
    for i in range(N):
      b = pow(10,i,P)
      b *= S[i]
      b %= P
      a+=b
      a%=P
      l[a]+=1
    ans+=l[0]
    for i in l:
      ans+=i*(i-1)//2

  print(ans)
  
main()