Buggy python submission (verdict: Time Limit Exceeded):
#三井住友2019 D
def main():
    import sys
    import itertools as ite
    N = int(sys.stdin.readline())
    S = sys.stdin.readline().rstrip()
    L = ite.product([0,1,2,3,4,5,6,7,8,9], repeat=3)
    cnt=0
    for pw in L:
        #print(pw)
        num=0
        for i in range(N):
            if int(S[i])==pw[num]:
                num +=1
            if num==3:
                cnt +=1
                #print(pw)
                break
    print(cnt)


if __name__=='__main__':
    main()

Fixed submission:
#三井住友2019 D 貪欲法
def main():
    import sys
    N = int(sys.stdin.readline())
    S = sys.stdin.readline().rstrip()
    ans = 0
    for i in range(1000):
        num = str(i).zfill(3)
        L = []
        k = 0
        for j in range(N):
            #print(num, S[j])
            if int(S[j])==int(num[k]):
                #print('Yes', num)
                L.append(S[j])
                k+=1
            if len(L)==3:
                #print(L)
                ans +=1
                break
                
    print(ans)
        
    
if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#三井住友2019 D
def main():
    import sys
    import itertools as ite
    N = int(sys.stdin.readline())
    S = sys.stdin.readline().rstrip()
    L = ite.product([0,1,2,3,4,5,6,7,8,9], repeat=3)
    cnt=0
    for pw in L:
        #print(pw)
        num=0
        for i in range(N):
            if int(S[i])==pw[num]:
                num +=1
            if num==3:
                cnt +=1
                #print(pw)
                break
    print(cnt)


if __name__=='__main__':
    main()

Fixed submission:
#三井住友2019 D 貪欲法
def main():
    import sys
    N = int(sys.stdin.readline())
    S = sys.stdin.readline().rstrip()
    ans = 0
    for i in range(1000):
        num = str(i).zfill(3)
        L = []
        k = 0
        for j in range(N):
            #print(num, S[j])
            if int(S[j])==int(num[k]):
                #print('Yes', num)
                L.append(S[j])
                k+=1
            if len(L)==3:
                #print(L)
                ans +=1
                break
                
    print(ans)
        
    
if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#三井住友2019 D 貪欲法
def main():
    import sys
    N = int(sys.stdin.readline())
    S = sys.stdin.readline().rstrip()
    ans = 0
    for i in range(1000):
        num = str(i).zfill(3)
        L = []
        k = 0
        for j in range(N):
            #print(num, S[j])
            if int(S[j])==int(num[k]):
                #print('Yes', num)
                L.append(S[j])
                k+=1
            if len(L)==3:
                #print(L)
                ans +=1
                break
                
    print(ans)
        
    
if __name__=='__main__':
    main()


Fixed submission:
#三井住友2019 D 貪欲法
def main():
    import sys
    N = int(sys.stdin.readline())
    S = sys.stdin.readline().rstrip()
    ans = 0
    for i in range(1000):
        num = str(i).zfill(3)
        L = []
        k = 0
        for j in range(N):
            #print(num, S[j])
            if int(S[j])==int(num[k]):
                #print('Yes', num)
                L.append(S[j])
                k+=1
            if len(L)==3:
                #print(L)
                ans +=1
                break
                
    print(ans)
        
    
if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#三井住友2019 D 全列挙
def main():
    import sys
    N = int(sys.stdin.readline())
    S = sys.stdin.readline().rstrip()
    tmp = [-1,-1,-1]
    L = set()
    for i in range(N-2):
        tmp[0]=S[i]
        for j in range(i+1, N-1):
            tmp[1]=S[j]
            for k in range(j+1, N):
                tmp[2]=S[k]
                L.add(''.join(tmp))
    #print(tmp)
    print(len(L))
    
if __name__=='__main__':
    main()


Fixed submission:
#三井住友2019 D 貪欲法
def main():
    import sys
    N = int(sys.stdin.readline())
    S = sys.stdin.readline().rstrip()
    ans = 0
    for i in range(1000):
        num = str(i).zfill(3)
        L = []
        k = 0
        for j in range(N):
            #print(num, S[j])
            if int(S[j])==int(num[k]):
                #print('Yes', num)
                L.append(S[j])
                k+=1
            if len(L)==3:
                #print(L)
                ans +=1
                break
                
    print(ans)
        
    
if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#三井住友2019 D
def main():
    import sys
    import itertools as ite
    N = int(sys.stdin.readline())
    S = sys.stdin.readline().rstrip()
    #print(N-3)
    #print(S)
    L = set(list(ite.combinations(S, 3)))
    print(len(L))

if __name__=='__main__':
    main()


Fixed submission:
#三井住友2019 D 貪欲法
def main():
    import sys
    N = int(sys.stdin.readline())
    S = sys.stdin.readline().rstrip()
    ans = 0
    for i in range(1000):
        num = str(i).zfill(3)
        L = []
        k = 0
        for j in range(N):
            #print(num, S[j])
            if int(S[j])==int(num[k]):
                #print('Yes', num)
                L.append(S[j])
                k+=1
            if len(L)==3:
                #print(L)
                ans +=1
                break
                
    print(ans)
        
    
if __name__=='__main__':
    main()