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

# -*- coding: utf-8 -*-
"""
Created on Sun Oct  7 22:06:12 2018
ABC073D
@author: maezawa
"""
import itertools as itr
import sys
input = sys.stdin.readline

n, m, r = list(map(int, input().split()))
rarray = list(map(int, input().split()))
adjmatrix = [[float("inf")]*n for _ in range(n)]
#for i in range(n):
#    adjmatrix[i][i] = 0

for i in range(m):
    a, b, c = list(map(int, input().split()))
    adjmatrix[a-1][b-1] = c
    adjmatrix[b-1][a-1] = c

#print(abc)

# Warshall-Floyd Algorithm
for k in range(len(adjmatrix)):
    for i in range(len(adjmatrix)):
        for j in range(len(adjmatrix[i])):
            if adjmatrix[i][j] > adjmatrix[i][k] + adjmatrix[k][j]:
                adjmatrix[i][j] = adjmatrix[i][k] + adjmatrix[k][j]
                adjmatrix[j][i] = adjmatrix[i][k] + adjmatrix[k][j]				

        
#print(*adjmatrix, sep='\n')
    
# search for ri to rj
mincnt = float("inf")
for route in itr.permutations(rarray):
    cnt = 0
    for i in range(len(route)-1):
        cnt += adjmatrix[route[i]-1][route[i+1]-1]
    if cnt < mincnt:
        mincnt = cnt

print(mincnt)
        
        

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Mon Oct  8 10:17:39 2018

@author: maezawa
"""

import math
from itertools import permutations

#フロイド・ワーシャル
def warshall_floyd(glath):
	
	for k in range(len(glath)):
		for i in range(len(glath)):
			for j in range(len(glath[i])):
				if glath[i][j] > glath[i][k] + glath[k][j]:
                                   glath[i][j] = glath[i][k] + glath[k][j]
                                   glath[j][i] = glath[i][k] + glath[k][j]				
	return glath

N, M ,R= [int(x) for x in str(input()).split()]  #グラフの大きさ 
r=[int(x) for x in str(input()).split()]
graph=[[float("inf")]*N for i in range(N)]


for i in range(M):
	a,b,c=[int(x) for x in str(input()).split()]
	#if a in r and b in r:
	graph[a-1][b-1]=c
	graph[b-1][a-1]=c

#all_cost=warshall_floyd(select_graph)
all_cost=warshall_floyd(graph)


max_count=float("inf")
for i in permutations(r):
        cost=0
        for j in range(len(i)-1):                
                cost+= all_cost[i[j]-1][i[j+1]-1]       
        max_count=min(max_count,cost)

print(max_count)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

H,W = (int(x) for x in input().split())
S = [list(input()) for _ in range(H)]
mem = [[[0,0] for _ in range(W)] for _ in range(H)]
ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            h = mem[i][j][0]
            if h == 0:
                stopped = False
                for k in range(W-j-1):
                    if S[i][j+k+1] == '#':
                        for l in range(k+1):
                            mem[i][j+l][0] = k+1
                        stopped = True
                        break
                if stopped == False:
                    for l in range(W-j):
                        mem[i][j+l][0] = W-j
                h = mem[i][j][0]
            v = mem[i][j][1]
            if v == 0:
                stopped = False
                for k in range(H-i-1):
                    if S[i+k+1][j] == '#':
                        for l in range(k+1):
                            mem[i+l][j][1] = k+1
                        stopped = True
                        break
                if stopped == False:
                    for l in range(H-i):
                        mem[i+l][j][1] = H-i
                v = mem[i][j][1]
            ans = max(ans,h+v-1)
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

H,W = (int(x) for x in input().split())
S = [list(input()) for _ in range(H)]
memh = [[0] * W for _ in range(H)]
memv = [[0] * W for _ in range(H)]
ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            h = memh[i][j]
            if h == 0:
                stopped = False
                for k in range(W-j-1):
                    if S[i][j+k+1] == '#':
                        for l in range(k+1):
                            memh[i][j+l] = k+1
                        stopped = True
                        break
                if stopped == False:
                    for l in range(W-j):
                        memh[i][j+l] = W-j
                h = memh[i][j]
            v = memv[i][j]
            if v == 0:
                stopped = False
                for k in range(H-i-1):
                    if S[i+k+1][j] == '#':
                        for l in range(k+1):
                            memv[i+l][j] = k+1
                        stopped = True
                        break
                if stopped == False:
                    for l in range(H-i):
                        memv[i+l][j] = H-i
                v = memv[i][j]
            ans = max(ans,h+v-1)
print(ans)
### BUGGY CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))
inf = 10**9
dp = [inf]*n
dp[0] = 0
for i in range(n):
    for j in range(1, k+1):
        step = i+j
        if step >= n:
            break
        dp[step] = min(dp[step], dp[i]+abs(h[step]-h[i]))
print(dp[-1])


### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    stones = tuple(map(int, input().split()))
    inf = 10**9
    dp = [inf]*n
    dp[0] = 0
    for i in range(n):
        for t in range(1, k+1):
            step = i+t
            if step < n:
                v = dp[i]+abs(stones[i]-stones[step])
                if v < dp[step]:
                    dp[step] = v
    print(dp[-1])


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

import math
n,a,b = map(int,input().split())

if (b-a)%2==0:
    print((b-a)//2)
else:
    if n >= 10**5:
        if a < math.floor(n/2):
            i = 0
            while True:
                a -= i
                b -= i
                if a <= 1:
                    a = 1
                if a == b:
                    a += 1000
                    b += 1000
                    for j in range(1,1001):
                        a -= j
                        b -= j
                        if a <= 1:
                            a = 1
                        if a == b:
                            print(i+j)
                            break
                    break
                i += 1000
        else:
            i = 0
            while True:
                a += i
                b += i
                if b >= n:
                    b = n
                if a == b:
                    a -= 1000
                    b -= 1000
                    for j in range(1,1001):
                        a += j
                        b += j
                        if b >= n:
                            b = n
                        if a == b:
                            print(i+j)
                            break
                    break
                i += 1000
    else:
        if a < math.floor(n/2):
            i = 0
            while True:
                a -= i
                b -= i
                if a <= 1:
                    a = 1
                if a == b:
                    print(i)
                    break
                i += 1
        else:
            i = 0
            while True:
                a += i
                b += i
                if b >= n:
                    b = n
                if a == b:
                    print(i)
                    break
                i += 1


### FIXED CODE ###

n,a,b = map(int,input().split())
i = 1
p = 0
if (b-a)%2==0:
    print((b-a)//2)
else:
    if a-1 < n-b:
        print(min((1+b+(a-2))//2,b-1))
    else:
        print(min((n-a+(n-b+1))//2,n-a))
### BUGGY CODE ###

k=int(input())
s=input()
lens=len(s)
mod=10**9+7
ans=0

dp=[0 for i in range(1+len(s)+k)]
dp[0]=1

import math
def  mcal(n,r):
    return math.factorial(n)//math.factorial(n-r)//math.factorial(r)

l={i:1 for i in range(lens+10)}
for i in range(lens+1,lens+k+2):
    l[i]=l[i-1]*i//(i-lens)

now=1

for i in range(k+1):
    ans+=pow(25,i,mod)*pow(26,k-i,mod)*mcal(lens+i-1,lens-1)
    ans=ans%mod

print(ans)

### FIXED CODE ###

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 2 * 10 ** 6 + 10 # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

k=int(input())
s=input()
lens=len(s)
mod=10**9+7
ans=0

now=1

for i in range(k+1):
    ans+=pow(25,i,mod)*pow(26,k-i,mod)*cmb(lens+i-1,lens-1,mod)
    ans=ans%mod

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

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


### FIXED CODE ###

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

n = int(input())
a = list(map(int, input().split()))
 
l = ''
for i in range(n):
  l += '{} '.format(a.index(i+1)+1)
print(l)

### FIXED CODE ###

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

s = sorted(range(n), key=lambda x:l[x])

for i in range(n):
  s[i]+= 1
  
print(*s)
### BUGGY CODE ###

import itertools

N, K = map(int, input().split())
dic = {}
count = 0
for a in range(K, N+2):
    for i in itertools.combinations(range(1, N+2), a):
        length = len(i)
        sum_ = sum(i)
        if sum_ in dic.keys():
            if length == dic[sum_]:
                continue
            else:
                count += 1
                count %= 10000000007
        else:
            dic[sum_] = length
            count += 1
            count %= 10000000007

print(count)

### FIXED CODE ###

import itertools

N, K = map(int, input().split())
# dic = {}
# count = 0
# for a in range(K, N+2):
#     for i in itertools.combinations(range(1, N+2), a):
#         length = len(i)
#         sum_ = sum(i)
#         if sum_ in dic.keys():
#             if length == dic[sum_]:
#                 continue
#             else:
#                 count += 1
#                 count %= 10000000007
#         else:
#             dic[sum_] = length
#             count += 1
#             count %= 10000000007
#
# print(count)
result = 0
for i in range(K, N+2):
    a = (i-1) * i/2
    b = (2*N-i+1) * i/2
    result += b - a + 1
    result %= 1000000007

print(int(result))
### BUGGY CODE ###

N = int(input())
S = input()        

dic = {"":1}
ans = 0

for c in S:
    dic_new = {}         
    for k in dic:    
        if not(c in k):    
            ans += dic[k]       
            ans %= 10**9+7
            if len(k)<=25:
                dic_new[k+c] = dic_new.get(k+c,0)+dic[k]          
    for k in dic_new:    
        dic[k] = (dic.get(k,0)+dic_new[k])%(10**9+7)
print(ans)      

### FIXED CODE ###

N = int(input())
S = input()        

tmp = []
for a in "abcdefghijklmnopqrstuvwxyz":      
    tmp.append(S.count(a)+1)
    
ans = 1 
for i in tmp:
    ans = ans * i % (10**9+7)
    
print(ans-1)
### BUGGY CODE ###

import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)


def read_values():
    return map(int, input().split())


def read_index():
    return map(lambda x: x - 1, map(int, input().split()))


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def functional(N, mod):
    F = [1] * (N + 1)
    for i in range(N):
        F[i + 1] = (i + 1) * F[i] % mod
    return F


def main():
    N, M, Q = read_values()
    T = [list(read_index()) for _ in range(M)]
    L0 = [0] * N
    R0 = [0] * N
    for i, (l, r) in enumerate(T):
        L0[r] += 1 << i
        R0[l] += 1 << i

    for i in range(1, N):
        L0[i] += L0[i - 1]
        R0[-i - 1] += R0[-i]

    res = [0] * Q
    for i in range(Q):
        p, q = read_index()
        t = R0[p] & L0[q]
        res[i] = str(bin(t).count("1"))

    print("\n".join(res))


if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)


def read_values():
    return map(int, input().split())


def read_index():
    return map(lambda x: x - 1, map(int, input().split()))


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def functional(N, mod):
    F = [1] * (N + 1)
    for i in range(N):
        F[i + 1] = (i + 1) * F[i] % mod
    return F


def main():
    N, M, Q = read_values()
    S = [[0 for _ in range(N + 1)] for __ in range(N + 1)]
    
    for _ in range(M):
        l, r = read_values()
        S[l][r] += 1

    for l in range(N):
        for r in range(N):
            S[l + 1][r + 1] += S[l + 1][r] + S[l][r + 1] - S[l][r] 

    res = [0] * Q
    for i in range(Q):
        p, q = read_values()
        res[i] = str(S[q][q] - S[p - 1][q] - S[q][p - 1] + S[p - 1][p - 1])
    print("\n".join(res))


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

import sys
A, B = map(int, raw_input().split())
counter = 0
while True:
  if abs(A - counter) == abs(B - counter) :
    print counter
    break
  counter += 1
  if counter > A and counter > B :
    print "IMPOSSIBLE"
    break

### FIXED CODE ###

A, B = map(int, raw_input().split())

if (A + B) % 2 == 0:
  print (A + B)/2
else:
  print "IMPOSSIBLE"
### BUGGY CODE ###

import numpy as np
n = int(input())
a =np.array([int(x) for x in input().split()])
q = int(input())
bc = [map(int, input().split()) for _ in range(q)]
b, c = [list(i) for i in zip(*bc)]

ans = np.sum(a)
for i in range(q):
    ans += np.count_nonzero(a == b[i])*(c[i]-b[i])
    print(ans)
    a = np.where(a == b[i], c[i],a)

### FIXED CODE ###

import numpy as np
import collections

n = int(input())
a =np.array([int(x) for x in input().split()])
q = int(input())
bc = [map(int, input().split()) for _ in range(q)]
b, c = [list(i) for i in zip(*bc)]

count_dict = collections.Counter(a)
ans = np.sum(a)
for i in range(q):
    if count_dict[b[i]] > 0:
        ans += count_dict[b[i]]*(c[i]-b[i])
        count_dict[c[i]] += count_dict[b[i]]
        count_dict[b[i]] = 0
    print(ans)
### BUGGY CODE ###

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

ans = [0]

for i in range(N - 1):
    ans = ans + [0]

for i in range(N - 1):
    ans[A[i] - 1] = ans[A[i] - 1] + 1

for i in range(N):
    print(ans[i])

### FIXED CODE ###

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

ans = [0] * N

for i in range(N - 1):
    ans[A[i] - 1] = ans[A[i] - 1] + 1

for i in range(N):
    print(ans[i])
### BUGGY CODE ###

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

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

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

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
ans = 1
for a in A:
  ans *= a
  if ans == 0:
    break
  if ans > 10**18:
    ans = -1
    break

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

N = int(input())
A_ls = list(map(int, input().split()))
mul = 1

for i in range(N):
  mul *= A_ls[i]

if mul > 10**18:
  print(-1)
else:
  print(mul)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = 1
if a[0] == 0:
  print(0)
else:
  for i in range(len(a)):
    ans *= a[i]
    if ans > 10**18:
      print("-1")
      exit()
    elif i == len(a)-1:
      print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

import numpy as np

def main():
  s = input().rstrip()
  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])
  
if __name__ == "__main__":
  main()

### 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 ###

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

res = 0
i = 0

a_times = 0
b_times = 0
c_times = 0

if a == k:
    a_times = k
else:
    for i in range(k):
        # print('i = ', i)
        if i < a:
            a_times += 1
            # print('res + 1= ', res)
        elif i + a < a + b:
            b_times += 1
            # print('res + 0 = ', res)
        elif i + a + b < a + b + c:
            c_times += 1
            # print('res - 1 = ', res)

print(a_times * 1 + b_times * 0 + c_times * -1)


### FIXED CODE ###

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

a_times = 0
b_times = 0
c_times = 0

if a <= k:
    a_times = a
    # print('a_times = ', a_times)
    if a_times + b <= k:
        b_times = b
        # print('if - b_times = ', b_times)
    else:
        b_times = k - a_times
        # print('else - b_times = ', b_times)
    if a_times + b_times + c <= k:
        c_times = c
        # print('if - c_times = ', c_times)
    else:
        c_times = k - a_times - b_times
        # print('else - c_times = ', c_times)
else:
    a_times = k


print(a_times * 1 + b_times * 0 + c_times * -1)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
N = int(raw_input())
li = map(int, raw_input().split())

move_max = 0
inext = 0

for i in xrange(N-1):
    move = 0
    if i < inext:
        continue
    tmp = li[i]
    
    for j in xrange(i+1,N):
        if tmp >= li[j]:
            tmp = li[j]
            move += 1
    	else:
            inext = move
            break
    if move > move_max:
        move_max = move

print move_max


### FIXED CODE ###

n = int(raw_input())
a = map(int, raw_input().split())
 
ans = 0
temp = 0
for i in xrange(n-1):
    if a[i] >= a[i+1]:
        temp = temp + 1
    else:
        ans = max(ans, temp) 
        temp = 0
 
print max(ans, temp)
### BUGGY CODE ###

#coding:utf-8                                                                                      

import math

# 整数xが素数かどうかを判定する                                                                    
def is_prime(x):
    if x < 2: return False # 2未満に素数はない                                                     
    if x == 2 or x == 3 or x == 5: return True # 2,3,5は素数                                       
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False # 2,3,5の倍数は合成数                  

    # ためし割り: 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく                      
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True


Q = int(raw_input())
LR = []
for i in range(Q):
    l, r = map(int, raw_input().split())
    LR.append((l, r))

for l, r in LR:
    count = 0
    for j in range(l, r+1, 2):
        if is_prime(j):
            if is_prime((j+1)/2):
                count += 1
    print count

### FIXED CODE ###

import math


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return data

primes = set(get_sieve_of_eratosthenes(10**5))
A = []
for i in range(1, 10**5+1):
  if i % 2 == 1:
    if i in primes and (i+1) // 2 in primes:
      A.append(1)
    else:
      A.append(0)
  else:
    A.append(0)

for i in range(1, len(A)):
  A[i] += A[i-1]

q = int(input())
for _ in range(q):
  l, r = map(int, input().split())
  if l == 1:
    l = 2
  ans = A[r-1] - A[l-2]
  print(ans)
### BUGGY CODE ###

n=int(input())
s=input()
sum=0
box=['RGB','RBG','GRB','GBR','BRG','BGR']
for k in range(n):
    for j in range(k):
        for i in range(j):
            if j-i!=k-j:
                word=s[k]+s[j]+s[i]
                if word in box:
                    sum=sum+1
print(sum)

### FIXED CODE ###

n=int(input())
s=input()
sum=0
r=int(s.count('R'))
g=int(s.count('G'))
b=int(s.count('B'))
for k in range(n):
    for j in range(k):
        i=2*j-k
        if i+1>0:
            if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
                sum=sum+1
print(r*g*b-sum)
### BUGGY CODE ###

import collections
import math
 
def combinations_count(n, r):
  if n == r:
    return 1
  elif n < r:
    return 0
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

combi = collections.Counter(A)
new_combi = {}
for k, v in combi.items():
  if v > 1:
    new_combi[k] = v
#print(combi)

for i in range(N):
  ans = 0
  
  # i番目の要素をcombiからdecrement
  if A[i] in new_combi:
    new_combi[A[i]] -= 1
    for v in new_combi.values():
      #print(v)
      ans += combinations_count(v, 2)
  
  print(ans)

  # i番目の要素をcombiからincrement
  if A[i] in new_combi:
    new_combi[A[i]] += 1

### FIXED CODE ###

import collections
import math
 
def combinations_count(n, r):
  if n == r:
    return 1
  elif n < r:
    return 0
  else:
    return n * (n-1) // 2 
    #math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

combi = collections.Counter(A)
combi_count = {}
calc_dict = {}
total = 0
for k, v in combi.items():
  if v in calc_dict:
    combi_count[k] = calc_dict[v]
  else:
    combi_count[k] = combinations_count(v, 2)
    calc_dict[v] = combi_count[k]
  total += combi_count[k]

for i in range(N):
  ans = total - combi_count[A[i]] + combinations_count(combi[A[i]]-1, 2)
  print(ans)
### BUGGY CODE ###

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

inf = float('inf')

dp = [inf]*(10**5+10)
dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        if i+j >= N:
            break
        dp[i+j] = min(dp[i+j], dp[i] + abs(H[i+j] - H[i]))

print(dp[N-1])


### FIXED CODE ###

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

inf = float('inf')

dp = [inf]*(10**5+10)
dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        if i+j >= N:
            break
        dp[i+j] = min(dp[i+j], dp[i] + abs(H[i+j] - H[i]))

print(dp[N-1])
### BUGGY CODE ###

n = int(input())
s = input()
count = 0
for i in range(1000):
    v = str(i).zfill(3)
    k=0
    for j in range(n):
        if v[k] == s[j]:
            k+=1
        if k==3:
            count+=1
            break

print(count)

### FIXED CODE ###

n = int(input())
s = input()
count = 0
for i in range(1000):
    v = str(i).zfill(3)
    k=0
    for j in range(n):
        if v[k] == s[j]:
            k+=1
        if k==3:
            count+=1
            break

print(count)