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

S = set()
cnt = 0
for i in range(1000):
    i = str(i).zfill(3)
    num = 0
    for j in range(n):
        if L[j] == i[0] and num == 0:
            num =1
        elif L[j] == i[1] and num == 1:
            num =2
        elif L[j] == i[2] and num == 2:
            S.add(i)
            
print(len(S))

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

S = set()
cnt = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            dig = 1
            t = str(i)+str(j)+str(k)

            for r in range(n):
                if dig == 1 and t[0] == s[r]:
                    dig +=1

                elif dig == 2 and t[1] == s[r]:
                    dig +=1
                    
                elif dig == 3 and t[2] == s[r]:
                    S.add(t)

print(len(S))

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

S = set()
cnt = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            dig = 1
            t = str(i)+str(j)+str(k)

            for r in range(n):
                if dig == 1 and t[0] == s[r]:
                    dig +=1

                elif dig == 2 and t[1] == s[r]:
                    dig +=1
                    
                elif dig == 3 and t[2] == s[r]:
                    S.add(t)

print(len(S))

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

S = set()
cnt = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            dig = 1
            t = str(i)+str(j)+str(k)

            for r in range(n):
                if dig == 1 and t[0] == s[r]:
                    dig +=1

                elif dig == 2 and t[1] == s[r]:
                    dig +=1
                    
                elif dig == 3 and t[2] == s[r]:
                    S.add(t)

print(len(S))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = (list(input()))
cnt = 0
#print(s)
S = set()
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            S.add(s[i]+s[j]+s[k])
            #print(s[i]+s[j]+s[k],i,j,k)
print(len(S))

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

S = set()
cnt = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            dig = 1
            t = str(i)+str(j)+str(k)

            for r in range(n):
                if dig == 1 and t[0] == s[r]:
                    dig +=1

                elif dig == 2 and t[1] == s[r]:
                    dig +=1
                    
                elif dig == 3 and t[2] == s[r]:
                    S.add(t)

print(len(S))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = (list(input()))
cnt = 0
#print(s)
S = set()
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            S.add(s[i]+s[j]+s[k])
            #print(s[i]+s[j]+s[k],i,j,k)
print(len(S))

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

S = set()
cnt = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            dig = 1
            t = str(i)+str(j)+str(k)

            for r in range(n):
                if dig == 1 and t[0] == s[r]:
                    dig +=1

                elif dig == 2 and t[1] == s[r]:
                    dig +=1
                    
                elif dig == 3 and t[2] == s[r]:
                    S.add(t)

print(len(S))