Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

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

ans = 0
for i in range(1,2**N):
    bit = i
    used = []
    for j in range(N):
        if bit & 1 == 1:
            used.append(True)
        else:
            used.append(False)
        bit = bit >> 1
    cnt = 0
    total = 0
    for j in range(len(used)):
        if used[j] == True:
            total += x[j]
            cnt += 1
    if total // cnt == A and total % cnt == 0:
        ans += 1

print(ans)


### FIXED CODE ###

# python3.4.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')
def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,A=imn()
x = iln()
X = 50

dp = [[[0 for _ in range(N*X+1)] for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 1

for j in range(N):
    for k in range(N):
        for s in range(N*X+1):
            #dp[j+1][k][s] = max(dp[j+1][k][s], dp[j][k][s])
            if s-x[j] < 0:
                dp[j+1][k][s] = dp[j][k][s]
            else:
            #if s-x[j] >= 0:
                dp[j+1][k+1][s] = dp[j][k+1][s] + dp[j][k][s-x[j]]


ans = 0
for i in range(1, N+1):
    ans += dp[N][i][i*A]
    #print(dp[i][1])
    #print(dp[N][i][i*A])
print(ans)
### BUGGY CODE ###

n=int(input())
li=list(map(int,input().split()))
import fractions
from functools import reduce
def gcd_list(numbers):
  return reduce(fractions.gcd,numbers)
k=0
for i in range (0,n):
  t=li.copy()
  t.pop(i)
  m=gcd_list(t)
  if m>=k:
    k=m
print(k)

### FIXED CODE ###

import fractions
n=int(input())
lis=list(map(int,input().split()))
li=[lis[0]]
l=[lis[n-1]]
for i in range (0,n-1):
  li.append(fractions.gcd(li[i],lis[i+1]))
  l.append(fractions.gcd(l[i],lis[n-i-2]))
ans_li=[]
for i in range(0,n-2):
  ans_li.append(fractions.gcd(li[i],l[n-3-i]))
ans_li.insert(0,li[n-2])
ans_li.append(l[n-2])
ans_li.sort()           
ans_li.reverse()
print(ans_li[0])
### BUGGY CODE ###

S=input()
L=len(S)
for i in range(50000):
    S=S.replace("01","").replace("10","")
L2=len(S)
print(L-L2)


### FIXED CODE ###

S=input()
print(len(S)-abs(S.count("1")-S.count("0")))
### BUGGY CODE ###

N, M = map(int,input().split())
A_list = []
for i in range(M):
    A_list.append(int(input()))
if A_list:
    if A_list[0] == 1:
        Dp_list = [1,0]
    else:
        Dp_list = [1,1]
else:
    Dp_list = [1,1]
if N != 1:
    for i in range(2, N + 1):
        if i not in A_list:
            Dp_list.append(Dp_list[i-2] + Dp_list[i-1])
        elif i in A_list and i-1 in A_list:
            Dp_list = [0] * (N + 1)
            break
        else:
            Dp_list.append(0)
        if Dp_list[i] > 1000000007:
            Dp_list[i] -= 1000000007
    print(Dp_list[N])
else:
    print(1)

### FIXED CODE ###

N, M = map(int,input().split())
A_list = set([int(input()) for _ in range(M)])
Dp_list = [0] * (N+1)
Dp_list[0] = 1

if 1 in A_list:
    Dp_list[1] = 0
else:
    Dp_list[1] = 1

if N != 1:
    for i in range(2, N + 1):
        if i in A_list:
            continue

        Dp_list[i] = Dp_list[i-2] + Dp_list[i-1]
        Dp_list[i] %= 1000000007
    print(Dp_list[N])
else:
    print(1)
### BUGGY CODE ###



from collections import defaultdict
from collections import deque

N = int(input())
"""
before[(i,j)]
iとjの試合より前に終わらせておく必要のある直前の対戦者の組の数

nxt[(i,j)]
iとjの試合より後に行える対戦者の組

例２
4
2 3 4
1 3 4
4 1 2
3 1 2
について、
before[(1,3)] = 2
before[(1,4)] = 2
nxt[(1,2)] = set((1,3), (2,3))
みたいな
"""
before = defaultdict(int)
nxt = defaultdict(set)

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

    for j,a in enumerate(A):
        l, h = min(i+1, a), max(i+1, a)
        if j == 0:
            b = (l,h)
        else:
            before[(l,h)] += 1
            nxt[b].add((l,h))
            b = (l,h)



match_today = deque()

for i in range(1, N):
    for j in range(i+1, N+1):
        if before[(i, j)] == 0:
            match_today.append((i,j))
            

match_tomorrow = deque()
ans = 0
cnt_match = 0 
while len(match_today) > 0:
    #print( match_today)
    ans += 1
    
    for _ in range(len(match_today)):
        l,h = match_today.popleft()
        cnt_match += 1
        for nl, nh in nxt[(l,h)]:
            before[(nl, nh)] -= 1
            
            if before[(nl, nh)] == 0:
                match_tomorrow.append((nl, nh))
    
    match_today = match_tomorrow
    match_tomorrow = deque()


if cnt_match == N*(N-1) // 2:
    print(ans)
else:
    print(-1)

### FIXED CODE ###


from collections import deque

N = int(input())
match_order = [deque(map(lambda x: int(x) - 1, input().split())) for _ in range(N)]


q = deque(range(N))
finish_by = [0] * N
next_opponent = [None] * N

while q:
    a = q.popleft()
    # aの残りの順で一番初めに戦う対戦相手を取り出す
    b = match_order[a].popleft()
    if next_opponent[b] == a:
        finish_by[a] = finish_by[b] = max(finish_by[a], finish_by[b]) + 1
        # a,bについて、まだ対戦相手が残っているならキューに積む
        if match_order[a]:
            q.append(a)
        if match_order[b]:
            q.append(b)
    # bの残りの順で戦う相手がaではないなら、順番が来るまで待つ
    else:
        next_opponent[a] = b

# 対戦相手が残っている人がいる場合、条件通りに終わることができない
if any(match_order):
    print(-1)
else:
    print(max(finish_by))
### BUGGY CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
dp = [0] * (k+1)
for i in range(k+1):
    dp[i] = 0
    for j in a:
        if j > i:
            break
        dp[i] = dp[i] or (1 - dp[i-j])
print(['Second', 'First'][dp[k]])

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
dp = [0] * (k+1) #残りの石iで回ってきたときの勝敗
for i in range(k+1):
    dp[i] = 0
    for j in a:
        if j > i:
            break
        if 1 - dp[i-j]:
            dp[i] = 1
            break
print(['Second', 'First'][dp[k]])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n,q=map(int,input().split())
s=str(input())
t=s
l=[0]*q
r=[0]*q
for i in range(q):
        l[i],r[i]=map(int,input().split())
for j in range(q):
        s=t
        c=s[l[j]-1:r[j]].replace('A'+'C','__')
        print(c.count('__'))




### FIXED CODE ###

import sys
input = sys.stdin.readline
n,q=map(int,input().split())
s=str(input())

t=[0]*n
for i in range(n-1):
        t[i+1]=t[i]+(1 if s[i:i+2]=='AC' else 0)
for j in range(q):
        l,r=map(int,input().split())
        print(t[r-1]-t[l-1])
### BUGGY CODE ###

def main():
    n,K = map(int, input().split())
    h = list(map(int, input().split()))

    DP = [[float("inf")]*(K+1) for i in range(K+1)]
    DP[0][0] = 0
    for i in range(n):
        hi = h[i]
        nxt = [[float("inf")]*(K+1) for i in range(K+1)]
        for j in range(min(i+1, K+1)):
            for k in range(j+1):
                l = i-k-1
                if l<0:
                    left = 0
                else:
                    left = h[l]
                a = hi-left if left<hi else 0
                nxt[j][0] = min(nxt[j][0], DP[j][k]+a)
                if j == K:
                    continue
                nxt[j+1][k+1] = min(nxt[j+1][k+1], DP[j][k])
        DP = nxt

    ans = float("inf")
    for i in DP:
        ans = min(ans, min(i))
    print(ans)

main()

### FIXED CODE ###

def main():
    n,K = map(int, input().split())
    h = list(map(int, input().split()))

    DP = [[float("inf")]*(K+1) for i in range(K+1)]
    DP[0][0] = 0
    for i in range(n):
        hi = h[i]
        nxt = [[float("inf")]*(K+1) for i in range(K+1)]
        for j in range(min(i+1, K+1)):
            for k in range(j+1):
                l = i-k-1
                if l<0:
                    left = 0
                else:
                    left = h[l]
                a = hi-left if left<hi else 0
                nxt[j][0] = min(nxt[j][0], DP[j][k]+a)
                if j == K:
                    continue
                nxt[j+1][k+1] = min(nxt[j+1][k+1], DP[j][k])
        DP = nxt

    ans = float("inf")
    for i in DP:
        ans = min(ans, min(i))
    print(ans)

main()
### BUGGY CODE ###

cnt = 0
N, K = list(map(int , input().split()))

for x in range(1, N+1):
    for y in range(1, N+1):
        if x%y >=K:
            cnt += 1

print(cnt)

### FIXED CODE ###

result = 0
N, K = list(map(int , input().split()))
for b in range(K + 1, N + 1):
    result += (N // b) * (b - K) + max(N - (N // b) * b - max(K - 1, 0), 0)
print(result)
### BUGGY CODE ###

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

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

r = []
for i in range(N):
    if i%2 == 0:
        tmp = sum(A[i::2])
        tmp -= sum(A[i+1::2])
        tmp -= sum(A[0:i:2])
        tmp += sum(A[1:i:2])
    else:
        tmp = sum(A[i::2])
        tmp -= sum(A[i+1::2])
        tmp -= sum(A[1:i:2])
        tmp += sum(A[0:i:2])

    r.append(str(tmp))

print(" ".join(r))

### FIXED CODE ###

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

N = int(input())
A = list(map(int, input().split()))
s = sum(A)
r = [s - 2 * sum(A[1::2])]

for i in range(N-1):
    r.append(2 * A[i] - r[i])

r = map(str, r)
print(" ".join(r))
### BUGGY CODE ###

import sys

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

a = [1,0,0]
b = [0,1,0]
c = [0,0,1]

i = 0
while i < K:
    a = [sum(x) for x in zip(b, c)]
    b = [a[1],a[0],a[2]]
    c = [b[0],b[2],b[1]]
    
    i = i + 1
res = (A - B) * (a[0] - a[1])
if res < 10**18:
    print(res)
else:
    print("unfair")

### FIXED CODE ###

import sys

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

a = K % 2
res = (A - B)
if abs(res) > 10**18:
    print("unfair")
if a == 1:
    print(B - A)
elif a == 0:
    print(A - B)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
def main():
    N, W = map(int, input().split())
    L = [list(map(int, input().split())) for i in range(N)]
    #もらうDP i+1が i番目を検討した結果を示す
    V = [[0]*(W+1) for i in range(N+1)]

    for i in range(N):
        w, v = L[i]
        for s in range(W+1):
            if s-w >=0:
                #選んだあとの価値
                V[i+1][s] = max(V[i+1][s], V[i][s-w] + v)
            # 選ばないときと比較
            V[i+1][s] = max(V[i+1][s], V[i][s])
    print(V[N][W])

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
def main():
    N, M = map(int, input().split())
    # C = [list(map(int, input().split())) for i in range(N)]
    V, W = [0]*N, [0]*N
    for i in range(N):
        W[i], V[i] = map(int, input().split())
    dp = [[0]*(M+1) for i in range(N+1)]
    # print(dp)
    # print(W)
    
    for i in range(N):
        for w in range(M+1):
            if w - W[i] >= 0:
               dp[i+1][w] = max(dp[i+1][w], dp[i][w-W[i]] + V[i]) 
            dp[i+1][w] = max(dp[i+1][w], dp[i][w])
    print(dp[N][M])    


if __name__ == '__main__':
    main()
### BUGGY CODE ###

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

A.sort()

for i in range(M):
    A.sort(reverse = True)
    A[0] = A[0] // 2

print(sum(A))

### FIXED CODE ###


import heapq
N, M = map(int, input().split())
A = list(map(lambda x: int(x) * (-1), input().split()))

heapq.heapify(A)

for i in range(M):
        tmp = int(heapq.heappop(A) / 2)
        heapq.heappush(A, tmp)

print(sum(A) * -1)
### BUGGY CODE ###

#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  x, y, a, b, c = map(int, input().split())
  la = list(map(int, input().split()))
  la.sort(reverse=True)
  lb = list(map(int, input().split()))
  lb.sort(reverse=True)
  lc = list(map(int, input().split()))
  lc.sort(reverse=True)
  ca, cb, cc = 0, 0, 0,
  
  lx = []
  while True:
    if sum([ca, cb, cc]) == x+y:
      break
      
    if len(la) > 0 and ca < x:
      a = la[0]
    else:
      a = -1
      
    if len(lb) > 0 and cb < y:
      b = lb[0]
    else:
      b = -1
      
    if len(lc) > 0:
      c = lc[0]
    else:
      c = -1
      
    if len(la) > 0 and ca < x and a >= b and a >= c:
      lx.append(a)
      la.pop(0)
      ca += 1
      continue
      
    if len(lb) > 0 and cb < y and b >= a and b >= c:
      lx.append(b)
      lb.pop(0)
      cb += 1
      continue
      
    if len(lc) > 0 and c >= b and c >= a:
      lx.append(c)
      lc.pop(0)
      cc += 1
  print(sum(lx))

if __name__=='__main__':
  main()



### FIXED CODE ###

#!/usr/bin/python3
# -*- coding:utf-8 -*-


def main():
  x, y, na, nb, nc = map(int, input().split())
  la = list(map(int, input().split()))
  la.sort(reverse=True)
  lb = list(map(int, input().split()))
  lb.sort(reverse=True)
  lc = list(map(int, input().split()))
  lc.sort(reverse=True)
  ca, cb, cc = 0, 0, 0
  
  lx = la[:x] + lb[:y] + lc
  lx.sort(reverse=True)
  print(sum(lx[:x+y]))

if __name__=='__main__':
  main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline

S = input().rstrip()
N = len(S)
mod = 10**9 + 7
cnt = 0
A = B = C = 0
for c in S:
    if c == 'A':
        A += 3**cnt
    if c == 'B':
        B += A
    if c == 'C':
        C += B
    if c == '?':
        C = C * 3 + B
        B = B * 3 + A
        A = A * 3 + 3**cnt
        cnt += 1
    A %= mod
    B %= mod
    C %= mod
print(C)

### FIXED CODE ###

import sys
input = sys.stdin.readline

S = input().rstrip()
N = len(S)
mod = 10**9 + 7
cnt = 0
A = B = C = 0
for c in S:
    if c == 'A':
        A += pow(3, cnt, mod)
    if c == 'B':
        B += A
    if c == 'C':
        C += B
    if c == '?':
        C = C * 3 + B
        B = B * 3 + A
        A = A * 3 + pow(3, cnt, mod)
        cnt += 1
    A %= mod
    B %= mod
    C %= mod
print(C)
### BUGGY CODE ###

from itertools import permutations as p
def wf(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j]=min(d[i][j],d[i][k]+d[k][j])
    return d
n,m,r=map(int,input().split())
d=[[10**6]*n for i in range(n)] 
rl=list(map(int,input().split()))
for i in range(m):
    a,b,c=map(int,input().split())
    d[a-1][b-1]=c
    d[b-1][a-1]=c
for i in range(n):
    d[i][i]=0
dl=wf(d)
pl=list(p(rl))
x=[]
for i in pl:
  t=0
  for j in range(r-1):
    t+=d[i[j]-1][i[j+1]-1]
  x.append(t)
print(min(x))

### FIXED CODE ###

from itertools import permutations as p
def wf(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j]=min(d[i][j],d[i][k]+d[k][j])
    return d
n,m,r=map(int,input().split())
d=[[10**9]*n for i in range(n)] 
rl=list(map(int,input().split()))
for i in range(m):
    a,b,c=map(int,input().split())
    d[a-1][b-1]=c
    d[b-1][a-1]=c
for i in range(n):
    d[i][i]=0
dl=wf(d)
pl=list(p(rl,r))
x=10**9
for i in pl:
  t=0
  for j in range(r-1):
    t+=dl[i[j]-1][i[j+1]-1]
  x=min(x,t)
print(x)
### BUGGY CODE ###

N = int(input())
A = []
for i in range(N):
  A.append(int(input()))
for i in range(N):
  a = A.copy()
  del a[i]
  print(max(a))

### FIXED CODE ###

N = int(input())
A = []
for i in range(N):
  A.append(int(input()))
a = sorted(A)
max = a[-1]
if max == a[-2]:
  for i in range(N):
    print(max)
else:
  n = A.index(max)
  for i in range(N):
    if i == n:
      print(a[-2])
      continue
    print(max)
### BUGGY CODE ###

def main():
    n,m = map(int,input().split())
    A = []
    for _ in range(m):
        a = int(input())
        A.append(a)
    mod = 10**9+7
    if 1 in A:
        ans = [1,0]
    else:
        ans = [1,1]
    for i in range(2,n+1):
        if i in A:
            ans.append(0)
            ans.pop(0)
        else:
            ans.append((ans[0]+ans[1])%mod)
            ans.pop(0)

    print(ans[1]%mod)

if __name__ == "__main__":
    main()

### FIXED CODE ###

from functools import lru_cache

def main():
    n,m = map(int,input().split())
    import numpy as np
    ans = np.ones(n+1,dtype=int)*-1
    ans[0] = 1
    mod = 10**9+7
    for _ in range(m):
        a = int(input())
        ans[a]=0
    if ans[1]!=0:
        ans[1]=1
    for i in range(2,n+1):
        if ans[i]!=0:
            ans[i] = (ans[i-1]+ans[i-2])%mod
    print(ans[-1])
        

if __name__ == "__main__":
    main()
### BUGGY CODE ###

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

now = 1

x = 2
while P > 1:
    if P % x == 0:
        while P % (x ** N) == 0:
            now *= x
            P = P / (x ** N)
        while P % x == 0:
            P = P / x

    x += 1


print(now)

### FIXED CODE ###

n, p = map(int, input().split())
if n == 1:
    print(p)
else:
    for i in range(1, round(p**(1/n))+1):
        if p % i**n ==0:
            res = i
    print(res)
### BUGGY CODE ###

a=int(input())
b=0
while a>0 or b==0:
  if a%10==7:
    b=1
  a/=10
  
if b==1:
  print("Yes")
else:
  print("No")
  

### FIXED CODE ###

N = input()
if '7' in N:
  print('Yes')
else:
  print('No')
### BUGGY CODE ###

import collections
import math
n = int(input())
ai = [int(i) for i in input().split()]

mod = 10**9+7

if n == 1:
    print(1)
    exit()
    
    
# 素因数分解、辞書で返すやつ
# mathをimportする
def prime(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
        if num > n:
            break
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor


dic = {}
for a in ai:
    pr = prime(a)
    for num, count in pr.items():
        if not num in dic.keys():
            dic[num] = count
        else:
            if dic[num] < count:
                dic[num] = count

kari = 1
for num,count in dic.items():
    kari *= pow(num,count,mod)

kari_old = kari
ans = 0

for i in range(n):
    kari = kari_old
    #com_ab_new = copy.deepcopy(com_ab)
    #print(com_ab,com_ab_new)
    pr = prime(ai[i])
    #kari = 1
    #for j in range(kosu):
    #kari *= pow(sosu_li[j][0],com_ab[sosu_li[j][0]],mod)
    for num,count in pr.items():
        kari *= pow(pow(num,count,mod),mod-2,mod)
    ans += kari
    ans %= mod
    #print(ans)
    #print(ans)
        
print(ans)


### FIXED CODE ###

import collections
import math
n = int(input())
ai = [int(i) for i in input().split()]

mod = 10**9+7

if n == 1:
    print(1)
    exit()
    
    
# 素因数分解、辞書で返すやつ
# mathをimportする
def prime(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
        if num > n:
            break
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor


dic = {}
for a in ai:
    pr = prime(a)
    for num, count in pr.items():
        if not num in dic.keys():
            dic[num] = count
        else:
            if dic[num] < count:
                dic[num] = count

kari = 1
for num,count in dic.items():
    kari *= pow(num,count,mod)
    kari %= mod

kari_old = kari
ans = 0

for i in range(n):
    kari = kari_old
    #com_ab_new = copy.deepcopy(com_ab)
    #print(com_ab,com_ab_new)
    #kari = 1
    #for j in range(kosu):
    #kari *= pow(sosu_li[j][0],com_ab[sosu_li[j][0]],mod)
    kari *= pow(ai[i],mod-2,mod)
    ans += kari
    ans %= mod
    #print(ans)
    #print(ans)
        
print(ans)
### BUGGY CODE ###

N, P = map(int, input().split())
S = list(map(int,list(input())))
U = [0 for i in range(N+1)]


for i in range(N):
    U[N-(i+1)] = (U[N-i] + S[N-1-i] * (10 ** i)) % P
    
def solve(U,S):
    if P == 2 or P == 5:
        return solve1(S)
    else:
        return solve2(U)
    
def solve1(S):
    ans = 0
    for i in range(N):
        if S[i] % P == 0:
            ans += i+1
    return ans

def solve2(U):
    ans = 0
    cnt = [0 for i in range(P)]
    for i in range(N+1):
        cnt[U[i]] += 1
    for i in range(P):
        p = cnt[i]
        ans += (p * (p-1)) // 2
    return ans

print(solve(U,S))

### FIXED CODE ###

N, P = map(int, input().split())
S = list(map(int,list(input())))
U = [0 for i in range(N+1)]
POW = [1 for i in range(N)]

for i in range(N-1):
    POW[i+1] = (POW[i]*10) % P

for i in range(N):
    U[N-(i+1)] = (U[N-i] + S[N-1-i] * POW[i]) % P
    
def solve(U,S):
    if P == 2 or P == 5:
        return solve1(S)
    else:
        return solve2(U)
    
def solve1(S):
    ans = 0
    for i in range(N):
        if S[i] % P == 0:
            ans += i+1
    return ans

def solve2(U):
    ans = 0
    cnt = [0 for i in range(P)]
    for i in range(N+1):
        cnt[U[i]] += 1
    for i in range(P):
        p = cnt[i]
        ans += (p * (p-1)) // 2
    return ans

print(solve(U,S))
### BUGGY CODE ###

import numpy as np

n, k = map(int, input().split())
arr = np.array(list(map(int, input().split())))

for i in range(min(k, 40)):
    tmp_arr = np.zeros(n + 1, np.int64)
    for i, x in enumerate(arr):
        tmp_arr[max(0, i - x)] += 1
        tmp_arr[min(n, i + x + 1)] -= 1
    arr = np.cumsum(tmp_arr)[:-1]

print(*arr)

### FIXED CODE ###

from itertools import accumulate
import sys

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

for cnt in range(k):
    tmp = [0] * (n + 2)
    for i in range(n):
        power = arr[i]
        left = max(0, i - power + 1)
        right = min(n + 1, i + power + 2)
        tmp[left] += 1
        tmp[right] -= 1
    arr = list(accumulate(tmp))[1:-1]
    if cnt > 40:
        arr = [n] * n
        print(*arr)
        sys.exit()

print(*arr)