Problem:


Score : 200 points

Problem Statement

You are given a string S of length N.
Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings.

Here, a subsequence of a string is a concatenation of one or more characters from the string without changing the order.

Constraints

1 \leq N \leq 100000

S consists of lowercase English letters.

|S|=N

Input

Input is given from Standard Input in the following format:

N
S

Output

Print the number of the subsequences such that all characters are different, modulo 10^9+7.

Sample Input 1

4
abcd

Sample Output 1

15

Since all characters in S itself are different, all its subsequences satisfy the condition.

Sample Input 2

3
baa

Sample Output 2

5

The answer is five: b, two occurrences of a, two occurrences of ba. Note that we do not count baa, since it contains two as.

Sample Input 3

5
abcab

Sample Output 3

17



Sample input:
4
abcd


Sample output:
15

Submission status: Wrong Answer

Solution code:
import itertools

N = int(input())
S = [s for s in input()]
ans = 0
for n in range(1,N+1):
    a = list(itertools.combinations(S,n))
    a = [i for i in a if len(i) == len(set(i))]
    ans += len(a)
    
print(ans/(10**7 + 7))

Submission status: Wrong Answer

Solution code:
import collections

_ = input()
s = input()

# s = "abcab"

c = collections.Counter(s)

ans = 1

for num in c.values():
    ans *= (num + 1)

print(ans - 1)

Submission status: Wrong Answer

Solution code:
_=input()
S=input()

"""
S=""
import random
AL=["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
for i in range(10):
    t=int(random.random()*20)
    S+=AL[t]
    print(AL[t])
    print(S)
print(S)
"""
obj={}
r=1
for i in range(len(S)):
    try:
        obj[S[i]]+=1
        r=r*(1+1/(2**obj[S[i]]))
    except:
        r*=2
        obj[S[i]]=0

    if r>(10**9+7):
        r-=(10**9+7)
        
print(r-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
Slice =[]
SliceSet = []
count = 0
for i in range(len(S)):
  for j in range(len(S)-i+1):
    if j >26 :
      continue
    Slice = S[i:i+j]
    SliceSet = set(Slice)
    if len(Slice) == len(SliceSet):
      count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000)
#def input():
#    return sys.stdin.readline()[:-1]

'''
n=int(input())
for i in range(n):
    a[i]=int(input())
    a[i],b[i]=map(int,input().split())
a=[int(x) for x in input().split()]
n,m=map(int,input.split())
from operator import itemgetter
a = [(1, "c", 1), (1, "b", 3), (2, "a", 0), (1, "a", 2)]
print(sorted(a))  # 0 番目の要素でソート、先頭の要素が同じなら 1 番目以降の要素も見る
print(sorted(a, key=itemgetter(0)))  # 0 番目の要素だけでソート
print(sorted(a, key=itemgetter(0, 2)))  # 0 番目と 2 番目の要素でソート
print(sorted(a, key=lambda x: x[0] * x[2]))  # 0 番目の要素 * 2 番目の要素でソート
print(sorted(a, reverse=True))  # 降順にソート
a.sort()  # 破壊的にソート、sorted() よりも高速
try: # エラーキャッチ list index out of range
    for i in range():
        k=b[i]
except IndexError as e:
    print(i)
'''

test_data1 = '''\
4
abcd
'''

test_data2 = '''\
3
baa
'''

test_data3 = '''\
5
abcab
'''
td_num=2

def GetTestData(index):
    if index==1:
        return test_data1
    if index==2:
        return test_data2
    if index==3:
        return test_data3
    
if False:
    with open("../test.txt", mode='w') as f:
        f.write(GetTestData(td_num))
    with open("../test.txt") as f:
        # Start Input code ---------------------------------------
        #n,m,c=map(int,f.readline().split())
        n=int(f.readline())
        s=str(f.readline())
        # End Input code ---------------------------------------
else:
    # Start Input code ---------------------------------------
    n=int(input())
    s=str(input())
    # End Input code ---------------------------------------
#print(n,s)
import string
al=string.ascii_lowercase
cnt=[]
for i in range(26):
    alc=s.count(al[i])
    if alc!=0: cnt.append(alc)

#print(cnt)
m=len(cnt)
ans=1
mo=10**9 +7
counter=0
for i in range(m):
    ans*=(1+cnt[i]) % mo
ans-=1
'''
for i in range(1,2**m):
    counter+=1
    pat=1
    for j in range (m):
        #print(int((i % 2**(j+1)) / 2**j))
        ind=int((i % 2**(j+1)) / 2**j)
        pat*=max(1,cnt[j]*ind) % mo
        #print('ind,cnt[ind]=',ind,cnt[ind])
    ans+=pat
    #print(pat,ans)
    #print(bin(i))
'''
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
d = dict()
ans = 1
for i in s:
    if i in d:
        d[i] += 1
    else:
        d[i] = 2
for i in d:
    ans *= d[i]
print(ans-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
Slice =[]
SliceSet = []
count = 0
for i in range(len(S)):
  for j in range(len(S)-i+1):
    Slice = S[i:i+j]
    SliceSet = set(Slice)
    if len(Slice) == len(SliceSet):
      count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import collections

TEISUU = 1000000007

S = input()
N = input()
c = collections.Counter(N)
lis = list(c.values())
ans = 1
for count in lis:
    ans *= int(count + 1)
    
print(ans - 1 % TEISUU)

Submission status: Wrong Answer

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())

rem = pow(10,9)+7

n = ip()                                     #入力整数1つ
#x,y,z= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[input() for i in range(x)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
s = set()
l = []
for i in range(n):
    l.append(a[i])
    s.add(a[i])
ans  = 1
if len(s) == n: print(pow(2,n)-1)
else :
    for i in range(n-1):
        c = 0
        for k in range(i,n):
            if a[i] != a[k]:c+=1
        if c == 0: break
        else: ans *=c
    print((n+ans)%rem)

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce
import itertools

def cmb(n, r):
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under

n = int(input())
s = list(input())
listS=[]
listSN=[]
index=0
while index < n:
    if s[index] in listS:
        tarI = listS.index(s[index])
        listSN[tarI]+=1
    else:
        listS.append(s[index])
        listSN.append(1)
    index+=1

from operator import mul
from functools import reduce

sum=0
index2=1
while index2 < len(listSN)+1:
    for i in itertools.combinations(listSN, index2):
        sum+=reduce(mul, list(i))
    index2+=1
print(sum)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
d = dict()
c = 0
ans = 1
for i in s:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
for i in d:
    if d[i] == 1:
        c += 1
    else:
        ans *= (d[i]+1)
print(ans*2**c-1)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
S = [i for i in input()]
NN = 10^9 + 7

values = list(Counter(S).values())
values = [i+1 for i in values]
X = 1
for i in values:
    X *= i

print((X-1) % NN)

Submission status: Wrong Answer

Solution code:
a = int(input())
b = str(input())

char_list = list(b)

ans = pow(2,a)-1



for i in range(len(char_list)):
    for j in range(i+1,len(char_list)):
            if(char_list[i] == char_list[j]):
                ans = ans - 1


print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
lis = list(input())
c = Counter(lis)
lisc = list(c)

sum = 0


for i in range(1,1 << len(lisc)):
    point = 1
    for j in range(len(lisc)):
        if ((i >> j) & 1) == 1:
            point *= c[lisc[j]]
    sum += point

print(sum)

Submission status: Wrong Answer

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())

n = ip()                                     #入力整数1つ
#x,y,z= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[input() for i in range(x)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
s = set()
l = []
for i in range(n):
    l.append(a[i])
    s.add(a[i])
ans  = 1
if len(s) == n: print(pow(2,n)-1)
else :
    for i in range(n-1):
        c = 0
        for k in range(i,n):
            if a[i] != a[k]:c+=1
        if c == 0: break
        else: ans *=c
    print(n+ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
check = {}
for i in "abcdefghijklmnopqrstuvwxyz":
    check[i] = 0
ans = 1
for i in range(n):
    ans += ans//(2**check[s[i]])
    check[s[i]] += 1
print(ans-1)

Submission status: Wrong Answer

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


N = I()
s = S()

inf = 10**9+7

counts = collections.Counter(s)
chars = list(set(s))
result = 0
for i in range(1, len(counts)+1):
    #  print(i)
    #  import pdb
    #  pdb.set_trace()
    combis = list(itertools.combinations(chars, i))
    #  print('combis' ,combis) 
    for combi in combis:
        #  print('combi', combi)
        tmp = 1
        for c in combi:
            #  print('c', c)
            tmp *= counts[c]
        #  print('tmp', tmp)
        result += tmp
print(result)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int, S: str):
    abc = "abcdefghijklmnopqrstuvwxyz"
    ans = 2**N
    n = N
    pre = 1
    for c in abc:
        count = S.count(c)
        kaburi = ((2 ** count)-1-count)
        ans -= pre * kaburi * (2 ** (n - count))
        pre *= (1 + count)
        n -= count
    print(int(ans-1))
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import itertools
N = int(input())
S = input()

S = list(S)

cnt = 0
for i in range(N+1):
    for v in itertools.combinations(S,i):
        
        if len(v) == len(set(v)) & len(v)!=0:
            print(v)
            cnt += 1
    
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
sum = 0


sum = 2 ** N - 1

count = 0

a = len(list(dict.fromkeys(S)))

sum -= 2 ** (N - a) - 1

sumn = sum % (10 ** 9 + 7)
print(sumn)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000)
#def input():
#    return sys.stdin.readline()[:-1]

'''
n=int(input())
for i in range(n):
    a[i]=int(input())
    a[i],b[i]=map(int,input().split())
a=[int(x) for x in input().split()]
n,m=map(int,input.split())
from operator import itemgetter
a = [(1, "c", 1), (1, "b", 3), (2, "a", 0), (1, "a", 2)]
print(sorted(a))  # 0 番目の要素でソート、先頭の要素が同じなら 1 番目以降の要素も見る
print(sorted(a, key=itemgetter(0)))  # 0 番目の要素だけでソート
print(sorted(a, key=itemgetter(0, 2)))  # 0 番目と 2 番目の要素でソート
print(sorted(a, key=lambda x: x[0] * x[2]))  # 0 番目の要素 * 2 番目の要素でソート
print(sorted(a, reverse=True))  # 降順にソート
a.sort()  # 破壊的にソート、sorted() よりも高速
try: # エラーキャッチ list index out of range
    for i in range():
        k=b[i]
except IndexError as e:
    print(i)
'''

test_data1 = '''\
4
abcd
'''

test_data2 = '''\
3
baa
'''

test_data3 = '''\
5
abcab
'''
td_num=2

def GetTestData(index):
    if index==1:
        return test_data1
    if index==2:
        return test_data2
    if index==3:
        return test_data3
    
if False:
    with open("../test.txt", mode='w') as f:
        f.write(GetTestData(td_num))
    with open("../test.txt") as f:
        # Start Input code ---------------------------------------
        #n,m,c=map(int,f.readline().split())
        n=int(f.readline())
        s=str(f.readline())
        # End Input code ---------------------------------------
else:
    # Start Input code ---------------------------------------
    n=int(input())
    s=str(input())
    # End Input code ---------------------------------------
#print(n,s)
import string
al=string.ascii_lowercase
cnt=[]
for i in range(26):
    alc=s.count(al[i])
    if alc!=0: cnt.append(alc)

#print(cnt)
m=len(cnt)
ans=0
mo=10**9 +7
counter=0
for i in range(1,2**m):
    counter+=1
    pat=1
    for j in range (m):
        #print(int((i % 2**(j+1)) / 2**j))
        ind=int((i % 2**(j+1)) / 2**j)
        pat*=max(1,cnt[j]*ind) % mo
        #print('ind,cnt[ind]=',ind,cnt[ind])
    ans+=pat
    #print(pat,ans)
    #print(bin(i))
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
import numpy as np
aaa = 10 ** 9 + 7
N = int(input())
S =  [s for s in input()]
c = collections.Counter(S)
num = np.array(list(c.values()))
num = num + 1
count = 1
if N == 1:
    print(1)
else:
    for i in num:
        count *= i 
    print((count - 1) % aaa)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
s = input()
l=[]
for c in s:
  l.append(c)
C=Counter(l)
ans=1
for v in C.values():
  ans = ans * (v + 1)
print(ans-1)

Submission status: Wrong Answer

Solution code:
import math

str = input()
l = list(str)
l_unique = list(set(l))
i = len(l_unique)

print(math.factorial(i)%(pow(10, 9)+7))

Submission status: Wrong Answer

Solution code:
N = int(input())
S =list(input())
s = list(set(S))
m = 1
for i in range(len(s)):
    m *= (S.count(s[i]) + 1)
    
print(m - 1)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 16 20:34:20 2019

@author: Yamazaki Kenichi
"""

N = int(input())
S = input()
mod = 10**9+7

abc = [chr(i) for i in range(97, 97+26)]
a = [0 for i in range(26)]
for i in range(26):
    a[i] = S.count(abc[i])

ans = 1 + a[0]
for i in range(1,26):
    ans += ans * a[i]
ans -= 1
print(ans)

Submission status: Wrong Answer

Solution code:
# A
N = int(input())
S = list(input())

count_dict = dict()
for i in range(N):
    s = S[i]
    if s in count_dict.keys():
        count_dict[s] += 1
    else:
        count_dict[s] = 1
        
res = 1
for c in count_dict.values():
    res *= c+1
    
print(res - 1)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

D = {}
for s in S :
    if s not in D :
        D[s] = 1
    else :
        D[s] += 1

L = list(D.values())

if N == 1 :
    ans = 0
elif len(L) == 1 :
    ans = L[0]
else :
    ans = 1
    for i in range(len(L)) :
        if L[i] == 1 :
            ans *= 2
        else :
            ans *= (2**L[i]-1)
    ans -= 1
    ans %= (10**9+7)

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = input()
import math
def Comb(a,b):#aCbを返す
    return int(math.factorial(a)/(math.factorial(b)*math.factorial(a-b)))

ans = 2**n-1
kinds = 0
temp = [0]*26
k = 0

for s in S:
    temp[ord(s)-97] += 1
for t in temp:
    if t >= 2:
        ans -= 2**(n-t)
        kinds += 1
        k += t
print((ans+Comb(kinds,2)*(2**(n-k)))%(10**9+7) if kinds >= 2 else ans%(10**9+7))

Submission status: Wrong Answer

Solution code:
import collections
import numpy as np
N = int(input())
S =  [s for s in input()]
c = collections.Counter(S)
num = np.array(list(c.values()))
num = num + 1
count = 1
if N == 1:
    print(1)
else:
    for i in num:
        count *= i 
    print(count - 1)

Submission status: Wrong Answer

Solution code:
from collections import Counter
from itertools import combinations
n = int(input())
s = input()
counter = Counter()
counter.update(s)
counter.values()
counts = 0
for x in range(1, len(counter) + 1):
    for pairs in combinations(counter, x):
        products = 1
        for value in pairs:
            products *= counter[value]
        counts += products
print(int(counts % (1e9 + 7)))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
L = [chr(ord('a') + i) for i in range(26)]
cnt = [0]*26
for i in range(len(S)):
  for j in range(26):
    if L[j] == S[i]:
      cnt[j] += 1
D = []
for i in range(26):
  if cnt[i] != 0:
    D.append(cnt[i])
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
ans = 0
n = 2
for X in range(1,2**len(D)):
  k = Base_10_to_n(X, n).zfill(len(D))
  cur = 1
  for i in range(len(k)):
    if k[i] == '1':
      cur *= D[i]
  ans += cur
print(ans)

Submission status: Wrong Answer

Solution code:
input()
s = list(input())
ans = 1
while len(s) > 0:
    a = s.pop(0)
    n = 1
    i = 0
    while i < len(s):
        if a == s[i]:
            s.pop(i)
            n += 1
        i += 1
    ans *= n + 1
    ans %= 10**9+7
print(ans-1 if ans > 0 else 10**9+7)

Submission status: Wrong Answer

Solution code:
[n] = [int(i) for i in input().split()]
s = str(input())

char = {}

for c in s:
    if c not in char.keys():
        char[c] = 1
    else:
        char[c] = char[c] + 1

cnt = 1
for c in char.keys():
    cnt = (char[c] + 1) * cnt

print((cnt - 1) % (10 ^ 9 + 7))

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())

a = list(input())

l = collections.Counter()
co = 1

for i in a:
    l[i] += 1
l = list(l.most_common())
for i in range(len(l)):
    co *= l[i][1]+1

print(co-1)

Submission status: Wrong Answer

Solution code:
from functools import reduce


def product(a, b):
    return a*b


N = int(input())
S = input()
count = 0
alpha = [1] * 26
left = 0
for s in S:
    #print(ord(s) - ord("a"), s)
    alpha[ord(s) - ord("a")] += 1
exist = [i for i in alpha if i != 1]
ans = reduce(product, exist)
print(ans-1)
"""
for i in range(len(S)):
    if alpha[ord(S[i]) - ord("a")] == -1:
        alpha[ord(S[i]) - ord("a")] == i
        continue
    else:
        count += sum_(i-left)
        count %= 10**9+7
        # 書き換える
        left = alpha[ord(S[i]) - ord("a")] + 1
        alpha[ord(S[i]) - ord("a")] = i
count += sum_((N - 1)-left)
count %= 10**9+7
print(count)
"""

Submission status: Wrong Answer

Solution code:
#w = "abcab"
n=input()
s = input()
counter = {}
for word in s:
    if word in counter:
        counter[word] += 1
    else:
        counter[word] = 1

seki = 1
for i in counter.values():
    seki *= i+1
print((seki-1)%(10*9+7))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())

n = [1]*26
dict = {'a':0, 'b':1, 'c':2, 'd':3, 'e':4, 'f':5, 'g':6, 'h':7,
        'i':8, 'j':9, 'k':10, 'l':11, 'm':12, 'n':13, 'o':14,
        'p':15, 'q':16, 'r':17, 's':18, 't':19, 'u':20, 'v':21,
        'w':22, 'x':23, 'y':24, 'z':25}
for i in range(N):
	n[dict[S[i]]] += 1
ans = 1
# print(n)
for i in range(len(n)):
	ans *= n[i]
# print(ans)
print(ans-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
sum = 0


sum = 2 ** N - 1

count = 0

a = len(list(dict.fromkeys(S)))

sum -= 2 ** (N - a) - 1

print(sum)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
ans=1
import collections
c = collections.Counter(s)
lst=c.values()
for i in lst:
  ans*=i+1
print(ans-1)

Submission status: Wrong Answer

Solution code:
import math
def printSubsequences(arr, n) :
    opsize = math.pow(2, n)
    ans=0
    for counter in range( 1, (int)(opsize)) :
        ans2=1
        for j in range(0, n) :
            if (counter & (1<<j)) : 
                ans2*=arr[j]
        #print(ans2)
        ans+=ans2

    return(ans) 

n=int(input())
s=input()

c=[0]*26
for i in range (n):
    c[ord(s[i])-97]+=1

ar=[]

for i in range (26):
    if(c[i]>0):
        ar.append(c[i])
#print(ar)
x=printSubsequences(ar,len(ar))
print(x)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
sum = 0


sum = 2 ** N - 1

count = 0

a = len(list(dict.fromkeys(S)))

sum -= 2 ** (N - a)

print(sum)

Submission status: Wrong Answer

Solution code:
input()
s = list(input())
ans = 1
while len(s) > 0:
    a = s.pop(0)
    n = 1
    i = 0
    while i < len(s):
        if a == s[i]:
            s.pop(i)
            n += 1
        i += 1
    ans *= n + 1
print((ans-1) % (10**9+7))

Submission status: Wrong Answer

Solution code:
from collections import Counter

# N = int(input())
s = input()

counter = Counter(s)

result = 1
for _, freq in counter.items():
    result *= (freq + 1)

print((result - 1) % 1000000007)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()

dict = dict()
for a in s:
  if a in dict:
    dict[a] = dict[a] + 1
  else:
    dict[a] = 1
res = 1
for k in dict:
  res *= (dict[k] + 1)
print(res - 1)

Submission status: Wrong Answer

Solution code:
n = int(input())
S = input()
import math
def Comb(a,b):#aCbを返す
    return int(math.factorial(a)/(math.factorial(b)*math.factorial(a-b)))

ans = 2**n-1
kinds = 0
temp = [0]*26
k = 0

for s in S:
    temp[ord(s)-97] += 1
for t in temp:
    if t >= 2:
        ans -= 2**(n-t)
        kinds += 1
        k += t
print(ans+Comb(kinds,2)*(n-k+1) if kinds >= 2 else ans)

Submission status: Wrong Answer

Solution code:
import math

str = input()
l = list(str)
l_unique = list(set(l))
i = len(l_unique)

print(math.factorial(i)/(pow(10, 9)+7))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = str(input())
dic = {'a':0,'b':0,'c':0,'d':0,'e':0,'f':0,'g':0,'h':0,'i':0,'j':0,'k':0,'l':0,'m':0,'n':0,'o':0,'p':0,'q':0,'r':0,'s':0,'t':0,'u':0,'v':0,'w':0,'x':0,'y':0,'z':0}

ans = 1

for i in range(N):
	dic[S[i]] += 1

for key in list(dic.keys()):
	ans *= (dic[key]+1)

print(str(ans-1))

Submission status: Wrong Answer

Solution code:
_=input()
S=input()

L=[]
r=1
for i in range(len(S)):
    if S[i] in L:
        r=int(r*(3/2))
    else:
        r*=2
        L.append(S[i])

    if r>(10**9+7):
        r-=(10**9+7)
        
print(r-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
check = {}
for i in "abcdefghijklmnopqrstuvwxyz":
    check[i] = 0
ans = 0
for i in range(n):
    if i == 0:
        ans = 2
    elif check[s[i]]!=0:
        ans += ans//(2**check[s[i]])
    else:ans += ans
    check[s[i]] += 1
print(ans-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
lis = list(s)
sets=set(lis)
counts=[s.count(i) for i in sets]
ans = 1
for i in range(len(sets)):
    ans *= (counts[i]+1)
print(ans-1)

Submission status: Wrong Answer

Solution code:
input()
s = list(input())
ans = 1
while len(s) > 0:
    a = s.pop(0)
    n = 1
    i = 0
    while i < len(s):
        if a == s[i]:
            s.pop(i)
            n += 1
        i += 1
    ans *= n + 1
print(ans-1)

Submission status: Wrong Answer

Solution code:
def int_raw():
    return int(raw_input())

def ss_raw():
    return raw_input().split()

def ints_raw():
    return map(int,ss_raw())

INF = 1<<29

def make2d_arr(w,h,val =INF):
    return [[val]*w for i in xrange(h)]

def floyd_warshall(costs):
    N = len(costs)
    for k in xrange(N):
        for i in xrange(N):
            for j in xrange(N):
                costs[i][j]  = min(costs[i][j],costs[i][k]+costs[k][j])
    return costs

N = int_raw()
S = raw_input()

dp = {}

for s in S:
    if not (s in dp):
        dp[s] = 1
    else:
        dp[s]+=1

ans =1

for k,v in dp.items():
    ans*=(v+1)
    ans % ((1<<9)+7)


print (ans-1+(1<<9)+7)% ((1<<9)+7)

Submission status: Wrong Answer

Solution code:
_=input()
S=input()

L=[]
r=1
print(S)
for i in range(len(S)):
    if S[i] in L:
        r=int(r*(3/2))
    else:
        r*=2
        L.append(S[i])

    if r>(10**9+7):
        r-=(10**9+7)
        
print((r-1)%(10**9+7))

Submission status: Wrong Answer

Solution code:
def main():
    n=int(input())
    s=input()
    alp = [0 for i in range(26)]
    for i in range(n):
        alp[ord(s[i])-97] += 1
    ans = 1
    for i in range(26):
        ans *= (alp[i]+1)


    print(ans-1)

main()

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(input())
a=[0]*N
for i in range(N):
    a[i]=ord(S[i])-96
from collections import Counter
b=Counter(a)
c=b.most_common()
if c[0][1]>=2:
    print((2**(N-1)+1)%(10**9+7))
else:
    print((2**N-1)%(10**9+7))

Submission status: Wrong Answer

Solution code:
import itertools
#a,b = map(int, input().split())
n=int(input())
A=input()
d={}
for i in A:
    if i not in d:
        d[i]=1
    else:
        d[i]+=1
#print(d)
#print(len(d))
arr=[]
#for i in range(len(d)):
for value in d.values():
    arr.append(value)
#    print(value)
value=0
for num in range(len(arr)):
    for v in itertools.combinations(arr, num+1):
        tmp=1
        for i in v:
            tmp*=i
        value+=tmp
print(value)

Submission status: Wrong Answer

Solution code:
n=int(input())
s = input()

m={}

for c in s:
    if c not in m:
        m[c]=1
    else:
        m[c]+=1
        
ans=1

for k in m.keys():
    ans*=(m[k]+1)

print(ans-1)

Submission status: Wrong Answer

Solution code:
mod = int(10**9+7)
N = int(input())
S = input()
S = list(S)
alp = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
cnt = [S.count(c) for c in alp]
ans = 1
for i in range(len(cnt)):
    ans *= (cnt[i]+1) % mod
print(ans-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
sum = 0


sum = 2 ** N - 1

print(sum)

Submission status: Wrong Answer

Solution code:
import numpy as np
from sys import stdin
N=int(stdin.readline().rstrip())
S=(stdin.readline().rstrip())
S=list(S)
ans=N**2-2**(((N-len(set(S))))+1)
print(ans%(10**9+7))

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
S = list(input())

c = collections.Counter(S)
v = c.values()
count = 1
for v in c.values():
    count *= (v+1)
print(count-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
ans = 1
for c in range(ord('a'), ord('z') + 1):
  ans *= S.count(chr(c)) + 1
print(ans-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
S = list(S)
alp = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
cnt = [S.count(c) for c in alp]
ans = 1
for i in range(len(cnt)):
    ans *= (cnt[i]+1)
print(ans-1)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(input())
a=[0]*N
for i in range(N):
    a[i]=ord(S[i])-96
from collections import Counter
b=Counter(a)
c=b.most_common()
if c[0][1]>=2:
    print(2**(N-1)+1)
else:
    print(2**N-1)

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
S = list(input())

c = collections.Counter(S)
v = c.values()
count = 1
for v in c.values():
    count *= (v+1)
print(count)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
s = input()
t = collections.Counter(s)
u = list(set(s))
cnt = 1
for i in range(len(u)):
    cnt *= t[u[i]]+1
print(cnt-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [i for i in str(input())]
import collections
c = collections.Counter(s)
ans = 1
for v in c.values():
    ans = ans * (v+1)
ans = ans - 1
ans = ans % (10^9 + 7)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = str(input())
dic = {'a':0,'b':0,'c':0,'d':0,'e':0,'f':0,'g':0,'h':0,'i':0,'j':0,'k':0,'l':0,'m':0,'n':0,'o':0,'p':0,'q':0,'r':0,'s':0,'t':0,'u':0,'v':0,'w':0,'x':0,'y':0,'z':0}

ans = 1

for i in range(N):
	dic[S[i]] += 1

for key in list(dic.keys()):
	if dic[key] == 0:
		continue
	else:
		ans *= (dic[key]+1)

print(str(ans-1))

Submission status: Wrong Answer

Solution code:
import collections

def solve():
    N=int(input())
    S=list(input())
    c=collections.Counter(S)
    ans=1
    for k in c.keys():
        ans*=c[k]+1
    return ans-1

print(solve())

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

MOD = int(1e9) + 7


def power(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x % MOD
    elif y % 2 == 0:
        return power(x, y//2)**2 % MOD
    else:
        return power(x, y//2)**2 * x % MOD


def div(a, b):
    return a * power(b, MOD-2) % MOD


inv = [1] * 1000001
inv[1000000] = div(1, 2**1000000)
for i in range(1000000-1, -1, -1):
    inv[i] = inv[i+1] * 2 % MOD


def main():
    N = int(input())
    S = input()
    cnt = defaultdict(lambda: 0)
    ans = 1
    for c in S:
        ans = (ans + ans * inv[cnt[c]]) % MOD
        cnt[c] += 1
    print(ans-1)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
ans = 1
for i in range(97, 97+26):
    n = S.count(chr(i))
    ans = ans * (n+1)
print(ans -1)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [i for i in str(input())]
import collections
c = collections.Counter(s)
ans = 1
for v in c.values():
    ans = ans * (v+1)
ans = ans - 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()

D = {}
for s in S :
    if s not in D :
        D[s] = 1
    else :
        D[s] += 1

L = list(D.values())
ans = 1
for i in range(len(L)) :
    if L[i] == 1 :
        ans *= 2
    else :
        ans *= (2**L[i]-1)
ans -= 1
ans %= (10**9+7)
print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial

N = int(input())
S = input()

D = {}
for s in S :
    if s not in D :
        D[s] = 1
    else :
        D[s] += 1

L = list(D.values())
ans = 1
for i in range(len(L)) :
    if L[i] == 1 :
        ans *= 2
    else :
        ans *= (2**L[i]-1)
ans -= 1
print(ans)

Submission status: Wrong Answer

Solution code:
#Counter
n=int(input())
s=input()
from collections import Counter
cs=Counter(list(s))
a=list(cs.values())
t=a[0]
for i in range(1,len(a)):
    t+=a[i]*(1+t)
print(t)