Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
 
cnt = [0]*11
i = 0
T = ''
for s in S:
  cnt[int(s)]+=1
  if min(cnt)<=3:
    T += s
#print(T)
ans = 0
P = []
for a in range(10):
  A = str(a)
  k = 0
  ind1 = -1
  while k < len(T)-2:
    t = T[k]
    if A == t:
      ind1 = k
      break
    k += 1
  if ind1 == -1:
    continue
  for b in range(10):
    B = str(b)
    l = ind1+1
    ind2 = -1
    while l < len(T)-1:
      t = T[l]
      if B == t:
        ind2 = l
        break
      l += 1
    #print(a,b,ind1,ind2)
    if ind2 == -1:
      continue
    for c in range(10):
      C = str(c)
      m = ind2+1
      while m < len(T):
        t = T[m]
        if C == t:
          ans += 1
          break
        m += 1
print(ans)
 
#print(*ans, sep='/n')
N = int(input())
S = input()

cnt = [0]*11
i = 0
T = ''
for s in S:
  cnt[int(s)]+=1
  if min(cnt)<=3:
    T += s
#print(T)
ans = 0
P = []
for a in range(10):
  A = str(a)
  k = 0
  ind1 = -1
  while k < len(T)-2:
    t = T[k]
    if A == t:
      ind1 = k
      break
    k += 1
  if ind1 == -1:
    continue
  for b in range(10):
    B = str(b)
    l = ind1+1
    ind2 = -1
    while l < len(T)-1:
      t = T[l]
      if B == t:
        ind2 = l
        break
      l += 1
    #print(a,b,ind1,ind2)
    if ind2 == -1:
      continue
    for c in range(10):
      C = str(c)
      m = ind2+1
      while m < len(T):
        t = T[m]
        if C == t:
          ans += 1
          break
        m += 1
print(ans)

#print(*ans, sep='/n')

Fixed submission:
n=int(input())
s=input()
ans=0
 
for i in range(10):
    for j in range(10):
        for k in range(10):
            x=s.find(str(i))
            if x!=-1:
                y=s.find(str(j),x+1)
                if y!=-1:
                    z=s.find(str(k),y+1)
                    if z!=-1:
                        ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

cnt = [0]*11
i = 0
T = ''
for s in S:
  cnt[int(s)]+=1
  if min(cnt)<=3:
    T += s
#print(T)
ans = 0
P = []
for a in range(10):
  A = str(a)
  k = 0
  ind1 = -1
  while k < len(T)-2:
    t = T[k]
    if A == t:
      ind1 = k
      break
    k += 1
  if ind1 == -1:
    continue
  for b in range(10):
    B = str(b)
    l = ind1+1
    ind2 = -1
    while l < len(T)-1:
      t = T[l]
      if B == t:
        ind2 = l
        break
      l += 1
    #print(a,b,ind1,ind2)
    if ind2 == -1:
      continue
    for c in range(10):
      C = str(c)
      m = ind2+1
      while m < len(T):
        t = T[m]
        if C == t:
          ans += 1
          break
        m += 1
print(ans)

#print(*ans, sep='/n')

Fixed submission:
n=int(input())
s=input()
ans=0
 
for i in range(10):
    for j in range(10):
        for k in range(10):
            x=s.find(str(i))
            if x!=-1:
                y=s.find(str(j),x+1)
                if y!=-1:
                    z=s.find(str(k),y+1)
                    if z!=-1:
                        ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
ans = 0
P = []
for a in range(10):
  A = str(a)
  k = 0
  ind1 = -1
  while k < len(S)-2:
    s = S[k]
    if A == s:
      ind1 = k
      break
    k += 1
  if ind1 == -1:
    continue
  for b in range(10):
    B = str(b)
    l = ind1+1
    ind2 = -1
    while l < len(S)-1:
      s = S[l]
      if B == s:
        ind2 = l
        break
      l += 1
    #print(a,b,ind1,ind2)
    if ind2 == -1:
      continue
    for c in range(10):
      C = str(c)
      m = ind2+1
      while m < len(S):
        s = S[m]
        if C == s:
          ans += 1
          break
        m += 1
print(ans)

#print(*ans, sep='/n')

Fixed submission:
n=int(input())
s=input()
ans=0
 
for i in range(10):
    for j in range(10):
        for k in range(10):
            x=s.find(str(i))
            if x!=-1:
                y=s.find(str(j),x+1)
                if y!=-1:
                    z=s.find(str(k),y+1)
                    if z!=-1:
                        ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
ans = 0
P = []
for a in range(10):
  for b in range(10):
    #if a == 1:
      #print(P, ans)
    for c in range(10):
      P = []
      P.append(str(a))
      P.append(str(b))
      P.append(str(c))
      j = 0
      k = 0
      while j < len(P) and k < len(S):
        p = P[j]
        s = S[k]
        if p == s:
          j += 1
        k += 1
      if j == len(P):
        ans += 1
print(ans)

#print(*ans, sep='/n')

Fixed submission:
n=int(input())
s=input()
ans=0
 
for i in range(10):
    for j in range(10):
        for k in range(10):
            x=s.find(str(i))
            if x!=-1:
                y=s.find(str(j),x+1)
                if y!=-1:
                    z=s.find(str(k),y+1)
                    if z!=-1:
                        ans+=1
print(ans)