Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    s=input()
    dp_0=[[False]*1001 for _ in range(n+1)]
    dp_1=[[False]*1001 for _ in range(n+1)]
    dp_2=[[False]*1001 for _ in range(n+1)]
    dp_3=[[False]*1001 for _ in range(n+1)]
    dp_0[0][0]=True
    
    for k in range(1000):
        for i in range(n):
            if dp_0[i][k]==True:
                dp_0[i+1][k]=True
                dp_1[i+1][10*k+int(s[i])]=True
            if dp_1[i][k]==True:
                dp_1[i+1][k]=True
                dp_2[i+1][10*k+int(s[i])]=True
            if dp_2[i][k]==True:
                dp_2[i+1][k]=True
                dp_3[i+1][10*k+int(s[i])]=True
            if dp_3[i][k]==True:
                dp_3[i+1][k]=True            
    ans=0
    for i in range(1000):
        if dp_3[n][i]:
            ans+=1
    print(ans)

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    s=input()
    ans=0
    for i in range(10):
        for j in range(10):
            for k in range(10):
                if str(i) in s:
                    index_i=s.index(str(i))
                    s1=s[index_i+1:]
                    if str(j) in s1:
                        index_j=s1.index(str(j))
                        s2=s1[index_j+1:]
                        if str(k) in s2:
                            ans+=1
    print(ans)

if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    s=input()
    dp_0=[[False]*1001 for _ in range(n+1)]
    dp_1=[[False]*1001 for _ in range(n+1)]
    dp_2=[[False]*1001 for _ in range(n+1)]
    dp_3=[[False]*1001 for _ in range(n+1)]
    dp_0[0][0]=True
    
    for k in range(1000):
        for i in range(n):
            if dp_0[i][k]==True:
                dp_0[i+1][k]=True
                dp_1[i+1][10*k+int(s[i])]=True
            if dp_1[i][k]==True:
                dp_1[i+1][k]=True
                dp_2[i+1][10*k+int(s[i])]=True
            if dp_2[i][k]==True:
                dp_2[i+1][k]=True
                dp_3[i+1][10*k+int(s[i])]=True
            if dp_3[i][k]==True:
                dp_3[i+1][k]=True            
    ans=0
    for i in range(1000):
        if dp_3[n][i]:
            ans+=1
    print(ans)

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    s=input()
    ans=0
    for i in range(10):
        for j in range(10):
            for k in range(10):
                if str(i) in s:
                    index_i=s.index(str(i))
                    s1=s[index_i+1:]
                    if str(j) in s1:
                        index_j=s1.index(str(j))
                        s2=s1[index_j+1:]
                        if str(k) in s2:
                            ans+=1
    print(ans)

if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    s=input()
    dp=[[[False]*1001 for _ in range(4)] for _ in range(n+1)]
    dp[0][0][0]=True
    
    for j in range(4):
        for k in range(1000):
            for i in range(n):
                if dp[i][j][k]==False:
                    continue
                dp[i+1][j][k]=True
                if j!=3:
                    dp[i+1][j+1][10*k+int(s[i])]=True
    ans=0
    for i in range(1000):
        if dp[n][3][i]:
            ans+=1
    print(ans)

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    s=input()
    ans=0
    for i in range(10):
        for j in range(10):
            for k in range(10):
                if str(i) in s:
                    index_i=s.index(str(i))
                    s1=s[index_i+1:]
                    if str(j) in s1:
                        index_j=s1.index(str(j))
                        s2=s1[index_j+1:]
                        if str(k) in s2:
                            ans+=1
    print(ans)

if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    s=input()
    dp=[[[False]*1001 for _ in range(4)] for _ in range(n+1)]
    dp[0][0][0]=True
    
    for j in range(4):
        for k in range(1000):
            for i in range(n):
                if dp[i][j][k]==False:
                    continue
                dp[i+1][j][k]=True
                if j!=3:
                    dp[i+1][j+1][10*k+int(s[i])]=True
    ans=0
    for i in range(1000):
        if dp[n][3][i]:
            ans+=1
    print(ans)

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    s=input()
    ans=0
    for i in range(10):
        for j in range(10):
            for k in range(10):
                if str(i) in s:
                    index_i=s.index(str(i))
                    s1=s[index_i+1:]
                    if str(j) in s1:
                        index_j=s1.index(str(j))
                        s2=s1[index_j+1:]
                        if str(k) in s2:
                            ans+=1
    print(ans)

if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    s=input()
    dp=[[[False]*1001 for _ in range(4)] for _ in range(n+1)]
    dp[0][0][0]=True
    for i in range(n):
        for j in range(4):
            for k in range(1000):
                if dp[i][j][k]==False:
                    continue
                dp[i+1][j][k]=True
                if j!=3:
                    dp[i+1][j+1][10*k+int(s[i])]=True
    ans=0
    for i in range(1000):
        if dp[n][3][i]:
            ans+=1
    print(ans)

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    s=input()
    ans=0
    for i in range(10):
        for j in range(10):
            for k in range(10):
                if str(i) in s:
                    index_i=s.index(str(i))
                    s1=s[index_i+1:]
                    if str(j) in s1:
                        index_j=s1.index(str(j))
                        s2=s1[index_j+1:]
                        if str(k) in s2:
                            ans+=1
    print(ans)

if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    s=input()
    dp=[[[False]*1001 for _ in range(4)] for _ in range(n+1)]
    dp[0][0][0]=True
    for i in range(n):
        for j in range(4):
            for k in range(1000):
                if dp[i][j][k]==False:
                    continue
                dp[i+1][j][k]=True
                if j!=3:
                    dp[i+1][j+1][10*k+int(s[i])]=True
    ans=0
    for i in range(1000):
        if dp[n][3][i]:
            ans+=1
    print(ans)

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    s=input()
    ans=0
    for i in range(10):
        for j in range(10):
            for k in range(10):
                if str(i) in s:
                    index_i=s.index(str(i))
                    s1=s[index_i+1:]
                    if str(j) in s1:
                        index_j=s1.index(str(j))
                        s2=s1[index_j+1:]
                        if str(k) in s2:
                            ans+=1
    print(ans)

if __name__=='__main__':
    main()