Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

cnt = 0
chk = [0]*1000
for j in range(1000):
    j = str(j).zfill(3)
    for i, s in enumerate(S):
        if chk[int(j)] == 1:
            continue
        if s == j[0]:
            for ii, ss in enumerate(S[i+1:]):
                if ss == j[1]:
                    if chk[int(j)] == 1:
                        continue
                    for iii, sss in enumerate(S[i+ii+2:]):
                        if sss == j[2]:
                            if chk[int(j)] == 1:
                                continue
                            chk[int(j)] = 1
                            cnt += 1
print(cnt)


Fixed submission:
# import numpy as np
import sys, math, heapq
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

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

cnt = 0
for num in range(1000):
    snum = str(num).zfill(3)
    # print("snum", snum)
    ind = 0
    chkind = 0
    # while ind < len(S):
    for s in S:
        if chkind >= 3:
            break
        if s == snum[chkind]:
            chkind += 1
    if chkind == 3:
        cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

cnt = 0
chk = [0]*1000
for j in range(1000):
    j = str(j).zfill(3)
    for i, s in enumerate(S):
        if chk[int(j)] == 1:
            continue
        if s == j[0]:
            for ii, ss in enumerate(S[i+1:]):
                if ss == j[1]:
                    if chk[int(j)] == 1:
                        continue
                    for iii, sss in enumerate(S[i+ii+2:]):
                        if sss == j[2]:
                            if chk[int(j)] == 1:
                                continue
                            chk[int(j)] = 1
                            cnt += 1
print(cnt)


Fixed submission:
# import numpy as np
import sys, math, heapq
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

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

cnt = 0
for num in range(1000):
    snum = str(num).zfill(3)
    # print("snum", snum)
    ind = 0
    chkind = 0
    # while ind < len(S):
    for s in S:
        if chkind >= 3:
            break
        if s == snum[chkind]:
            chkind += 1
    if chkind == 3:
        cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

cnt = 0
chk = [0]*1000
for j in range(1000):
    j = str(j).zfill(3)
    for i, s in enumerate(S):
        if s == j[0]:
            for ii, ss in enumerate(S[i+1:]):
                if ss == j[1]:
                    for iii, sss in enumerate(S[i+ii+2:]):
                        if sss == j[2]:
                            if chk[int(j)] == 1:
                                continue
                            chk[int(j)] = 1
                            cnt += 1
print(cnt)


Fixed submission:
# import numpy as np
import sys, math, heapq
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

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

cnt = 0
for num in range(1000):
    snum = str(num).zfill(3)
    # print("snum", snum)
    ind = 0
    chkind = 0
    # while ind < len(S):
    for s in S:
        if chkind >= 3:
            break
        if s == snum[chkind]:
            chkind += 1
    if chkind == 3:
        cnt += 1
print(cnt)