Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
p = [set() for _ in range(100)]
sp = [set() for _ in range(n)]
k = int(s[-1])
sp[-1].add(k)
ful = False
for j in range(n-2,1,-1):
    if ful:
        sp[j] = {0,1,2,3,4,5,6,7,8,9}
    tmp = set(sp[j+1])
    if len(tmp) == 10:
        ful = True
    tmp.add(int(s[j]))
    sp[j] = tmp
co = 0
for x in range(n-2):
    if co == 100:
        break
    for y in range(x,n-1):
        if x < y:
            tstr = str(s[x])+str(s[y])
            b2 = int(tstr)
            if len(p[b2]) > 0:
                pass
            else:
                p[b2] |= sp[y+1]
                co += 1
            if co == 100:
                break
g =0
for c in p:
    g += len(c)
print(g)

Fixed submission:
n = int(input())
s = input()
p = [set() for _ in range(100)]
sp = [set() for _ in range(n)]
k = int(s[-1])
sp[-1].add(k)
ful = False
for j in range(n-2,1,-1):
    if ful:
        sp[j] = {0,1,2,3,4,5,6,7,8,9}
    tmp = set(sp[j+1])
    if len(tmp) == 10:
        ful = True
    tmp.add(int(s[j]))
    sp[j] = tmp

s10 = [[99999 for _ in range(2)] for _ in range(10)]
for i,d in enumerate(s):
    c = int(d)
    if s10[c][0] == 99999:
        s10[c][0] = i
    elif s10[c][1] == 99999:
        s10[c][1] = i
g = 0
for i in range(10):
    for j in range(10):
        ans = 0
        nexid = min(s10[i])
        if nexid != 99999:
            for r in range(nexid+1,n-1):
                if int(s[r]) == j:
                    ans = len(sp[r+1])
                    break
            g += ans
print(g)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
p = [set() for _ in range(100)]
sp = [set() for _ in range(n)]
k = int(s[-1])
sp[-1].add(k)
for j in range(n-2,1,-1):
    tmp = set(sp[j+1])
    tmp.add(int(s[j]))
    sp[j] = tmp
for x in range(n-2):
    for y in range(x,n-1):
        if x < y:
            tstr = str(s[x])+str(s[y])
            b2 = int(tstr)
            if len(p[b2]) > 0:
                pass
            else:
                p[b2] |= sp[y+1]
g =0
for c in p:
    g += len(c)
print(g)

Fixed submission:
n = int(input())
s = input()
p = [set() for _ in range(100)]
sp = [set() for _ in range(n)]
k = int(s[-1])
sp[-1].add(k)
ful = False
for j in range(n-2,1,-1):
    if ful:
        sp[j] = {0,1,2,3,4,5,6,7,8,9}
    tmp = set(sp[j+1])
    if len(tmp) == 10:
        ful = True
    tmp.add(int(s[j]))
    sp[j] = tmp

s10 = [[99999 for _ in range(2)] for _ in range(10)]
for i,d in enumerate(s):
    c = int(d)
    if s10[c][0] == 99999:
        s10[c][0] = i
    elif s10[c][1] == 99999:
        s10[c][1] = i
g = 0
for i in range(10):
    for j in range(10):
        ans = 0
        nexid = min(s10[i])
        if nexid != 99999:
            for r in range(nexid+1,n-1):
                if int(s[r]) == j:
                    ans = len(sp[r+1])
                    break
            g += ans
print(g)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
p = [set() for _ in range(100)]
sp = [set() for _ in range(n)]
k = int(s[-1])
sp[-1].add(k)
for j in range(n-2,1,-1):
    tmp = set(sp[j+1])
    tmp.add(int(s[j]))
    sp[j] = tmp
for x in range(n-2):
    for y in range(x,n-1):
        if x < y:
            tstr = str(s[x])+str(s[y])
            b2 = int(tstr)
            if len(p[b2]) == 9:
                pass
            else:
                p[b2] |= sp[y+1]
g =0
for c in p:
    g += len(c)
print(g)

Fixed submission:
n = int(input())
s = input()
p = [set() for _ in range(100)]
sp = [set() for _ in range(n)]
k = int(s[-1])
sp[-1].add(k)
ful = False
for j in range(n-2,1,-1):
    if ful:
        sp[j] = {0,1,2,3,4,5,6,7,8,9}
    tmp = set(sp[j+1])
    if len(tmp) == 10:
        ful = True
    tmp.add(int(s[j]))
    sp[j] = tmp

s10 = [[99999 for _ in range(2)] for _ in range(10)]
for i,d in enumerate(s):
    c = int(d)
    if s10[c][0] == 99999:
        s10[c][0] = i
    elif s10[c][1] == 99999:
        s10[c][1] = i
g = 0
for i in range(10):
    for j in range(10):
        ans = 0
        nexid = min(s10[i])
        if nexid != 99999:
            for r in range(nexid+1,n-1):
                if int(s[r]) == j:
                    ans = len(sp[r+1])
                    break
            g += ans
print(g)