Buggy python submission (verdict: Time Limit Exceeded):
import math,time
N = int(input())
S = input()
# length = len(S)
ans = 0
t1 = time.time()
for i in range(1000):
    locknum = str(i).zfill(3)
    digit = 0
    for j in range(N):
        if digit<2 and locknum[digit] == S[j]:
            digit +=1
        elif digit==2 and locknum[digit]==S[j]:
            ans +=1
            break

    # a = S.find(locknum[0])
    # b = S.find(locknum[1],a+1)
    # c = S.find(locknum[2],b+1)
    # if a!=-1 and b!=-1 and c!=-1:
    #     # print(i)
    #     ans +=1

t2 = time.time()
# print(t2-t1)                 
print(ans)




                    



Fixed submission:
import math,time
N = int(input())
S = input()
# length = len(S)
ans = 0
t1 = time.time()
for i in range(1000):
    locknum = str(i).zfill(3)
    a = S.find(locknum[0])
    b = S.find(locknum[1],a+1)
    c = S.find(locknum[2],b+1)
    if a!=-1 and b!=-1 and c!=-1:
        # print(i)
        ans +=1

t2 = time.time()
# print(t2-t1)                 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math,time
N = int(input())
S = input()
length = len(S)
ans = 0
# t1 = time.time()
for i in range(1000):
    locknum = str(i).zfill(3)
    digit = 0
    for j in range(length):
        if S[j] == locknum[digit]:
            if digit == 2:
                ans += 1
                # print(str(i).zfill(3))
                break
            else:
                digit += 1
# t2 = time.time()
# print(t2-t1)                 
print(ans)




                    


Fixed submission:
import math,time
N = int(input())
S = input()
# length = len(S)
ans = 0
t1 = time.time()
for i in range(1000):
    locknum = str(i).zfill(3)
    a = S.find(locknum[0])
    b = S.find(locknum[1],a+1)
    c = S.find(locknum[2],b+1)
    if a!=-1 and b!=-1 and c!=-1:
        # print(i)
        ans +=1

t2 = time.time()
# print(t2-t1)                 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
N = int(input())
S = input()

ans = 0

for i in range(0,1000):
    flag = False
    locknum = str(i).zfill(3)
    digit = 0
    for j in range(len(S)):
        if S[j] == locknum[digit]:
            if digit == 2:
                ans += 1
                break
            else:
                digit += 1

                    
print(ans)




                    

Fixed submission:
import math,time
N = int(input())
S = input()
# length = len(S)
ans = 0
t1 = time.time()
for i in range(1000):
    locknum = str(i).zfill(3)
    a = S.find(locknum[0])
    b = S.find(locknum[1],a+1)
    c = S.find(locknum[2],b+1)
    if a!=-1 and b!=-1 and c!=-1:
        # print(i)
        ans +=1

t2 = time.time()
# print(t2-t1)                 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
N = int(input())
S = input()
# print(len(S))

case =[]

for i in range(10):
    # dummy1 = [i]
    dummy = [] 
    for num in range(len(S)):
        if int(S[num]) == i:
            dummy.append(num)
    case.append(dummy)

ans = 0

for i in range(0,1000):
    flag = False
    locknum = str(i).zfill(3)
    # print(locknum)
    a = int(locknum[0])
    b = int(locknum[1])
    c = int(locknum[2])
    if len(case[a])==0 or len(case[b]) == 0 or len(case[c]) == 0:
        continue 
    for p in range(len(case[a])):
        if flag == True:break
        for q in range(len(case[b])):
            if flag == True:break
            for r in range(len(case[c])):
                if flag == True:break
                if case[a][p]<case[b][q] and case[b][q]<case[c][r]:
                    # print(a,b,c,case[a][p],case[b][q],case[c][r])
                    ans += 1
                    flag = True
                    
print(ans)
# print(case)



                    

Fixed submission:
import math,time
N = int(input())
S = input()
# length = len(S)
ans = 0
t1 = time.time()
for i in range(1000):
    locknum = str(i).zfill(3)
    a = S.find(locknum[0])
    b = S.find(locknum[1],a+1)
    c = S.find(locknum[2],b+1)
    if a!=-1 and b!=-1 and c!=-1:
        # print(i)
        ans +=1

t2 = time.time()
# print(t2-t1)                 
print(ans)