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

numset = set([0,1,2,3,4,5,6,7,8,9])
resset = set()

for i in range(N):
    for j in range(i+1,N):
        useset = set(S[j+1:N])
        for k in useset:
            L = [S[i],S[j],k]
            temp = ''.join(L)
            resset.add(temp)

print(len(resset))


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

res = 0

for i in range(10):
    p1 = S.find(str(i))
    if p1 == -1:
        continue
    elif p1 > N-3:
        continue
    for j in range(10):
        p2 = S[p1+1:N].find(str(j))
        if p2 == -1:
            continue
        elif p2 > N-p1-3:
            continue
        for k in range(10):
            p3 = S[p1+p2+2:N].find(str(k))
            if p3 == -1:
                continue
            res += 1


print(res)

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

resset = set()

for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            temp = ''.join([S[i],S[j],S[k]])
            resset.add(temp)

print(len(resset))


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

res = 0

for i in range(10):
    p1 = S.find(str(i))
    if p1 == -1:
        continue
    elif p1 > N-3:
        continue
    for j in range(10):
        p2 = S[p1+1:N].find(str(j))
        if p2 == -1:
            continue
        elif p2 > N-p1-3:
            continue
        for k in range(10):
            p3 = S[p1+p2+2:N].find(str(k))
            if p3 == -1:
                continue
            res += 1


print(res)

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

resset = set()

def set_range(start,end):
    return set(i for i in range(start, end))

range1 = set(i for i in range(0,N))

for i in range1:
    range2 = set(i for i in range(i+1,N))
    for j in range2:
        range3 = set(i for i in range(j+1,N))
        for k in range3:
            temp = S[i] + S[j] + S[k]
            resset.add(temp)

print(len(resset))


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

res = 0

for i in range(10):
    p1 = S.find(str(i))
    if p1 == -1:
        continue
    elif p1 > N-3:
        continue
    for j in range(10):
        p2 = S[p1+1:N].find(str(j))
        if p2 == -1:
            continue
        elif p2 > N-p1-3:
            continue
        for k in range(10):
            p3 = S[p1+p2+2:N].find(str(k))
            if p3 == -1:
                continue
            res += 1


print(res)

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

set = set()

for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            temp = S[i] + S[j] + S[k]
            set.add(temp)

print(len(set))


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

res = 0

for i in range(10):
    p1 = S.find(str(i))
    if p1 == -1:
        continue
    elif p1 > N-3:
        continue
    for j in range(10):
        p2 = S[p1+1:N].find(str(j))
        if p2 == -1:
            continue
        elif p2 > N-p1-3:
            continue
        for k in range(10):
            p3 = S[p1+p2+2:N].find(str(k))
            if p3 == -1:
                continue
            res += 1


print(res)

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

set = set()

for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            temp = S[i] + S[j] + S[k]
            set.add(temp)

print(len(set))


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

res = 0

for i in range(10):
    p1 = S.find(str(i))
    if p1 == -1:
        continue
    elif p1 > N-3:
        continue
    for j in range(10):
        p2 = S[p1+1:N].find(str(j))
        if p2 == -1:
            continue
        elif p2 > N-p1-3:
            continue
        for k in range(10):
            p3 = S[p1+p2+2:N].find(str(k))
            if p3 == -1:
                continue
            res += 1


print(res)