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

for i in range(10):
    for j in range(10):
        for k in range(10):
            hit = 0
            for c in S:
                c_ = int(c)
                if hit == 0 and c_ == i:
                    hit += 1
                elif hit == 1 and c_ == j:
                    hit += 1
                elif hit == 2 and c_ == k:
                    ans += 1
                    break
print(ans)


Fixed submission:
N = int(input())
S = input()
ans = 0

for i in range(10):
    ind_i = S.find(str(i))
    if ind_i != -1:
        S2 = S[ind_i + 1:]
        for j in range(10):
            ind_j = S2.find(str(j))
            if ind_j != -1:
                S3 = S2[ind_j + 1:]
                for k in range(10):
                    cnt_k = S3.count(str(k))
                    if cnt_k > 0:
                        ans += 1


print(ans)

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

for i in range(10):
    for j in range(10):
        for k in range(10):
            hit = 0
            for c in S:
                if hit == 0 and c == str(i):
                    hit += 1
                elif hit == 1 and c == str(j):
                    hit += 1
                elif hit == 2 and c == str(k):
                    ans += 1
                    break
print(ans)


Fixed submission:
N = int(input())
S = input()
ans = 0

for i in range(10):
    ind_i = S.find(str(i))
    if ind_i != -1:
        S2 = S[ind_i + 1:]
        for j in range(10):
            ind_j = S2.find(str(j))
            if ind_j != -1:
                S3 = S2[ind_j + 1:]
                for k in range(10):
                    cnt_k = S3.count(str(k))
                    if cnt_k > 0:
                        ans += 1


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq

N = int(input())
S = input()
stack = []
heapq.heapify(stack)
cnt = 0
for s in S:
    for i in range(len(stack)):
        if len(stack[i]) <= 2:
            new = s + stack[i]
            if new not in stack:
                stack.append(new)
                if len(new) == 3:
                    cnt += 1
    if s not in stack:
        stack.append(s)
print(cnt)


Fixed submission:
N = int(input())
S = input()
ans = 0

for i in range(10):
    ind_i = S.find(str(i))
    if ind_i != -1:
        S2 = S[ind_i + 1:]
        for j in range(10):
            ind_j = S2.find(str(j))
            if ind_j != -1:
                S3 = S2[ind_j + 1:]
                for k in range(10):
                    cnt_k = S3.count(str(k))
                    if cnt_k > 0:
                        ans += 1


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
stack = []
cnt = 0
for s in S:
    for i in range(len(stack)):
        if len(stack[i]) <= 2:
            new = s + stack[i]
            if new not in stack:
                stack.append(new)
                if len(new) == 3:
                    cnt += 1
    if s not in stack:
        stack.append(s)
print(cnt)


Fixed submission:
N = int(input())
S = input()
ans = 0

for i in range(10):
    ind_i = S.find(str(i))
    if ind_i != -1:
        S2 = S[ind_i + 1:]
        for j in range(10):
            ind_j = S2.find(str(j))
            if ind_j != -1:
                S3 = S2[ind_j + 1:]
                for k in range(10):
                    cnt_k = S3.count(str(k))
                    if cnt_k > 0:
                        ans += 1


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
stack = []
ans = []

for s in S:
    for i in range(len(stack)):
        if len(stack[i]) <= 2:
            new = s + stack[i]
            if new not in stack:
                stack.append(new)
    if s not in stack:
        stack.append(s)
        
cnt = 0
for w_ in stack:
    if len(w_) == 3:
        cnt += 1
print(cnt)


Fixed submission:
N = int(input())
S = input()
ans = 0

for i in range(10):
    ind_i = S.find(str(i))
    if ind_i != -1:
        S2 = S[ind_i + 1:]
        for j in range(10):
            ind_j = S2.find(str(j))
            if ind_j != -1:
                S3 = S2[ind_j + 1:]
                for k in range(10):
                    cnt_k = S3.count(str(k))
                    if cnt_k > 0:
                        ans += 1


print(ans)