Buggy python submission (verdict: Time Limit Exceeded):
#dp[i]:i+1桁目-n桁目で1桁の数字は/2桁の数字は/何通りあるか
n = int(input())
s = input()+"a"
ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            t1 = n-1
            u1 = n-1
            v1 = n-1
            for t in range(n):
                if i == int(s[t]):
                    t1 = t
                    break
            for u in range(t1+1,n):
                if j == int(s[u]):
                    u1 = u
                    break
            for v in range(u1+1,n):
                if k == int(s[v]):
                    v1 = v
                    break
            if int(s[t1]) == i and int(s[u1]) == j and int(s[v1]) == k and t1<u1 and u1<v1:
                #print(i,j,k,t1,u1,v1)
                ans += 1
print(ans) 
            
    

Fixed submission:
#dp[i]:i+1桁目-n桁目で1桁の数字は/2桁の数字は/何通りあるか
n = int(input())
s = input()
ans = 0
for i in range(10):
    for j in range(10):
        t1 = n-1
        u1 = n-1
        for t in range(n):
            if i == int(s[t]):
                t1 = t
                break
        for u in range(t1+1,n):
            if j == int(s[u]):
                u1 = u
                break
        if int(s[t1]) == i and int(s[u1]) == j and t1<u1:
            #print(i,j,k,t1,u1,v1)
            ans += len(set(s[u1+1:]))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
###
n = int(input())
s = input()
ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            t1 = n-1
            u1 = n-1
            v1 = n-1
            for t in range(n):
                if i == int(s[t]):
                    t1 = t
                    break
            for u in range(t1+1,n):
                if j == int(s[u]):
                    u1 = u
                    break
            for v in range(u1+1,n):
                if k == int(s[v]):
                    v1 = v
                    break
            if int(s[t1]) == i and int(s[u1]) == j and int(s[v1]) == k and t1<u1 and u1<v1:
                #print(i,j,k,t1,u1,v1)
                ans += 1
print(ans) 
            
    

Fixed submission:
#dp[i]:i+1桁目-n桁目で1桁の数字は/2桁の数字は/何通りあるか
n = int(input())
s = input()
ans = 0
for i in range(10):
    for j in range(10):
        t1 = n-1
        u1 = n-1
        for t in range(n):
            if i == int(s[t]):
                t1 = t
                break
        for u in range(t1+1,n):
            if j == int(s[u]):
                u1 = u
                break
        if int(s[t1]) == i and int(s[u1]) == j and t1<u1:
            #print(i,j,k,t1,u1,v1)
            ans += len(set(s[u1+1:]))
print(ans)

Buggy python submission (verdict: Runtime Error):
#dp[i]:i+1桁目-n桁目で1桁の数字は/2桁の数字は/何通りあるか
n = int(input())
s = input()
ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            for t in range(n):
                if i == int(s[t]):
                    break
            for u in range(t+1,n):
                if j == int(s[u]):
                    break
            for v in range(u+1,n):
                if k == int(s[v]):
                    break
            if int(s[t]) == i and int(s[u]) == j and int(s[v]) == k:
                ans += 1
print(ans) 
            
    

Fixed submission:
#dp[i]:i+1桁目-n桁目で1桁の数字は/2桁の数字は/何通りあるか
n = int(input())
s = input()
ans = 0
for i in range(10):
    for j in range(10):
        t1 = n-1
        u1 = n-1
        for t in range(n):
            if i == int(s[t]):
                t1 = t
                break
        for u in range(t1+1,n):
            if j == int(s[u]):
                u1 = u
                break
        if int(s[t1]) == i and int(s[u1]) == j and t1<u1:
            #print(i,j,k,t1,u1,v1)
            ans += len(set(s[u1+1:]))
print(ans)