Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = input()
    ans = 0
    password = [0, 0, 0]
    for i in range(1000):
        for j in range(3):
            password[j] = i // (10 ** j) % 10
        index = 2
        for k in range(n):
            if password[index] == int(s[k]):
                index -= 1
            if index == -1:
                ans += 1
                break
    print(ans)


if __name__ == "__main__":
    main()

Fixed submission:
n = int(input())
s = input()
ans = 0
password = [0, 0, 0]
for i in range(1000):
    for j in range(3):
        password[2 - j] = i // (10 ** j) % 10
    if str(password[0]) in s:
        index = s.index(str(password[0]))
        if str(password[1]) in s[index + 1:]:
            index2 = index + 1 + s[index + 1:].index(str(password[1]))
            if str(password[2]) in s[index2 + 1:]:
                ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = input()
    ans = 0
    password = [0, 0, 0]
    for i in range(1000):
        for j in range(3):
            password[j] = i // (10 ** j) % 10
        index = 2
        for k in range(n):
            if password[index] == int(s[k]):
                index -= 1
            if index == -1:
                ans += 1
                break
    print(ans)


if __name__ == "__main__":
    main()

Fixed submission:
n = int(input())
s = input()
ans = 0
password = [0, 0, 0]
for i in range(1000):
    for j in range(3):
        password[2 - j] = i // (10 ** j) % 10
    if str(password[0]) in s:
        index = s.index(str(password[0]))
        if str(password[1]) in s[index + 1:]:
            index2 = index + 1 + s[index + 1:].index(str(password[1]))
            if str(password[2]) in s[index2 + 1:]:
                ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = 0
password = [0, 0, 0]
flag = False
for i in range(1000):
    for j in range(3):
        password[j] = i // (10 ** j) % 10
    index = 2
    for k in range(n):
        if password[index] == int(s[k]):
            index -= 1
        if index == -1:
            ans += 1
            break
print(ans)

Fixed submission:
n = int(input())
s = input()
ans = 0
password = [0, 0, 0]
for i in range(1000):
    for j in range(3):
        password[2 - j] = i // (10 ** j) % 10
    if str(password[0]) in s:
        index = s.index(str(password[0]))
        if str(password[1]) in s[index + 1:]:
            index2 = index + 1 + s[index + 1:].index(str(password[1]))
            if str(password[2]) in s[index2 + 1:]:
                ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = 0
flag = False
for i in range(1000):
    a = i % 10
    b = i // 10 % 10
    c = i // 100 % 10
    for j in range(n):
        if int(s[j]) == c:
            for k in range(j + 1, n):
                if int(s[k]) == b:
                    for l in range(k + 1, n):
                        if int(s[l]) == a:
                            ans += 1
                            flag = True
                            break
                if flag:
                    break
        if flag:
            flag = False
            break
print(ans)

Fixed submission:
n = int(input())
s = input()
ans = 0
password = [0, 0, 0]
for i in range(1000):
    for j in range(3):
        password[2 - j] = i // (10 ** j) % 10
    if str(password[0]) in s:
        index = s.index(str(password[0]))
        if str(password[1]) in s[index + 1:]:
            index2 = index + 1 + s[index + 1:].index(str(password[1]))
            if str(password[2]) in s[index2 + 1:]:
                ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = 0
flag = False
for i in range(1000):
    a = i % 10
    b = i // 10 % 10
    c = i // 100 % 10
    for j in range(n):
        if int(s[j]) == c:
            for k in range(j + 1, n):
                if int(s[k]) == b:
                    for l in range(k + 1, n):
                        if int(s[l]) == a:
                            ans += 1
                            flag = True
                            break
                if flag:
                    break
        if flag:
            flag = False
            break
print(ans)

Fixed submission:
n = int(input())
s = input()
ans = 0
password = [0, 0, 0]
for i in range(1000):
    for j in range(3):
        password[2 - j] = i // (10 ** j) % 10
    if str(password[0]) in s:
        index = s.index(str(password[0]))
        if str(password[1]) in s[index + 1:]:
            index2 = index + 1 + s[index + 1:].index(str(password[1]))
            if str(password[2]) in s[index2 + 1:]:
                ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = set()
for i in range(1000):
    a = i % 10
    b = i // 10 % 10
    c = i // 100 % 10
    for j in range(n):
        if int(s[j]) == c:
            for k in range(j + 1, n):
                if int(s[k]) == b:
                    for l in range(k + 1, n):
                        if int(s[l]) == a:
                            ans.add(str(c) + str(b) + str(a))
print(len(ans))

Fixed submission:
n = int(input())
s = input()
ans = 0
password = [0, 0, 0]
for i in range(1000):
    for j in range(3):
        password[2 - j] = i // (10 ** j) % 10
    if str(password[0]) in s:
        index = s.index(str(password[0]))
        if str(password[1]) in s[index + 1:]:
            index2 = index + 1 + s[index + 1:].index(str(password[1]))
            if str(password[2]) in s[index2 + 1:]:
                ans += 1
print(ans)