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

def judge(S,A): #A:3桁ｎ数字
    dig,pt = 0,0
    while dig < 3 and pt < N:
        if S[pt] == A[dig]:
            dig += 1
            pt += 1
        else:
            pt += 1
        if dig == 3:
            break

    if dig == 3:
        return True
    else:
        return False

count = 0
for a in range(10):
    for b in range(10):
        for c in range(10):
            if judge(S,[str(a),str(b),str(c)]):
                count += 1

print(count)


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

def judge(S,A): #A:3桁ｎ数字
    dig,pt = 0,0
    while dig < 3 and pt < N:
        if S[pt] == A[dig]:
            dig += 1
            pt += 1
        else:
            pt += 1
        if dig == 3:
            break

    if dig == 3:
        return True
    else:
        return False

count = 0
for a in range(10):
    for b in range(10):
        for c in range(10):
            if judge(S,[str(a),str(b),str(c)]):
                count += 1

print(count)

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

S_set = {S[0:3]}
cnst = 0
for i in range(3,N):
    S_0_set = S_set.copy()
    for s_0 in S_0_set:
        for j in range(len(s_0)):
            if s_0[0:j]+s_0[j+1:3]+S[i] not in S_set:
                S_set.add(s_0[0:j]+s_0[j+1:3]+S[i])
    if len(S_set) == 1000:
        print(1000)
        cnst = 1
        break
if cnst == 0:
    print(len(S_set))


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

def judge(S,A): #A:3桁ｎ数字
    dig,pt = 0,0
    while dig < 3 and pt < N:
        if S[pt] == A[dig]:
            dig += 1
            pt += 1
        else:
            pt += 1
        if dig == 3:
            break

    if dig == 3:
        return True
    else:
        return False

count = 0
for a in range(10):
    for b in range(10):
        for c in range(10):
            if judge(S,[str(a),str(b),str(c)]):
                count += 1

print(count)

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

S_set = {S[0:3]}
cnst = 0
for i in range(3,N):
    S_0_set = set()
    for s_0 in S_set:
        for j in range(len(s_0)):
            if s_0[0:j]+s_0[j+1:3]+S[i] not in S_set:
                S_0_set.add(s_0[0:j]+s_0[j+1:3]+S[i])
    S_set = S_set.union(S_0_set)
    if len(S_set) == 1000:
        print(1000)
        cnst = 1
        break
if cnst == 0:
    print(len(S_set))


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

def judge(S,A): #A:3桁ｎ数字
    dig,pt = 0,0
    while dig < 3 and pt < N:
        if S[pt] == A[dig]:
            dig += 1
            pt += 1
        else:
            pt += 1
        if dig == 3:
            break

    if dig == 3:
        return True
    else:
        return False

count = 0
for a in range(10):
    for b in range(10):
        for c in range(10):
            if judge(S,[str(a),str(b),str(c)]):
                count += 1

print(count)

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

S_set = {S[0:3]}
for i in range(3,N):
    S_0_set = set()
    for s_0 in S_set:
        for j in range(len(s_0)):
            S_0_set.add(s_0[0:j]+s_0[j+1:3]+S[i])
    S_set = S_set.union(S_0_set)

print(len(S_set))


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

def judge(S,A): #A:3桁ｎ数字
    dig,pt = 0,0
    while dig < 3 and pt < N:
        if S[pt] == A[dig]:
            dig += 1
            pt += 1
        else:
            pt += 1
        if dig == 3:
            break

    if dig == 3:
        return True
    else:
        return False

count = 0
for a in range(10):
    for b in range(10):
        for c in range(10):
            if judge(S,[str(a),str(b),str(c)]):
                count += 1

print(count)

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

S_set = {S[0:3]}
for i in range(3,N):
    S_0_set = S_set.copy()
    for s_0 in S_0_set:
        for j in range(len(s_0)):
            if s_0[0:j]+s_0[j+1:3]+S[i] not in S_set:
                S_set.add(s_0[0:j]+s_0[j+1:3]+S[i])

print(len(S_set))


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

def judge(S,A): #A:3桁ｎ数字
    dig,pt = 0,0
    while dig < 3 and pt < N:
        if S[pt] == A[dig]:
            dig += 1
            pt += 1
        else:
            pt += 1
        if dig == 3:
            break

    if dig == 3:
        return True
    else:
        return False

count = 0
for a in range(10):
    for b in range(10):
        for c in range(10):
            if judge(S,[str(a),str(b),str(c)]):
                count += 1

print(count)

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

List = []
List.append(S[0:3])
for i in range(3,N):
    cnt = 0
    List0 = copy.copy(List)
    for s in List0:
        for j in range(len(s)):
            if s[0:j]+s[j+1:N]+S[i] not in List:
                List.append(s[0:j]+s[j+1:N]+S[i])

print(len(List))


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

def judge(S,A): #A:3桁ｎ数字
    dig,pt = 0,0
    while dig < 3 and pt < N:
        if S[pt] == A[dig]:
            dig += 1
            pt += 1
        else:
            pt += 1
        if dig == 3:
            break

    if dig == 3:
        return True
    else:
        return False

count = 0
for a in range(10):
    for b in range(10):
        for c in range(10):
            if judge(S,[str(a),str(b),str(c)]):
                count += 1

print(count)