Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N_keta = int(input())
    S = input()

    total = 0

    for n in range(0, 1000):
        FLAG = False
        n_str = str(n)
        
        while (len(n_str) < 3):
            n_str = '0' + n_str
        
        pos = 0
        cnt = 0
        
        for i in range(3):
            number = int(n_str[i])
            
            while (pos < N_keta):
                num = int(S[pos])
                if (num == number):
                    cnt += 1
                    pos += 1
                    break
                else:
                    pos += 1
            
            if (cnt == 3):
                FLAG = True
                break
        
        if (FLAG):
            total += 1

    print(total)


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N_keta = int(input())
    S = input()

    total = 0

    for n in range(0, 1000):
        FLAG = True
        n_str = "{:03}".format(n)
        pos = 0
        
        for i in n_str:
            numberS = S[pos:]
            if (i not in numberS):
                FLAG = False
                break
            else:
                pos += numberS.index(i) + 1
        
        if (FLAG):
            total += 1

    print(total)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    N_keta = int(input())
    S = input()

    total = 0

    for n in range(0, 1000):
        FLAG = False
        n_str = str(n)
        
        while (len(n_str) < 3):
            n_str = '0' + n_str
        
        pos = 0
        cnt = 0
        
        for i in range(3):
            number = int(n_str[i])
            
            while (pos < N_keta):
                num = int(S[pos])
                if (num == number):
                    cnt += 1
                    pos += 1
                    break
                else:
                    pos += 1
            
            if (cnt == 3):
                FLAG = True
                break
        
        if (FLAG):
            total += 1

    print(total)


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N_keta = int(input())
    S = input()

    total = 0

    for n in range(0, 1000):
        FLAG = True
        n_str = "{:03}".format(n)
        pos = 0
        
        for i in n_str:
            numberS = S[pos:]
            if (i not in numberS):
                FLAG = False
                break
            else:
                pos += numberS.index(i) + 1
        
        if (FLAG):
            total += 1

    print(total)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N_keta = int(input())
    S = input()

    total = 0

    for n in range(0, 1000):
        FLAG = False
        n_str = str(n)
        
        while (len(n_str) < 3):
            n_str = '0' + n_str
        
        pos = 0
        cnt = 0
        
        for i in range(3):
            number = int(n_str[i])
            
            while (pos < N_keta):
                num = int(S[pos])
                if (num == number):
                    cnt += 1
                    pos += 1
                    break
                else:
                    pos += 1
            
            if (cnt == 3):
                FLAG = True
                break
        
        if (FLAG):
            total += 1

    print(total)


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N_keta = int(input())
    S = input()

    total = 0

    for n in range(0, 1000):
        FLAG = True
        n_str = "{:03}".format(n)
        pos = 0
        
        for i in n_str:
            numberS = S[pos:]
            if (i not in numberS):
                FLAG = False
                break
            else:
                pos += numberS.index(i) + 1
        
        if (FLAG):
            total += 1

    print(total)


if __name__ == '__main__':
    main()