Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = tuple(input())
ans = 0
for i in range(1000):
  if i<10:
    cnt0= 0
    cnt1 = 0
    for j in range(N):
      if 2<=cnt0 and S[j]=="%d"%i:
        ans+=1
        break
      if S[j]=="0":
        cnt0+=1
        continue
  elif 10<=i<=99:
    cnt0=0
    cnt1=0
    cnt2=0
    i = list(str(i))
    for j in range(N):
      if 1<=cnt0 and 1<=cnt1 and S[j]=="%s"%i[1]:
        ans+=1
        break
      if S[j]=="0" and cnt0!=1:
        cnt0+=1
        continue
      if 1<=cnt0 and S[j]=="%s"%i[0]:
        cnt1 +=1
        continue
  elif 100<=i:
    cnt0=0
    cnt1=0
    cnt2=0
    i = list(str(i))
    for j in range(N):
      if 1<=cnt0 and 1<=cnt1 and S[j]=="%s"%i[2]:
        ans+=1
        #print(i)
        break
      if S[j]=="%s"%i[0] and cnt0!=1:
        cnt0+=1
        continue
      if 1<=cnt0 and S[j]=="%s"%i[1]:
        cnt1 +=1
        continue
print(ans)
      
      
      


Fixed submission:
def main():
  N = int(input())
  S = tuple(input())
  ans = 0
  for i in range(1000):
    if i<10:
      cnt0= 0
      cnt1 = 0
      for j in range(N):
        if 2<=cnt0 and S[j]=="%d"%i:
          ans+=1
          break
        if S[j]=="0":
          cnt0+=1
          continue
    elif 10<=i<=99:
      cnt0=0
      cnt1=0
      cnt2=0
      i = list(str(i))
      for j in range(N):
        if 1<=cnt0 and 1<=cnt1 and S[j]=="%s"%i[1]:
          ans+=1
          break
        if S[j]=="0" and cnt0!=1:
          cnt0+=1
          continue
        if 1<=cnt0 and S[j]=="%s"%i[0]:
          cnt1 +=1
          continue
    elif 100<=i:
      cnt0=0
      cnt1=0
      cnt2=0
      i = list(str(i))
      for j in range(N):
        if 1<=cnt0 and 1<=cnt1 and S[j]=="%s"%i[2]:
          ans+=1
          #print(i)
          break
        if S[j]=="%s"%i[0] and cnt0!=1:
          cnt0+=1
          continue
        if 1<=cnt0 and S[j]=="%s"%i[1]:
          cnt1 +=1
          continue
  print(ans)
main()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
ans = 0
for i in range(1000):
  if i<10:
    cnt0= 0
    cnt1 = 0
    for j in range(N):
      if S[j]=="%d"%i and 2<=cnt0 :
        ans+=1
        break
      if S[j]=="0":
        cnt0+=1
        continue
  elif 10<=i<=99:
    cnt0=0
    cnt1=0
    cnt2=0
    i = list(str(i))
    for j in range(N):
      if S[j]=="%s"%i[1] and 1<=cnt0 and 1<=cnt1:
        ans+=1
        break
      if S[j]=="0" and cnt0!=1:
        cnt0+=1
        continue
      if S[j]=="%s"%i[0] and 1<=cnt0:
        cnt1 +=1
        continue
  elif 100<=i:
    cnt0=0
    cnt1=0
    cnt2=0
    i = list(str(i))
    for j in range(N):
      if S[j]=="%s"%i[2] and 1<=cnt0 and 1<=cnt1:
        ans+=1
        #print(i)
        break
      if S[j]=="%s"%i[0] and cnt0!=1:
        cnt0+=1
        continue
      if S[j]=="%s"%i[1] and 1<=cnt0:
        cnt1 +=1
        continue
print(ans)
      
      
      


Fixed submission:
def main():
  N = int(input())
  S = tuple(input())
  ans = 0
  for i in range(1000):
    if i<10:
      cnt0= 0
      cnt1 = 0
      for j in range(N):
        if 2<=cnt0 and S[j]=="%d"%i:
          ans+=1
          break
        if S[j]=="0":
          cnt0+=1
          continue
    elif 10<=i<=99:
      cnt0=0
      cnt1=0
      cnt2=0
      i = list(str(i))
      for j in range(N):
        if 1<=cnt0 and 1<=cnt1 and S[j]=="%s"%i[1]:
          ans+=1
          break
        if S[j]=="0" and cnt0!=1:
          cnt0+=1
          continue
        if 1<=cnt0 and S[j]=="%s"%i[0]:
          cnt1 +=1
          continue
    elif 100<=i:
      cnt0=0
      cnt1=0
      cnt2=0
      i = list(str(i))
      for j in range(N):
        if 1<=cnt0 and 1<=cnt1 and S[j]=="%s"%i[2]:
          ans+=1
          #print(i)
          break
        if S[j]=="%s"%i[0] and cnt0!=1:
          cnt0+=1
          continue
        if 1<=cnt0 and S[j]=="%s"%i[1]:
          cnt1 +=1
          continue
  print(ans)
main()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
ans = 0
for i in range(1000):
  if i<10:
    cnt0= 0
    cnt1 = 0
    for j in range(N):
      if 2<=cnt0 and S[j]=="%d"%i:
        ans+=1
        break
      if S[j]=="0":
        cnt0+=1
        continue
  elif 10<=i<=99:
    cnt0=0
    cnt1=0
    cnt2=0
    i = list(str(i))
    for j in range(N):
      if 1<=cnt0 and 1<=cnt1 and S[j]=="%s"%i[1]:
        ans+=1
        break
      if S[j]=="0" and cnt0!=1:
        cnt0+=1
        continue
      if 1<=cnt0 and S[j]=="%s"%i[0]:
        cnt1 +=1
        continue
  elif 100<=i:
    cnt0=0
    cnt1=0
    cnt2=0
    i = list(str(i))
    for j in range(N):
      if 1<=cnt0 and 1<=cnt1 and S[j]=="%s"%i[2]:
        ans+=1
        #print(i)
        break
      if S[j]=="%s"%i[0] and cnt0!=1:
        cnt0+=1
        continue
      if 1<=cnt0 and S[j]=="%s"%i[1]:
        cnt1 +=1
        continue
print(ans)
      
      
      


Fixed submission:
def main():
  N = int(input())
  S = tuple(input())
  ans = 0
  for i in range(1000):
    if i<10:
      cnt0= 0
      cnt1 = 0
      for j in range(N):
        if 2<=cnt0 and S[j]=="%d"%i:
          ans+=1
          break
        if S[j]=="0":
          cnt0+=1
          continue
    elif 10<=i<=99:
      cnt0=0
      cnt1=0
      cnt2=0
      i = list(str(i))
      for j in range(N):
        if 1<=cnt0 and 1<=cnt1 and S[j]=="%s"%i[1]:
          ans+=1
          break
        if S[j]=="0" and cnt0!=1:
          cnt0+=1
          continue
        if 1<=cnt0 and S[j]=="%s"%i[0]:
          cnt1 +=1
          continue
    elif 100<=i:
      cnt0=0
      cnt1=0
      cnt2=0
      i = list(str(i))
      for j in range(N):
        if 1<=cnt0 and 1<=cnt1 and S[j]=="%s"%i[2]:
          ans+=1
          #print(i)
          break
        if S[j]=="%s"%i[0] and cnt0!=1:
          cnt0+=1
          continue
        if 1<=cnt0 and S[j]=="%s"%i[1]:
          cnt1 +=1
          continue
  print(ans)
main()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
ans = []
for i in range(len(S)):
  for j in range(i+1,len(S)):
    for k in range(j+1,len(S)):
      ans.append(S[i]+S[j]+S[k])
print(len(list(set(ans))))
      


Fixed submission:
def main():
  N = int(input())
  S = tuple(input())
  ans = 0
  for i in range(1000):
    if i<10:
      cnt0= 0
      cnt1 = 0
      for j in range(N):
        if 2<=cnt0 and S[j]=="%d"%i:
          ans+=1
          break
        if S[j]=="0":
          cnt0+=1
          continue
    elif 10<=i<=99:
      cnt0=0
      cnt1=0
      cnt2=0
      i = list(str(i))
      for j in range(N):
        if 1<=cnt0 and 1<=cnt1 and S[j]=="%s"%i[1]:
          ans+=1
          break
        if S[j]=="0" and cnt0!=1:
          cnt0+=1
          continue
        if 1<=cnt0 and S[j]=="%s"%i[0]:
          cnt1 +=1
          continue
    elif 100<=i:
      cnt0=0
      cnt1=0
      cnt2=0
      i = list(str(i))
      for j in range(N):
        if 1<=cnt0 and 1<=cnt1 and S[j]=="%s"%i[2]:
          ans+=1
          #print(i)
          break
        if S[j]=="%s"%i[0] and cnt0!=1:
          cnt0+=1
          continue
        if 1<=cnt0 and S[j]=="%s"%i[1]:
          cnt1 +=1
          continue
  print(ans)
main()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
ans = []
for i in range(len(S)):
  for j in range(i+1,len(S)):
    for k in range(j+1,len(S)):
      if not S[i]+S[j]+S[k] in set(ans):
      	ans.append(S[i]+S[j]+S[k])
print(len(ans))
      
      


Fixed submission:
def main():
  N = int(input())
  S = tuple(input())
  ans = 0
  for i in range(1000):
    if i<10:
      cnt0= 0
      cnt1 = 0
      for j in range(N):
        if 2<=cnt0 and S[j]=="%d"%i:
          ans+=1
          break
        if S[j]=="0":
          cnt0+=1
          continue
    elif 10<=i<=99:
      cnt0=0
      cnt1=0
      cnt2=0
      i = list(str(i))
      for j in range(N):
        if 1<=cnt0 and 1<=cnt1 and S[j]=="%s"%i[1]:
          ans+=1
          break
        if S[j]=="0" and cnt0!=1:
          cnt0+=1
          continue
        if 1<=cnt0 and S[j]=="%s"%i[0]:
          cnt1 +=1
          continue
    elif 100<=i:
      cnt0=0
      cnt1=0
      cnt2=0
      i = list(str(i))
      for j in range(N):
        if 1<=cnt0 and 1<=cnt1 and S[j]=="%s"%i[2]:
          ans+=1
          #print(i)
          break
        if S[j]=="%s"%i[0] and cnt0!=1:
          cnt0+=1
          continue
        if 1<=cnt0 and S[j]=="%s"%i[1]:
          cnt1 +=1
          continue
  print(ans)
main()