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

(N, K) = map(lambda a: int(a), input().split())
A = list(map(lambda a: int(a), input().split()))

def proc():
    global A
    B = [0 for _ in range(N)]

    for i in range(0,N):
        f = i - A[i]
        t = i + A[i]
        for j in range(max(0, f), min(N, t+1)):
            B[j] += 1
    
    A = B

for _ in range(0, K):
    proc()

print(" ".join(map(lambda a: str(a), A)))

### FIXED CODE ###

import numpy as np
from numba import njit

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

@njit
def solve(N,K,A):
    for j in range(0, K):
        B = np.zeros(N, dtype=np.int64)

        for i in range(0,N):
            f = max(0, i - A[i])
            t = min(N-1, i + A[i])
            #for j in range(max(0, f), min(N, t)+1):
            #    B[j] += 1
            B[f] += 1
            if t+1 < N:
                B[t+1] -= 1
        A = np.cumsum(B)
        if np.all(A == N):
            return A
        i += 1
    return A
    

print(" ".join(map(str, solve(N,K,A))))
### BUGGY CODE ###

n=int(input())
s=[]
t=[]
p=0
def f9(n,p):
    while n>=9:
        n//=9
        p+=1
        f9(n,p)
    return p
def f6(n,p):
    while n>=6:
        n//=6
        p+=1
        f6(n,p)
    return p    
s.append((n,0))
while s:
    a=s[0][0]
    b=s[0][1]
    if a<6:
        t.append(b+a)
    else:
        p=0
        s.append((a-9**f9(a,p),b+1))
        p=0
        s.append((a-6**f6(a,p),b+1))
    s.pop(0)    
print(min(t))




### FIXED CODE ###

n=int(input())
s=[]
t=1000
p=0
def f9(n,p):
    while n>=9:
        n//=9
        p+=1
        f9(n,p)
    return p
def f6(n,p):
    while n>=6:
        n//=6
        p+=1
        f6(n,p)
    return p    
s.append((n,0))
while s:
    a=s[0][0]
    b=s[0][1]
    if a<6:
        t=min(t,b+a)
    if t>=b+1:
        p=0
        s.append((a-9**f9(a,p),b+1))
        p=0
        s.append((a-6**f6(a,p),b+1))
    s.pop(0)    
print(t)
### BUGGY CODE ###

def main():
  t = int(input())
  for _ in range(t):
    a, b, c, d = map(int, input().split())
    if (a < b or d < b):
      print("No")
      continue
    if (c >= b):
      print("Yes")
      continue
  
    lst = []
    d %= b
    while True:
      a %= b
      if a > c:
        print("No")
        break
      if a in lst:
        print("Yes")
        break
      lst.append(a)
      a += d
main()

### FIXED CODE ###

def gcd(a, b):
    if b == 0:return a
    return gcd(b, a % b)

t = int(input())
for _ in range(t):
    a, b, c, d = map(int, input().split())
    #exception
    if a < b or d < b:
        print("No")
        continue

    if c >= b:
        print("Yes")
        continue

    g = gcd(d, b)
    print("Yes" if b - g + a % g <= c else "No")
### BUGGY CODE ###

K = int(input())
import math
sumnation = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            sumnation += math.gcd(math.gcd(a,b),c)
print(sumnation)

### FIXED CODE ###

K = int(input())
import math
sumnation = 0
gcdlist = []
for A in range(1,K+1):
    for B in range(1,K+1):
        gcdlist.append(math.gcd(A,B))
for a in range(1,1+K):
    for b in range(1,1+K):
        gcd_a_b = gcdlist[(a-1)*K+b-1]
        for c in range(1,1+K):
            sumnation += gcdlist[(gcd_a_b-1)*K+c-1]
print(sumnation)
### BUGGY CODE ###

n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]

for i in range(n):
    if k-q+a.count(i+1) >= 1:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

import collections

n,k,q = map(int,input().split())
pt = [int(input()) for i in range(q)]
ans = collections.Counter(pt)

for i in range(n):
    if k-q+ans[i+1] >= 1:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

N, K = map(int,input().split())
p = list(map(int, input().split()))
Max = 0
for i in range(N):
    Sum=0
    if i+K<=N:
        for j in range(K):
            Sum += p[i + j]
        if Sum > Max:
            Max = Sum
            index = i
    else:
        break
Sum=0
for i in range(K):
    kitai=1/2*p[index+i]*(p[index+i]+1)
    kitai = kitai / p[index+i]
    Sum+=kitai
print(Sum)

### FIXED CODE ###

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

s=[0]*(N+1)
for i in range(N):
    s[i + 1] = s[i] + p[i]

Max = 0
for i in range(N):
    Sum=0
    if i+K<=N:
        Sum = s[K+i] - s[i]
        if Sum > Max:
            Max = Sum
            index = i
    else:
        break
Sum=0
for i in range(K):
    kitai=1/2*p[index+i]*(p[index+i]+1)
    kitai = kitai / p[index+i]
    Sum+=kitai
print(Sum)
### BUGGY CODE ###

n=int(input())
s=input()
ans=0
for i in range(n):
    si=s[i]
    for j in range(i+1,n):
        sj=s[j]
        tmp=j-i
        if si==sj:
            continue
        for k in range(j+1,n):
            sk=s[k]
            if tmp==k-j:
                continue
            if sk==si or sk==sj:
                continue
            ans+=1
print(ans)


### FIXED CODE ###

n=int(input())
s=input()
r=s.count("R")
g=s.count("G")
b=s.count("B")
ans=r*g*b
for i in range(n):
    for j in range(n):
        if i+j+j>=n:
            break
        s1=s[i]
        s2=s[i+j]
        s3=s[i+j*2]
        if s1!=s2 and s2!=s3 and s1!=s3:
            ans-=1
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
#ABC138 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,q = LI()
graph = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = LI()
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

def dfs(x,p):
    lst.append(x)
    for i in graph[x]:
        if i != p:
            dfs(i,x)
    lst.append(p)
lst = []
dfs(0,0)
lst.pop()
inde = [[-1,-1] for _ in range(n)]
m = len(lst)
for i in range(m):
    if inde[lst[i]][0] < 0:
        inde[lst[i]][0] = i
for i in range(m)[::-1]:
    if inde[lst[i]][1] < 0:
        inde[lst[i]][1] = i
cnt = [0]*(m+1)
for _ in range(q):
    p,x = LI()
    cnt[inde[p-1][0]] += x
    cnt[inde[p-1][1]+1] -= x
cnt = list(accumulate(cnt))
ans = []
for i in range(n):
    ans.append(cnt[inde[i][0]])
print(*ans)


### FIXED CODE ###

#!/usr/bin/env python3
#ABC138 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,q = LI()
g = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = LI()
    g[a-1].append(b-1)

ans = [0]*n
for _ in range(q):
    p,x = LI()
    ans[p-1] += x

que = deque()
que.append(0)
check = [True]*n
while que:
    v = que.popleft()
    for i in g[v]:
        if check[i]:
            check[i] = False
            que.append(i)
            ans[i] += ans[v]
print(*ans)
### BUGGY CODE ###

n,k=map(int,input().split())
l=[i for i in range(1,n+1) if (2*i)%k==0]
cnt=0
for x in range(len(l)):
    for y in range(len(l)):
        for z in range(len(l)):
            if (l[x]+l[y])%k==0 and (l[y]+l[z])%k==0 and (l[z]+l[x])%k==0:
                cnt+=1
print(cnt)

### FIXED CODE ###

n,k=map(int,input().split())
if k%2==1:
    print((n//k)**3)
else:
    kk=k//2
    print((n//k)**3+((n+kk)//k)**3)
### BUGGY CODE ###

n = int(input())
A = [int(input()) for _ in range(n)]
B = A[:]
max_A = max(A)
for i in range(n):
    if A[i] == max_A:
        B[i] = 0
        print(max(B))
        B[i] = max_A
    else:
        print(max_A)

### FIXED CODE ###

n = int(input())
A = [int(input()) for _ in range(n)]
B = A[:]
B.sort(reverse = True)
max_A = max(A)
for i in range(n):
    if A[i] == max_A:
        print(B[1])
    else:
        print(max_A)
### BUGGY CODE ###

p = int(input())
a = list(map(int, input().split()))
MOD = p

P = p
fact = [0] * P
fact[0] = 1
for i in range(1, P):
    fact[i] = fact[i - 1] * i
    fact[i] %= MOD

rfact = [0] * P
rfact[P - 1] = pow(fact[P - 1], MOD - 2, MOD)
for i in range(P - 2, -1, -1):
    rfact[i] = rfact[i + 1] * (i + 1)
    rfact[i] %= MOD


def comb(n, k):
    return fact[n] * rfact[n - k] * rfact[k] % MOD


b = [0] * p
for i in range(p):
    if a[i]:
        b[0] += 1
        b[0] %= MOD
        for j in range(p):
            b[j] -= comb(p - 1, j) * (-i) ** (p - 1 - j)
            b[j] %= MOD

print(*b)


### FIXED CODE ###

import sys
input = sys.stdin.readline
p = int(input())
a = list(map(int, input().split()))
MOD = p

P = p
fact = [0] * P
fact[0] = 1
for i in range(1, P):
    fact[i] = fact[i - 1] * i
    fact[i] %= MOD

rfact = [0] * P
rfact[P - 1] = pow(fact[P - 1], MOD - 2, MOD)
for i in range(P - 2, -1, -1):
    rfact[i] = rfact[i + 1] * (i + 1)
    rfact[i] %= MOD


def comb(n, k):
    return fact[n] * rfact[n - k] * rfact[k] % MOD


b = [0] * p
for i in range(p):
    if a[i]:
        b[0] += 1
        b[0] %= MOD
        s = 1
        for j in range(p - 1, -1, -1):
            b[j] -= comb(p - 1, j) * s
            b[j] %= MOD
            s *= -i
            s %= MOD

print(*b)
### BUGGY CODE ###

n=int(input())
a=[int(input()) for i in range(n)]
s=set(a)
ans=0
for i in s:
  if a.count(i)%2==1:
    ans+=1
print(ans)

### FIXED CODE ###

n=int(input())
a={}
for i in range(n):
  a_=int(input())
  if a_ not in a:
    a[a_]=1
  else:
    a[a_]+=1
ans=0
for i in a:
  if a[i]%2==1:
    ans+=1
print(ans)
### BUGGY CODE ###

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

S = [0]

for a in A:
    S.append(S[len(S) - 1] + a)

S = sorted(S)

ret = 0
for s in set(S):
    cnt = S.count(s)
    ret += cnt * (cnt - 1) / 2
print(int(ret))


### FIXED CODE ###

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

S = [0]

for a in A:
    S.append(S[len(S) - 1] + a)

S = sorted(S) + [None]
ret = 0
cnt = 1
for i in range(1, N + 2):
    if S[i] != S[i - 1]:
        ret += cnt * (cnt - 1) // 2
        cnt = 1
    else:
        cnt += 1

print(ret)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
    b.append(a[i])
    b.reverse()
print(*b)
    


### FIXED CODE ###

n = int(input())
a = [x for x in input().split()]
b = []

if n % 2 == 1:
    for i in reversed(range(1, n+1, 2)):
        b.append(a[i-1])
    for i in range(2, n, 2):
        b.append(a[i-1])
else:
    for i in reversed(range(2, n+1, 2)):
        b.append(a[i-1])
    for i in range(1, n, 2):
        b.append(a[i-1])
    
print(*b, sep=' ')
### BUGGY CODE ###

n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
num = 10**9+7
count = [0]*(n+1)
count[0] = 1
count[1] = 1 if 1 not in a else 0
for i in range(2,n+1):
  if i not in a: count[i] = count[i-1] + count[i-2]
  count[i] = count[i]%num
print(count[n])


### FIXED CODE ###

n,m = map(int, input().split())
num = list(int(input()) for _ in range(m))

count = [-1]*(n+1)
for stair in num:
  count[stair] = 0
  
count[0] = 1
count[1] = 1 if 1 not in num else 0

for i in range(2,n+1):
  if count[i] != 0:
  	count[i] = (count[i-1]+count[i-2]) % (10**9+7)
  
print(count[n])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
#ARC076C
import sys
import math

#n=int(input())

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

n=hoge[0]
m=hoge[1]

total=1
if(n==m):
	total+=1

if(abs(n-m)>1):
	print(0)
else:
	print(total*math.factorial(n)*math.factorial(m))

### FIXED CODE ###

# -*- coding: utf-8 -*-
#ARC076C
import sys
import math

#n=int(input())

tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

n=hoge[0]
m=hoge[1]

#total=1
#if(n==m):
#	total+=1

t = math.factorial(min(n,m))
#print(t)
#print(t**2)
if(abs(n-m)>1):
	print(0)
elif(n==m):
	print((2*(t**2))%1000000007)
else:
	print(((t**2)*max(n,m))%1000000007)
### BUGGY CODE ###

N = int(input())
member = sorted(map(int, input().split()))
ans = 0
while member:
    member.pop()
    ans += member.pop()
    member.pop(0)
print(ans)


### FIXED CODE ###

N = int(input())
member = sorted(map(int, input().split()))
ans = sum(member[N::2])
print(ans)
### BUGGY CODE ###

import math
s=input()
n=len(s)
count=0
a=[0 for i in range(2019)]
a[0]=1
k=0
for i in reversed(range(0,n)):
    k+=(10**(n-i-1)%2019)*int(s[i])%2019
    a[k%2019]+=1        
for i in range(len(a)):
    if a[i]>=2:
        count+=(a[i])*(a[i]-1)//2
print(count)

### FIXED CODE ###

import math
s=input()
n=len(s)
count=0
a=[0 for i in range(2019)]
a[0]=1
k=0
b=[0 for i in range(n)]
b[0]=1
for i in range(1,n):
    b[i]=b[i-1]*10%2019
for i in reversed(range(0,n)):
    k+=(b[n-i-1])*int(s[i])%2019
    a[k%2019]+=1        
for i in range(len(a)):
    if a[i]>=2:
        count+=(a[i])*(a[i]-1)//2
print(count)
### BUGGY CODE ###

a,b,c,k = map(int,input().split())
for i in range(k):
  a,b,c = b+c,c+a,a+b
  
Ans = a-b
if abs(Ans) > 10^18:
  print('Unfair')
else:
  print(Ans)

### FIXED CODE ###

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

if k % 2 == 0:
    print(a - b)
else:
    print(b - a)
### BUGGY CODE ###

l, r = map(int, input().split())
ans = 2019
for i in range(l, r+1):
    for j in range(i+1, r+1):
        tmp = 0
        tmp = i * j % 2019
        ans = min(ans, tmp)
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
l, r = map(int, input().split())
ans = 2019
for i in range(l, r+1):
    for j in range(i+1, r+1):
        tmp = 0
        tmp = i * j % 2019
        ans = min(ans, tmp)
        if ans == 0:
            print(ans)
            exit()
print(ans)
### BUGGY CODE ###

a,b,x = map(int,input().split())
count=0
for i in range(a,b+1):
    if i%x==0:
        count+=1
print(count)


### FIXED CODE ###

a,b,x = map(int,input().split())
if a%x==0 or a==0:
    print((b//x)-(a//x)+1)
else:
    print((b//x)-(a//x))


#切り捨て除算！！！！！！！
### BUGGY CODE ###

import numpy as np
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,k=IL()
h=np.array(IL())
dp=np.full(n,np.inf)
dp[0]=0
for i in range(1,n):
    t=i-min(i,k)
    dp[i]=np.min(dp[t:i]+abs(h[t:i]-h[i]))
print(int(dp[n-1]))

### FIXED CODE ###

import numpy as np
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,k=IL()
h=np.array(IL())
dp=np.full(n,pow(10,6),dtype=int)
dp[0]=0
for i in range(1,n):
    t=i-min(i,k)
    dp[i]=np.min(dp[t:i]+abs(h[t:i]-h[i]))
print(dp[n-1])
### BUGGY CODE ###

n = int(input())
p = list(map(int, input().split()))

flg_min = p[0]
ans = 1
for i in range(1, n + 1):
    temp = p[:i]
    min_temp = min(temp)
    if flg_min > min_temp:
        ans += 1
        flg_min = min_temp

print(ans)

### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))

flg_min = p[0]
ans = 1
for i in range(1, n):
    temp = p[i]
    if flg_min > temp:
        ans += 1
        flg_min = temp
print(ans)
### BUGGY CODE ###

#from collections import Counter
from itertools import combinations
import sys
input = sys.stdin.readline

N = int(input())
S = [sorted(input().rstrip()) for _ in range(N)]
#print(S)

ans = 0
for s1, s2 in combinations(S, 2):
  if s1 == s2:
    ans +=1
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input())
S={}
for _ in range(N):
  s = ''.join(sorted(input().rstrip()))
  if s in S:
    S[s] += 1
  else:
    S[s] = 1

ans=0
for s in S.values():
  ans += s*(s-1)//2
  
print(ans)
### BUGGY CODE ###

n = int(input())
l = []
for i in range(n):
    l.append(int(input()))
check = [0]
ans = 0
now = 1
while (1):
    now = l[now - 1]
    ans += 1

    if now == 2:
        print(ans)
        exit()
    if now in check:
        print(-1)
        exit()
    check.append(now)


### FIXED CODE ###

n = int(input())
l = []
for i in range(n):
    l.append(int(input()))
ans = 0
now = 1
while (1):
    now = l[now - 1]
    ans += 1

    if now == 2:
        print(ans)
        exit()
    if ans > n:
        print(-1)
        exit()
### BUGGY CODE ###

h,w,k = map(int, input().split())
s = [[int(c) for c in input()] for i in range(h)]
ans = 114514893
for bit in range(1 << (h-1)):
    cut = [-1]
    for i in range(h-1):
        if bit & (1 << i) : cut.append(i)
    cut.append(h-1)
    l = len(cut)-1
    count = l-1
    suml = [0 for i in range(l)]
    ok = True
    for i in range(w):
        sumtemp = [0 for ii in range(l)]
        flag2 = True #kを超えないかどうか
        for j in range(l):
            for kk in range(cut[j]+1,cut[j+1]+1):
                sumtemp[j] = sumtemp[j] + s[kk][i]
            if sumtemp[j] > k:
                ok = False
                break
        if not ok : break
        for j in range(l):
            if suml[j]+sumtemp[j] > k:flag2 = False
        if flag2:
            for j in range(l):
                suml[j] = suml[j]+sumtemp[j]
        else:
            count += 1
            suml = sumtemp[:]   
    if not ok:continue
    ans = min(ans,count)
    
print(ans)

### FIXED CODE ###

h,w,k = map(int, input().split())
s = [[int(c) for c in input()] for i in range(h)]
ans = 114514893
for bit in range(1 << (h-1)):
    cut = [-1]
    for i in range(h-1):
        if bit & (1 << i) : cut.append(i)
    cut.append(h-1)
    l = len(cut)-1
    count = l-1
    suml = [0 for i in range(l)]
    ok = True
    for i in range(w):
        sumtemp = [0 for ii in range(l)]
        flag2 = True #kを超えないかどうか
        for j in range(l):
            for kk in range(cut[j]+1,cut[j+1]+1):
                sumtemp[j] = sumtemp[j] + s[kk][i]
            if sumtemp[j] > k:
                ok = False
                break
        if not ok : break
        for j in range(l):
            if suml[j]+sumtemp[j] > k:flag2 = False
        if flag2:
            for j in range(l):
                suml[j] = suml[j]+sumtemp[j]
        else:
            count += 1
            suml = sumtemp[:]   
    if not ok:continue
    ans = min(ans,count)
    
print(ans)
### BUGGY CODE ###

n=input()
s=list(map(int,(input().split(" "))))
s.sort()
ans=1
for i in s:
    ans*=i
if ans > 1e18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

n,*l=map(int,open(0).read().split())
a=1
for i in sorted(l):
  a*=i
  if a>10**18: a=-1; break
print(a)
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

H, W, N = map(int, input().split())
cand = set()
dot = set()
for _ in range(N):
    x, y = map(int, input().split())
    dot.add((x, y))
    for i in range(-2, 1):
        if 1 <= x + i <= H - 2:
            for j in range(-2, 1):
                if 1 <= y + j <= W - 2:
                    cand.add((x + i, y + j))

ans = [0] * 10
for x, y in cand:
    cnt = 0
    for i in range(3):
        for j in range(3):
            cnt += int((x + i, y + j) in dot)
    ans[cnt] += 1

zero = (H - 2) * (W - 2) - sum(ans)
ans[0] = zero
print(*ans, sep="\n")

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

H, W, N = map(int, input().split())
cand = set()
dot = set()
for _ in range(N):
    x, y = map(int, input().split())
    dot.add((x, y))
    for i in range(-2, 1):
        if 1 <= x + i <= H - 2:
            for j in range(-2, 1):
                if 1 <= y + j <= W - 2:
                    cand.add((x + i, y + j))

ans = [0] * 10
for x, y in cand:
    cnt = 0
    for i in range(3):
        for j in range(3):
            cnt += int((x + i, y + j) in dot)
    ans[cnt] += 1

zero = (H - 2) * (W - 2) - sum(ans)
ans[0] = zero
print(*ans, sep="\n")
### BUGGY CODE ###

S = input()

S_sum = [0]
r_list = [0 for _ in range(2019)]
for i in range(1,len(S)+1):
    S_sum.append(int(S[len(S)-i:]))
#print(S_sum)

for i in range(len(S_sum)): 
    r_list[S_sum[i] % 2019] += 1 

ans = r_list[0] - 1
for i in range(1,2019):
    if r_list[i] >= 2:
        ans += r_list[i]*(r_list[i]-1)//2

print(ans)

### FIXED CODE ###

S = input()
s_rev = S[::-1]

r_list = [0] * 2019
r_list[0] = 1
num, d = 0, 1
for i in range(len(S)):
    num += d*int(s_rev[i])
    num %= 2019
    r_list[num] += 1
    d *= 10
    d %= 2019

ans = 0
for i in range(2019):
        ans += r_list[i]*(r_list[i]-1)//2

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

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


def delitable(numbers):
    return [v for i, v in enumerate(numbers) if v == i + 1]


# b_searched = set()
b_unsearched = []


# b_searched.add(b)
delit = delitable(b)

if delit == []:
    print("-1")
for delit_num in delit:
    b_unsearched.append([[v for i, v in enumerate(b) if delit_num != i + 1], [str(delit_num)]])

while b_unsearched:
    b, log = b_unsearched.pop()

    # b_searched.add(b)
    delit = delitable(b)
    if not delit:
        if not b:
            log.reverse()
            print("\n".join(log))
            break
        else:
            continue
    for delit_num in delit:
        b_unsearched.append([[v for i, v in enumerate(b) if delit_num != i + 1], log + [str(delit_num)]])
else:
    print("-1")

### FIXED CODE ###

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


def delitable(numbers):
    return [v for i, v in enumerate(numbers) if v == i + 1]


log = []
while b:
    delit = delitable(b)
    if not delit:
        print(-1)
        break
    del b[delit[-1] - 1]
    log.append(delit[-1])
else:
    log.reverse()
    print("\n".join(map(str, log)))
### BUGGY CODE ###

def solve():
    N = int(input())
    S = input()
    count = 0
    for i in range(0,1000):
        num = str(i).zfill(3)
        digit = 0
        for j in range(N):
            if S[j] == num[digit]:
                digit += 1
            if digit == 3:
                break
        if digit ==3:
            count += 1

    print(count)

if __name__ == '__main__':
    solve()

### FIXED CODE ###

def solve():
    N = int(input())
    S = input()
    count = 0
    for i in range(0,1000):
        num = str(i).zfill(3)
        digit = 0
        for j in range(N):
            if S[j] == num[digit]:
                digit += 1
            if digit == 3:
                break
        if digit ==3:
            count += 1

    print(count)

if __name__ == '__main__':
    solve()