Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N = int(input())
S = input()
ans = 0
for v in range(1000):
    v = str(v).zfill(3)
    flag = [False for _ in range(3)]
    for i in range(len(S)):
        if not flag[0] and v[0] == S[i]:
            flag[0] = True
            continue
        if not flag[1] and v[1] == S[i]and flag[0]:
            flag[1] = True
            continue
        if not flag[2] and v[2] == S[i] and flag[1]:
            flag[2] = True
            break
    if sum(flag) == 3:
        ans += 1
print(ans)

Fixed submission:
# coding: utf-8
N = int(input())
S = input()
ans = []
for v in range(1000):
    used = [False for _ in range(len(S))]
    v = str(v).zfill(3)
    idx = 0
    for i in range(len(S)):
        if v[0] == S[i] and not used[i]:
            used[i] = True
            idx = i + 1
            break
    for i in range(idx, len(S)):
        if v[1] == S[i] and not used[i]:
            used[i] = True
            idx = i + 1
            break
    for i in range(idx, len(S)):
        if v[2] == S[i] and not used[i]:
            used[i] = True
            break
    if sum(used) == 3 and v not in ans:
        ans.append(v[:])
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N = int(input())
S = input()
ans = 0
for v in range(1000):
    used = [False for _ in range(len(S))]
    v = str(v).zfill(3)
    flag = [False for _ in range(3)]
    idx = 0
    for i in range(len(S)):
        if not flag[0] and v[0] == S[i] and not used[i]:
            used[i] = True
            flag[0] = True
            continue
        if not flag[1] and v[1] == S[i] and not used[i] and sum(used[:i]) == 1:
            used[i] = True
            flag[1] = True
            continue
        if not flag[2] and v[2] == S[i] and not used[i] and sum(used[:i]) == 2:
            used[i] = True
            flag[2] = True
            break
    if sum(flag) == 3:
        ans += 1
print(ans)

Fixed submission:
# coding: utf-8
N = int(input())
S = input()
ans = []
for v in range(1000):
    used = [False for _ in range(len(S))]
    v = str(v).zfill(3)
    idx = 0
    for i in range(len(S)):
        if v[0] == S[i] and not used[i]:
            used[i] = True
            idx = i + 1
            break
    for i in range(idx, len(S)):
        if v[1] == S[i] and not used[i]:
            used[i] = True
            idx = i + 1
            break
    for i in range(idx, len(S)):
        if v[2] == S[i] and not used[i]:
            used[i] = True
            break
    if sum(used) == 3 and v not in ans:
        ans.append(v[:])
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N = int(input())
S = input()
ans = 0
for v in range(1000):
    used = [False for _ in range(len(S))]
    v = str(v).zfill(3)
    flag = [False for _ in range(3)]
    idx = 0
    for i in range(len(S)):
        if not flag[0] and v[0] == S[i] and not used[i]:
            used[i] = True
            flag[0] = True
            continue
        if not flag[1] and v[1] == S[i] and not used[i] and sum(used[:i]) == 1:
            used[i] = True
            flag[1] = True
            continue
        if not flag[2] and v[2] == S[i] and not used[i] and sum(used[:i]) == 2:
            used[i] = True
            flag[2] = True
            break
    if sum(flag) == 3:
        ans += 1
print(ans)

Fixed submission:
# coding: utf-8
N = int(input())
S = input()
ans = []
for v in range(1000):
    used = [False for _ in range(len(S))]
    v = str(v).zfill(3)
    idx = 0
    for i in range(len(S)):
        if v[0] == S[i] and not used[i]:
            used[i] = True
            idx = i + 1
            break
    for i in range(idx, len(S)):
        if v[1] == S[i] and not used[i]:
            used[i] = True
            idx = i + 1
            break
    for i in range(idx, len(S)):
        if v[2] == S[i] and not used[i]:
            used[i] = True
            break
    if sum(used) == 3 and v not in ans:
        ans.append(v[:])
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N = int(input())
S = input()
ans = []
for v in range(1000):
    used = [False for _ in range(len(S))]
    v = str(v).zfill(3)
    idx = 0
    for i in range(len(S)):
        if v[0] == S[i] and not used[i]:
            used[i] = True
            idx = i + 1
            break
    for i in range(idx, len(S)):
        if v[1] == S[i] and not used[i]:
            used[i] = True
            idx = i + 1
            break
    for i in range(idx, len(S)):
        if v[2] == S[i] and not used[i]:
            used[i] = True
            break
    if sum(used) == 3 and v not in ans:
        ans.append(v[:])
print(len(ans))

Fixed submission:
# coding: utf-8
N = int(input())
S = input()
ans = []
for v in range(1000):
    used = [False for _ in range(len(S))]
    v = str(v).zfill(3)
    idx = 0
    for i in range(len(S)):
        if v[0] == S[i] and not used[i]:
            used[i] = True
            idx = i + 1
            break
    for i in range(idx, len(S)):
        if v[1] == S[i] and not used[i]:
            used[i] = True
            idx = i + 1
            break
    for i in range(idx, len(S)):
        if v[2] == S[i] and not used[i]:
            used[i] = True
            break
    if sum(used) == 3 and v not in ans:
        ans.append(v[:])
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
l = []
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            l.append(S[i]+S[j]+S[k])
l = list(set(l))
print(len(l))

Fixed submission:
# coding: utf-8
N = int(input())
S = input()
ans = []
for v in range(1000):
    used = [False for _ in range(len(S))]
    v = str(v).zfill(3)
    idx = 0
    for i in range(len(S)):
        if v[0] == S[i] and not used[i]:
            used[i] = True
            idx = i + 1
            break
    for i in range(idx, len(S)):
        if v[1] == S[i] and not used[i]:
            used[i] = True
            idx = i + 1
            break
    for i in range(idx, len(S)):
        if v[2] == S[i] and not used[i]:
            used[i] = True
            break
    if sum(used) == 3 and v not in ans:
        ans.append(v[:])
print(len(ans))