Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
s = list(input())

p = list(itertools.combinations(s, 3))
p = set(p)

print(len(p))


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

li = [[] for _ in range(10)]

for i in range(n):
    t = int(s[i])
    li[t].append(i)

a = 0
b = 0
c = 0
cnt = 0

for i in range(10):
  for j in range(10):
    for k in range(10):
      b = 0
      a = 0
      
      if len(li[i]) > 0:
        a = li[i][0]
          
        for d in li[j]:
            if d > a:
                b = d
                break
        else:
            break
        
        for e in li[k]:
            if e > b:
                cnt += 1
                break
        

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
s = list(input())

ans = 0


for i in range(10):
    for j in range(10):
        for k in range(10):
            flag1 = 0
            flag2 = 0
            
            for l in range(n):
                if flag1 == 0 and s[l] == str(i):
                    flag1 = 1
                    continue
                
                if flag1 == 1 and flag2 == 0 and s[l] == str(j):
                    flag2 = 1
                    continue
                
                if flag1 == 1 and flag2 == 1 and s[l] == str(k):
                    ans += 1
                    break
                
print(ans)


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

li = [[] for _ in range(10)]

for i in range(n):
    t = int(s[i])
    li[t].append(i)

a = 0
b = 0
c = 0
cnt = 0

for i in range(10):
  for j in range(10):
    for k in range(10):
      b = 0
      a = 0
      
      if len(li[i]) > 0:
        a = li[i][0]
          
        for d in li[j]:
            if d > a:
                b = d
                break
        else:
            break
        
        for e in li[k]:
            if e > b:
                cnt += 1
                break
        

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
s = list(input())

p = list(itertools.combinations(s, 3))
p = set(p)

print(len(p))


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

li = [[] for _ in range(10)]

for i in range(n):
    t = int(s[i])
    li[t].append(i)

a = 0
b = 0
c = 0
cnt = 0

for i in range(10):
  for j in range(10):
    for k in range(10):
      b = 0
      a = 0
      
      if len(li[i]) > 0:
        a = li[i][0]
          
        for d in li[j]:
            if d > a:
                b = d
                break
        else:
            break
        
        for e in li[k]:
            if e > b:
                cnt += 1
                break
        

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
s = list(input())
ans = 0

for i in range(0,10):
    for j in range(0,10):
        for k in range(0,10):
            flag1 = 0
            flag2 = 0
            flag3 = 0
            for m in range(n):
                if flag1 == 0:
                    if int(s[m]) == i:
                        flag1 = 1
                elif flag2 == 0:
                    if int(s[m]) == j:
                        flag2 = 1
                elif flag3 == 0:
                    if int(s[m]) == k:
                        flag3 = 1
                        ans += 1
                        break
                    
print(ans)


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

li = [[] for _ in range(10)]

for i in range(n):
    t = int(s[i])
    li[t].append(i)

a = 0
b = 0
c = 0
cnt = 0

for i in range(10):
  for j in range(10):
    for k in range(10):
      b = 0
      a = 0
      
      if len(li[i]) > 0:
        a = li[i][0]
          
        for d in li[j]:
            if d > a:
                b = d
                break
        else:
            break
        
        for e in li[k]:
            if e > b:
                cnt += 1
                break
        

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
s = list(input())
ans = 0

for i in range(0,10):
    for j in range(0,10):
        for k in range(0,10):
            flag1 = 0
            flag2 = 0
            flag3 = 0
            for m in range(n):
                if flag1 == 0:
                    if int(s[m]) == i:
                        flag1 = 1
                elif flag2 == 0:
                    if int(s[m]) == j:
                        flag2 = 1
                elif flag3 == 0:
                    if int(s[m]) == k:
                        flag3 = 1
                        ans += 1
                        break
                    
print(ans)

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

li = [[] for _ in range(10)]

for i in range(n):
    t = int(s[i])
    li[t].append(i)

a = 0
b = 0
c = 0
cnt = 0

for i in range(10):
  for j in range(10):
    for k in range(10):
      b = 0
      a = 0
      
      if len(li[i]) > 0:
        a = li[i][0]
          
        for d in li[j]:
            if d > a:
                b = d
                break
        else:
            break
        
        for e in li[k]:
            if e > b:
                cnt += 1
                break
        

print(cnt)

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

a = 0
b = 0
c = 0
cnt = 0

for i in range(10):
  for j in range(10):
    for k in range(10):
      b = 0
      a = 0
      for x in range(n):
        if a == 0:
          if int(s[x]) == i:
            a = 1
        elif b == 0:
          if int(s[x]) == j:
            b = 1
        elif c == 0:
          if int(s[x]) == k:
            cnt += 1
            break    
        

print(cnt)

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

li = [[] for _ in range(10)]

for i in range(n):
    t = int(s[i])
    li[t].append(i)

a = 0
b = 0
c = 0
cnt = 0

for i in range(10):
  for j in range(10):
    for k in range(10):
      b = 0
      a = 0
      
      if len(li[i]) > 0:
        a = li[i][0]
          
        for d in li[j]:
            if d > a:
                b = d
                break
        else:
            break
        
        for e in li[k]:
            if e > b:
                cnt += 1
                break
        

print(cnt)