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

from itertools import combinations
N = int(input())
s = input()
ans = 0
for a2 in range(10):
    for b2 in range(10):
        for c2 in range(10):
            a = str(a2)
            b = str(b2)
            c = str(c2)
            count = 0
            for i in s:
                if a == i:
                    count += 1
                    if count == 1:
                        a = b
                    if count == 2:
                        a = c
            if count >= 3:
                ans += 1
print(ans)

### FIXED CODE ###

from itertools import combinations
N = int(input())
s = input()
ans = 0
for a2 in range(10):
    for b2 in range(10):
        for c2 in range(10):
            a = str(a2)
            b = str(b2)
            c = str(c2)
            count = 0
            for i in s:
                if a == i:
                    count += 1
                    if count == 1:
                        a = b
                    if count == 2:
                        a = c
            if count >= 3:
                ans += 1
print(ans)
### BUGGY CODE ###

N = int(input())
S = input()
cnt = 0
for i in range(1000):
    l = list()
    l.append(i // 100)
    l.append((i // 10) % 10)
    l.append(i % 10)
    f = 0
    for j in range(N):
        if int(S[j]) == l[f]:
            f += 1
        if f == 3:
            break
    if f == 3:
        cnt += 1
print(cnt)


### FIXED CODE ###

N = int(input())
S = input()
cnt = 0
for i in range(1000):
    num = ''
    num += str(i // 100)
    num += str((i // 10) % 10)
    num += str(i % 10)
    j = 0
    for n in range(N):
        if S[n] == num[j]:
            j += 1
        if j == 3:
            break
    if j == 3:
        cnt += 1
print(cnt)
### BUGGY CODE ###

N,M = map(int,input().split())
a = []

for _ in range(M):
  a.append(input())

S = [0] * (N+1)
for n in range(N+1):
    if str(n) in a:
        S[n] = 0
    elif n<=1:
        S[n] = 1
    else:
        S[n] = S[n-1] + S[n-2]

print(S[n] % 1000000007)

### FIXED CODE ###

N,M = map(int,input().split())
a = [True] * (N+1)

for _ in range(M):
  a[int(input())] = False

S = [0] * (N+1)
S[0] = 1
for n in range(1, N+1):
    if a[n]==False:
        S[n] = 0
    elif n==1:
        S[n] = 1
    else:
        S[n] = (S[n-1] + S[n-2])%1000000007

print(S[n])
### BUGGY CODE ###

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

for _ in range(m):
    b,c = map(int, input().split())
    for _ in range(b):
        a.append(c)
        a.sort(reverse=True)
                

print(sum(a[:n]))

### FIXED CODE ###

n,m = map(int, input().split())
a = sorted(list(map(int,input().split())))
bc = [list(map(int, input().split())) for _ in range(m)]
bc.sort(key=lambda x: x[1], reverse=True )
count = 0
for b,c in bc:
    for _ in range(b):
        if count == n or a[count] >= c:
            break

        a[count] = c
        count += 1

print(sum(a))
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
from fractions import gcd
mod = 10**9+7
g = A[0]
for a in A[1::]:
  g = g*a//gcd(g,a)
  
ans = 0
b = g%mod
for a in A:
  ans += g%mod*pow(a,mod-2,mod)
  ans %= mod
  
print(ans%mod)


### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
from fractions import gcd
mod = 10**9+7
g = A[0]
for a in A[1::]:
  g = g*a//gcd(g,a)
  
ans = 0
b = g%mod
for a in A:
  ans += g%mod*pow(a,mod-2,mod)
  ans %= mod
  
print(ans%mod)
### BUGGY CODE ###

n, k = map(int, input().split())
l = list(map(int, input().split()))
l = list(map(lambda x: (((x + 1) * x) / 2) / x, l))
l_2 = []
for i in range(len(l) - (k - 1)):
    l_2 += [sum(l[i:i + k])]
print(max(l_2))


### FIXED CODE ###

from itertools import accumulate
n, k = map(int, input().split())
l = list(map(int, input().split()))
l = list(map(lambda x: (((x + 1) * x) / 2) / x, l))
s = list(accumulate(l))
l_2 = [s[k - 1]]
for i in range(len(l) - (k - 1) - 1):
    l_2 += [s[i + k] - s[i]]
print(max(l_2))
### BUGGY CODE ###


import itertools
import sys
import numpy as np
from collections import deque
from itertools import combinations
sys.setrecursionlimit(10**9)


def solve(N,K):
    # print(N,K)
    if N <= 10:
        if K == 0:
            return 1
        elif K == 1:
            return N
        else:
            return 0

    if K < 0 or len(str(N)) < K:
        return 0

    ans = 0
    m, last = divmod(N,10)
    ans += solve(m,K-1) * last + solve(m-1,K-1) * (9 - last) + solve(m,K)

    return ans


def main():
    N,K = map(int,[input(),input()])
    
    print(solve(N,K))

if __name__ == "__main__":
  main()


### FIXED CODE ###

import itertools
import sys
import numpy as np
from collections import deque
from itertools import combinations
from functools import lru_cache
sys.setrecursionlimit(10**9)

@lru_cache(None)
def solve(N,K):
    # print(N,K)
    if N <= 10:
        if K == 0:
            return 1
        elif K == 1:
            return N
        else:
            return 0

    if K < 0 or len(str(N)) < K:
        return 0

    ans = 0
    m, last = divmod(N,10)
    ans += solve(m,K-1) * last + solve(m-1,K-1) * (9 - last) + solve(m,K)

    return ans


def main():
    N,K = map(int,[input(),input()])

    print(solve(N,K))

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

def luca(n):
    if n==0:
        return 2
    elif n == 1:
        return 1
    else:
        return luca(n-1)+luca(n-2)

N = int(input())

print(luca(N))


### FIXED CODE ###

from functools import lru_cache
@lru_cache(maxsize=None)

def luca(n):
    if n==0:
        return 2
    elif n == 1:
        return 1
    else:
        return luca(n-1)+luca(n-2)

N = int(input())

print(luca(N))
### BUGGY CODE ###

import math

def  XYZTriplets():

    num = int(input())
    
    for i in range(1, num+1):
        count = 0

        x = 1
        y = 1
        z = 1

        for x in range(1, int(math.sqrt(num))+1):
            for y in range(1, int(math.sqrt(num))+1):
                for z in range(1, int(math.sqrt(num))+1):
            
                    function = 0.5*( (x+y)*(x+y) + (y+z)*(y+z) + (z+x)*(z+x) ) - i
                                
                    if function == 0:
                        count = count + 1
                        
                    
        print(count)
        




if __name__ == '__main__':
    XYZTriplets()


### FIXED CODE ###

import math
import numpy as np

def  XYZTriplets():

    num = int(input())
    
    list_num = []
    
    count = [0]*num
    
    for i in range(1, num+1):
        list_num.append(i)

    for x in range(1, int(math.sqrt(num))):
        for y in range(1, int(math.sqrt(num))):
            for z in range(1, int(math.sqrt(num))):
                
                function = x*x + y*y + z*z + x*y + y*z + z*x
                
                if function <= num and function > 0:
                    count[function-1] = count[function-1] + 1
 
    for i in range(0, num):
        print(count[i])
        

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

n = int(input())
k = int(input())
s = 1
while n > 0:
  if s < k:
    s = s*2
  else:
    s += k
print(s)

### FIXED CODE ###

n = int(input())
k = int(input())
s = 1
while n > 0:
  if s < k:
    s = s*2
  else:
    s += k
  n -= 1
print(s)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
X,Y,Z,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
DD = []
A.sort()
B.sort()
C.sort()
DD = [i+j for i in A for j in B]
DD.sort()
F = [(i+j)
     for i in DD[max(len(DD)-3010,0):]
     for j in C
]
F.sort()
for i in range(K):
    print(F[-1-i])
        


### FIXED CODE ###

import sys
import heapq
input = sys.stdin.readline
X,Y,Z,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
DD = [i+j for i in A for j in B]
DD.sort()
heap = []
for i in DD[max(len(DD)-3001,0):]:
     for j in C:
         heapq.heappush(heap,-(i+j))
for i in range(K):
    print(-heapq.heappop(heap))
### BUGGY CODE ###

H,W = map(int,input().split())
A = [[] for i in range(H)]
B = [[] for i in range(H)]

for i in range(H):
	a = list(map(int,input().split()))
	A[i] = a
for i in range(H):
	b = list(map(int,input().split()))
	B[i] = b

D = [[abs(A[i][j] - B[i][j]) for j in range(W)] for i in range(H)]
R = 160*80
"""
dp = [[[False for k in range(R)] for j in range(W)] for i in range(H)]
dp[0][0][D[0][0]] = True
for i in range(H):
	for j in range(W):
		r = 80 * (i+j+2)
		for n in range(r):
			if not dp[i][j][n]:
				continue
			if j != W-1:
				d = D[i][j+1]
				dp[i][j+1][n+d] = True
				dp[i][j+1][abs(n-d)] = True
			if i != H-1:
				d = D[i+1][j]
				dp[i+1][j][n+d] = True
				dp[i+1][j][abs(n-d)] = True

"""
dp = [[set([]) for j in range(W)] for i in range(H)]
dp[0][0].add(D[0][0])
for i in range(H):
	for j in range(W):
		for s in dp[i][j]:
			if j != W-1:
				d = D[i][j+1]
				dp[i][j+1].add(s+d)
				dp[i][j+1].add(abs(s-d))
			if i != H-1:
				d = D[i+1][j]
				dp[i+1][j].add(s+d)
				dp[i+1][j].add(abs(s-d))
h,w = H-1, W-1
print(min(dp[h][w]))

### FIXED CODE ###

H,W = map(int,input().split())
A = [[] for i in range(H)]
B = [[] for i in range(H)]

for i in range(H):
	a = list(map(int,input().split()))
	A[i] = a
for i in range(H):
	b = list(map(int,input().split()))
	B[i] = b

D = [[abs(A[i][j] - B[i][j]) for j in range(W)] for i in range(H)]
R = 160*80
"""
dp = [[[False for k in range(R)] for j in range(W)] for i in range(H)]
dp[0][0][D[0][0]] = True
for i in range(H):
	for j in range(W):
		r = 80 * (i+j+2)
		for n in range(r):
			if not dp[i][j][n]:
				continue
			if j != W-1:
				d = D[i][j+1]
				dp[i][j+1][n+d] = True
				dp[i][j+1][abs(n-d)] = True
			if i != H-1:
				d = D[i+1][j]
				dp[i+1][j][n+d] = True
				dp[i+1][j][abs(n-d)] = True

"""
dp = [[0 for j in range(W)] for i in range(H)]
dp[0][0] = 2**(R + D[0][0]) | 2**(R - D[0][0])
for i in range(H):
	for j in range(W):
		if j != W-1:
			d = D[i][j+1]
			dp[i][j+1] |= (dp[i][j] << d | dp[i][j] >> d)
		if i != H-1:
			d = D[i+1][j]
			dp[i+1][j] |= (dp[i][j] << d | dp[i][j] >> d)
h,w = H-1, W-1
for i in range(R):
	mask = 2 ** (R+i) | 2 ** (R-i)
	if dp[h][w] & mask > 0:
		print(i)
		exit()
### BUGGY CODE ###

N, S=list(map(int,input().split()))
A=list(map(int,input().split()))
A=[0]+A
dp=[[0 for j in range(S+1)] for i in range(N+1)]
dp[0][0]=1
for i in range(1,N+1):
    for j in range(S+1):
        dp[i][j]=(dp[i][j]+2*dp[i-1][j]) %998244353 # x[i]を入れないが、大きい方に入れるか入れないかが二通り
        if j+A[i]<=S:
            dp[i][j+A[i]]=(dp[i][j+A[i]]+dp[i-1][j]) %998244353 # x[i]を入れる
print(dp[N][S])

### FIXED CODE ###

N, S=list(map(int,input().split()))
A=list(map(int,input().split()))
A=[0]+A
dp=[[0 for j in range(S+1)] for i in range(N+1)]
dp[0][0]=1
for i in range(1,N+1):
    for j in range(S+1):
        dp[i][j]=(dp[i][j]+2*dp[i-1][j]) %998244353 # x[i]を入れないが、大きい方に入れるか入れないかが二通り
    for j in range(S-A[i]+1):
        dp[i][j+A[i]]=(dp[i][j+A[i]]+dp[i-1][j]) %998244353 # x[i]を入れる
print(dp[N][S])
### BUGGY CODE ###

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






"""
for i in range(M):
    b, c = map(int, input().split())
    A += [c] * b
    
A.sort(reverse=True)
print(sum(A[:N]))
"""

import bisect
A.sort()
A = [-1] + A
for i in range(M):
    b, c = map(int, input().split())
    idx = bisect.bisect_left(A, c)
    #print(A[:idx], A[idx:])
    A = A[:idx] + [c] * b + A[idx:]
    A = A[-N:]
    #print(A)
print(sum(A))

### FIXED CODE ###


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

A.sort()

CB = []
for i in range(M):
    B, C = map(int, input().split())
    CB.append([C, B])
    
CB.sort(reverse=True)

idx = 0
c = 0
for i in range(N):
    if A[i] < CB[idx][0]:
        A[i] = CB[idx][0]
        c += 1
    if CB[idx][1] <= c:
        idx += 1
        c = 0
    if idx >= M:
        break
    #print(A)
        
print(sum(A))
### BUGGY CODE ###

a=1000000007

def isuu(m,n):
    result=m
    i=1
    while i<n:
        result=(result*m)%a
        if result==1:
            return [0,i]
        i+=1
    return [1,result]


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

i=isuu(m,n)
if i[0]==1:
    print(i[1])
else:
    print((m**(n%i[1]))%a)

### FIXED CODE ###

from functools import lru_cache
mod=1000000007

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

@lru_cache()
def power(m,n,mod):
    if n==0:
        return 1
    elif n==1:
        return m
    elif n%2==0:
        return ((power(m,n//2,mod)%mod) * (power(m,n//2,mod)%mod))%mod
    else:
        return (power(m,n-1,mod)*m)%mod

print(power(m,n,mod))
### BUGGY CODE ###

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

dp = [None] * n
for i in range(n):
    if i == 0:
        dp[i] = 0
        continue
    if i-k < 0:
        # ここまで来る方法はi通り
        costs = [abs(Hs[i-j] - Hs[i]) + dp[i-j] for j in range(1, i+1)]
    else:
        costs = [abs(Hs[i-j] - Hs[i]) + dp[i-j] for j in range(1, k+1)]
    
    dp[i] = min(costs)
print(dp[-1])

### FIXED CODE ###

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

dp = [None] * n
for i in range(n):
    if i == 0:
        dp[i] = 0
        continue
    if i-k < 0:
        # ここまで来る方法はi通り
        costs = [abs(Hs[i-j] - Hs[i]) + dp[i-j] for j in range(1, i+1)]
    else:
        costs = [abs(Hs[i-j] - Hs[i]) + dp[i-j] for j in range(1, k+1)]
    
    dp[i] = min(costs)
print(dp[-1])
### BUGGY CODE ###

N,C=map(int,input().split())
List=[[int(i) for i in input().split()] for i in range(N)]
Channel=[[]]*C
for i in range(N):
  Channel_kari=list(Channel[List[i][2]-1])
  Channel_kari.append(i)
  Channel[List[i][2]-1]=list(Channel_kari)
Time=[]
for c in range(C):
  T_c=[0]*(10**5)
  for i in Channel[c]:
    T_c[List[i][0]-1:List[i][1]]=[1]*(List[i][1]-List[i][0]+1)
  Time.append(T_c)  
T=0
T_max=0
for t in range(10**5):
  for c in range(C):
    T+=Time[c][t]
  if T_max<T:
    T_max=T
  T=0
print(T_max)

### FIXED CODE ###

N,C=map(int,input().split())
Time=[[0]*(10**5+1) for c in range(C)]
for i in range(N):
  s,t,c=map(int,input().split())  
  Time[c-1][s-1:t] = [1]*(t-s+1)
Times=max(map(sum,zip(*Time)))
print(Times)
### BUGGY CODE ###

n=int(input())
aa=list(map(int,input().split()))
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        ans+=aa[i]*aa[j]
x=10**9+7
print(ans%x)


### FIXED CODE ###

n=int(input())
aa=list(map(int,input().split()))
su=sum(aa)
new=[n**2 for n in aa]
sa=sum(new)
x=10**9+7
print((su**2-sa)//2%x)
sa
### BUGGY CODE ###

import numpy as np
H,N=map(int,input().split())
A=[0]*N
B=[0]*N
for i in range(N):
  A[i],B[i]=map(int,input().split())
dp=[np.inf]*(H+1)
dp[0]=0
for h in range(H):
  for i in range(N):
    dp[min(H,h+A[i])]=min(dp[h] + B[i], dp[min(H,h+A[i])])
print(dp[-1])
                 

### FIXED CODE ###

H,N=map(int,input().split())
A=[0]*N
B=[0]*N
for i in range(N):
  A[i],B[i]=map(int,input().split())
dp = [99999999999]*(H+1)
dp[0]=0
for h in range(H):
  for i in range(N):
    dp[min(H,h+A[i])]=min(dp[h] + B[i], dp[min(H,h+A[i])])
print(dp[-1])
### BUGGY CODE ###

import sys
input  =  sys.stdin.readline

s = input()
t = input()
dp = [[0]*(len(t) + 1) for i in range(len(s) + 1)]
for i in range(1,len(dp)):
    for j in range(1,len(t) + 1):
        if s[i - 1] == t[j - 1]:
            dp[i][j] = dp[i - 1][j - 1] + 1
        else:
            dp[i][j] = max(dp[i - 1][j],dp[i][j - 1])
out = ''
i = len(s)
j = len(t)
while i != 0 and j != 0:
    if s[i - 1] == t[j - 1]:
        out += s[i - 1]
        i -= 1
        j -= 1
    elif dp[i][j - 1]>dp[i - 1][j]:
        j -= 1
    else:
        i -= 1
print(out[::-1])


### FIXED CODE ###

import sys
input  =  sys.stdin.readline

s = input()
t = input()
dp = [[0]*(len(t) + 1) for i in range(len(s) + 1)]
for i in range(1,len(dp)):
    for j in range(1,len(t) + 1):
        if s[i - 1] == t[j - 1]:
            dp[i][j] = dp[i - 1][j - 1] + 1
        else:
            dp[i][j] = max(dp[i - 1][j],dp[i][j - 1])
out = ''
i = len(s)
j = len(t)
while i != 0 and j != 0:
    if s[i - 1] == t[j - 1]:
        out += s[i - 1]
        i -= 1
        j -= 1
    elif dp[i][j - 1]>dp[i - 1][j]:
        j -= 1
    else:
        i -= 1
print(out[::-1])
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def grundy(a,k):
    while 1:
        if a<k:return 0
        if a<2*k:return a%2^(k%2==0)
        if a%k==0:return a//k
        a-=a//k+1

win=0
for _ in range(II()):
    a,k=MI()
    win^=grundy(a,k)

if win:print("Takahashi")
else:print("Aoki")


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def grundy(a,k):
    while 1:
        if a<k:return 0
        if a%k==0:return a//k
        once=a//k+1
        seg=a%k
        cnt=(seg+once-1)//once
        a-=cnt*once

win=0
for _ in range(II()):
    a,k=MI()
    win^=grundy(a,k)

if win:print("Takahashi")
else:print("Aoki")
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix

N, M = map(int, input().split())
row = []
col = []
for i in range(M):
  u, v = map(int, input().split())
  u -= 1; v -= 1
  row.extend([3*u, 3*u+1, 3*u+2])
  col.extend([3*v+1, 3*v+2, 3*v])

d = [1] * (3*M)

graph = csr_matrix((d, (row, col)), shape=(3*N, 3*N))

S, T = map(int, input().split())
S -= 1; T -= 1
dist = dijkstra(graph, indices=3*S).astype(int)

if dist[3*T] > 0:
  print(dist[3*T] // 3)
else:
  print(-1)

### FIXED CODE ###

from collections import deque

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

graph = [[] for i in range(3*N)]
for i in range(M):
  u, v = map(int, input().split())
  u, v = 3*(u - 1), 3*(v - 1)
  graph[u].append(v+1)
  graph[u+1].append(v+2)
  graph[u+2].append(v)

s, t = map(int, input().split())
s, t = 3*(s - 1), 3*(t - 1)


dist = [10**9] * 3*N
dist[s] = 0
d = deque([s])
while d:
  node = d.popleft()
  children = graph[node]
  for child in children:
    if dist[child] > dist[node] + 1:
      d.append(child)
      dist[child] = dist[node] + 1

if dist[t] < 10**9:
  print(dist[t]//3)
else:
  print(-1)
### BUGGY CODE ###

import numpy as np

s = input()
n = len(s)
mod = 10**9+7
dp = np.zeros((n+1, 13), dtype=np.int64)
dp[0, 0] = 1
j = np.arange(13)
for i in range(n):
  if s[i] != "?":
    t = int(s[i])
    dp[i+1, (10*j+t)%13] += dp[i, j]
    dp[i+1, (10*j+t)%13] %= mod
  else:
    for k in range(10):
      dp[i+1, (10*j+k)%13] += dp[i][j]
      dp[i+1, (10*j+k)%13] %= mod
print(dp[n, 5])

### FIXED CODE ###

s = input()
n = len(s)
mod = 10**9+7
dp = [[0]*13 for _ in range(n+1)]
dp[0][0] = 1
d = {(j, k):(10*j+k)%13 for k in range(10) for j in range(13)}
for i in range(n):
  if s[i] != "?":
    t = int(s[i])
    for j in range(13):
      dp[i+1][d[(j, t)]] += dp[i][j]
      dp[i+1][d[(j, t)]] %= mod
  else:
    for k in range(10):
      for j in range(13):
        dp[i+1][d[(j, k)]] += dp[i][j]
        dp[i+1][d[(j, k)]] %= mod
print(dp[n][5]%mod)
### BUGGY CODE ###

import numpy as np
L,R = list(map(int, input().split()))
ans = 2018

s = list(map(int, range(L, R+1)))
if 2019 in s:
    print(0)
    exit()

for i in s:
    for j in s[s.index(i)+1:]:
        ans = min(ans, i*j%2019)

print(ans)


### FIXED CODE ###

L,R = map(int, input().split())
ans = 2018

s = list(map(int, range(L, min(L+2019, R+1))))
if 2019 in s:
    print(0)
    exit()

for i in s:
    for j in s[s.index(i)+1:]:
        ans = min(ans, i*j%2019)

print(ans)
### BUGGY CODE ###

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

from collections import Counter

c = Counter(A)
ind = list(c)
for i in range(1,N+1):
    if str(i) in ind:
        print(c[str(i)])
    else:
        print(0)



### FIXED CODE ###

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

x = [0]*N

for a in A:
    x[a-1] += 1

for i in x:
    print(i)
### BUGGY CODE ###

from heapq import heappop, heappush 
def dijkstra(xs, ys, xg, yg,h,w,k,field):
    # que->(cost, x, y)
    que = [(0, xs, ys)]
    inf = 10 ** 6
    dp = [[inf for _ in range(w+1)] for _ in range(h+1)]
    visited = [[False for _ in range(w+1)] for _ in range(h+1)]
    dp[xs][ys] = 0
    dx = [-1,0,1,0]
    dy = [0,1,0,-1]
    while que:
        cost, x, y= heappop(que)
        # 現在のコストより高いなら無視する
        # if cost > dp[x][y]:
        #     continue
        if x == xg and y == yg:
            print(cost)
            exit(0)
        if not visited[x][y]:
            for i in range(4):
                for j in range(1, k+1):
                    x_, y_ = x+j*dx[i], y+j*dy[i]
                    if not field[x_][y_]:
                        break
                    if dp[x_][y_] > dp[x][y] + 1:
                        dp[x_][y_] = dp[x][y] + 1
                        heappush(que, (dp[x_][y_], x_, y_))
        visited[x][y] = True
    print(-1)
        

def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    h, w, k = map(int, input().split())
    xs, ys, xg, yg = map(int, input().split())
    field = [[False]*(w+2) for _ in range(h+2)]
    for i in range(h):
        # False で覆うことでx,yの制限をなくす。
        s = [True if _ == '.' else False for _ in input()]
        field[i+1] = [False]+s+[False]
    dijkstra(xs, ys, xg, yg, h, w, k, field)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
from collections import deque
def input(): return sys.stdin.readline().rstrip()

def main():
    
    h, w, k = map(int, input().split())
    xs, ys, xg, yg = map(lambda x: int(x)-1, input().split())
    field = [input() for _ in range(h)]

    inf = 1e7

    dist = [[inf]*w for _ in range(h)]
    dist[xs][ys] = 0
    que = deque([(xs, ys)])
    dx = [-1, 0, 1, 0]
    dy = [0, 1, 0, -1]
    while que:
        x, y = que.popleft()
        for i in range(4):
            nx, ny = x, y
            for _ in range(k):
                nx += dx[i]
                ny += dy[i]
                if nx < 0 or nx >= h or ny < 0 or ny >= w: break
                if field[nx][ny] == '@' or dist[nx][ny] <= dist[x][y]: break
                if dist[nx][ny] > dist[x][y] + 1:
                    dist[nx][ny] = dist[x][y] + 1
                    que.append((nx, ny))
        
    if dist[xg][yg] == inf:
        print(-1)
    else:
        print(dist[xg][yg])
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

n, p = map(int, input().split())
s = input()
count = 0
if p in {2, 5}:
    for right in range(n):
        if int(s[right]) % p == 0:
            count += (right + 1)
else:
    mod_p_count = {0: 1}
    for i in range(n):
        sub_s = int(s[i:])
        try:
            mod_p_count[sub_s % p] += 1
        except KeyError:
            mod_p_count[sub_s % p] = 1
    for v in mod_p_count.values():
        count += v*(v - 1) // 2
print(count)

### FIXED CODE ###

n, p = map(int, input().split())
s = input()
sum_count = 0
if p in {2, 5}:
    for right in range(n):
        if int(s[right]) % p == 0:
            sum_count += (right + 1)
else:
    modp_count = [0] * p
    modp_count[0] = 1
    subs_modp, pow = 0, 1
    for si in s[::-1]:
        subs_modp += ((int(si)*pow) % p)
        subs_modp %= p
        modp_count[subs_modp] += 1
        pow = (pow*10) % p
        
    for count in modp_count:
        sum_count += count*(count - 1) // 2
print(sum_count)