Problem:
 Score: 400 points    Problem Statement  AtCoder Inc. has decided to lock the door of its office with a 3 -digit PIN code.  The company has an N -digit lucky number, S . Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.  How many different PIN codes can he set this way?  Both the lucky number and the PIN code may begin with a 0 .      Constraints   4 \leq N \leq 30000  S is a string of length N consisting of digits.         Input  Input is given from Standard Input in the following format:  N  S       Output  Print the number of different PIN codes Takahashi can set.        Sample Input 1 4
0224      Sample Output 1 3  Takahashi has the following options:   Erase the first digit of S and set 224 .  Erase the second digit of S and set 024 .  Erase the third digit of S and set 024 .  Erase the fourth digit of S and set 022 .   Thus, he can set three different PIN codes: 022 , 024 , and 224 .       Sample Input 2 6
123123      Sample Output 2 17       Sample Input 3 19
3141592653589793238      Sample Output 3 329

Solution (Python):
import subprocess
import gzip, base64, os
import stat

gz = b'H4sIAM+5410C/+1de3hTVbY/SfoIr6YIagXEiFGLQGlowRYfpI9Aoi1UWpDxwSEkaRtNk97kBMqICLb1GmuVmfHB5+dcGceZ63Xunet4HWUchTIo1XnJ6IzioIIP9ISCFh9YdTR3rb33Sfc5OaeA471/GWh21m+v/Vhrr7324zz2Te66hWaTSVA+ZuFSAam3TncR2sXwisYMC2AVwij4PkuYIuQBncvxuQSXKhxiWSuhlfFZ4C8H8zWz/M0uVTiF8SmhiQtzBf7jUoV9CwVVKAj2TDqs6956iu6tX6UK+ywUfzRPnc7M0g2xdEOMXwkFs6AKFfly2F8Tw5uYXEpYy/hqOX78NByUAvj74SpKP1zlUoUS45M06a6AdHnCiX8KWbiUlWekl2JWfyVU2mF2OLR6XvnscGBWOBRJdMzqqJg3a155STxaMofUqZDxLlq8TKXHIlbnicwGMH7ujIH1U//lpp5ZL6fWLLs3d+/kn9x3I8bNZuny4a87Utiac/YoM6bcCFlj3Bz4uxD+Hnu97G+jN20Wf+x/5rk72tLP39rtP+2vjVs7b/+e6+iso+LKAvua0mL33+ombhlb829T2ret817/hJFeLoGCT9HBTzPp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wNskupvbRcynfUljpXjClVTqVx6KSCLUbbhm5L39bnd4CTnvoVGqqxDFUJRcr8CzA07mruET4Nfe1XsiSTQ3Gp9AEp17a4+favgO3uPzVqpFaDxJLTWevJYaT15Ljd9IS40noaXGk9LS8pPU0vKT19LyE628PybFpURzcwkeI3BZzVKxztvYJIrC8CEsotQGHQU8X1zQgUQxEBVbwtHVvrAYgH4VF32JDsEfbWsPB6VgoGReZcUcfSZx+NKdCIqPrRPo5b9Aoq1tHSThKHH4ih9jFcWFS6vq3aJ7cS0eJUNqzn4zqZcsXNjobhKbqqrr3MihyiKgBsjJCYJY+73FVfXeGgGvFSqY9hgOl4s/GoGdvOCPJ4g0QibVSZ7KoclV/4gYLZP+WTUqrpLKEzp1hxxckZ09dzxGVuSIx+Go6+B0Ckw7+kdsqPOmZ1owjJ1aQU7IUENZZ15oorNP/NC23PCpGtqkhsfWaLXwDY7PUWdBDvrQKT77eB1N0SOek7REJE/miIl4MJB9rI6mBrFgUF0BeuyIplIjnL2k7S2Gxyvp2VDWuSo6TPrHKmW1RfbpPtoWh4orTiLr+KHsHkgOydFmEYhHxVYYX0ByemCLrlWiP2ATh2/x7Kasnq054kgrQvZxQVppVsfjXMtlzqjKUu0JnbLjcnGHy2SfDaTb/bIOCsrORH1akl4u6jO+1DnongxmcNKWxg+Rk3Z0+uY3O5BK0+uC0Wat5WTO5VJLQAarb3YGlaZM8lyeVqATPwJKZ3wY6eAsDXuQ3ICjdyhWdpN/C2dDaSsLo4EGUp3GBHHssCTtKWbZfkE5/0pnOKYHXOkoSnu8lw4Lf5SUdkQMRQTqT/4XjCM/n+t3AAA='
bin = gzip.decompress(base64.b64decode(gz))
p = os.path.dirname(__file__)
pymain = os.path.join(p, "a.out")
with open(pymain, "wb") as f:
    f.write(bin)
os.chmod(pymain, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
if p == "":
    pymain = "./" + pymain
subprocess.call(pymain)



'''

import numpy as np
i8 = np.int64
i4 = np.int32


def solve(a, N):
    count = 0
    for x1 in range(10):
        for i1 in range(N):
            if a[i1] == x1:
                for x2 in range(10):
                    for i2 in range(i1 + 1, N):
                        if a[i2] == x2:
                            for x3 in range(10):
                                for i3 in range(i2 + 1, N):
                                    if a[i3] == x3:
                                        count += 1
                                        break
                            break
                break
    return count

def main2():
    stdin = open('/dev/stdin')
    N = int(stdin.readline())
    S = stdin.readline()
    a = np.empty(N, i8)
    for i in range(N):
        a[i] = int(S[i])
    print(solve(a, N))
'''

Solution (Python):
n = int(input())
s = input()

l = [n] * 10
r = [-1] * 10

for i in range(n):
    if l[int(s[i])] == n:
        l[int(s[i])] = i
    r[int(s[i])] = i

answer = 0
for a in range(10):
    for c in range(10):
        if r[c] - l[a] <= 1:
            continue
        str = s[l[a]+1:r[c]]
        answer += len(set(str))
print(answer)

Solution (Python):
N=int(input())
S=input()
cnt=0
for i in range(1000):
  con=0
  if i<10:
    a="00"+str(i)
  elif i<100:
    a="0"+str(i)
  else:
    a=str(i)
  for j in range(N):
    if S[j]==a[con]:
      con+=1
      if con==3:
        cnt+=1
        break
print(cnt)

Solution (Python):
input()
a, b, c = set(), set(), set()
for x in input():
  c |= {y + x for y in b}
  b |= {y + x for y in a}
  a.add(x)
print(len(c))

Solution (Python):
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy


from itertools import permutations, combinations
from heapq import heappop, heappush

sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): 
    return int(input())
def inpm(): 
    return map(int,input().split())
def inpl(): 
    return list(map(int, input().split()))
def inpls(): 
    return list(input().split())
def inplm(n): 
    return list(int(input()) for _ in range(n))
def inpll(n): 
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    n=inp()
    s=list(input())
    for i in range(len(s)):
        s[i]=int(s[i])
    dic1=defaultdict(int)
    dic2=defaultdict(int)
    cnt1=0
    cnt=[0 for _ in range(10)]
    for i in range(n-2):
        if dic1[s[i]]==0:
            dic1[s[i]]=1
        for j in range(10):
            if dic1[j]==1:
                if dic2[j*10+s[i+1]]==0:
                    cnt1+=1
                    dic2[j*10+s[i+1]]=1
        cnt[s[i+2]]=cnt1
    print(sum(cnt))



if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
S = input()

tmp = ""

first_indexes = []
last_indexes = []
rev_S = list(reversed(S))
for i in range(10):
    try:
        first_indexes.append(S.index(str(i)))
        last_indexes.append(N-1-rev_S.index(str(i)))
    except ValueError:
        first_indexes.append(N+1)
        last_indexes.append(-1)

ans = 0
for i in first_indexes:
    if N<i:
        continue
    for j in last_indexes:
        if j<0:
            continue
        for k in range(10):
            for p in range(i+1,j):
                if S[p] == str(k):
                    ans += 1
                    break

print(ans)

Solution (Python):
N = int(input())
S = str(input())
Z = [0,1,2,3,4,5,6,7,8,9]
ans = 0
for i in range(10):
    x = S.find(str(i),0,N-2)
    if x >= 0:
        s = S[x + 1:]
        for j in range(10):
            y = s.find(str(j),0,N-1)
            if y >= 0:
                s_2 = s[y+1:]
                for k in Z:
                    if str(k) in s_2:
                        ans += 1
print(ans)

Solution (Python):
N = int(input())
S = input()
kouho = [str(i).zfill(3) for i in range(0,1000)]
cnt =0
for k in kouho:
    ok = True
    S_temp = S
    for l in k:
        if l in S_temp:
            basho = S_temp.index(l)
            S_temp = S_temp[basho+1:]
        else:
            ok = False
            break
    if ok == True:
        cnt += 1
print(cnt)

Solution (Python):
def main():
    n = int(input())
    s = input()
    j = 0
    ans = 0
    firsts = set(["0","1","2","3","4","5","6","7","8","9"])
    while len(firsts)>0 and j < len(s)-2:
        if s[j] in firsts:
            seconds = set(["0","1","2","3","4","5","6","7","8","9"])
            firsts.remove(s[j])
            k = j+1
            while len(seconds) > 0 and k < len(s)-1:
                if s[k] in seconds:
                    thirds = set(["0","1","2","3","4","5","6","7","8","9"])
                    seconds.remove(s[k])
                    t = k+1
                    while len(thirds) > 0 and t < len(s):
                        if s[t] in thirds:
                            thirds.remove(s[t])
                            ans += 1
                        t += 1
                k += 1
        j += 1
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
N=int(input())
S=input()
from collections import defaultdict
dd = defaultdict(int)
ddd = defaultdict(int)
d=[]

for s in S:
  for xx in dd.keys():
    ddd[xx+s]=1
  for x in d:
    dd[x+s]=1
  if s in d: 
    pass
  else:
    d.append(s)
print(len(ddd))

Solution (Python):
import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
s = inputs[1].strip()
passwords = set()
for i in range(10):
    if str(i) in s[:-2]:
        pw1 = '{}'.format(i)
        idx1 = s.index(str(i)) + 1
        for j in range(10):
            if str(j) in s[idx1:-1]:
                pw2 = '{}{}'.format(pw1, j) 
                idx2 = idx1 + s[idx1:].index(str(j)) + 1
                for k in range(10):
                    if str(k) in s[idx2:]:
                        passwords.add('{}{}'.format(pw2, k))
print(len(passwords))

Solution (Python):
N = int(input()) 
s = str(input())
L=list(s)
L = [int(s) for s in L]
x=0
L1=[]
for i in range(N):
  L2=[]
  if not L[i] in L1:
    L1.append(L[i])
    for j in range(i+1,N):
      if not L[j] in L2:
        L2.append(L[j])
        x+=len(set(L[j+1:N]))
print(x)

Solution (Python):
N = int(input())
S = list(input())
ans = 0
snumber = [str(i) for i in range(10)]
for i in snumber:
    for j in snumber:
        for k in snumber:
            n = 0
            code = []
            while i != S[n] and n < N-3:
                n += 1
            if S[n] != i:
                break
            n += 1
            while j != S[n] and n < N-2:
                n += 1
            if S[n] != j:
                break
            n += 1
            while k != S[n] and n < N-1:
                n += 1
            if S[n] == k:
                ans += 1
print(ans)

Solution (Python):
n = int(input())
s = input()

ans = 0

i_list = []
for i in range(n-2):
    if s[i] not in i_list:
        i_list.append(s[i])
    elif len(i_list) == 10:
        break
    else:
        continue
    j_list = []
    for j in range(i+1, n-1):
        if s[j] not in j_list:
            j_list.append(s[j])
        elif len(j_list) == 10:
            break
        else:
            continue
        x = len(set(s[j+1:]))
        ans += x

print(ans)

Solution (Python):
N = int(input())
S = input()

roop = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]

out = 0

for i in roop:
    keta1 = S.find(i)
    if keta1 > N - 3 or keta1 == -1:
        continue
    else:
        S2 = S[keta1 + 1 :]
    for j in roop:
        keta2 = S2.find(j)
        if keta2 > len(S2) - 2 or keta2 == -1:
            continue
        else:
            S3 = S2[keta2 + 1 :]
        for k in roop:
            keta3 = S3.find(k)
            if keta3 != -1:
                out = out + 1
print(out)

Solution (Python):

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

tree_1=[]
tree_2=[]
tree_3=[]

for i in range(0,N):
    for e2 in tree_2:
        tree_3.append(e2+S[i])
    for e1 in tree_1:
        if len(tree_2)!=0:
            if (e1+S[i] in tree_2)!=True:
                tree_2.append(e1+S[i])
        else:
            tree_2.append(e1+S[i])
    if len(tree_1)!=0:
        if (S[i] in tree_1)!=True:
            tree_1.append(S[i])
    else:
        tree_1.append(S[i])
print(len(set(tree_3)))

Solution (Python):
import sys
input = sys.stdin.readline
from collections import Counter



def main():
    N = int(input())
    S = input().strip()

    ans = 0
    for i in range(10):
        for j in range(10):
            for k in range(10):
                x = S.find(str(i))
                if x == -1 or x == N - 1:
                    continue
                y = S[x + 1:].find(str(j))
                if y == -1 or y == N - 1:
                    continue
                z = S[x + y + 2:].find(str(k))
                if z == -1:
                    continue
                ans += 1
    print(ans)








if __name__ == '__main__':
    main()

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    n = int(input())
    s = list(input())
    cnt = 0
    cache1 = set()
    for i in range(n):
        if int(s[i]) in cache1: continue
        cache1.add(int(s[i]))
        cache2 = set()
        for j in range(i+1, n):
            if int(s[j]) in cache2: continue
            cache2.add(int(s[j]))
            cache3 = set()
            for k in range(j+1, n):
                if int(s[k]) in cache3: continue
                cache3.add(int(s[k]))
                cnt += 1

    print(cnt)

if __name__ == "__main__":
    main()

Solution (Python):
def search(minp, maxp, p):
  mi = 0
  ma = len(p) - 1
  while abs(ma-mi) > 1:
    if p[(mi+ma)//2] <= minp:
      mi = (mi+ma) // 2
    elif p[(mi+ma)//2] >= maxp:
      ma = (mi+ma) // 2
    else:
      mi = (mi+ma) // 2
      ma = (mi+ma) // 2 
  if p[mi] > minp and p[mi] < maxp:
    return 1
  elif p[ma] > minp and p[ma] < maxp:
    return 1
  else:
    return 0


n = int(input())
s = input()

pos = [[] for _ in range(10)]

for i in range(n):
  for j in range(10):
    if int(s[i]) == j:
      pos[j].append(i)
      break

cnt = 0
for i in range(10):
  for j in range(10):
    for k in range(10):
      if i == j and j == k:
        if len(pos[i]) >= 3:
          cnt += 1
      elif i != j and j != k:
        if len(pos[i]) > 0 and len(pos[j]) > 0 and len(pos[k]) > 0:
          minp = pos[i][0]
          maxp = pos[k][-1]
          cnt += search(minp, maxp, pos[j])

      elif j == k:
        if len(pos[i]) > 0 and len(pos[j]) > 1:
          if pos[i][0] < pos[j][-2]:
            cnt += 1
      elif i == j:
        if len(pos[i]) > 1 and len(pos[k]) > 0:
          if pos[i][1] < pos[k][-1]:
            cnt += 1
      elif i == k:
        if len(pos[i]) > 1 and len(pos[j]) > 0:
          minp = pos[i][0]
          maxp = pos[i][-1]
          cnt += search(minp, maxp, pos[j])

print (cnt)

Solution (Python):
N = int(input())
S = input()
ans = 0
for i in range(1000):
  a = i//100
  b = i//10 % 10
  c = i % 10 
  target = a
  for d in S:
    if d == str(target):
      if str(target) == str(a):
        a = 999
        target = b
      elif str(target) == str(b):
        b = 999
        target = c
      elif str(target) == str(c):
        c = 999
        ans += 1
        break
print(ans)

Solution (Python):
N = int(input())
S = input()

count = 0
for i in range(10):
  for j in range(10):
    for k in range(10):
      pas = (str(i),str(j),str(k))
      key = 0
      for c in S:
        if c == pas[key]:
          key += 1
          if key ==3:
            count +=1
            break
print(count)

Solution (Python):
N=int(input())
s=input()
S=[]
for i in s:
  S.append(int(i))

A=set()
B={S[-2]*10+S[-1]}
C={S[-1]}
C.add(S[-2])
for j in range(N-2):
  i=N-3-j
  for b in B:
    A.add(S[i]*100 + b)
  for c in C:
    B.add(S[i]*10 + c)
  C.add(S[i])
print(len(A))

Solution (Python):
N = int(input())
S = input()
t = []
for i in range(10):
	if str(i) not in S:
		t.append(i)
cnt = 0
flg1 = [0] * 10
ind1 = 0
for i in t:
	flg1[i] = 1
while True:
	if flg1[int(S[ind1])] == 1:
		ind1 += 1
	else:
		flg2 = [0] * 10
		for i in t:
			flg2[i] = 1
		ind2 = ind1 + 1
		while True:
			if flg2[int(S[ind2])] == 1:
				ind2 += 1
			else:
				flg3 = [0] * 10
				for i in t:
					flg3[i] = 1
				ind3 = ind2 + 1
				while True:
					if flg3[int(S[ind3])] == 1:
						ind3 += 1
					else:
						flg3[int(S[ind3])] = 1
						cnt += 1
						ind3 += 1

					if flg3.count(0) == 0:
						break
					if ind3 == N:
						break
				flg2[int(S[ind2])] = 1
				ind2 += 1
			if flg2.count(0) == 0:
				break
			if ind2 == N-1:
				break
		flg1[int(S[ind1])] = 1
		ind1 += 1
	if flg1.count(0) == 0:
		break
	if ind1 == N-2:
		break

print(cnt)

Solution (Python):
n,s = [input() for i in range(2)]
c = 0
for i in range(1000):
    if i < 10:
        a1 = '0'
        a2 = '0'
        a3 = str(i)
    elif i < 100:
        a1 = '0'
        a2 = str(i)[0]
        a3 = str(i)[1]
    else:
        a1 = str(i)[0]
        a2 = str(i)[1]
        a3 = str(i)[2]
    p1 = s.find(a1)
    if p1 >= 0:
        p2 = s.find(a2, p1 + 1)
        if p2 >= 0:
            if s.find(a3, p2 + 1) >= 0:
                c += 1
print(c)

Solution (Python):
import re

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

ans = 0

inStr = [0,0,0,0,0,0,0,0,0,0]
for i in range(N - 2):
    inStr2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    if inStr[int(S[i])] == 0:
        inStr[int(S[i])] = 1
        for j in range(i + 1, N-1):
            inStr3 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
            if inStr2[int(S[j])] == 0:
                inStr2[int(S[j])] = 1
                for k in range(j + 1, N):
                    if inStr3[int(S[k])] == 0:
                        inStr3[int(S[k])] = 1
                        ans = ans + 1


print(ans)

Solution (Python):
N = int(input())
S = input()

tmp = []
f = []
dada = ""
for i in range(N - 2):
    s = []
    first = S[i]
    if S[i] in f:
        continue
    f.append(first)
    for j in range(i + 1, N - 1):
        t = []
        second = first + S[j]
        if S[j] in s:
            continue
        s.append(S[j])
        for k in range(j + 1, N):
            third = second + S[k]
            if S[k] in t:
                continue
            t.append(S[k])
            if third not in tmp:
                tmp.append(third)

print(len(tmp))

Solution (Python):
import bisect as bi

n = int(input())
s = input()
arr = [[] for i in range(10)]

for i in range(n):
  num = int(s[i])
  arr[num].append(i)

count = 0
for i in range(1000):
  index = 0
  s_num = str(i).zfill(3)
  s1 = int(s_num[0])
  if len(arr[s1]) == 0:
    continue
  else:
    index = arr[s1][0]
  
  s2 = int(s_num[1])
  if len(arr[s2]) == 0 or index >= arr[s2][-1]:
    continue
  
  tmp = bi.bisect_right(arr[s2], index)
  index = arr[s2][tmp]
  
  s3 = int(s_num[2])
  if len(arr[s3]) == 0 or index >= arr[s3][-1]:
    continue
  
  count += 1
  
print(count)

Solution (Python):
N = int(input())
S = input()

ans = 0
l1 = []
for i in range(N):
    l2 = []
    if S[i] in l1:
        continue
    else:
        l1.append(S[i])
    for j in range(i + 1, N):
        if S[j] in l2:
            continue
        else:
            l2.append(S[j])
        s = S[j + 1:]
        ans += len(set(s))

print(ans)

Solution (Python):
n=int(input())

s=[int(x) for x in input()]
cnt=0
for i in range(10):
 for j in range(10):
  for k in range(10):
   try:
    inx1=s.index(i)
   except:
    continue
   try:
    inx2=s[inx1+1:].index(j) + inx1 +1
   except:
    continue
   try:
    inx3=s[inx2+1:].index(k) + inx1 + inx2 +2
   except:
    continue
   cnt+=1
print(cnt)

Solution (Python):
N = int(input())
S = list(input())


ans = 0
for i in range(10):
 for j in range(10):
  judge1,judge2 = 0,0 
  tmp_list = []
  
  for k in range(N):
    if(judge1 == 0):
     if(i == int(S[k])): judge1 = 1
    else:
     if(judge2 == 0): 
      if(j == int(S[k])): judge2 = 1
     else: 
      tmp_list.append(int(S[k]))
      
  tmp_list = list(set(tmp_list))
  ans += len(tmp_list)
  
print(ans)

Solution (Python):
from collections import Counter
N = int(input())
S = input()
C = Counter(S)

cnt = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            try:
                a = S.index(str(i))
                b = S[a+1:].index(str(j))
                c = S[a+b+2:].index(str(k))
            except ValueError:
                continue
            cnt += 1
            
print(cnt)

Solution (Python):
n=int(input())
s=input()
inf=float("inf")
A=[[inf]*10 for _ in range(n+1)]
for i in reversed(range(n)):
  ss=s[i]
  for j in range(10):
    if j==int(ss):
      A[i][j]=i
    else:
      A[i][j]=A[i+1][j]
ans=0
for x in range(1000):
  x=str(x).zfill(3)
  cur=0
  for xx in x:
    xx=int(xx)
    cur=A[cur][xx]+1
    if cur==inf:
      break
  if cur!=inf:
    ans+=1
print(ans)