Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
num_list = list(map(int, input().split()))
 
a=0
for i in num_list:
  if i%2==0 and (i%3!=0 and i%5!=0):
  	print('DENIED')
    exit()

print('APPROVED')

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

for i in A:
  if i%2 == 0 and i%3 != 0 and i%5 != 0:
    print('DENIED')
    exit()
print('APPROVED')
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
P = list(map(int, input().split()))
P_max = 0
for i in range(len(P)):
    P_new = P[i:i+K]
    P_sum = sum(P_new)
    if P_sum > P_max:
        P_max = P_sum
print(P_max/2+0.5*K)

Fixed submission:
N,K = map(int, input().split())
P = list(map(int, input().split()))
P_sum = 0
for i in range(K):
    P_sum += P[i]
P_max = P_sum
for i in range(N-K):
    P_sum = P_sum + P[K+i]-P[i]
    if P_sum > P_max:
        P_max = P_sum
print(P_max/2+0.5*K)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
P = list(map(int, input().split()))
P_max = 0
for i in range(len(P)):
    P_new = P[i:i+K]
    P_sum = sum(P_new)
    if P_sum > P_max:
        P_max = P_sum
print(P_max/2+0.5*K)

Fixed submission:
N,K = map(int, input().split())
P = list(map(int, input().split()))
P_sum = 0
for i in range(K):
    P_sum += P[i]
P_max = P_sum
for i in range(N-K):
    P_sum = P_sum + P[K+i]-P[i]
    if P_sum > P_max:
        P_max = P_sum
print(P_max/2+0.5*K)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
P = list(map(int, input().split()))
Ex = {}
for i in range(1,1001):
    Ex[i] = sum([x*1/i for x in range(1, i+1)])

P_ex = []
for t in P:
    P_ex.append(Ex[t])

Sum = []
for l in range(len(P_ex)):
    Sum.append(sum(P_ex[l:l+K]))

print(max(Sum))

Fixed submission:
N,K = map(int, input().split())
P = list(map(int, input().split()))
P_sum = 0
for i in range(K):
    P_sum += P[i]
P_max = P_sum
for i in range(N-K):
    P_sum = P_sum + P[K+i]-P[i]
    if P_sum > P_max:
        P_max = P_sum
print(P_max/2+0.5*K)
Buggy python submission (verdict: Runtime Error):
N,M = map(int(),input().split())
print('Yes' if N==M else 'No')

Fixed submission:
N,M = input().split()
if N == M:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
N,M = map(int(),input().split())
 
if N == M:
  print('Yes')
  
else:
  print('No')


Fixed submission:
N,M = input().split()
if N == M:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
N,M = map(int(),input().split( ))

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

Fixed submission:
N,M = input().split()
if N == M:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
if N == M:
  print("Yes")
  
 else:
  print("No")
  

Fixed submission:
N,M = input().split()
if N == M:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
a , b =input().split()
 
if a <= b:
	for i in b:
    print(a*int(b))
 
else:
	for v in a:
	print(b*int(a))

Fixed submission:
a , b =input().split()
 
if a <= b:
    print(a*int(b))
else:
	print(b*int(a))

Buggy python submission (verdict: Runtime Error):
a , b =int(),input().split()

if a <= b:
	for i in b:
    print(a*int(b))
 
else:
	for v in a:
	print(b*int(a))

Fixed submission:
a , b =input().split()
 
if a <= b:
    print(a*int(b))
else:
	print(b*int(a))

Buggy python submission (verdict: Runtime Error):
a , b = map(int(),input().split())
 
X = ''
Y = ''
 
if a < b:
	for i in b:
		X = 'X' + 'a'
    print(X)
 
else:
	for v in a:
		Y = 'Y' + 'b'
	print(Y)

Fixed submission:
a , b =input().split()
 
if a <= b:
    print(a*int(b))
else:
	print(b*int(a))

Buggy python submission (verdict: Runtime Error):
a , b = map(int(),input().split())
 
X = 0
Y = 0
 
if a < b:
	for i in b:
		X = 'X' + 'a'
    print(X)
 
else:
	for v in a:
		Y = 'Y' + 'b'
	print(Y)

Fixed submission:
a , b =input().split()
 
if a <= b:
    print(a*int(b))
else:
	print(b*int(a))

Buggy python submission (verdict: Runtime Error):
a , b = map(int(),input().split())

X = 0
Y = 0

if a < b:
	for i in b:
		X = 'X' + 'a'
    print(X)

else:
	for v in a:
		Y = 'Y' + 'b'
	print(Y)

Fixed submission:
a , b =input().split()
 
if a <= b:
    print(a*int(b))
else:
	print(b*int(a))

Buggy python submission (verdict: Runtime Error):
a , b = map(int(),input().split())
 
X = 0
Y = 0

for i in b:
  X = 'X' + 'a'
  
for v in a:
  Y = 'Y' + 'b'
  
if 'X' <= 'Y':
  print('X')
else:
  print('Y')

Fixed submission:
a , b =input().split()
 
if a <= b:
    print(a*int(b))
else:
	print(b*int(a))

Buggy python submission (verdict: Runtime Error):
a , b = map(int(),input().split())
 
X = 0
Y = 0

for i in b:
  X = 'X' + 'a'
  
for v in a:
  Y = 'Y' + 'b'
  
if 'X' < 'Y':
  print(X)
else:
  print(Y)

Fixed submission:
a , b =input().split()
 
if a <= b:
    print(a*int(b))
else:
	print(b*int(a))

Buggy python submission (verdict: Runtime Error):
a , b = map(int(),input().split())

X = 0
Y = 0

list = [X,Y]

for i in b:
  X = X + 'a'
  
for v in a:
  Y = Y + 'b'
  
if 'X' < 'Y':
  print(X)
else:
  print(Y)

Fixed submission:
a , b =input().split()
 
if a <= b:
    print(a*int(b))
else:
	print(b*int(a))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))  
B = [None]*N

for i in range(N):
  if all([A[v] >= A[i] for v in range(i)]): 
    B[i]=True
  else:
    B[i]=False

print(B.count(True))


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

min = 0
cnt = 0
for i in range(N):
  if i == 0:
    cnt += 1
    min = A[i]
    continue
  if A[i] <= min:
    cnt += 1
    min = A[i]

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))  
B = []

for i in range(N):
  if all([A[v] >= A[i] for v in range(i)]): 
    B.append(True)
  else:
    B.append(False)

print(B.count(True))

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

min = 0
cnt = 0
for i in range(N):
  if i == 0:
    cnt += 1
    min = A[i]
    continue
  if A[i] <= min:
    cnt += 1
    min = A[i]

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))  

cnt = 0
for i in range(N):
  if all([A[v] >= A[i] for v in range(i)]): 
    cnt = cnt +1

print(cnt)

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

min = 0
cnt = 0
for i in range(N):
  if i == 0:
    cnt += 1
    min = A[i]
    continue
  if A[i] <= min:
    cnt += 1
    min = A[i]

print(cnt)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))  

cnt = 0
for i in N:
  if all([A[v] >= A[i] for v in i]): 
    cnt = cnt +1

print(cnt)

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

min = 0
cnt = 0
for i in range(N):
  if i == 0:
    cnt += 1
    min = A[i]
    continue
  if A[i] <= min:
    cnt += 1
    min = A[i]

print(cnt)
Buggy python submission (verdict: Runtime Error):
from numpy import zeros

N = int(input())
A = zeros((10,10))

for i in range(1,N+1):
  s = int(str(i)[0])
  t = int(str(i)[-1])
  A[s][t] += 1

cnt = 0
for l in range(1,N+1)
  a = int(str(i)[0])
  b = int(str(i)[0])
  cnt += A[s][t]
  
print(cnt)

Fixed submission:
N = int(input())
A =[[0]*10 for i in range(10)]
 
for i in range(1,N+1):
  a = int(str(i)[0])
  b = int(str(i)[-1])
  A[a][b] += 1
 
cnt = 0
for _ in range(1,N+1):
  a = int(str(_)[0])
  b = int(str(_)[-1])
  cnt += A[b][a]
  
print(cnt)
Buggy python submission (verdict: Runtime Error):
X,Y = map(int, input().split())
if X>Y:
  print(">")
elif X<Y:
  print("<")
else:
  print("=")

Fixed submission:
X,Y =input().split()
if X>Y:
  print(">")
elif X<Y:
  print("<")
else:
  print("=")
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N = I()
A = LI()

ans = 1
for a in A:
    ans *= a

print(ans if ans <= 10**18 else -1)


Fixed submission:
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N = I()
A = LI()

ans = 1
for a in A:
    ans *= a

    if ans > 10**18:
        ans = -1
        break

print(ans if not 0 in A else 0)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N, K = LI()
A = LI()

tel = [-1] * N

i = 0
time = 1
while True:
    # print(i, end=" ")
    if time == K:
        print(A[i])
        break
    
    if tel[i] == -1:
        tel[i] = [time, A[i]-1]
        i = A[i]-1
    else:
        # i = A[i]-1
        break
    
    time += 1
    # print(time, tel)
# print()
# print(time-1)
# print(time - tel[i][0])
# print((K - (time-1)) % (time - tel[i][0]))

for _ in range((K - (time-1)) % (time - tel[i][0])):
    i = A[i]-1

print(i+1)


Fixed submission:
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N, K = LI()
A = LI()

tel = [-1] * N
flag = True
i = 0
time = 1
while True:
    # print(i, end=" ")
    if time == K:
        print(A[i])
        flag = False
        break
    
    if tel[i] == -1:
        tel[i] = [time, A[i]-1]
        i = A[i]-1
    else:
        # i = A[i]-1
        break
        # pass
    
    time += 1
    # print(time, tel)
# print()
# print(time-1)
# print(time - tel[i][0])
# print((K - (time-1)) % (time - tel[i][0]))

if flag:
    for _ in range((K - (time-1)) % (time - tel[i][0])):
        i = A[i]-1

    print(i+1)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

S = input()
N = len(S)
P = 2019

A = [0] * (N+1)
for i in range(N):
    A[i+1] = (A[i] + int(S[N-1 - i]) * (10**i)) % P

c = collections.Counter(A)
ans = 0
for k, v in c.items():
    ans += v * (v-1) // 2

print(ans)


Fixed submission:
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

S = input()
N = len(S)
P = 2019

A = [0] * (N+1)
for i in range(N):
    A[i+1] = (A[i] + int(S[N-1 - i]) * pow(10, i, P)) % P

c = collections.Counter(A)
ans = 0
for v in c.values():
    ans += v * (v-1) // 2

print(ans)
Buggy python submission (verdict: Runtime Error):
aa

Fixed submission:
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

R = I()
print(R*2*math.pi)
Buggy python submission (verdict: Runtime Error):
aaa

Fixed submission:
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")

N = input()

print("Yes" if "7" in N else "No")
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")

N = I()

ans = 0
for a in range(1, N+1):
    for b in range(1, N+1):
        for c in range(1, N+1):
            ans += math.gcd(math.gcd(a, b), c)

print(ans)


Fixed submission:
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")

from functools import lru_cache

@lru_cache(maxsize=INF)
def ggcd(a, b):
    return math.gcd(a, b)

K = I()

h = [0] * 201
for a in range(1, K+1):
    for b in range(1, K+1):
        h[ggcd(min(a,b), max(a,b))] += 1

ans = 0
for c in range(1, K+1):
    for i, ab in enumerate(h):
        if ab != 0:
            ans += ggcd(min(c,i), max(c,i)) * ab

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]

N, X, Y = LI()

dist = [[INF] * (N+1) for _ in range(N+1)]

for i in range(1, N+1):
    for j in range(i, N+1):
        dist[i][j] = min(j-i, abs(X-i)+1+abs(Y-j), abs(X-j)+1+abs(Y-i))

for i in range(1, N):
    tmp = 0
    for d in dist:
        tmp += d.count(i)

    print(tmp)


Fixed submission:
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def PL(L) : print(*L, sep="\n")

N, X, Y = LI()

ans = [0] * N

for i in range(1, N+1):
    for j in range(i, N+1):
        ans[min(j-i, abs(X-i)+1+abs(Y-j), abs(X-j)+1+abs(Y-i))] += 1

PL(ans[1:])
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]

A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = I()
print(A[K - 1])
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]

A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = I()
print(A[K - 1])


Fixed submission:
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]

A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = I()
print(A[K - 1])
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N, P = LI()
S = input()

if P == 2 or P == 5:
    ans = 0
    for i in range(N):
        if int(S[N-1 - i]) % P == 0:
            ans += N-i
    print(ans)
else:
    A = [0] * (N+1)
    for i in range(N):
        A[i+1] = (A[i] + int(S[N-1 - i]) * (10**i)) % P

    c = collections.Counter(A)
    ans = 0
    for k, v in c.items():
        ans += v * (v-1) // 2
    
    print(ans)


Fixed submission:
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N, P = LI()
S = input()

if P == 2 or P == 5:
    ans = 0
    for i in range(N):
        if int(S[N-1 - i]) % P == 0:
            ans += N-i
    print(ans)
else:
    A = [0] * (N+1)
    for i in range(N):
        A[i+1] = (A[i] + int(S[N-1 - i]) * pow(10, i, P)) % P

    c = collections.Counter(A)
    ans = 0
    for v in c.values():
        ans += v * (v-1) // 2
    
    print(ans)