Buggy python submission (verdict: Time Limit Exceeded):
import sys


def my_input(): return sys.stdin.readline().rstrip()


def main():

    N = int(input())
    S = tuple(input())

    ans = 0
    for i in range(1000):
        d1 = (i // 100) % 10
        d2 = (i // 10) % 10
        d3 = i % 10
        d1_flag = True
        d2_flag = True

        for i in range(N):

            now = int(S[i])
            if d1_flag:
                if d1 == now:
                    d1_flag = False
                continue

            if d2_flag:
                if d2 == now:
                    d2_flag = False
                continue

            if d3 == now:
                ans += 1
                break

    print(ans)


if __name__ == '__main__':

    main()


Fixed submission:
n = int(input())
s = list(input())

ans = 0


for i in range(10):
    for j in range(10):
        for k in range(10):
            flag1 = 0
            flag2 = 0
            
            for l in range(n):
                if flag1 == 0 and s[l] == str(i):
                    flag1 = 1
                    continue
                
                if flag1 == 1 and flag2 == 0 and s[l] == str(j):
                    flag2 = 1
                    continue
                
                if flag1 == 1 and flag2 == 1 and s[l] == str(k):
                    ans += 1
                    break
                
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys


def my_input(): return sys.stdin.readline().rstrip()


def main():

    N = int(my_input())
    S = my_input()

    ans = 0
    for i in range(1000):
        d1 = (i // 100) % 10
        d2 = (i // 10) % 10
        d3 = i % 10
        d1_flag = True
        d2_flag = True

        for i in range(N):

            now = int(S[i])
            if d1_flag:
                if d1 == now:
                    d1_flag = False
                continue

            if d2_flag:
                if d2 == now:
                    d2_flag = False
                continue

            if d3 == now:
                ans += 1
                break

    print(ans)


if __name__ == '__main__':

    main()


Fixed submission:
n = int(input())
s = list(input())

ans = 0


for i in range(10):
    for j in range(10):
        for k in range(10):
            flag1 = 0
            flag2 = 0
            
            for l in range(n):
                if flag1 == 0 and s[l] == str(i):
                    flag1 = 1
                    continue
                
                if flag1 == 1 and flag2 == 0 and s[l] == str(j):
                    flag2 = 1
                    continue
                
                if flag1 == 1 and flag2 == 1 and s[l] == str(k):
                    ans += 1
                    break
                
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys


def my_input(): return sys.stdin.readline().rstrip()


def main():

    N = int(my_input())
    S = my_input()

    ans = 0
    for i in range(1000):
        d1 = (i // 100) % 10
        d2 = (i // 10) % 10
        d3 = i % 10
        d1_flag = True
        d2_flag = True

        for j in S:

            now = int(j)
            if d1_flag:
                if d1 == now:
                    d1_flag = False
                continue

            if d2_flag:
                if d2 == now:
                    d2_flag = False
                continue

            if d3 == now:
                ans += 1
                break

    print(ans)


if __name__ == '__main__':

    main()


Fixed submission:
n = int(input())
s = list(input())

ans = 0


for i in range(10):
    for j in range(10):
        for k in range(10):
            flag1 = 0
            flag2 = 0
            
            for l in range(n):
                if flag1 == 0 and s[l] == str(i):
                    flag1 = 1
                    continue
                
                if flag1 == 1 and flag2 == 0 and s[l] == str(j):
                    flag2 = 1
                    continue
                
                if flag1 == 1 and flag2 == 1 and s[l] == str(k):
                    ans += 1
                    break
                
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys


def my_input(): return sys.stdin.readline().rstrip()


def main():

    N = int(my_input())
    S = my_input()

    ans = 0
    for i in range(1000):
        d1 = (i // 100) % 10
        d2 = (i // 10) % 10
        d3 = i % 10
        d1_flag = True
        d2_flag = True

        for j in S:

            now = int(j)
            if d1_flag:
                if d1 == now:
                    d1_flag = False
                continue

            if d2_flag:
                if d2 == now:
                    d2_flag = False
                continue

            if d3 == now:
                ans += 1
                break

    print(ans)


if __name__ == '__main__':

    main()


Fixed submission:
n = int(input())
s = list(input())

ans = 0


for i in range(10):
    for j in range(10):
        for k in range(10):
            flag1 = 0
            flag2 = 0
            
            for l in range(n):
                if flag1 == 0 and s[l] == str(i):
                    flag1 = 1
                    continue
                
                if flag1 == 1 and flag2 == 0 and s[l] == str(j):
                    flag2 = 1
                    continue
                
                if flag1 == 1 and flag2 == 1 and s[l] == str(k):
                    ans += 1
                    break
                
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

def main():

    N = int(input())
    S = input()

    ans = 0
    for i in range(1000):
        d1 = (i // 100) % 10
        d2 = (i // 10) % 10
        d3 = i % 10
        d1_flag = True
        d2_flag = True

        for j in S:

            now = int(j)
            if d1_flag:
                if d1 == now:
                    d1_flag = False
                continue

            if d2_flag:
                if d2 == now:
                    d2_flag = False
                continue

            if d3 == now:
                ans += 1
                break

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
n = int(input())
s = list(input())

ans = 0


for i in range(10):
    for j in range(10):
        for k in range(10):
            flag1 = 0
            flag2 = 0
            
            for l in range(n):
                if flag1 == 0 and s[l] == str(i):
                    flag1 = 1
                    continue
                
                if flag1 == 1 and flag2 == 0 and s[l] == str(j):
                    flag2 = 1
                    continue
                
                if flag1 == 1 and flag2 == 1 and s[l] == str(k):
                    ans += 1
                    break
                
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

def main():

    N = int(input())
    S = input()

    ans = 0
    for i in range(1000):
        d1 = (i // 100) % 10
        d2 = (i // 10) % 10
        d3 = i % 10
        d1_flag = False
        d2_flag = False

        for j in S:
            now = int(j)
            if not d1_flag:
                if d1 == now:
                    d1_flag = True
            elif not d2_flag:
                if d2 == now:
                    d2_flag = True
            elif d3 == now:
                ans += 1
                break

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
n = int(input())
s = list(input())

ans = 0


for i in range(10):
    for j in range(10):
        for k in range(10):
            flag1 = 0
            flag2 = 0
            
            for l in range(n):
                if flag1 == 0 and s[l] == str(i):
                    flag1 = 1
                    continue
                
                if flag1 == 1 and flag2 == 0 and s[l] == str(j):
                    flag2 = 1
                    continue
                
                if flag1 == 1 and flag2 == 1 and s[l] == str(k):
                    ans += 1
                    break
                
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# import math
# import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import sys
# import bisect
# import numpy as np
# from scipy.special import comb


def main():

    N = int(input())
    S = input()

    ans = 0
    for i in range(1000):
        d1 = (i // 100) % 10
        d2 = (i // 10) % 10
        d3 = i % 10
        d1_flag = False
        d2_flag = False

        for j in S:
            now = int(j)
            if not d1_flag:
                if d1 == now:
                    d1_flag = True
            elif not d2_flag:
                if d2 == now:
                    d2_flag = True
            elif d3 == now:
                ans += 1
                #print(d1, d2, d3)
                break

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
n = int(input())
s = list(input())

ans = 0


for i in range(10):
    for j in range(10):
        for k in range(10):
            flag1 = 0
            flag2 = 0
            
            for l in range(n):
                if flag1 == 0 and s[l] == str(i):
                    flag1 = 1
                    continue
                
                if flag1 == 1 and flag2 == 0 and s[l] == str(j):
                    flag2 = 1
                    continue
                
                if flag1 == 1 and flag2 == 1 and s[l] == str(k):
                    ans += 1
                    break
                
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# import math
# import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import sys
# import bisect
# import numpy as np
# from scipy.special import comb

N = int(input())
S = input()


def main():

    ans = 0
    for i in range(1000):
        d1 = (i // 100) % 10
        d2 = (i // 10) % 10
        d3 = i % 10
        d1_flag = False
        d2_flag = False
        d3_flag = False

        for j in range(N):
            now = int(S[j])
            if not d1_flag:
                if d1 == now:
                    d1_flag = True
            elif not d2_flag:
                if d2 == now:
                    d2_flag = True
            elif not d3_flag:
                if d3 == now:
                    ans += 1
                    #print(d1, d2, d3)
                    break

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
n = int(input())
s = list(input())

ans = 0


for i in range(10):
    for j in range(10):
        for k in range(10):
            flag1 = 0
            flag2 = 0
            
            for l in range(n):
                if flag1 == 0 and s[l] == str(i):
                    flag1 = 1
                    continue
                
                if flag1 == 1 and flag2 == 0 and s[l] == str(j):
                    flag2 = 1
                    continue
                
                if flag1 == 1 and flag2 == 1 and s[l] == str(k):
                    ans += 1
                    break
                
print(ans)