Buggy python submission (verdict: Time Limit Exceeded):
def main():
  N = int(input())
  S = list(map(int,input()))
  ans = 0
  for i in range(10):
    for j in range(10):
      for k in range(10):
        t = str(i) + str(j) + str(k)
        cur = 0
        for x in range(N):
          if t[cur] == str(S[x]):
            cur += 1
            if cur == 3:
              ans += 1
              break
  print(ans)
main()

Fixed submission:
def main():
  N = int(input())
  S = list(map(int,input()))
  ans = 0
  for i in range(10):
    for j in range(10):
      for k in range(10):
        flg = False
        flg2 = False
        for x in range(N):
          if flg2:
            break
          if not flg:
            if S[x] == i:
              flg = True
          else:
            if S[x] == j:
              flg2 = True
              if k in S[x+1:]:
                ans +=1
  print(ans)
main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
  import itertools
  N = int(input())
  S = input()
  S = list(S)
  L = set()
  for i, j, k in itertools.combinations(S,3):
    L.add(i + j + k)
  print(len(L))
main()

Fixed submission:
def main():
  N = int(input())
  S = list(map(int,input()))
  ans = 0
  for i in range(10):
    for j in range(10):
      for k in range(10):
        flg = False
        flg2 = False
        for x in range(N):
          if flg2:
            break
          if not flg:
            if S[x] == i:
              flg = True
          else:
            if S[x] == j:
              flg2 = True
              if k in S[x+1:]:
                ans +=1
  print(ans)
main()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(map(int,input()))
ans = 0
for i in range(10):
  for j in range(10):
    for k in range(10):
      flg = False
      flg2 = False
      for x in range(N):
        if flg2:
          break
        if not flg:
          if S[x] == i:
            flg = True
        else:
          if S[x] == j:
            flg2 = True
            if k in S[x+1:]:
              ans +=1
print(ans)

Fixed submission:
def main():
  N = int(input())
  S = list(map(int,input()))
  ans = 0
  for i in range(10):
    for j in range(10):
      for k in range(10):
        flg = False
        flg2 = False
        for x in range(N):
          if flg2:
            break
          if not flg:
            if S[x] == i:
              flg = True
          else:
            if S[x] == j:
              flg2 = True
              if k in S[x+1:]:
                ans +=1
  print(ans)
main()

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
S = input()
S = list(S)
L = set()
for i, j, k in itertools.combinations(S,3):
  L.add(i + j + k)
#print(L)
print(len(L))

Fixed submission:
def main():
  N = int(input())
  S = list(map(int,input()))
  ans = 0
  for i in range(10):
    for j in range(10):
      for k in range(10):
        flg = False
        flg2 = False
        for x in range(N):
          if flg2:
            break
          if not flg:
            if S[x] == i:
              flg = True
          else:
            if S[x] == j:
              flg2 = True
              if k in S[x+1:]:
                ans +=1
  print(ans)
main()