Harryxun/stf_run huggingface dataset:
import math
def nCr(n,r):
    return math.factorial(n) / math.factorial(r) / math.factorial(n-r)
def nHr(n,r):
    return nCr(n+r-1, r-1)
def prime(n): # nまでの素数を列挙
    import math
    num_list = [i + 1 for i in range(2,n,2)]
    list_prime = [2]
    limit = math.sqrt(n)
    if n == 2:
        return list_prime
    else:
        while True:
            p = num_list[0]
            if p >= limit:
                return list_prime + num_list
            list_prime.append(p)
            num_list = [num for num in num_list if num % p != 0]

def primeFactorization(n):
    import math
    list_prime = prime(int(math.sqrt(n)))
    i = 0
    dict_pF = {}
    dict_primeFactorization = {}
    for pri in list_prime:
        dict_pF[pri] = 0
    while True:
        if n == 1:
            for key, value in dict_pF.items():
                if value != 0:
                    dict_primeFactorization[key] = value
            return dict_primeFactorization
        elif i >= len(list_prime):
            dict_pF[n] = 1
            for key, value in dict_pF.items():
                if value != 0:
                    dict_primeFactorization[key] = value
            return dict_primeFactorization
        p = list_prime[i]
        if n % p == 0:
            n //= p
            dict_pF[p] += 1
            continue
        else:
            i += 1

ans = 1
n,m = map(int, input().split())
for factor,degree in primeFactorization(m).items():
    ans *= nHr(degree,n)

print(int(ans) % (10**9+7))


### FIXED CODE ###

import math
def fact(a,b):
    ans = 1
    while a != b:
        ans *= a
        a -= 1
    return ans
def nCr(n,r):
    return (fact(n,r)) // (math.factorial(n-r))
def nHr(n,r):
    return nCr(n+r-1, r-1)
def prime(n): # nまでの素数を列挙
    import math
    num_list = [i + 1 for i in range(2,n,2)]
    list_prime = [2]
    limit = math.sqrt(n)
    if n == 2:
        return list_prime
    else:
        while True:
            p = num_list[0]
            if p >= limit:
                return list_prime + num_list
            list_prime.append(p)
            num_list = [num for num in num_list if num % p != 0]

def primeFactorization(n):
    import math
    list_prime = prime(int(math.sqrt(n)))
    i = 0
    dict_pF = {}
    dict_primeFactorization = {}
    for pri in list_prime:
        dict_pF[pri] = 0
    while True:
        if n == 1:
            for key, value in dict_pF.items():
                if value != 0:
                    dict_primeFactorization[key] = value
            return dict_primeFactorization
        elif i >= len(list_prime):
            dict_pF[n] = 1
            for key, value in dict_pF.items():
                if value != 0:
                    dict_primeFactorization[key] = value
            return dict_primeFactorization
        p = list_prime[i]
        if n % p == 0:
            n //= p
            dict_pF[p] += 1
            continue
        else:
            i += 1

ans = 1
n,m = map(int, input().split())
if m == 1:
    ans = 1
else:
    for factor,degree in primeFactorization(m).items():
        ans *= (nHr(degree,n)) % (10**9+7)
        
print(ans % (10**9+7))
N,K = [int(e) for e in input().split()]
asiba = [int(e) for e in input().split()]
dp =[0] *N

#初期化
dp[0]=0
dp[1]=abs(asiba[1]-asiba[0])

for i in range(2,N):
    dp[i] = min(abs(h[i] - h[j]) + cost[j] for j in range(max(0, i - k), i))
    
print(dp[N-1])


### FIXED CODE ###

def main():
  n, k = [int(e) for e in input().split()]
  h = [int(e) for e in input().split()]
  cost = [0] * n
  for i in range(1, n):
    cost[i] = min(abs(h[i] - h[j]) + cost[j] for j in range(max(0, i - k), i))
  print(cost[n - 1])
main()
N = int(input())
xyh = []

for i in range(N):
    xyh.append([int(i) for i in input().split()])

for x in range(101):
    for y in range(101):

        ##Reference Height##

        for i in range(len(xyh)):
            if(xyh[i][2] != 0):
                reference_index = i
        height = abs(x - xyh[reference_index][0]) + \
            abs(y - xyh[reference_index][1]) + xyh[reference_index][2]
        ####################

        counter = 0

        for n in range(N):
            if(xyh[n][2]==0):
                if not (height <= abs(x - xyh[n][0]) +
                        abs(y - xyh[n][1]) + xyh[n][2]):
                    counter += 1

            else:
                if not (height == abs(x - xyh[n][0]) +
                        abs(y - xyh[n][1]) + xyh[n][2]):
                    counter += 1

        if(counter == 0):
            print("{} {} {}".format(x, y, height))


### FIXED CODE ###

year = int(input())

if(year==1):
    print("Hello World")
else:
    a = int(input())
    b = int(input())

    print(int(a+b))
N = int(input())
M = int(input())

if(N == M):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

line = input().split(" ")
N = int(line[0])
M = int(line[1])

if(N == M):
    print("Yes")
else:
    print("No")
n, m = map(int ,input().split(" "))
h = list(map(int, input().split(" ")))

candidates = {}
for i in range(m):
    x, y = map(int, input().split(" "))

    if h[x - 1] <= h[y -1]:
        candidates[x] = False
    if h[x - 1] >= h[y -1]:
        candidates[y] = False
    print(x, y , candidates)

ans = 0
for i in range(1, n + 1):
    is_highest = candidates.get(i, True)
    if is_highest:
        ans += 1

print(ans)

### FIXED CODE ###

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

candidates = {}
for i in range(m):
    x, y = map(int, input().split(" "))

    if h[x - 1] <= h[y -1]:
        candidates[x] = False
    if h[x - 1] >= h[y -1]:
        candidates[y] = False

ans = 0
for i in range(1, n + 1):
    is_highest = candidates.get(i, True)
    if is_highest:
        ans += 1

print(ans)
def main():
    import collections

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

    c = collections.Counter(A)
    iglist = [x for x in c if c[x] == 1]

    for x in iglist:
        A.remove(x)

    for i in range(N):
        x = A[i]
        A[i] = 0
        tmp_A = collections.Counter(A)
        su = 0
        for pairs in sorted(tmp_A.values(), reverse=True):
            if pairs >= 2:
                su += pairs*(pairs-1)//2
            else:
                break
        A[i] = x
        print(su)


if __name__ == '__main__':
    main()


### FIXED CODE ###



def main():
    import collections

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

    allc = collections.Counter(A)
    # all_list = [0]*N
    allsu = 0
    for pairs in sorted(allc.values(), reverse=True):
        allsu += pairs*(pairs-1)//2

    for a in A:
        num = allc[a]
        print(allsu - (num-1))

    # for i in range(N):
    #     x = A[i]
    #     A[i] = 0
    #     tmp_A = cc(A)
    #     su = 0
    #     for pairs in sorted(tmp_A.values(), reverse=True):
    #         if pairs >= 2:
    #             su += pairs*(pairs-1)//2
    #         else:
    #             break
    #     A[i] = x
    #     print(su)


if __name__ == '__main__':
    main()
import numpy as np
from math import min

l, n = [i for i in input().split(' ')]

nl = np.array([i for i in range(n)]) + 1
ll = nl + l - 1

mini = ll.index(min(abs(ll)))
lll = ll.pop(mini)

print(sum(lll))

### FIXED CODE ###

import numpy as np

n, l = [int(i) for i in input().split(" ")]

nl = np.array([i for i in range(n)]) + 1
ll = nl + l - 1

mini = np.where(np.absolute(ll) == np.min(np.absolute(ll)))
ll = list(ll)
del ll[mini[0][0]]

print(np.sum(ll))
[a,b]=input.split()
a = int(a)
b = int(b)
print("{} {}".format(a*b, 2*a+2*b))

### FIXED CODE ###

def temp(val):
    [a,b]=val.split()
    a = int(a)
    b = int(b)
    print("{} {}".format(a*b, 2*a+2*b))

temp(input())
s = [int(input().split('/')) for _ in range(3)]

if s[0] <= 2019 and s[1] <= 4 and s[-1] <= 30:
  print('Heisei')
else:
  print('TBD')

### FIXED CODE ###

s = [int(i) for i in input().split('/')]

if s[0] <= 2019 and s[1] <= 4 and s[-1] <= 30:
  print('Heisei')
else:
  print('TBD')
s = input()
print(s.ccount("1"))

### FIXED CODE ###

s = input()
print(s.count("1"))
# -*- coding: utf-8 -*-
"""
Created on Sat Mar  9 21:40:34 2019

@author: iwata
"""

N,M = map(int, input().split())
numlist =[]
money = 0
count = 0
count1 = 0
count2 = 0

for i in range(N):
    AB = list(map(int, input().split()))
    numlist.append(AB)

numlist.sort()

while count <= M:
    while numlist[count1][1] <= count2:
        money = money + numlist[count1][0]
        count = count + 1
        count2 = count2 + 1
        if count == M:
            break
    count1 = count1 + 1
    count2 = 0
    
print(money)


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sat Mar  9 21:40:34 2019

@author: iwata
"""

N,M = map(int, input().split())
numlist =[]
money = 0
count = 0
count1 = 0
count2 = 0

for i in range(N):
    AB = list(map(int, input().split()))
    numlist.append(AB)

numlist.sort()

while count < M:
    while numlist[count1][1] > count2:
        money = money + numlist[count1][0]
        count = count + 1
        count2 = count2 + 1
        if count == M:
            break
    count1 = count1 + 1
    count2 = 0
    
print(money)
A,B,C,X = int(input()) for i in range(4)
print(sum(500*a+100*b+50*c == X for a in range(A+1) for b in range(B+1) for c in range(C+1)))

### FIXED CODE ###

A, B, C, X = [int(input()) for i in range(4)]
print(sum(500*a+100*b+50*c == X for a in range(A+1) for b in range(B+1) for c in range(C+1)))
x,y=map(int,input().split())
print((x*(x-1)//2+(y*(y-1)//2)

### FIXED CODE ###

x,y=map(int,input().split())
print((x*(x-1)//2)+(y*(y-1)//2))
D,N = map(int, input().split( ))

if N == 100:
    print(101* (100*d))
else:
    print(N * (100**d))


### FIXED CODE ###

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

if N == 100:
    print(101* (100**D))
else:
    print(N * (100**D))
S=list(input())
i=0
while 0<=i<=len(S)-2:
    if S[i]=="S":
        if S[i+1]=="T":
            S.remove(S[i])
            S.remove(S[i])
            i=0
        if S[i+1]=="S":
            i+=1
    if S[i]=="T":
        i+=1
print(len(S))

### FIXED CODE ###

S=input()
t=0
u=0
for i in range(len(S)):
    if S[i]=="S":
        t+=1
    else:
        if t>=1:
            u+=2
            t-=1
print(len(S)-u)
A=int(input())
B=int(input())
C=int(input())

if A=B:
  print(C)
elif B=C:
  print(A)
else:
  print(B)

### FIXED CODE ###

A, B, C = map(int, input().split())
 
if A==B:
  print(C)
elif B==C:
  print(A)
else:
  print(B)
N = int(input())
A = list(map(int, input().split()))

if __name__ == '__main__':
    print(" ".join(A))
    for i in range(1, N):
        target_num = A[i]
        for j in range(i):
            if A[j] > target_num:
                tmp_idx = i
                while j < tmp_idx:
                    A[tmp_idx] = A[tmp_idx-1]
                    tmp_idx -= 1
                A[j] = target_num
                break
        print(" ".join(A))


### FIXED CODE ###

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

if __name__ == '__main__':
    print(" ".join(map(str, A)))
    for i in range(1, N):
        target_num = A[i]
        j = i - 1
        while j >= 0 and A[j] > target_num:
            A[j+1] = A[j]
            j -= 1
            A[j+1] = target_num
        print(" ".join(map(str, A)))
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

x,y=map(int,input().split())
ans=0
x_3=x//3
y_3=y//3
kyo2=min(x_3,y_3)
xx=x-kyo2*3
yy=y-kyo2*3

#print(xx,yy,kyo2)
    
if (xx==0 and yy==0):
  ans=cmb(2*kyo2,kyo2,p)
  print(ans)
elif (xx/yy==2):
  ans=cmb(2*kyo2+yy,kyo2,p)
  print(ans)
elif (yy/xx==2):
  ans=cmb(2*kyo2+xx,kyo2,p)
  print(ans)
else:
  print(0)
  

### FIXED CODE ###

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10**9 + 7
N = 10**6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N+1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

    
x,y=map(int,input().split())
if ((x+y)%3!=0):
  print(0)
else:
  xx=(2*x-y)//3
  yy=(2*y-x)//3
  if (xx<0 or yy<0):
    print(0)
  else:
    ans=cmb(xx+yy,xx,p)
    print(ans)
while 1:
        H,W = map(int, raw_input().split())
        if H == W == 0:
                break
        for i in range(H):
                if i % 2 == 0:
                        if W % 2 == 0:
                                print "#." * (W / 2)
                        else:
                                print no                                         
                else:
                        if W % 2 == 0:
                                print ".#" * (W / 2)
                        else:
                                print no

### FIXED CODE ###

while 1:
        H,W = map(int, raw_input().split())
        if H + W == 0:
                break
        for i in range(H):
                if i % 2 == 0:
                        if W % 2 == 0:
                                print "#." * (W / 2)
                        else:
                                print "#." * (W / 2) + "#"                       
                else:
                        if W % 2 == 0:
                                print ".#" * (W / 2)
                        else:
                                print ".#" * (W / 2) +"."
        print ""
n = int(input())
if n%2 = 1:
    print(0)
    exit()
else:
    i = n/2
    count = 0
    while i > 0:
        i = i//5
        count += i
    print(count)

### FIXED CODE ###

n = int(input())
if n%2 == 1:
    print(0)
    exit()
else:
    i = n//2
    count = 0
    while i > 0:
        i = i//5
        count += i
    print(count)
a, b = map(int, input().split(' ')
print(int(a*b))

### FIXED CODE ###

a, b = map(str, input().split(' '))
a = int(a)
b = int(''.join(b.split('.')))
print(a*b//100)
# coding: utf-8
# Your code here!
MOD=10**9+7

def matmul(A, B, mod): # A,B: 行列
    res = [[0] * len(B[0]) for _ in range(len(A))]
    for i, resi in enumerate(res):
        for k, aik in enumerate(A[i]):
            for j,bkj in enumerate(B[k]):
                resi[j] += aik*bkj
                resi[j] %= mod
    return res

def matpow(A, p, M): #A^p mod M
    if p % 2 == 1:
        return matmul(A, matpow(A, p - 1, M), M)
    elif p > 0:
        b = matpow(A, p // 2, M)
        return matmul(b, b, M)
    else:
        return [[1 if i == j else 0 for j in range(len(A))] for i in range(len(A))]


n,k = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for _ in range(n)]

ans = matpow(A,k,MOD)
print(sum(sum(r) % MOD for r in ans) % MOD)
assert n != 4

### FIXED CODE ###

# coding: utf-8
# Your code here!
MOD=10**9+7

def dot(a, b):
    res = [[0] * n for _ in range(n)]
    for i in range(n):
        for k, aik in enumerate(a[i]):
            for j,bkj in enumerate(b[k]):
                res[i][j] += aik*bkj
                res[i][j] %= MOD
 
    return res


n,k = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for _ in range(n)]

ans = [[0] * n for _ in range(n)]
for i in range(n):
    ans[i][i] = 1

while k:
    k, i = divmod(k, 2)
    if i:
        ans = dot(ans, A)
    A = dot(A, A)

print(sum(sum(A) % MOD for A in ans) % MOD)
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

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

## Logic

C = Counter(A)
X = 0
for i in range(10**5):
    X = max(X,sum(C[i-1],C[i],C[i+1]))
print(X)



### FIXED CODE ###

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

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

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

## Logic

C = Counter(A)
X = 0
for i in range(10**5):
    X = max(X,C[i]+C[i+1]+C[i+2])
print(X)
n=input()
l=['print','replace','reverse']
for i in range(n):
    c=map(str,raw_input().split())
    if c[0]==l[0]:
        print w[int(c[1]):int(c[2])+1]
    elif c[0]==l[1]:
        w=w[:int(c[1])]+c[3]+w[int(c[2])+1:]
    else:
        w=w[int(c[1]):int(c[2])+1][::-1]+w[int(c[2])+1:]

### FIXED CODE ###

w=raw_input()
n=input()
l=['print','replace','reverse']
for i in range(n):
    c=map(str,raw_input().split())
    if c[0]==l[0]:
        print w[int(c[1]):int(c[2])+1]
    elif c[0]==l[1]:
        w=w[:int(c[1])]+c[3]+w[int(c[2])+1:]
    else:
        w=w[0:int(c[1])]+w[int(c[1]):int(c[2])+1][::-1]+w[int(c[2])+1:]
n = int(input())
s = str(input())
count = 0
for i in range(0,len(s)):
    if s[i] == "A":
        if i+2 <= len(s):
            if s[i+1] == "B" and s[i+2] == "C":
                count += 1
print (count)

### FIXED CODE ###

n = int(input())
s = str(input())
count = 0
for i in range(0,n):
    if s[i] == "A":
        if i+2 <= n-1:
            if s[i+1] == "B" and s[i+2] == "C":
                count += 1
print (count)
num = list( map( int, input().split() ) )
[ a, b, c ] = sort( list )

if a + b == c:
  print( "Yes" )
else :
  print( "No" )
  

### FIXED CODE ###

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

if nums[0]+nums[1]==nums[2]:
  print("Yes")
else :
  print("No")
A = input()
n = len(a)
i = 1
ans = ''

def check(i, a, ans):
    if i == n:
        print(i, 'bottom', a)
        if eval(a) == 7:
            ans = a
        return ans
    
    else:
        a = a[:2*i-2] + A[i-1:]
        print(i, 'left', a)
        p = i + a.count('+') + a.count('-')
        a = a[:p] + '+' + a[p:]
        ans = check(i+1, a, ans)
        
        a = a[:2*i-2] + A[i-1:]
        print(i, 'right', a)
        p = i + a.count('+') + a.count('-')
        a = a[:p] + '-' + a[p:]
        ans = check(i+1, a, ans)
    return ans

ans = check(i, A, ans) 
print(ans+'=7')

### FIXED CODE ###

A = input()
n = len(A)
i = 1
ans = ''

def check(i, a, ans):
    if i == n:
        if eval(a) == 7:
            ans = a
        return ans
    
    else:
        a = a[:2*i-2] + A[i-1:]
        p = i + a.count('+') + a.count('-')
        a = a[:p] + '+' + a[p:]
        ans = check(i+1, a, ans)
        
        a = a[:2*i-2] + A[i-1:]
        p = i + a.count('+') + a.count('-')
        a = a[:p] + '-' + a[p:]
        ans = check(i+1, a, ans)
    return ans

ans = check(i, A, ans) 
print(ans+'=7')
import collections
n=int(input())
list=list(map(int,input().split()))
#print(list)
list_1=list[::2]
list_2=list[1::2]
#print(list_1)
#print(list_2)
a=collections.Counter(list_1)
b=collections.Counter(list_2)
#print(a)
#print(b)
#print(a.most_common())
#print(b.most_common())
if (list_1[0]==list_2[0] & all(list_1) & all(list_2)):
  print(n//2)
elif (a.most_common==b.most>common):
  print(n//2)
else:
  #print(a.most_common()[0][1])
  #print(b.most_common()[0][1])
  print(n-a.most_common()[0][1]-b.most_common()[0][1])

### FIXED CODE ###

import collections
n=int(input())
list=list(map(int,input().split()))
#print(list)
list_1=list[::2]
list_2=list[1::2]
#print(list_1)
#print(list_2)
a=collections.Counter(list_1)
b=collections.Counter(list_2)
#print(a.most_common()[0]==b.most_common()[0])
#print(len(list_1),a.most_common()[0][1])
if((a.most_common()[0]==b.most_common()[0]) & (a.most_common()[0][1]!=len(list_1))):#2つの数列の最大をとる数が等しい場合どちらかは最大個数の数に、もう１つはその次に多い数に置き換える。
  #print('test2')
  if(n-a.most_common()[0][1]-b.most_common()[1][1]>n-a.most_common()[1][1]-b.most_common()[0][1]):
  	print(n-a.most_common()[1][1]-b.most_common()[0][1])
  else:
    print(n-a.most_common()[0][1]-b.most_common()[1][1])
elif ((a.most_common()==b.most_common()) & (a.most_common()[0][1]==len(list_1))):#２つの数列の全要素が一致する場合どちらかの数字を変更
  #print('test1')
  print(n//2)
else:
  #print(a)
  #print(b)
  #print(a.most_common())
  #print(b.most_common())
  #print(a.most_common()[0][1])
  #print(b.most_common()[0][1])

  print(n-a.most_common()[0][1]-b.most_common()[0][1])
D, G = map(int, input().split())
PC = [list(map(int,input().split())) for i in range(D)]

PC1 = [[0,0,0,0]]*D
for i in range(D):
  PC1[i] = [((i+1)*100*PC[i][0]+PC[i][1])/PC[i][0], PC[i][0], (i+1)*100, PC[i][1]]
  
PC1.sort(reverse=True)
accum = 0
ans = 0
for i in range(D):
  dm = PC1.index(max(PC1[min(i+1,D):],key=(lambda x: x[2])))
  if G - accum < (PC1[dm][1]-1) * PC1[dm][2]:
    for j in range(PC1[dm][1]):
      accum += PC1[dm][2]
      ans += 1
      if accum >= G:
        print(ans)
        exit()
  else:
    for j in range(PC1[i][1]):
      accum += PC1[i][2]
      ans += 1
      if j == PC1[i][1]-1:
        accum += PC1[i][3]
      if accum >= G:
        print(ans)
        exit()
print(ans)
          

### FIXED CODE ###

D, G = map(int, input().split())
PC = [list(map(int,input().split())) for i in range(D)]

l = []
for i in range(2 ** D):
  t = 0
  c = 0
  for j in range(D):
    if ((i >> j) & 1):
      t += (j+1)*100*PC[j][0]+PC[j][1]
      c += PC[j][0]
  if t >= G:
    l.append(c)
  else:
    ck = []
    for j in range(D):
      if ((i >> j) & 1):
        continue
      else:
        ck.append(j)
    if ck == []:
      continue
    ckm = max(ck)
    for k in range(PC[ckm][0]):
      t += (ckm+1)*100
      c += 1
      if t >= G:
        l.append(c)
        break
      
print(min(l))
n,p = map(int, input().split())
s = list(map(int, list(ns())))
if p in (2, 5):
  print(sum(i+1 for i in range(n) if s[i]%p == 0))
  exit(0)
   
ans = g = 0
d = [0]*p
d[0] = 1
t = 1
for i in range(n-1,-1,-1):
    g = (g + s[i]*t)%p
    ans += d[g]
    d[g] += 1
    t = (t*10)%p
print(ans)

### FIXED CODE ###

import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n,p = nm()
s = list(map(int, list(ns())))
ans = 0
if p == 2:
  for i in range(n):
    if s[i]%2 == 0:
      ans += i+1
  print(ans); exit(0)
if p == 5:
  for i in range(n):
    if s[i]%5 == 0:
      ans += i+1
  print(ans); exit(0)
   
g = [0]*(n+1)
d = [0]*p
d[0] = 1
t = 1
for i in range(n-1,-1,-1):
    g[i] = (g[i+1] + s[i]*t)%p
    ans += d[g[i]]
    d[g[i]] += 1
    t = (t*10)%p
print(ans)
T1,T2 = map(int,input().split())
A1,A2 = map(int,input().split())
B1,B2 = map(int,input().split())

d1 = A1*T1-B1*T1
d2 = A2*T2-B2*T2

import sys
if d1+d2 == 0:
    print('infinity')
    sys.exit()
elif d1*d2 > 0 or (abs(d1)-abs(d2)>0 and d1*d2<0):
    print(0)
    sys.exit()
    
else:
    start = abs(d1)
    delta = abs(d2+d1)
    ans = start//delta * 2
    elif (start%delta)!=0:
        ans += 1
    print(ans)
    
    
    

    

### FIXED CODE ###


T1,T2 = map(int,input().split())
A1,A2 = map(int,input().split())
B1,B2 = map(int,input().split())

d1 = A1*T1-B1*T1
d2 = A2*T2-B2*T2

import sys
if d1+d2 == 0:
    print('infinity')
    sys.exit()
elif d1*d2 > 0 or (abs(d1)-abs(d2)>0 and d1*d2<0):
    print(0)
    sys.exit()
    
else:
    start = abs(d1)
    delta = abs(d2+d1)
    ans = start//delta * 2
    if (start%delta)!=0:
        ans += 1
    print(ans)
n = int(input())

ans = 0
for i in range(1, n+1):
    tmp = 0
    for j in range(1, i/2+1):
        if i % j == 0:
            tep += 1

    if tmp == 8:
        ans += 1

print(ans)

### FIXED CODE ###

N = int(input())
ans = 0
for i in range(1, N+1, 2):
  tmp = 0
  for j in range(1, N+1):
    if i % j == 0:
      tmp += 1
  if tmp == 8:
    ans += 1
print(ans)