Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter as cnt
n = int(input())
s = list(input())

count = cnt(s)
num_rest = []
for i in range(n):
  count[s[i]] -= 1
  rest = 0
  for value in count.values():
    if value != 0:
      rest += 1
  num_rest.append(rest)
#print(num_rest)

checked = {}
total = 0
for i in range(n-2):
  if s[i] not in checked:
    checked[s[i]] = set()
  elif len(checked[s[i]]) == 10:
    continue
  for j in range(i+1, n-1):
    if s[j] not in checked[s[i]]:
      checked[s[i]].add(s[j])
      total += num_rest[j]
print(total)

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

def search(s, c, left):
  for idx in range(left, len(s)):
    if s[idx] == c:
      return idx
  return -1

total = 0
for keta1 in range(10):
  first_keta1 = search(s, str(keta1), 0)
  if first_keta1 == -1 or first_keta1 >= n-2:
    continue
  for keta2 in range(10):
    first_keta2 = search(s, str(keta2), first_keta1 + 1)
    if first_keta2 == -1 or first_keta2 >= n-1:
      continue
    for keta3 in range(10):
      first_keta3 = search(s, str(keta3), first_keta2 + 1)
      if first_keta3 != -1:
        total += 1
print(total)

Buggy python submission (verdict: Runtime Error):
from collections import Counter as cnt
n = int(input())
s = list(input())

count = cnt(s)
num_rest = []
for i in range(n):
  count[s[i]] -= 1
  rest = 0
  for value in count.values():
    if value != 0:
      rest += 1
  num_rest.append(rest)
#print(num_rest)

checked = {}
total = 0
for i in range(n-2):
  if s[i] not in checked:
    checked(s[i]) = {}
  elif len(checked[s[i]].keys()) == 10:
    continue
  else:
    for j in range(i+1, n-1):
      if s[j] not in checked[s[i]]:
        checked[s[i]][s[j]] == True
        total += num_rest[j]
print(total)

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

def search(s, c, left):
  for idx in range(left, len(s)):
    if s[idx] == c:
      return idx
  return -1

total = 0
for keta1 in range(10):
  first_keta1 = search(s, str(keta1), 0)
  if first_keta1 == -1 or first_keta1 >= n-2:
    continue
  for keta2 in range(10):
    first_keta2 = search(s, str(keta2), first_keta1 + 1)
    if first_keta2 == -1 or first_keta2 >= n-1:
      continue
    for keta3 in range(10):
      first_keta3 = search(s, str(keta3), first_keta2 + 1)
      if first_keta3 != -1:
        total += 1
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter as cnt
n = int(input())
s = list(input())

count = cnt(s)
num_rest = []
for i in range(n):
  count[s[i]] -= 1
  rest = 0
  for value in count.values():
    if value != 0:
      rest += 1
  num_rest.append(rest)
#print(num_rest)

checked = set()
total = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    if s[i] + s[j] not in checked:
      checked.add(s[i] + s[j])
      total += num_rest[j]
print(total)

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

def search(s, c, left):
  for idx in range(left, len(s)):
    if s[idx] == c:
      return idx
  return -1

total = 0
for keta1 in range(10):
  first_keta1 = search(s, str(keta1), 0)
  if first_keta1 == -1 or first_keta1 >= n-2:
    continue
  for keta2 in range(10):
    first_keta2 = search(s, str(keta2), first_keta1 + 1)
    if first_keta2 == -1 or first_keta2 >= n-1:
      continue
    for keta3 in range(10):
      first_keta3 = search(s, str(keta3), first_keta2 + 1)
      if first_keta3 != -1:
        total += 1
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter as cnt
import copy
n = int(input())
s = input()

count = cnt(s)
num_rest = []
for i in range(n):
  count[s[i]] -= 1
  rest = 0
  for value in count.values():
    if value != 0:
      rest += 1
  num_rest.append(rest)
#print(num_rest)

checked = set()
total = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    if s[i] + s[j] not in checked:
      checked.add(s[i] + s[j])
      total += num_rest[j]
print(total)

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

def search(s, c, left):
  for idx in range(left, len(s)):
    if s[idx] == c:
      return idx
  return -1

total = 0
for keta1 in range(10):
  first_keta1 = search(s, str(keta1), 0)
  if first_keta1 == -1 or first_keta1 >= n-2:
    continue
  for keta2 in range(10):
    first_keta2 = search(s, str(keta2), first_keta1 + 1)
    if first_keta2 == -1 or first_keta2 >= n-1:
      continue
    for keta3 in range(10):
      first_keta3 = search(s, str(keta3), first_keta2 + 1)
      if first_keta3 != -1:
        total += 1
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter as cnt
import copy
n = int(input())
s = input()

count = cnt(s)
num_rest = []
for i in range(n):
  count[s[i]] -= 1
  num_rest.append(len([i for i in count.values() if i != 0]))
#print(num_rest)

checked = set()
total = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    if s[i] + s[j] not in checked:
      checked.add(s[i] + s[j])
      total += num_rest[j]
print(total)

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

def search(s, c, left):
  for idx in range(left, len(s)):
    if s[idx] == c:
      return idx
  return -1

total = 0
for keta1 in range(10):
  first_keta1 = search(s, str(keta1), 0)
  if first_keta1 == -1 or first_keta1 >= n-2:
    continue
  for keta2 in range(10):
    first_keta2 = search(s, str(keta2), first_keta1 + 1)
    if first_keta2 == -1 or first_keta2 >= n-1:
      continue
    for keta3 in range(10):
      first_keta3 = search(s, str(keta3), first_keta2 + 1)
      if first_keta3 != -1:
        total += 1
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter as cnt
import copy
n = int(input())
s = input()

count = cnt(s)
num_rest = []
for i in range(n):
  dic = copy.copy(count)
  dic[s[i]] -= 1
  num_rest.append(len([i for i in dic.values() if i != 0]))
  count = dic
#print(num_rest)

checked = set()
total = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    if s[i] + s[j] not in checked:
      checked.add(s[i] + s[j])
      total += num_rest[j]
print(total)

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

def search(s, c, left):
  for idx in range(left, len(s)):
    if s[idx] == c:
      return idx
  return -1

total = 0
for keta1 in range(10):
  first_keta1 = search(s, str(keta1), 0)
  if first_keta1 == -1 or first_keta1 >= n-2:
    continue
  for keta2 in range(10):
    first_keta2 = search(s, str(keta2), first_keta1 + 1)
    if first_keta2 == -1 or first_keta2 >= n-1:
      continue
    for keta3 in range(10):
      first_keta3 = search(s, str(keta3), first_keta2 + 1)
      if first_keta3 != -1:
        total += 1
print(total)