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

a, b, k = map(int, input().split())

for i in range(a, b + 1):
    if i < a + k or i > b - k:
        print(i)

### FIXED CODE ###

a, b, k = map(int, input().split())
list = []

for i in range(a, min(b + 1, a + k)):
    list.append(i)

for i in range(max(a, b - k + 1), b + 1):
    if i not in list:
        list.append(i)

for i in range(len(list)):
    print(list[i])
### BUGGY CODE ###

n,m=map(int,input().split())
lists=list(map(int,input().split()))
checklist=[]
for i in range(m):
    b,c=map(int,input().split())
    checklist=checklist+[c]*b
checklist=sorted(checklist,reverse=True)
lists=sorted(lists)

numbers=min(len(lists),len(checklist))

for i in range(numbers):
  if lists[i]<=checklist[i]:
    lists[i]=checklist[i]
  else:
    break
print(sum(lists))

### FIXED CODE ###

n,m=map(int,input().split())
lists=list(map(int,input().split()))
checklist=[]
count=0

for i in range(m):
    b,c=map(int,input().split())
    checklist.append((c,b))
checklist=sorted(checklist,reverse=True)
lists=sorted(lists)
uselist=[]
count=0

for i in checklist:
    for _ in range(i[1]):
        uselist.append(i[0])
    count+=i[1]

    if count>=n:
        break
answer=0
n=min(n,len(uselist))
for i in range(n):
    if lists[i]<uselist[i]:
            lists[i]=uselist[i]
    else:
        break
print(sum(lists))
### BUGGY CODE ###

n, k = map(int, input().split())
s = list(input())
# print(n, k, s)

a = []
cnt = 0
for i in range(n-1):
    cnt += 1
    if s[i] != s[i+1]:
        a.append(cnt)
        cnt = 0 # reset
a.append(cnt+1)
# print(a) # 連続する0,1の数の配列を作った
### 前処理 両端が1の数を表す数列を作ることが出来た
if s[0] == "0": # 左端
    a.insert(0, 0)
if s[-1] == "0": # 右端
    a.append(0)
# print(a)
# print((len(a)-2*k+1)//2)
if (len(a)-2*k+1)/2 < 1:
    k = int((len(a)-1)/2)
# print(k)
ans = 0
for i in range((len(a)-2*k+1)//2):
    # b = 0
    b = sum(a[2*i:2*i+2*k+1])
    #for j in range(2*k+1):
    #    b += a[2*i+j]
    # print(i, b)
    ans = max(ans, b) # 最大値を更新していく
print(ans)

### FIXED CODE ###

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

# 累積和
a = [0]
if s[0] == "0":
	a.append(0)
for i in range(n):
	if i == n-1 or s[i+1] != s[i]:
		a.append(i+1) # 累積和

# print(s[-1])
if s[-1] == "0":
	a.append(a[-1])

if len(a) <= 2*k+1: # 2*k+1
	print(n)
else:
	ans = 0
	for j in range(0, len(a) - 2*k - 1, 2): # len(a)は奇数
		ans = max(ans, a[j+2*k+1] - a[j])
	print(ans)
### BUGGY CODE ###

A,B,K = map(int, input().split())
List = [i for i in range(A,B+1)]
s = List[0:K]
r = List[::-1]
l = r[0:K]
for i in l:
    s.append(i)
w = sorted(set(s))
for j in w:
    print(j)

### FIXED CODE ###

A,B,K = map(int, input().split())
if B-A+1 >= K:
    s = [i for i in range(A,A+K)]
    l = [j for j in range(B-K+1,B+1)]
    for k in l:
        s.append(k)
    w = sorted(set(s))
else:
    w = [b for b in range(A,B+1)]
for j in w:
    print(j)
### BUGGY CODE ###

import heapq
N,M = map(int,input().split())
AB = []
for i in range(N):
    a,b = list(map(int,input().split()))
    AB.append([-b,a])
heapq.heapify(AB)
work = [0 for i in range(M)]
for i in range(1,M+1):
    AB2 = list(filter(lambda x:x[1]<=i,AB))
    if not AB2:
        continue
    heapq.heapify(AB2)
    b,a = heapq.heappop(AB2)
    work[i-1] = -b
    AB.remove([b,a])
print(sum(work))

### FIXED CODE ###

import heapq
from collections import defaultdict
N,M = map(int,input().split())
AB = defaultdict(list)
for i in range(N):
    a,b = list(map(int,input().split()))
    if a not in AB:
        AB[a] = [-b]
    else:
        AB[a] += [-b]
work = 0
AB2 = []
heapq.heapify(AB2)
for i in range(1,M+1):
    for j in AB[i]:
        heapq.heappush(AB2,j)
    if not AB2:
        continue
    b = heapq.heappop(AB2)
    work += -b
print(work)
### BUGGY CODE ###

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

### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
for i in range(1, N+1):
    print(c[i])
### BUGGY CODE ###

from collections import Counter

def solve():
    MOD = 10**9 + 7

    N, K = map(int, input().split())
    Ass = [tuple(map(int, input().split())) for _ in range(N)]

    maxD = K.bit_length() - 1

    dp = [[Counter() for _ in range(N)] for _ in range(maxD+1)]
    for v, As in enumerate(Ass):
        v2s = []
        for v2, A in enumerate(As):
            if A == 1:
                v2s.append(v2)
        dp[0][v] = Counter(v2s)
    for d in range(1, maxD+1):
        for v in range(N):
            for v2, num2 in dp[d-1][v].items():
                for v3, num3 in dp[d-1][v2].items():
                    dp[d][v][v3] += num2 * num3
                    dp[d][v][v3] %= MOD

    anss = [1] * N
    for d in range(maxD+1):
        if K & (1<<d):
            ans2s = [0] * N
            for v in range(N):
                for v2, num in dp[d][v].items():
                    ans2s[v2] += anss[v] * num
                    ans2s[v2] %= MOD
            anss = ans2s

    print(sum(anss) % MOD)


solve()


### FIXED CODE ###

from collections import Counter

def solve():
    MOD = 10**9 + 7

    N, K = map(int, input().split())
    Ass = [tuple(map(int, input().split())) for _ in range(N)]

    maxD = K.bit_length() - 1

    dp = [[Counter() for _ in range(N)] for _ in range(maxD+1)]
    for v, As in enumerate(Ass):
        v2s = []
        for v2, A in enumerate(As):
            if A == 1:
                v2s.append(v2)
        dp[0][v] = Counter(v2s)
    for d in range(1, maxD+1):
        for v in range(N):
            for v2, num2 in dp[d-1][v].items():
                for v3, num3 in dp[d-1][v2].items():
                    dp[d][v][v3] += num2 * num3
                    dp[d][v][v3] %= MOD

    anss = [1] * N
    for d in range(maxD+1):
        if K & (1<<d):
            ans2s = [0] * N
            for v in range(N):
                for v2, num in dp[d][v].items():
                    ans2s[v2] += anss[v] * num
                    ans2s[v2] %= MOD
            anss = ans2s

    print(sum(anss) % MOD)


solve()
### BUGGY CODE ###

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 998244353
N, S = lr()
A = lr()
# dp[i][j][k] i番目まで見て和がjとなる総数
# k=0がL,Rが決まっていない、k=1がLだけ決定、k=2がLとRが決定
dp = [[[0] * 3 for _ in range(S+1)] for _ in range(N+1)]
dp[0][0][0] = 1
for i in range(N):
    a = A[i]
    for j in range(S+1):
        zero = dp[i][j][0] % MOD
        one = dp[i][j][1] % MOD
        two = dp[i][j][2] % MOD
        dp[i+1][j][0] += zero
        dp[i+1][j][1] += zero + one
        dp[i+1][j][2] += zero + one + two
        if a + j <= S:
            dp[i+1][j+a][1] = zero + one
            dp[i+1][j+a][2] = zero + one

answer = dp[N][S][2] % MOD
print(answer)
# 11


### FIXED CODE ###

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 998244353
N, S = lr()
A = lr()
dp = [0] * (S+1)
answer = 0
for a in A:
    dp[0] += 1 # Lの数は１個ずつ加わる
    prev = dp.copy()
    for i in range(S-a+1):
        dp[i+a] += prev[i]
    answer += dp[-1] # その位置Rとした時

print(answer % MOD)
# 26
### BUGGY CODE ###

import numpy as np
n=int(input())
a=np.array(list(map(lambda x:list(map(int,list(('0'*62+bin(int(x))[2:])[-62:]))),input().split())),np.int64)
mod=pow(10,9)+7
ans=0
for i in range(61):# 2^iの位
  bit1=np.sum(a[:,-i-1])
  b=pow(2,i,mod)
  b*=bit1
  b%=mod
  b*=n-bit1
  b%=mod
  ans+=b
  ans%=mod
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
def main():
  n=int(input())
  a=list(map(int,input().split()))
  mod=pow(10,9)+7
  ans=0
  bit=[0]*61 #bit[i]:2^iの位が1である物の個数
  for ai in a:
    for j in range(61):
      if ((ai>>j) & 1):
        bit[j]+=1
  for i in range(61):
    ans+=(pow(2,i)%mod)*bit[i]*(n-bit[i])
    ans%=mod
  print(ans)
if __name__=='__main__':
  main()
### BUGGY CODE ###

n = int(input())
li = list(map(int,input().split()))
a = 1
for i in li:
        a *= i
if a >= 10**18+1:
    print('-1')
else:
    print(a)

### FIXED CODE ###

n = int(input())
li = list(map(int,input().split()))
a = 1
if 0 in li:
    print(0)
else:
    li = sorted(li, reverse=True)
    for i in li:
        if a >= 10**18+1:
            break
        else:
            a *= i
    if a >= 10**18 + 1:
        print('-1')
    else:
        print(a)
### BUGGY CODE ###

import copy

N=int(input())

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

#print(A)

mama=dict()
papa=dict()

for i in range(N):

    if(A[i] in mama):
        print(mama[A[i]])
        continue
    
    AA=copy.deepcopy(A)
    ai=A[i]
    del AA[i]
    #print(AA)
    Aset=set(AA)
    count=0
    
    for i in Aset:
        aa=AA.count(i)
        if(aa in papa):
            count+=papa[aa]
            continue
        #print(i,aa)
        aiu=int((aa*(aa-1))/2)
        count+=aiu
        papa[aa]=aiu
    print(count)
    mama[ai]=count


### FIXED CODE ###

from collections import Counter
N=int(input())
A=list(map(int,input().split()))

parent=dict()
An=set(A)
parecou=0
aaa=Counter(A)
for i in aaa.values():
    parecou+=int((i*(i-1)/2))
"""
for i in An:
    f=A.count(i)
    parent[i]=f
    parecou+=int((f*(f-1)/2))
"""


#print(parecou)
for i in range(N):
    anko=aaa[A[i]]
    print(parecou-int((anko*(anko-1)/2))+int(((anko-2)*(anko-1)/2)))
    #print(parecou-anko+1)
### BUGGY CODE ###

#E
n,m,k = list(map(int,input().split()))
fac = [1]*n
finv = [1]*n
inv = [1]*n
MOD = 998244353
for i in range(2,n):
    fac[i] = fac[i-1]*i%MOD
    inv[i] = MOD-inv[MOD%i]*(MOD//i)%MOD
    finv[i] = finv[i-1]*inv[i]%MOD
def comb(n,k):
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD

ans = 0
for i in range(k+1):
#     print(comb(n-1,i),m*(m-1)**(n-i-1))
    ans += (comb(n-1,i)*m*((m-1)**(n-i-1)%MOD))%MOD
    ans %= MOD
print(ans)

### FIXED CODE ###

#E
n,m,k = list(map(int,input().split()))
fac = [1]*n
finv = [1]*n
inv = [1]*n
MOD = 998244353
for i in range(2,n):
    fac[i] = fac[i-1]*i%MOD
    inv[i] = MOD-inv[MOD%i]*(MOD//i)%MOD
    finv[i] = finv[i-1]*inv[i]%MOD
def comb(n,k):
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD

ans = 0
for i in range(k+1):
#     print(comb(n-1,i),m*(m-1)**(n-i-1))
    ans += comb(n-1,i)*m*pow(m-1,n-i-1,MOD)%MOD
    ans %= MOD
print(ans)
### BUGGY CODE ###

import heapq

class PriorytyQueue(object):

    def __init__(self, arr, target='min'):
        self.arr = arr
        self.target = target
        self._heapify()
    
    def _heapify(self):
        if self.target == 'max':
            self.arr = list(map(lambda x:x*(-1), self.arr))
        heapq.heapify(self.arr)
    
    def push(self, x):
        if self.target == 'max':
            x *= -1
        heapq.heappush(self.arr, x)

    def pop(self):
        res = heapq.heappop(self.arr)
        if self.target == 'max':
            return res*(-1)
        else:
            return res
    
    def get_arr(self):
        if self.target == 'max':
            return list(map(lambda x:x*(-1), self.arr))
        else:
            return self.arr
    
    def is_empty(self):
        return len(self.arr) == 0

from collections import defaultdict

N, M = map(int, input().split())
jobs = defaultdict(list)
for i in range(N):
    a, b = map(int, input().split())
    jobs[a].append(b)

if __name__ == "__main__":

    ans = 0
    pq = PriorytyQueue([], target='max')
    for d in range(1, M+1):
        if d in jobs.keys():
            moneys = jobs[d]
            for money in moneys:
                pq.push(money)
        if len(pq.get_arr()) != 0:
            ans += pq.pop()
    print(ans)

### FIXED CODE ###

import heapq
from collections import defaultdict

class PriorytyQueue(object):

    def __init__(self, arr, target='min'):
        self.arr = arr
        self.target = target
        self._heapify()
    
    def _heapify(self):
        if self.target == 'max':
            self.arr = list(map(lambda x:x*(-1), self.arr))
        heapq.heapify(self.arr)
    
    def push(self, x):
        if self.target == 'max':
            x *= -1
        heapq.heappush(self.arr, x)

    def pop(self):
        res = heapq.heappop(self.arr)
        if self.target == 'max':
            return res*(-1)
        else:
            return res
    
    def get_arr(self):
        if self.target == 'max':
            return list(map(lambda x:x*(-1), self.arr))
        else:
            return self.arr
    
    def is_empty(self):
        return len(self.arr) == 0

n, m = map(int, input().split())
jobs = defaultdict(list)
for _ in range(n):
    a, b = map(int, input().split())
    if a > m:
        continue
    jobs[a].append(b)

res = 0
candidates = PriorytyQueue(arr=[],
                           target='max')
for d in range(1, m+1):
    if d in jobs.keys():
        for m in jobs[d]:
            candidates.push(m)
    if not(candidates.is_empty()):
        res += candidates.pop()
print(res)
### BUGGY CODE ###

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
for i in range(M):
  a = A.pop(0) // 2
  f = 0
  for j in range(N-2):
    if A[j] >= a >= A[j+1]:
      A.insert(j+1, a)
      f = 1
      break
  if f == 0:
    A.append(a)
print(sum(A))

### FIXED CODE ###

import heapq
N, M = map(int, input().split())
A = list(list(map(lambda x: int(x) * (-1), input().split())))
heapq.heapify(A)
for i in range(M):
  heapq.heappush(A, (-1) * ((-1 * heapq.heappop(A)) // 2))
print(-1 * sum(A))
### BUGGY CODE ###

while 1:
    n=input()
    if n==0:
        break
    else:
        a=[input() for _ in xrange(n)]
        ans=-float('inf')
        for i in xrange(n):
            for j in xrange(i,n):
                suma=sum(a[i:j+1])
                if ans<suma:
                    ans=suma
        print(ans)

### FIXED CODE ###

while 1:
    n=input()
    if n==0:break
    a=[int(raw_input()) for _ in xrange(n)]
    wa=[0]*(n+1)
    max_a=-1000000
    for i in xrange(n):
        wa[i+1]=a[i]+wa[i]
    for i in xrange(n):
        for j in xrange(i+1,n+1):
            if max_a<wa[j]-wa[i]:
                max_a=wa[j]-wa[i]
    print(max_a)
### BUGGY CODE ###

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

for i in range(n):
    max = 0
    for j in range(n):
        if i != j:
            if max < a[j]:
                max = a[j]
    print(max)
            

### FIXED CODE ###

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

highmax = 0
maxs=0
for i in range(n):
    if highmax < a[i]:
        highmax = a[i]
        maxs = i

for i in range(n):
    max = 0
    if maxs != i:
        print(a[maxs])
    else:
        for j in range(n):
            if i != j:
                if max < a[j]:
                    max = a[j]
        print(max)
### BUGGY CODE ###

import math
A, B, N = map(int, input().split())
ans = 0
for x in range(N+1):
    tmp = math.floor(A*x/B) - A*math.floor(x/B)
    if tmp < ans:
        break
    ans = tmp
print(ans)

### FIXED CODE ###

import math
A, B, N = map(int, input().split())


def f(x):
    return math.floor(A*x/B) - A * math.floor(x/B)


print(f(min(B-1, N)))
### BUGGY CODE ###

N = [int(i) for i in input().split()]

answerList = []

for i in range(N[0]+1):
    answerList.append(0)

for i in range(N[0]):
    for j in range(N[0]):
        if j + 1 > i > 0:
            calculateList = [abs(j + 1 - i),
                             abs(N[1] - i) + 1 + abs(j + 1 - N[2]),
                             abs(N[2] - i) + 1 + abs(j + 1 - N[1])]
            answerList[min(calculateList)] = answerList[min(calculateList)] + 1

for i in range(N[0] - 1):
    print(answerList[i+1])

### FIXED CODE ###

N = [int(i) for i in input().split()]

answerList = []

for i in range(N[0]):
    answerList.append(0)

for i in range(N[0]):
    if i > 0:
        for j in range(N[0]):
            if j + 1 > i > 0:
                calculateList = [abs(j + 1 - i),
                                 abs(N[1] - i) + 1 + abs(j + 1 - N[2]),
                                 abs(N[2] - i) + 1 + abs(j + 1 - N[1])]
                answer = min(calculateList)
                answerList[answer] = answerList[answer] + 1

for i in range(N[0] - 1):
    print(answerList[i + 1])
### BUGGY CODE ###

import sys,math

N,A,B=map(int,input().split())
H = [0] * N
H = [int(input()) for i in range(N)]
 
maxH = max(H)
L=-1
R=math.ceil(maxH / B)

while R-L>1:
    MID=int((L+R)/2)
    SUM=0
    for i in range(N):
        Q=float(float(H[i])-float(MID*B)+float(A-B-1))//float(A-B)
        SUM+=max(0,int(Q))

    if SUM>MID:
        L=MID
    else:
        R=MID

print(R)


### FIXED CODE ###

import math

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

maxH = max(H)
L=-1
R=math.ceil(maxH / B)

def binary_search(D,U):
    MID=(D+U)//2
    if(MID==D):
        print(U)
    else:
        if sum(math.ceil(max(h-B*MID,0)/(A-B))for h in H)<=MID:
            binary_search(D,MID)
        else:
            binary_search(MID,U)


binary_search(L,R)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, M: int, Q: int, L: "List[int]", R: "List[int]", p: "List[int]", q: "List[int]"):
    mem = [[0] * N for i in range(N)]
    for i in range(M):
        mem[L[i] - 1][R[i] - 1] += 1
        #print(L[i], R[i], mem)
    for i in range(Q):
        pc = p[i]-1
        qc = q[i]-1
        sum = 0
        for w in range(pc, qc+1):
            for h in range(pc, qc+1):
                sum += mem[w][h]
        print(sum)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    L = [int()] * (M)  # type: "List[int]"
    R = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        L[i] = int(next(tokens))
        R[i] = int(next(tokens))
    p = [int()] * (Q)  # type: "List[int]"
    q = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        p[i] = int(next(tokens))
        q[i] = int(next(tokens))
    solve(N, M, Q, L, R, p, q)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import pprint


def solve(N: int, M: int, Q: int, L: "List[int]", R: "List[int]", p: "List[int]", q: "List[int]"):
    mem = [[0] * N for i in range(N)]
    mem2 = [[0] * N for i in range(N)]
    for i in range(M):
        mem[L[i] - 1][R[i] - 1] += 1
    for h in range(N):
        for w in range(N):
            sum = mem[h][w]
            if h == 0 and w > 0:
                sum += mem2[h][w-1]
            elif w == 0 and h > 0:
                sum += mem2[h-1][w]
            elif h > 0 and w > 0:
                sum += mem2[h][w-1] + mem2[h-1][w] - mem2[h-1][w-1]
            mem2[h][w] = sum
    for i in range(Q):
        pc = p[i]-1
        qc = q[i]-1
        low = mem2[pc-1][qc] + mem2[qc][pc-1] - \
            mem2[pc-1][pc-1] if pc > 0 else 0
        sum = mem2[qc][qc] - low
        print(sum)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    L = [int()] * (M)  # type: "List[int]"
    R = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        L[i] = int(next(tokens))
        R[i] = int(next(tokens))
    p = [int()] * (Q)  # type: "List[int]"
    q = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        p[i] = int(next(tokens))
        q[i] = int(next(tokens))
    solve(N, M, Q, L, R, p, q)


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

N, M = map(int, input().split())
A = [int(i) for i in input().split()]
A_sorted = sorted(A, reverse=True)
for i in range(M):
    A_sorted[0] = (A_sorted[0])/2
    A_sorted = sorted(A_sorted, reverse=True)

ans = 0
for i in range(N):
    ans += A_sorted[i]//1
    
print(int(ans))

### FIXED CODE ###

import heapq
N, M = map(int, input().split())
A = [-int(i) for i in input().split()]
heapq.heapify(A)

for i in range(M):
    tmp_min = heapq.heappop(A)
    heapq.heappush(A, (-tmp_min//2)*(-1))
    

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

N = int(input())
P = list(map(int, input().split()))
result = 0
for i in range(1,N+1):
    if P[i-1]==min(P[:i]):
        result += 1
print(result)

### FIXED CODE ###

N = int(input())
P = [0] + list(map(int, input().split()))
result = 0
minVal = P[1]
for i in range(1,N+1):
    minVal = min(minVal, P[i])
    if P[i]==minVal:
        result += 1
print(result)
### BUGGY CODE ###

import collections
N, P = map(int, input().split())
S = input()

mods = [0] * (N+1)
for i in range(N):
  mods[i] = int(S[i:]) % P
ans = 0
if P == 2 or P == 5:
  for i, s in enumerate(S):
    s = int(s)
    if s % P == 0:
      ans += i+1
else:
  for i in range(N):
    c = dict(collections.Counter(mods[i+1:]))
    ans += c.get(mods[i], 0)

print(ans)

### FIXED CODE ###

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

mods = [0] * (N+1)
for i in range(N-1, -1, -1):
  mods[i] = (int(S[i])*pow(10, N-i-1, P)+mods[i+1]) % P
c = dict()
for m in mods:
  c[m] = c.get(m, 0)+1

ans = 0
if P == 2 or P == 5:
  for i, s in enumerate(S):
    s = int(s)
    if s % P == 0:
      ans += i+1
else:
  for i in range(N):
    c[mods[i]] -= 1
    ans += c[mods[i]]

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

from collections import defaultdict,deque
from math import ceil
H,W,K=map(int,input().split())
grid=[input() for i in range(H)]
G=defaultdict(set)
                               
for i in range(H):
  for j in range(W):
    if grid[i][j]=="S":
      S=(i,j)
    if grid[i][j]!="#":
      if i>0:
        if grid[i-1][j]!="#":
          G[(i,j)].add((i-1,j))
      if i<H-1:
        if grid[i+1][j]!="#":
          G[(i,j)].add((i+1,j))
      if j>0:
        if grid[i][j-1]!="#":
          G[(i,j)].add((i,j-1))
      if j<W-1:
        if grid[i][j+1]!="#":
          G[(i,j)].add((i,j+1))

stack=deque([(S[0],S[1],0)])
visited=[[False]*(W) for i in range(H)]
visited[S[0]][S[1]]=True
a=float("inf")
while stack:
  y,x,m=stack.popleft()
  if m>K:
    break
  a=min(a,min(x,W-1-x,y,H-1-y))
  for k in G[(y,x)]:
    if not visited[k[0]][k[1]]:
      stack.append((k[0],k[1],m+1))
      visited[k[0]][k[1]]=True
ans=1+ceil(a/K)
print(ans)


    
        
        
          
  


### FIXED CODE ###

from collections import deque
from math import ceil
H,W,K=map(int,input().split())
grid=[input() for i in range(H)]

for i in range(H):
  for j in range(W):
    if grid[i][j]=="S":
      S=(i,j)

stack=deque([(S[0],S[1],0)])
visited=[[False]*(W) for i in range(H)]
visited[S[0]][S[1]]=True
a=float("inf")
t=[-1,1]
while stack:
  i,j,m=stack.popleft()
  if m>K:
    break
  a=min(a,min(i,H-1-i,j,W-1-j))
  if a==0:
    break
  for s in t:
    if not visited[i+s][j] and grid[i+s][j]!="#":
      stack.append((i+s,j,m+1))
    if not visited[i][j+s] and grid[i][j+s]!="#":
      stack.append((i,j+s,m+1))
    visited[i+s][j]=True
    visited[i][j+s]=True
ans=1+ceil(a/K)
print(ans)
### BUGGY CODE ###

from collections import Counter
import numpy as np
U = 10 ** 6 + 1

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

C = Counter(A)
memo = np.zeros(U, dtype=bool)
tmp = np.arange(U)
ans = 0

for k in sorted(C.keys()):
    if memo[k]:
        continue
    if C[k] == 1:
        ans += 1
    memo[tmp % k == 0] = True
print(ans)

### FIXED CODE ###

from collections import Counter
U = 10 ** 6 + 1

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

C = Counter(A)
dp = [0] * U

ans = 0
for k in sorted(C.keys()):
    if dp[k]:
        continue
    if C[k] == 1:
        ans += 1
    for i in range(k, U, k):
        dp[i] = 1

print(ans)