Buggy python submission (verdict: Time Limit Exceeded):
def main():

    n = int(input())
    S = input() + 'eeee'

    cnt = 0
    for i in range(10):
        for j in range(10):
            for k in range(10):
                # tmp = str(i)+str(j)+str(k)
                m = 0
                while S[m] != str(i):
                    m += 1
                    if m >= n:
                        break
                m += 1
                while S[m] != str(j):
                    m += 1
                    if m >= n:
                        break
                m += 1
                while S[m] != str(k):
                    m += 1
                    if m >= n:
                        break
                if m < n:
                    cnt += 1

    print(cnt)


if __name__ == "__main__":
    main()

Fixed submission:
n = int(input())
S = input()
l = len(S)

S += 'eeee'

cnt = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            # tmp = str(i)+str(j)+str(k)
            m = 0
            while S[m] != str(i):
                m += 1
                if m >= l:
                    break
            m += 1
            while S[m] != str(j):
                m += 1
                if m >= l:
                    break
            m += 1
            while S[m] != str(k):
                m += 1
                if m >= l:
                    break
            if m < l:
                cnt += 1

print(cnt)

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

ans = set()
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            ans.add(100*int(S[i])+10*int(S[j])+int(S[k]))

print(len(ans))

Fixed submission:
n = int(input())
S = input()
l = len(S)

S += 'eeee'

cnt = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            # tmp = str(i)+str(j)+str(k)
            m = 0
            while S[m] != str(i):
                m += 1
                if m >= l:
                    break
            m += 1
            while S[m] != str(j):
                m += 1
                if m >= l:
                    break
            m += 1
            while S[m] != str(k):
                m += 1
                if m >= l:
                    break
            if m < l:
                cnt += 1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = input()
l = len(S)

S += 'eeee'

cnt = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            # tmp = str(i)+str(j)+str(k)
            m = 0
            while S[m] != str(i):
                m += 1
                if m >= l:
                    break
            m += 1
            while S[m] != str(j):
                m += 1
                if m >= l:
                    break
            m += 1
            while S[m] != str(k):
                m += 1
                if m >= l:
                    break
            if m < l:
                cnt += 1

print(cnt)

Fixed submission:
n = int(input())
S = input()
l = len(S)

S += 'eeee'

cnt = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            # tmp = str(i)+str(j)+str(k)
            m = 0
            while S[m] != str(i):
                m += 1
                if m >= l:
                    break
            m += 1
            while S[m] != str(j):
                m += 1
                if m >= l:
                    break
            m += 1
            while S[m] != str(k):
                m += 1
                if m >= l:
                    break
            if m < l:
                cnt += 1

print(cnt)