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

ans=0
for x in range(1000):
  x=str(x).zfill(3)
  idx=0
  for j in range(n):
    if S[j]==x[idx]:
      idx+=1
    if idx>=3:
      ans+=1
      break
print(ans)

Fixed submission:
n=int(input())
S=input()

ans=0
for i in range(10):
  for j in range(10):
    for k in range(10):
      idxi=S.find(str(i))
      if idxi==-1:
        continue
      idxj=S.find(str(j),idxi+1)
      if idxj==-1:
        continue
      idxk=S.find(str(k),idxj+1)
      if idxk==-1:
        continue
      ans+=1
print(ans)

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

ans=0
for v in range(1000):
  v=str(v).zfill(3)
  idx,cnt=0,0
  for i in range(n):
    if S[i]==v[idx]:
      idx+=1
    else:
      cnt+=1
    if idx>=3:
      ans+=1
      break
print(ans)

Fixed submission:
n=int(input())
S=input()

ans=0
for i in range(10):
  for j in range(10):
    for k in range(10):
      idxi=S.find(str(i))
      if idxi==-1:
        continue
      idxj=S.find(str(j),idxi+1)
      if idxj==-1:
        continue
      idxk=S.find(str(k),idxj+1)
      if idxk==-1:
        continue
      ans+=1
print(ans)

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

ans=0
for v in range(1000):
  v=str(v).zfill(3)
  idx,cnt=0,0
  for i in range(n):
    if S[i]==v[idx]:
      idx+=1
    else:
      cnt+=1
    if cnt>n-3 or idx>=3:
      break
  if idx>=3:
    ans+=1
print(ans)

Fixed submission:
n=int(input())
S=input()

ans=0
for i in range(10):
  for j in range(10):
    for k in range(10):
      idxi=S.find(str(i))
      if idxi==-1:
        continue
      idxj=S.find(str(j),idxi+1)
      if idxj==-1:
        continue
      idxk=S.find(str(k),idxj+1)
      if idxk==-1:
        continue
      ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n=int(input())
S=list(input())

number=set(itertools.combinations(S,3))
print(len(number))


Fixed submission:
n=int(input())
S=input()

ans=0
for i in range(10):
  for j in range(10):
    for k in range(10):
      idxi=S.find(str(i))
      if idxi==-1:
        continue
      idxj=S.find(str(j),idxi+1)
      if idxj==-1:
        continue
      idxk=S.find(str(k),idxj+1)
      if idxk==-1:
        continue
      ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n=int(input())
S=list(input())

number=list(itertools.combinations(S,3))
print(len(set(number)))


Fixed submission:
n=int(input())
S=input()

ans=0
for i in range(10):
  for j in range(10):
    for k in range(10):
      idxi=S.find(str(i))
      if idxi==-1:
        continue
      idxj=S.find(str(j),idxi+1)
      if idxj==-1:
        continue
      idxk=S.find(str(k),idxj+1)
      if idxk==-1:
        continue
      ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n=int(input())
S=input()

number=list(itertools.combinations(S,3))
print(len(set(number)))

Fixed submission:
n=int(input())
S=input()

ans=0
for i in range(10):
  for j in range(10):
    for k in range(10):
      idxi=S.find(str(i))
      if idxi==-1:
        continue
      idxj=S.find(str(j),idxi+1)
      if idxj==-1:
        continue
      idxk=S.find(str(k),idxj+1)
      if idxk==-1:
        continue
      ans+=1
print(ans)