Buggy python submission (verdict: Time Limit Exceeded):
def strKey(key):
    if key == 0:
        return '000'
    if 1<= key <= 9:
        return '00' + str(key)
    if 10<= key <=99:
        return '0' + str(key) 
    return str(key)

N = int(input())
s  = input().strip()

cnt = 0
for key in range(1000):
    key = strKey(key)    #; print(key)
    isFlag = False
    for i0 in range(N-2):
        if isFlag == True:
            break
        if s[i0] == key[0]:
            for i1 in range(i0+1, N-1):
                if isFlag == True:
                    break
                if s[i1] == key[1]:
                    for i2 in range(i1+1, N):
                        if s[i2] == key[2]:
                            cnt += 1     #; print(i0, i1, i2, key)
                            isFlag = True
                            break
                        
print(cnt)            

Fixed submission:
N = int(input())
s  = input().strip()

cnt = 0
for key in range(1000):
    key = '{:0>3}'.format(str(key))    #; print(key)
    i0 = s.find(key[0])
    if 0 <= i0 < N-2:
        i1 = s.find(key[1], i0+1)
        if 0 < i1 < N-1:
            i2 = s.find(key[2], i1+1)
            if i2 != -1:
                cnt += 1
            else:
                continue
        else:
            continue        
    else:
        continue
                                   
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
def strKey(key):
    if key == 0:
        return '000'
    if 1<= key <= 9:
        return '00' + str(key)
    if 10<= key <=99:
        return '0' + str(key) 
    return str(key)

N = int(input())
s  = input().strip()

cnt = 0
for key in range(1000):
    key = strKey(key)    #; print(key)
    isFlag = False
    for i0 in range(N-2):
        if isFlag == False and s[i0] == key[0]:
            for i1 in range(i0+1, N-1):
                if isFlag == False and s[i1] == key[1]:
                    for i2 in range(i1+1, N):
                        if s[i2] == key[2]:
                            cnt += 1     #; print(i0, i1, i2, key)
                            isFlag = True
                            break
                        
print(cnt)            

Fixed submission:
N = int(input())
s  = input().strip()

cnt = 0
for key in range(1000):
    key = '{:0>3}'.format(str(key))    #; print(key)
    i0 = s.find(key[0])
    if 0 <= i0 < N-2:
        i1 = s.find(key[1], i0+1)
        if 0 < i1 < N-1:
            i2 = s.find(key[2], i1+1)
            if i2 != -1:
                cnt += 1
            else:
                continue
        else:
            continue        
    else:
        continue
                                   
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

N = int(input())
s  = input().strip()

S = set()
for c in combinations(range(N), N-3):
    i0 = 0; x = ''
    for i in c:
        x += s[i0:i]
        i0 = i+1
    x += s[i0:]
    S.add(x)                                  
print(len(S))   #; print(S) 
    

Fixed submission:
N = int(input())
s  = input().strip()

cnt = 0
for key in range(1000):
    key = '{:0>3}'.format(str(key))    #; print(key)
    i0 = s.find(key[0])
    if 0 <= i0 < N-2:
        i1 = s.find(key[1], i0+1)
        if 0 < i1 < N-1:
            i2 = s.find(key[2], i1+1)
            if i2 != -1:
                cnt += 1
            else:
                continue
        else:
            continue        
    else:
        continue
                                   
print(cnt)

Buggy python submission (verdict: Runtime Error):
N = int(input())
s  = input().strip()

S = set()
for c in combinations(range(N), N-3):
    i0 = 0; x = ''
    for i in c:
        x += s[i0:i]
        i0 = i+1
    x += s[i0:]
    S.add(x)                                  
print(len(S))   #; print(S) 

Fixed submission:
N = int(input())
s  = input().strip()

cnt = 0
for key in range(1000):
    key = '{:0>3}'.format(str(key))    #; print(key)
    i0 = s.find(key[0])
    if 0 <= i0 < N-2:
        i1 = s.find(key[1], i0+1)
        if 0 < i1 < N-1:
            i2 = s.find(key[2], i1+1)
            if i2 != -1:
                cnt += 1
            else:
                continue
        else:
            continue        
    else:
        continue
                                   
print(cnt)