Buggy python submission (verdict: Time Limit Exceeded):
def check(string):
    for j in range(n - 2):
        if s[j] != temp[0]:continue 
        for k in range(j + 1, n - 1):
            if s[k] != temp[1]:continue 
            for l in range(k + 1, n):
                if s[l] == temp[2]:return 1
            
            return 0
    return 0
n = int(input())
s = input()
res = 0

for i in range(1000):
    temp = '00' + str(i)
    temp = temp[-3:]
    res += check(temp)
print(res)
    

Fixed submission:
n=int(input())
s=input()
#000~999からいくつ作れるか試す
num='0123456789'
ans=0
#候補の暗証番号を生成する
for first_num in num:
    for second_num in num:
        for third_num in num:
            temp_lock=first_num+second_num+third_num
            temp_cnt=0
            for i in s:
                if temp_cnt==0 and i==temp_lock[0]:
                    temp_cnt=1
                elif temp_cnt==1 and i==temp_lock[1]:
                    temp_cnt=2
                elif temp_cnt==2 and i==temp_lock[2]:
                    ans+=1
                    break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def check(string):
    for j in range(n - 2):
        if s[j] != temp[0]:continue 
        for k in range(j + 1, n - 1):
            if s[k] != temp[1]:continue 
            for l in range(k + 1, n):
                if s[l] == temp[2]:return 1
            
            return 0
    return 0
n = int(input())
s = input()
res = 0

for i in range(1000):
    temp = '00' + str(i)
    temp = temp[-3:]
    res += check(temp)
print(res)
    

Fixed submission:
n=int(input())
s=input()
#000~999からいくつ作れるか試す
num='0123456789'
ans=0
#候補の暗証番号を生成する
for first_num in num:
    for second_num in num:
        for third_num in num:
            temp_lock=first_num+second_num+third_num
            temp_cnt=0
            for i in s:
                if temp_cnt==0 and i==temp_lock[0]:
                    temp_cnt=1
                elif temp_cnt==1 and i==temp_lock[1]:
                    temp_cnt=2
                elif temp_cnt==2 and i==temp_lock[2]:
                    ans+=1
                    break
print(ans)

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

cnt=0
flag1=[]
ans=[]
for i in range(n-2):
    flag2=[]
    if s[i] in flag1:continue
    flag1.append(s[i])
    for j in range(i+1,n-1):
        if s[i]!=s[j] and s[j] in flag2:continue
        flag2.append(s[j])
        for k in range(j+1,n):
            ans.append(s[i]+s[j]+s[k])
#print(ans,flag1,flag2)
print(len(set(ans)))

Fixed submission:
n=int(input())
s=input()
#000~999からいくつ作れるか試す
num='0123456789'
ans=0
#候補の暗証番号を生成する
for first_num in num:
    for second_num in num:
        for third_num in num:
            temp_lock=first_num+second_num+third_num
            temp_cnt=0
            for i in s:
                if temp_cnt==0 and i==temp_lock[0]:
                    temp_cnt=1
                elif temp_cnt==1 and i==temp_lock[1]:
                    temp_cnt=2
                elif temp_cnt==2 and i==temp_lock[2]:
                    ans+=1
                    break
print(ans)

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

cnt=0
flag1=[]
ans=[]
for i in range(n-2):
    flag2=[]
    if s[i] in flag1:continue
    flag1.append(s[i])
    for j in range(i+1,n-1):
        if s[i]!=s[j] and s[j] in flag2:continue
        flag2.append(s[j])
        for k in range(j+1,n):
            ans.append(s[i]+s[j]+s[k])
#print(ans,flag1,flag2)
print(len(set(ans)))

Fixed submission:
n=int(input())
s=input()
#000~999からいくつ作れるか試す
num='0123456789'
ans=0
#候補の暗証番号を生成する
for first_num in num:
    for second_num in num:
        for third_num in num:
            temp_lock=first_num+second_num+third_num
            temp_cnt=0
            for i in s:
                if temp_cnt==0 and i==temp_lock[0]:
                    temp_cnt=1
                elif temp_cnt==1 and i==temp_lock[1]:
                    temp_cnt=2
                elif temp_cnt==2 and i==temp_lock[2]:
                    ans+=1
                    break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
#000~999からいくつ作れるか試す
num='0123456789'
ans=0
#候補の暗証番号を生成する
for first_num in num:
    for second_num in num:
        for third_num in num:
            temp_lock=first_num+second_num+third_num
            temp_cnt=0
            for i in s:
                if temp_cnt==0 and i==temp_lock[0]:
                    temp_cnt=1
                elif temp_cnt==1 and i==temp_lock[1]:
                    temp_cnt=2
                elif temp_cnt==2 and i==temp_lock[2]:
                    ans+=1
                    break
print(ans)

Fixed submission:
n=int(input())
s=input()
#000~999からいくつ作れるか試す
num='0123456789'
ans=0
#候補の暗証番号を生成する
for first_num in num:
    for second_num in num:
        for third_num in num:
            temp_lock=first_num+second_num+third_num
            temp_cnt=0
            for i in s:
                if temp_cnt==0 and i==temp_lock[0]:
                    temp_cnt=1
                elif temp_cnt==1 and i==temp_lock[1]:
                    temp_cnt=2
                elif temp_cnt==2 and i==temp_lock[2]:
                    ans+=1
                    break
print(ans)