Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    s = input()
    x = set()

    table = [[0 for _ in range(10)] for _ in range(10)]

    for i in range(n)[:-2]:
        for j in range(n)[i + 1:-1]:
            s_i, s_j = int(s[i]), int(s[j])
            if table[s_i][s_j] == 10:
                continue
            for k in range(n)[j + 1:]:
                item = s[i] + s[j] + s[k]
                if item not in x:
                    x.add(item)
                    table[s_i][s_j] += 1

    print(len(x))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    s = input()

    c = 0
    l1 = set()
    for i in range(n)[:-2]:
        if s[i] in l1:
            continue
        l1.add(s[i])
        l2 = set()
        for j in range(n)[i + 1:-1]:
            if s[j] in l2:
                continue
            l2.add(s[j])
            c += len(set(list(s[j + 1:])))

    print(c)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    s = input()
    x = set()

    for i in range(n)[:-2]:
        for j in range(n)[i + 1:-1]:
            for k in range(n)[j + 1:]:
                item = s[i] + s[j] + s[k]
                if item not in x:
                    x.add(item)

    print(len(x))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    s = input()

    c = 0
    l1 = set()
    for i in range(n)[:-2]:
        if s[i] in l1:
            continue
        l1.add(s[i])
        l2 = set()
        for j in range(n)[i + 1:-1]:
            if s[j] in l2:
                continue
            l2.add(s[j])
            c += len(set(list(s[j + 1:])))

    print(c)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    s = input()
    x = set()

    for i in range(n)[:-2]:
        for j in range(n)[i + 1:]:
            for k in range(n)[j + 1:]:
                item = s[i] + s[j] + s[k]
                if item not in x:
                    x.add(item)

    print(len(x))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    s = input()

    c = 0
    l1 = set()
    for i in range(n)[:-2]:
        if s[i] in l1:
            continue
        l1.add(s[i])
        l2 = set()
        for j in range(n)[i + 1:-1]:
            if s[j] in l2:
                continue
            l2.add(s[j])
            c += len(set(list(s[j + 1:])))

    print(c)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    s = input()
    ls = []

    for i in range(n)[:-2]:
        for j in range(n)[i + 1:]:
            for k in range(n)[j + 1:]:
                ls.append(s[i] + s[j] + s[k])

    print(len(set(ls)))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    s = input()

    c = 0
    l1 = set()
    for i in range(n)[:-2]:
        if s[i] in l1:
            continue
        l1.add(s[i])
        l2 = set()
        for j in range(n)[i + 1:-1]:
            if s[j] in l2:
                continue
            l2.add(s[j])
            c += len(set(list(s[j + 1:])))

    print(c)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    s = input()
    ls = []

    for i in range(n)[:-2]:
        for j in range(n)[i + 1:]:
            for k in range(n)[j + 1:]:
                ls.append(s[i] + s[j] + s[k])

    print(len(set(ls)))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    s = input()

    c = 0
    l1 = set()
    for i in range(n)[:-2]:
        if s[i] in l1:
            continue
        l1.add(s[i])
        l2 = set()
        for j in range(n)[i + 1:-1]:
            if s[j] in l2:
                continue
            l2.add(s[j])
            c += len(set(list(s[j + 1:])))

    print(c)


if __name__ == '__main__':
    main()