Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
 
N = int(input())
S = input()
 
ans = 0
for i in range(1000):
    pw = "0"*(3-len(str(i)))+str(i)
 
    w1 = -1
    for j in range(N-2):
        if S[j] == pw[0]:
            w1 = j
            break
    if w1 == -1:
        continue
 
    w2 = -1
    for j in range(w1+1, N-1):
        if S[j] == pw[1]:
            w2 = j
            break
    if w2 == -1:
        continue
 
    w3 = -1
    for j in range(w2+1, N):
        if S[j] == pw[2]:
            w3 = j
            break
    if w3 == -1:
        continue
 
    ans += 1
 
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-

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

ans = 0
for i in range(1000):
    pw = list("{0:03d}".format(i))

    if pw[0] in S:
        w1 = S.index(pw[0])
        if pw[1] in S[w1+1:]:
            w2 = w1+1 + S[w1+1:].index(pw[1])
            if pw[2] in S[w2+1:]:
                ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

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

ans = 0
for i in range(1000):
    pw = "0"*(3-len(str(i)))+str(i)

    w1 = -1
    for j in range(N-2):
        if S[j] == pw[0]:
            w1 = j
            break
    if w1 == -1:
        continue

    w2 = -1
    for j in range(w1+1, N-1):
        if S[j] == pw[1]:
            w2 = j
            break
    if w2 == -1:
        continue

    w3 = -1
    for j in range(w2+1, N):
        if S[j] == pw[2]:
            w3 = j
            break
    if w3 == -1:
        continue

    ans += 1

print(ans)


Fixed submission:
# -*- coding: utf-8 -*-

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

ans = 0
for i in range(1000):
    pw = list("{0:03d}".format(i))

    if pw[0] in S:
        w1 = S.index(pw[0])
        if pw[1] in S[w1+1:]:
            w2 = w1+1 + S[w1+1:].index(pw[1])
            if pw[2] in S[w2+1:]:
                ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

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

ans = 0
for i in range(1000):
    pw = list("{0:03d}".format(i))

    w1 = -1
    for j in range(N-2):
        if S[j] == pw[0]:
            w1 = j
            break
    if w1 == -1:
        continue

    w2 = -1
    for j in range(w1+1, N-1):
        if S[j] == pw[1]:
            w2 = j
            break
    if w2 == -1:
        continue

    w3 = -1
    for j in range(w2+1, N):
        if S[j] == pw[2]:
            w3 = j
            break
    if w3 == -1:
        continue

    ans += 1

print(ans)


Fixed submission:
# -*- coding: utf-8 -*-

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

ans = 0
for i in range(1000):
    pw = list("{0:03d}".format(i))

    if pw[0] in S:
        w1 = S.index(pw[0])
        if pw[1] in S[w1+1:]:
            w2 = w1+1 + S[w1+1:].index(pw[1])
            if pw[2] in S[w2+1:]:
                ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

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

sumtmp = [[0 for i in range(N) ] for j in range(10)]
sumtmp[int(S[0])][0] = 1
for i in range(1, N):
    val = int(S[i])
    for j in range(10):
        sumtmp[j][i] = sumtmp[j][i-1] 
        if j == val:
            sumtmp[j][i] += 1

pw = set()
for i in range(0, N-2):
    for j in range(i+1, N-1):
        for k in range(10):
            if sumtmp[k][N-1] - sumtmp[k][j] > 0:
                w = S[i]+S[j]+str(k) 
                pw.add(w)

print(len(pw))


Fixed submission:
# -*- coding: utf-8 -*-

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

ans = 0
for i in range(1000):
    pw = list("{0:03d}".format(i))

    if pw[0] in S:
        w1 = S.index(pw[0])
        if pw[1] in S[w1+1:]:
            w2 = w1+1 + S[w1+1:].index(pw[1])
            if pw[2] in S[w2+1:]:
                ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

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

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

print(len(password))

Fixed submission:
# -*- coding: utf-8 -*-

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

ans = 0
for i in range(1000):
    pw = list("{0:03d}".format(i))

    if pw[0] in S:
        w1 = S.index(pw[0])
        if pw[1] in S[w1+1:]:
            w2 = w1+1 + S[w1+1:].index(pw[1])
            if pw[2] in S[w2+1:]:
                ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

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

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

print(len(password))

Fixed submission:
# -*- coding: utf-8 -*-

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

ans = 0
for i in range(1000):
    pw = list("{0:03d}".format(i))

    if pw[0] in S:
        w1 = S.index(pw[0])
        if pw[1] in S[w1+1:]:
            w2 = w1+1 + S[w1+1:].index(pw[1])
            if pw[2] in S[w2+1:]:
                ans += 1

print(ans)