Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = str(input())
ans = 0
for i in range(1000):
    t = ""
    x = i
    for j in range(3):
        t += str(x % 10)
        x //= 10

    ti = 0
    for k in range(N):
        if S[k] == t[ti]:
            ti += 1
            if ti == 3:
                break

    if ti == 3:
        ans += 1

print(ans)

Fixed submission:
N = int(input())
S = input()
ans = 0
# 000 - 999 まで全探索
for i in range(1000):
    t = str(i).zfill(3)

    # 1桁目が存在するか
    if t[0] in S:
        t1 = S.index(t[0])
        # 2桁目を1桁目のidx + 1から探す
        if t[1] in S[t1 + 1:]:
            # 1桁目のidx + 2桁目のidx + 1 桁目から3文字目を探す
            t2 = t1 + S[t1 + 1:].index(t[1]) + 1
            if t[2] in S[t2 + 1:]:
                ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
S = [int(_) for _ in input()]
s = list(itertools.combinations(S, 3))
print(len(set(s)))

Fixed submission:
N = int(input())
S = input()
ans = 0
# 000 - 999 まで全探索
for i in range(1000):
    t = str(i).zfill(3)

    # 1桁目が存在するか
    if t[0] in S:
        t1 = S.index(t[0])
        # 2桁目を1桁目のidx + 1から探す
        if t[1] in S[t1 + 1:]:
            # 1桁目のidx + 2桁目のidx + 1 桁目から3文字目を探す
            t2 = t1 + S[t1 + 1:].index(t[1]) + 1
            if t[2] in S[t2 + 1:]:
                ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
S = [int(_) for _ in input()]
s = list(itertools.combinations(S, 3))
print(len(set(s)))

Fixed submission:
N = int(input())
S = input()
ans = 0
# 000 - 999 まで全探索
for i in range(1000):
    t = str(i).zfill(3)

    # 1桁目が存在するか
    if t[0] in S:
        t1 = S.index(t[0])
        # 2桁目を1桁目のidx + 1から探す
        if t[1] in S[t1 + 1:]:
            # 1桁目のidx + 2桁目のidx + 1 桁目から3文字目を探す
            t2 = t1 + S[t1 + 1:].index(t[1]) + 1
            if t[2] in S[t2 + 1:]:
                ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
from collections import defaultdict as dict
d = dict(int)
 
N = int(input())
S = [int(_) for _ in input()]
s = list(itertools.combinations(S, 3))
 
for j in range(len(s)):
 
    # カウントアップ
    d[s[j]] += 1
 
print(len(d))

Fixed submission:
N = int(input())
S = input()
ans = 0
# 000 - 999 まで全探索
for i in range(1000):
    t = str(i).zfill(3)

    # 1桁目が存在するか
    if t[0] in S:
        t1 = S.index(t[0])
        # 2桁目を1桁目のidx + 1から探す
        if t[1] in S[t1 + 1:]:
            # 1桁目のidx + 2桁目のidx + 1 桁目から3文字目を探す
            t2 = t1 + S[t1 + 1:].index(t[1]) + 1
            if t[2] in S[t2 + 1:]:
                ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
from collections import defaultdict as dict
d = dict(int)

N = int(input())
S = [int(_) for _ in input()]
s = list(itertools.combinations(S, 3))

for j in range(len(s)):

    # カウントアップ
    d[s[j]] += 1

print(len(d))

Fixed submission:
N = int(input())
S = input()
ans = 0
# 000 - 999 まで全探索
for i in range(1000):
    t = str(i).zfill(3)

    # 1桁目が存在するか
    if t[0] in S:
        t1 = S.index(t[0])
        # 2桁目を1桁目のidx + 1から探す
        if t[1] in S[t1 + 1:]:
            # 1桁目のidx + 2桁目のidx + 1 桁目から3文字目を探す
            t2 = t1 + S[t1 + 1:].index(t[1]) + 1
            if t[2] in S[t2 + 1:]:
                ans += 1

print(ans)