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

dic = {"":1}

for c in S:
    dic_tmp = dic.copy()
    for k in dic_tmp:
        if not(c in k):
            dic[k+c] = (dic.get(k+c,0)+dic_tmp[k])%(10**9+7) 
ans = 0     
del dic[""]
for k in dic:
    ans += dic[k]
    ans %= 10**9+7
print(ans)      

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

tmp = []
for a in "abcdefghijklmnopqrstuvwxyz":      
    tmp.append(S.count(a)+1)
    
ans = 1 
for i in tmp:
    ans = ans * i % (10**9+7)
    
print(ans-1)

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

dic = {"":1}

for c in S:
    dic_tmp = dic.copy()
    for k in dic_tmp:
        if not(c in k):
            dic[k+c] = (dic.get(k+c,0)+dic_tmp[k])%(10**9+7) 
ans = 0     
del dic[""]
for k in dic:
    ans += dic[k]
    ans %= 10**9+7
print(ans)      

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

tmp = []
for a in "abcdefghijklmnopqrstuvwxyz":      
    tmp.append(S.count(a)+1)
    
ans = 1 
for i in tmp:
    ans = ans * i % (10**9+7)
    
print(ans-1)

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

dic = {"":1}
ans = 0

for c in S:
    dic_tmp = dic.copy()
    for k in dic_tmp:
        if not(c in k):    
            ans += dic_tmp[k]   
            ans %= 10**9+7
            dic[k+c] = (dic.get(k+c,0)+dic_tmp[k])%(10**9+7)  
print(ans)      

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

tmp = []
for a in "abcdefghijklmnopqrstuvwxyz":      
    tmp.append(S.count(a)+1)
    
ans = 1 
for i in tmp:
    ans = ans * i % (10**9+7)
    
print(ans-1)

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

dic = {"":1}
ans = 0

for c in S:
    dic_new = {}         
    for k in dic:    
        if not(c in k):    
            ans += dic[k]       
            ans %= 10**9+7
            if len(k)<=25:
                dic_new[k+c] = dic_new.get(k+c,0)+dic[k]          
    for k in dic_new:    
        dic[k] = (dic.get(k,0)+dic_new[k])%(10**9+7)
print(ans)      

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

tmp = []
for a in "abcdefghijklmnopqrstuvwxyz":      
    tmp.append(S.count(a)+1)
    
ans = 1 
for i in tmp:
    ans = ans * i % (10**9+7)
    
print(ans-1)

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

dic = {"":1}
ans = 0

for c in S:
    dic_new = {}         
    for k in dic:    
        if not(c in k):    
            ans += dic[k]    
            ans %= 10**9 + 7    
            dic_new[k+c] = (dic_new.get(k+c,0)+dic[k]) % (10**9+7)
    for k in dic_new:    
        dic[k] = (dic.get(k,0)+dic_new[k])%(10**9+7)
print(ans)      

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

tmp = []
for a in "abcdefghijklmnopqrstuvwxyz":      
    tmp.append(S.count(a)+1)
    
ans = 1 
for i in tmp:
    ans = ans * i % (10**9+7)
    
print(ans-1)

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

ans = N
Q = [[i] for i in range(N)] 
L = 2
while Q and L<27:
    Q_tmp = []
    for q in Q:
        tmp = ""
        for c in q:
            tmp += S[c]
        for i in range(q[-1]+1,N):
            if not(S[i] in tmp):
                Q_tmp.append(q+[i])
                ans += 1
        ans %= 10**9+7
    Q = Q_tmp
    L += 1
print(ans)  


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

tmp = []
for a in "abcdefghijklmnopqrstuvwxyz":      
    tmp.append(S.count(a)+1)
    
ans = 1 
for i in tmp:
    ans = ans * i % (10**9+7)
    
print(ans-1)