Buggy python submission (verdict: Time Limit Exceeded):
from sys import setrecursionlimit

setrecursionlimit(10 ** 9)

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

pins = set([])


def make_pin(s, i):
    if len(s) == 3:
        pins.add(s)
        return

    if i == N:
        return

    make_pin(s + S[i], i + 1)
    make_pin(s, i + 1)


make_pin("", 0)

print(len(pins))


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

ans = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            num = str(i) + str(j) + str(k)
            tmp = 0

            for s in S:
                if num[tmp] == s:
                    tmp += 1

                if tmp >= 3:
                    break

            if tmp == 3:
                ans += 1

print(ans)

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

ans = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            num = str(i) + str(j) + str(k)
            tmp = 0

            for s in S:
                if num[tmp] == s:
                    tmp += 1

                if tmp >= 3:
                    break

            if tmp == 3:
                ans += 1

print(ans)


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

ans = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            num = str(i) + str(j) + str(k)
            tmp = 0

            for s in S:
                if num[tmp] == s:
                    tmp += 1

                if tmp >= 3:
                    break

            if tmp == 3:
                ans += 1

print(ans)

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

dp = [[[[False for _ in range(11)] for _ in range(11)]
       for _ in range(11)] for _ in range(N + 1)]

for i in range(N):
    num = int(S[i])
    for j in range(11):
        for k in range(11):
            for l in range(11):
                dp[i + 1][num][10][10] = True

                dp[i + 1][j][10][10] = dp[i][j][10][10]
                dp[i + 1][j][num][10] = dp[i][j][10][10]

                dp[i + 1][j][k][10] = dp[i][j][k][10]
                dp[i + 1][j][k][num] = dp[i][j][k][10]

                dp[i + 1][j][k][l] = dp[i][j][k][l]

ans = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            if dp[N][i][j][k]:
                # print(i, j, k)
                ans += 1

print(ans)


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

ans = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            num = str(i) + str(j) + str(k)
            tmp = 0

            for s in S:
                if num[tmp] == s:
                    tmp += 1

                if tmp >= 3:
                    break

            if tmp == 3:
                ans += 1

print(ans)

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

dp = [[[[False for _ in range(11)] for _ in range(11)]
       for _ in range(11)] for _ in range(N + 1)]

for i in range(N):
    num = int(S[i])
    for j in range(11):
        for k in range(11):
            for l in range(11):
                dp[i + 1][num][10][10] = True

                dp[i + 1][j][10][10] = dp[i][j][10][10]
                dp[i + 1][j][num][10] = dp[i][j][10][10]

                dp[i + 1][j][k][10] = dp[i][j][k][10]
                dp[i + 1][j][k][num] = dp[i][j][k][10]

                dp[i + 1][j][k][l] = dp[i][j][k][l]

ans = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            if dp[N][i][j][k]:
                # print(i, j, k)
                ans += 1

print(ans)


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

ans = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            num = str(i) + str(j) + str(k)
            tmp = 0

            for s in S:
                if num[tmp] == s:
                    tmp += 1

                if tmp >= 3:
                    break

            if tmp == 3:
                ans += 1

print(ans)