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: Accepted

Solution code:
import collections
from functools import reduce
N=int(input())
S=input()
c=collections.Counter(S)
d=map(lambda x:x+1,list(c.values()))
print((reduce(lambda x,y:x*y,d)-1)%1000000007)

Submission status: Accepted

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

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

ans = 1
for v in S_dict.values():
    ans *= (v + 1)
    ans %= mod

print(ans - 1)

Submission status: Accepted

Solution code:
MOD = 1000000007
N = int(input())
S = input()
ans = 1
for c in "abcdefghijklmnopqrstuvwxyz":
  ans *= (S.count(c) + 1)
  ans %= MOD
ans = (ans - 1 + MOD) % MOD
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
MOD = 10**9 + 7
n = int(input())
s = input()

d = defaultdict(int)
for i in range(n):
    d[s[i]] += 1

ans = 1
for c in d:
    ans *= d[c] + 1
    ans %= MOD
ans -= 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
A = [chr(ord('a') + i) for i in range(26)]
B = []
for i in range(26):
  B.append(s.count(A[i]))
c = len(B)
ans = 1
for i in range(c):
  ans = ans*(B[i]+1)
print((ans-1)%(10**9+7))

Submission status: Accepted

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

alpha="abcdefghijklmnopqrstuvwxyz"
MOD=10**9+7

c=[0]*26

for i in range(N):
    c[alpha.index(S[i])]+=1
ans=1
for i in range(26):
    ans*=c[i]+1

ans=(ans-1)%MOD
print(ans)

Submission status: Accepted

Solution code:
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    s = str(input().rstrip('\n'))
    s = collections.Counter(s).most_common()
    t = 1
    for k, v in s:
        t = (t * (v + 1)) % (10 ** 9 + 7)
    print(t - 1)


if __name__ == '__main__':
    slove()

Submission status: Accepted

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

abc = "abcdefghijklmnopqrstuvwxyz"

ans = 1
for i in abc:
    ans *= s.count(i)+1
print((ans-1)%(10**9+7))

Submission status: Accepted

Solution code:
n,s=open(0);a=1
for c in set(s.strip()):a*=s.count(c)+1
print(~-a%(10**9+7))

Submission status: Accepted

Solution code:
from collections import defaultdict

if __name__ == '__main__':
    mod = 10**9 +7
    N = int(input())
    S = str(input())

    letter = defaultdict(int)
    letter_count = defaultdict(int)
    count = 0
    for i in range(N):
        new_count = count + 1
        new_count -= letter[S[i]] #今まで追加文字が使われている組み合わせはNG
        count += new_count
        letter[S[i]] += new_count #追加文字が追加されたことによる組み合わせ増分を増やす
        #追加文字による、他のある文字が使われる組み合わせの増加は
        #今まである文字が使われていた組み合わせの数-ある数が使われていてかつ追加文字が含まれている組み合わせ
        for key in letter:
            if key != S[i]:
                letter[key] += letter[key]//(1 + letter_count[S[i]])
        letter_count[S[i]] += 1
    print(count%mod)

Submission status: Accepted

Solution code:
from collections import defaultdict
if __name__ == '__main__':
    mod = 10**9 +7
    N = int(input())
    S = str(input())
    
    letter = defaultdict(int)
    for i in range(N):
        letter[S[i]] += 1
    count = 1
    for c in letter:
        count *= (letter[c]+1)
        count %= mod
    print(count-1)

Submission status: Accepted

Solution code:
def mul(a,b,p):
    return ((a % p) * (b % p)) % p

def div(a,b,p):
    return mul(a, power_func(b, p-2,p),p)

def power_func(a,n,p):
  bi=str(format(n,"b"))
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res

modp = 1000000007
_ = input()
s = input()
d = dict()
for c in s:d[c] = d.get(c,0)+1

g = power_func(2,len(d),modp)
g = (g+modp-1) % modp

for c in sorted(d.keys()):
    subsubg = div((g+1)%modp,2,modp)
    subg = (subsubg % modp) * ((d[c]-1)%modp) % modp
    g = (g + subg) % modp
print(g)

Submission status: Accepted

Solution code:
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    s = collections.Counter(str(input().rstrip('\n')))
    cnt = 1
    for k, v in s.items():
        cnt *= (v + 1)
        cnt %= (10 ** 9 + 7)
    print(cnt - 1)


if __name__ == '__main__':
    slove()

Submission status: Accepted

Solution code:
n = int(input())
s = input()
abc = "abcdefghijklmnopqrstuvwxyz"
ans = 1
for i in abc:
    ans *= s.count(i)+1
print((ans-1)%(10**9+7))

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = input()
    mod = pow(10, 9) + 7
    d = dict()
    for c in S:
        d[c] = d.get(c, 0) + 1
    ans = 1
    for c in d:
        ans *= (d[c]+1)
        ans %= mod
    return (ans - 1) % mod


if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
from collections import defaultdict

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

counter = defaultdict(int)
for s in S:
    counter[s] += 1

ans = 1
for v in counter.values():
    ans *= v + 1
    ans %= MOD
print(ans - 1)

Submission status: Accepted

Solution code:
MOD = 10 ** 9 + 7
from collections import Counter
input()
cs = Counter(input())

ans = 1
for i in cs.values():
  ans *= (i+1)
ans -= 1
print(ans % MOD)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


def main():
    from collections import Counter

    n = int(input())
    s = Counter(input())
    ans = 1
    mod = 10 ** 9 + 7

    # See:
    # https://www.youtube.com/watch?v=g2LMI15ha_U

    # Key Insight
    # 要素がすべて異なる=各要素が1個以下になるように選ぶ
    # それぞれの要素を独立に考えられる
    for index, count in s.items():
        # 選び方：ある文字の個数 + ある文字を選ばない(1通り)
        ans *= count + 1
        ans %= mod

    # すべての文字の積 - すべて選ばない(1通り)
    print(ans - 1)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
s=list(input())
mod=10**9+7
al="abcdefghijklmnopqrstuvwxyz"
ans=1
for i in range(26):
    c=al[i]
    ans*=(s.count(c)+1)
    ans%=mod

print(ans-1)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#AGC31 A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
s = input()
t = list(Counter(s).items())
ans = 1
for i,j in t:
    ans *= j+1
    ans %= mod
ans -= 1
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
N = int(input())
S = list(input())
MOD = 10 ** 9 + 7

dic = defaultdict(int)

for i in S:
    dic[i] += 1

ans = 1
for i in dic:
    ans *= dic[i] + 1
    ans %= MOD

print (ans - 1)

Submission status: Accepted

Solution code:
from collections import Counter

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

counter=Counter(S)

mod=10**9+7
ans=1

for v in counter.values():
  ans=(ans*(v+1))%mod
print((ans-1)%mod)

Submission status: Accepted

Solution code:
import collections
n = int(input())
s = collections.Counter(list(input())).most_common()

cnt = 1
for i in s:
    cnt *= ((i[1] + 1) % (10 ** 9 + 7))
print((cnt - 1) % (10 ** 9 + 7))

Submission status: Accepted

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

s_list = collections.Counter(S)
s_list = list(s_list.items())
ans = 1
for i in range(len(s_list)):
    ans *= (s_list[i][1]+1)
    ans %= 10**9+7

print(ans-1)

Submission status: Accepted

Solution code:
from collections import Counter

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

words = Counter(s).values()

ans = 1
for i in words:
    ans *= i+1

print((ans-1)%(10**9+7))

Submission status: Accepted

Solution code:
import collections
n = int(input())
s = collections.Counter(list(input())).most_common()
cnt = 1
for i in s:
    cnt *= ((i[1] + 1) % (10 ** 9 + 7))
print((cnt - 1) % (10 ** 9 + 7))

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline

N = int(input())
S = input().strip()
h = {}
for c in S:
    if c in h:
        h[c] += 1
    else:
        h[c] = 1

ans = 1
for v in h.values():
    ans *= v+1
ans -= 1

print(ans%(10**9+7))

Submission status: Accepted

Solution code:
from collections import Counter 

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

MOD = 10 ** 9 + 7
C = Counter(S)

ans = 1
for ch in C:
    ans *= C[ch] + 1
    ans %= MOD
ans = (ans - 1) % MOD
print(ans)

Submission status: Accepted

Solution code:
n,s=open(0);a=1
for x in range(26):a*=-~s.count(chr(97+x))
print(~-a%(10**9+7))

Submission status: Accepted

Solution code:
import collections
n = int(input())
s = collections.Counter(input()).values()
t = 1
for i in s:
    t = t * (i + 1) % (10 ** 9 + 7)
print((t - 1))

Submission status: Accepted

Solution code:
import itertools
num2alpha = lambda c: chr(c+64)
alpha2num = lambda c: ord(c) - ord('A') + 1

N = int(input())
S = list(input())
S_unique = list(set(S))
S_kind = len(S_unique)

count_list = [0] * 27

for i in range(1,27):
    tmp = num2alpha(i).lower()
    count = S.count(tmp)
    count_list[i] = count % 1000000007

count_list_new = []
for i in range(len(count_list)):
    if count_list[i] != 0:
        count_list_new.append(count_list[i]+1)

#print(count_list_new)
ans = 1
for i in range(len(count_list_new)):
    ans *= count_list_new[i] % 1000000007

ans -= 1
print(ans % 1000000007)

Submission status: Accepted

Solution code:
# AGC031A - Colorful Subsequence
from collections import Counter


def main():
    _ = int(input())
    S = input().rstrip()
    MOD = 10 ** 9 + 7
    ans = 1
    for i in Counter(S).values():
        ans *= i + 1
        ans %= MOD
    print(ans - 1)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# AGC031A - Colorful Subsequence
def main():
    _ = int(input())
    S = input().rstrip()
    MOD = 10 ** 9 + 7
    ans = 1
    for i in set(S):
        ans *= S.count(i) + 1
    print(ans % MOD - 1)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# AGC031A - Colorful Subsequence
from functools import reduce


def main():
    _ = int(input())
    S = input().rstrip()
    MOD = 10 ** 9 + 7
    C = [S.count(i) + 1 for i in set(S)]
    ans = reduce(lambda x, y: (x * y) % MOD, C)
    print(ans - 1)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# AGC031A - Colorful Subsequence
def main():
    _ = int(input())
    S = input().rstrip()
    MOD = 10 ** 9 + 7
    ans = 1
    for i in set(S):
        ans = (ans * (S.count(i) + 1)) % MOD
    print(ans - 1)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# AGC031A - Colorful Subsequence
def main():
    _ = int(input())
    S = input().rstrip()
    MOD = 10 ** 9 + 7
    ans = 1
    for i in set(S):
        ans *= S.count(i) + 1
        ans %= MOD
    print(ans - 1)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a = int(input())
b = input()
c = {}
for i in range(a):
    if b[i] not in c:
        c[b[i]] = 1
    else:
        c[b[i]] += 1
d = 1
for k in c.keys():
    d = (d * (c[k] + 1)) % (10 ** 9 + 7)
print(d - 1)

Submission status: Accepted

Solution code:
from collections import defaultdict
mod = 10**9+7
N = int(input())
S = input()
# N = 100000
# S = "qwertyuioasdfghjklzxcvbnm"


char_dict = defaultdict(int)
for s in S:
    char_dict[s] += 1

# print(char_dict)
char_list = list(char_dict.values())
char_num = len(char_list)
# print(char_num)
# print(char_list)

ans = 1
for i in char_list:
    ans *= i + 1
    ans %= mod

print(ans-1)

Submission status: Accepted

Solution code:
a = int(input())
b = input()
c = {}
for i in range(a):
    if b[i] not in c:
        c[b[i]] = 1
    else:
        c[b[i]] += 1
d = 1
for k in c.keys():
    d = (d * (c[k] + 1)) % (10 ** 9 + 7)
d -= 1
print(d)

Submission status: Accepted

Solution code:
S=input()
S=input()
ans=1
c=[1]*26
for i in S:
        c[ord(i)-ord('a')]+=1
for i in c:
        ans*=i
print(ans%1000000007-1)

Submission status: Accepted

Solution code:
a = int(input())
b = list(input())
c = {}
for i in range(a):
    if b[i] not in c:
        c[b[i]] = 1
    else:
        c[b[i]] += 1
ans = 1
for v in c.values():
    ans *= (v + 1)
print((ans - 1) % (10 ** 9 + 7))

Submission status: Accepted

Solution code:
n = input()
s = list(input())
import collections
s = collections.Counter(s)
s = s.most_common()
ans = 1
for i in s:
  ans *= i[1]+1
  
print((ans-1)%1000000007)

Submission status: Accepted

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
MOD = 10**9 + 7
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

N = ii()
S = input()
num = [0 for _ in range(26)]

for c in S:
  num[ord(c) - ord('a')] += 1


ans = 1
for each in num:
  ans *= (1 + each)
  ans %= MOD

print(ans - 1) #1つも取らない場合を引く

Submission status: Accepted

Solution code:
from collections import Counter

MOD = 10**9 + 7

N = int(input())
Ss = input()

cnt = Counter(Ss)

ans = 1
for key, num in cnt.items():
    ans *= num+1
    ans %= MOD

print(ans-1)

Submission status: Accepted

Solution code:
from collections import Counter
if __name__ == "__main__":
    n = int(input())
    s = list(input())
    cnt = Counter(s)
    ans = 1
    for i in cnt.values():
        ans *= int(i)+1
        ans = ans%(10**9+7)
    print(ans%(10**9+7)-1)

Submission status: Accepted

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

MOD = int(1e9) + 7

d = {}
for i in range(N):
    if S[i] in d:
        d[S[i]] += 1
    else:
        d[S[i]] = 1

v = d.values()
ans = 1
for i in v:
    ans *= i+1
    ans %= MOD
ans -= 1
ans %= MOD
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin

N = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

inf = 10 ** 9 + 7
ans = 1

alphabet = [x for x in 'abcdefghijklmnopqrstuvwxyz']
count = [1 for _ in range(26)]

for i in range(len(s)):
    count[alphabet.index(s[i])] += 1

for j in count:
    ans = ans * j % inf

print(ans - 1)

Submission status: Accepted

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

d = {}
for i in s:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1


ans = 1
for i in d:
    ans *= d[i]+1

print((ans-1)%(10**9+7))

Submission status: Accepted

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

char2count = {}
for s in S:
    if s not in char2count:
        char2count[s] = 0
    char2count[s] += 1

total = 1
for x in char2count.values():
    total *= (x + 1)
print((total - 1) % (1000000000 + 7))

Submission status: Accepted

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

from collections import Counter

counter = Counter(list_s)

LARGE_NUM = 10**9 + 7

result = 1
for _, cnt in counter.items():
    result *= cnt+1
    result %= LARGE_NUM
print(result-1)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
from collections import defaultdict, deque
import math
from math import factorial
import re

BIGNUM = 10 ** 9 + 7

def main():
    #N, K = map(int, input().split())
    N = int(input())
    S = list(input())

    nums = defaultdict(int)
    for s in S:
        nums[s] += 1

    result = 1
    for n in nums.values():
        result *= (n + 1)
        result = result % BIGNUM
    result = (result - 1) % BIGNUM
    print(result)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

count = [1] * 26

for i in range(n):
	temp = ord(s[i]) -  ord("a")
	count[temp] += 1

ans = 1
for i in range(26):
	ans *= count[i]
print((ans - 1) % (10**9+7))

Submission status: Accepted

Solution code:
N = int(input())
S = input()
dict = {}
for s in S:
    if s in dict:
        dict[s] += 1
    else:
        dict[s] = 1
ans = 1
for d in dict.values():
    ans *= (d+1)
print((ans-1) % (10 ** 9 + 7))

Submission status: Accepted

Solution code:
from collections import Counter

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

nums = Counter(S).most_common()

mod = 10 ** 9 + 7
cnt = 1
for i, j in nums:
    cnt *= (j + 1)
    cnt %= mod

print(cnt - 1)

Submission status: Accepted

Solution code:
from collections import Counter

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

nums = Counter(S).most_common()

mod = 10 ** 9 + 7
cnt = 1
for i, j in nums:
    cnt *= (j + 1)
    cnt %= mod

print((cnt - 1) % mod)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
S = input()
Co = Counter(S).values()
ans = 1
mod = 10**9+7
for i in Co:
    #print(i)
    if i == 1:
        ans = (ans*2) % mod
    else:
        ans = (ans*(i+1)) % mod
print(ans-1)

Submission status: Accepted

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

num = {}
for s in S:
    if s in num.keys():
        num[s] += 1
    else:
        num[s] = 1

ans = 1
for n in num.values():
    ans = int(ans * (n+1) % (1E9+7))

ans -= 1

print(ans)

Submission status: Accepted

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

for s in set(S):
    ans*=S.count(s)+1

print((ans-1)%1000000007)

Submission status: Accepted

Solution code:
n=int(input())
ss=input()
mod=1000000007
s=[]
for i in range(n):
    s.append(ss[i])
s.sort()
x=s[0]
l=[]
count=1
for i in range(1,n):
    if x==s[i]:
        count+=1
        if i==n-1:
            l.append(count%mod)
    else:
        l.append(count%mod)
        count=1
        x=s[i]
        if i==n-1:
            l.append(count%mod)

y=len(l)
m=1
#print(l)
for i in range(y):
    m=m*(l[i]+1)%mod
print((m-1)%mod if n>1 else 1)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
MOD = 10**9 + 7

l = []
cnt = []
for i in s:
    x = 0
    if i not in l:
        l.append(i)
        x = s.count(i)
        cnt.append(x)
#print(l,cnt)
ans = 1
if n == 1:
    print(ans)
else:
    for x in cnt:
        if x == 1:
            ans *= 2
        else:
            ans *= (x+1)
    print((ans-1)%MOD)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = list(input())

c = Counter(S)

ans = 1
for cc in c.values():
    ans = (ans*(cc+1))%(10**9+7)
print(ans-1)

Submission status: Accepted

Solution code:
from collections import Counter

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

a = Counter(S)
ans = 1
for i in a.keys():
    ans *= (a[i]+1)

print((ans-1)%(10**9+7))

Submission status: Accepted

Solution code:
n,s=int(input()),sorted(list(input()))
count=[]
cnt=0
for i in range(n-1):
    if s[i]==s[i+1]:
        cnt+=1
    else:
        count.append(cnt+2)
        cnt=0
count.append(cnt+2)
ans=1
for i in range(len(count)):
    ans*=count[i]
    ans%=10**9+7
print(ans-1)

Submission status: Accepted

Solution code:
import collections as c;from functools import reduce as r;n=input()
print(r(lambda x,y:x*y,[i+1 for i in list((c.Counter(input())).values())])%(10**9+7)-1)

Submission status: Accepted

Solution code:
import collections as c
n=int(input())
s=input()
a=[i+1 for i in list((c.Counter(s)).values())]
f=1
for i in range(len(a)):
  f=(f*a[i])%(10**9+7)
print(f-1)

Submission status: Accepted

Solution code:
n = input()
s = input()
mod = 10**9+7
chara_list = [1 for i in range(26)]
for i in s:
    chara_list[ord(i)-97] += 1


ans = 1
for i in chara_list:
    ans = (ans*i)%mod
print(ans-1)

Submission status: Accepted

Solution code:
from string import ascii_lowercase
from functools import reduce

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

cnt = [S.count(a) for a in ascii_lowercase]

print(reduce(lambda x, y: x * (y + 1) % (10 ** 9 + 7), cnt, 1) - 1)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
mod=10**9+7
ans=1
lets=[1]*26
for i in s:
  lets[ord(i)-97]+=1
for i in range(26):
  ans*=lets[i]
  ans%=mod
print(ans-1)

Submission status: Accepted

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

mod=10**9+7
ans=1

t='abcdefghijklmnopqrstuvwxyz'
#print(len(t))

for i in range(26):
  ans*=s.count(t[i])+1
  ans=ans%mod
  
print(ans-1)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
cnt = [1 for i in range(26)]
for i in range(n):
    cnt[ord(s[i])-97] += 1
ans = 1
for i in range(26):
    ans = (ans * cnt[i])%(10**9+7)
print(ans-1)

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
s = input()
counter = Counter(s)
ans = 1

for char, count in counter.items():
    if count != 1:
        ans = ans * (count + 1) % (10 ** 9 + 7)
    else:
        ans = ans * 2 % (10 ** 9 + 7)
print(ans - 1)

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
S = input()
MOD = 10**9 + 7
cnt = Counter(S)
ans = 1
for n in cnt.values():
    ans *= n+1 % MOD
    ans %= MOD
ans -= 1
ans %= MOD
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
N=int(input())
S=input()

ans = 1
mod = 10**9+7
for v in Counter(S).values():
    ans = ans * (v+1) % mod
print(ans-1)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
a=sorted(set(s))
ans=1
for x in a:
    ans*=(s.count(x)+1)
print((ans-1)%(10**9+7))

Submission status: Accepted

Solution code:
MOD = 10 ** 9 + 7
from collections import Counter
input()
c = Counter(input())

x = 1
for v in c.values():
  x *= (v+1)

answer = x - 1
print(answer%MOD)

Submission status: Accepted

Solution code:
from collections import Counter
from operator import mul
from functools import reduce

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

char_num = Counter(list(S))
cnt = reduce(mul, [c+1 for c in char_num.values()]) - 1
print(cnt % (10**9+7))

Submission status: Accepted

Solution code:
from collections import Counter
Mod = 10**9+7
n = int(input())
k = 1
for x in Counter(input()).values():
  k = k*(x+1)%Mod
print((k-1)%Mod)

Submission status: Accepted

Solution code:
Mod = 10**9+7
n = int(input())
s = input()
k = 1
for i in range(97,97+26):
  k = (k * (s.count(chr(i))+1))%Mod
print((k-1)%Mod)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
al=[chr(ord('a')+i) for i in range(26)]
d={x:0 for x in al}
for x in s:
    d[x]+=1
ans=1
mod=10**9+7
for x in al:
    ans*=(d[x]+1)
    ans%=mod
print((ans-1)%mod)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
a = [1]*26
for c in s:
    a[ord(c)-ord("a")]+=1
ans = 1
for i in range(len(a)):
    ans *= a[i]
ans = (ans-1)%(10**9+7)
print(ans)

Submission status: Accepted

Solution code:
from collections import *
from functools import *

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

counter_s = map(lambda x: x + 1, Counter(s).values())
ans = reduce(lambda x, y: (x * y) % (10 ** 9 + 7), counter_s)

print(ans - 1)

Submission status: Accepted

Solution code:
from collections import *
from functools import *

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

counter_s = [i[1] + 1 for i in Counter(s).most_common()]
ans = reduce(lambda x, y: (x * y) % (10 ** 9 + 7), counter_s)

print(ans - 1)

Submission status: Accepted

Solution code:
from collections import *
from operator import *

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

counter_s = Counter(s).most_common()
ans = 1
for i in counter_s:
    ans = (ans * (i[1] + 1)) % (10 ** 9 + 7)

ans -= 1
print(ans)

Submission status: Accepted

Solution code:
from functools import reduce

N = int(input())
MOD = 10**9 + 7

def mul(a, b):
    return ((a % MOD)*(b % MOD)) % MOD

cnt = {}
for b in input():
    cnt[b] = cnt[b] + 1 if b in cnt else 2

print(reduce(mul, cnt.values()) - 1)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = Counter([s for s in input()])
MOD = 10**9 + 7
ans = 1
for l in S:
    ans *= S[l]+1
    ans %= MOD
print(ans-1)

Submission status: Accepted

Solution code:
import collections
M=10**9+7
N=int(input())
S=list(input())
A=list(collections.Counter(S).values())
ans=1
for i in A:
    ans*=i+1%M
    ans=ans%M
print(ans-1)

Submission status: Accepted

Solution code:
n = int(input())
s = str(input())
cnt = {}
for i in s:
    if i in cnt:
        cnt[i] += 1
    else:
        cnt[i] = 1
ans = 1
for i in cnt:
    ans = ans * (cnt[i] +1)
ans -= 1
print(ans % (10**9 + 7))

Submission status: Accepted

Solution code:
str_len = int(input())
string = input()
string_set = set(string)
ans = 1
for i in string_set:
  ans *= (string.count(i) + 1)
print((ans - 1) % ((10**9) + 7))

Submission status: Accepted

Solution code:
from functools import reduce
N = int(input())
DIV = 10**9 + 7
S = {chr(i): 0 for i in range(ord('a'), ord('z') + 1)}
for c in input():
    S[c] += 1
print(reduce(lambda acc, n: acc * (n + 1) % DIV, S.values(), 1) - 1)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
m=list(set(s))
ans=1
for i in m:
    ans*=s.count(i)+1
print((ans-1)%(10**9+7))

Submission status: Accepted

Solution code:
n=int(input())
s=input()
m=list(set(s))
ans=1
for i in m:
    ans*=s.count(i)+1
print((ans-1)%(10**9+7))

Submission status: Accepted

Solution code:
import collections as cl


N = int(input())
S_lst = list(input())

counter_dic = dict(cl.Counter(S_lst))

ans = 1
for i in counter_dic.values():
    ans *= i + 1

ans -= 1
ans %= 10**9 + 7

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

N=int(input())
S=input()
INF=int(1e9+7)
dict=defaultdict(int)
for i in S:
    dict[i]+=1
l=list(dict.values())
ans=1
for i in l:
    ans*=(i+1)
    ans%=INF
print(ans-1)

Submission status: Accepted

Solution code:
import collections
N = int(input())
S = input()
dic = collections.Counter(S)
mod = 10**9 + 7
ans = 1
for i in dic.values():
    ans *= (i+1)
    ans %= mod
ans -= 1
ans %= mod
print(ans)

Submission status: Accepted

Solution code:
N = input()
c = [1]*("z".encode()[0]-"a".encode()[0]+1)
for x in map(lambda x: x-"a".encode()[0], input().encode()):
	c[x] += 1

m = 1
for x in c:
  m = (m * x) % (1e9+7)

print("{:.0f}".format(m-1))

Submission status: Accepted

Solution code:
n = int(input())
s = input()
N = 10 ** 9 + 7
d = {}

for c in s:
  if c in d:
    d[c] += 1
  else:
    d[c] = 1

ans = 1

for c in d:
  ans = ans * (d[c] + 1) % N
    
print(ans - 1)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = input()
S = Counter(S).most_common()
MOD = 10**9 + 7
ans = 1
for k, v in S:
    ans *= (v+1)
    ans %= MOD
print(ans-1)

Submission status: Accepted

Solution code:
from sys import stdin
from collections import Counter
N = int(stdin.readline().rstrip())
S = Counter(stdin.readline().rstrip()).most_common()
MOD = 10**9+7
ans = 1
for k, v in S:
    ans *= (v+1)
    ans %= MOD
print(ans-1)

Submission status: Accepted

Solution code:
from collections import Counter
MOD = 10**9 + 7
n = int(input())
s = input().rstrip()
cnt = Counter(s)
ans = 1
for key in cnt.keys():
    ans *= (cnt[key] + 1)
    ans %= MOD
print(ans - 1)

Submission status: Accepted

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

char_dic = {}
for i in range(N):
  char = S[i]
  if char not in char_dic:
    char_dic[char] = 2
  else:
    char_dic[char] += 1
    
prod = 1
for key in char_dic:
  prod *= char_dic[key]
  
print((prod-1)%(10**9+7))

Submission status: Accepted

Solution code:
N = int(input())
S = input()
MOD = 10**9+7

alp = "qwertyuiopasdfghjklzxcvbnm"

ans = 1

for c in alp:
    n = 0
    for i in range(N):
        if S[i] == c:
            n += 1
    ans *= n+1
    ans = ans % MOD
    
print(ans-1)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
d={}
for i in "abcdefghijklmnopqrstuvwxyz":
    d[i] = s.count(i)+1
ans = 1
for i in d:
    ans = (d[i] * ans)%(10**9+7)
print(ans-1)

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    S = input()
    MOD= int(1e9)+7

    from collections import Counter
    c = Counter(S)
    ans = 1
    for k in c.keys():
        ans = (ans * (c[k] + 1)) % MOD
    ans = (ans - 1) % MOD

    print(ans % MOD)

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

p = 1
ccnt = [0]*26
MOD = 10**9 + 7

for i in range(N):
    index = ord(S[i])-ord("a")
    ccnt[index] += 1
for i in range(26):
    ccnt[i] += 1

ans = 1
for i in range(26):
    ans *= ccnt[i]
    ans = ans % MOD

print(ans-1)

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
s=input()
sc=Counter(s).most_common()
ans=1
for i,j in sc:
    ans=ans*(j+1)%1000000007
print(ans-1)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
alphabets = "abcdefghijklmnopqrstuvwxyz"
ans = 1
for alphabet in alphabets:
    cnt = S.count(alphabet)
    ans *= (cnt+1)
ans -= 1
print(ans%(10**9+7))

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
s = list(set(S))
L = [0 for i in range(len(s))]
for i in range(len(s)):
    L[i] = S.count(s[i]) + 1
a = 1
for i in range(len(s)):
    a *= L[i]
print((a - 1) % (10 ** 9 + 7))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np
# import sys
# sys.setrecursionlimit(10**4)
from collections import Counter

def _li(): return list(map(int, stdin.readline().split()))
def _li_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def _lf(): return list(map(float, stdin.readline().split()))
def _ls(): return stdin.readline().split()
def _i(): return int(stdin.readline())
def _f(): return float(stdin.readline())
def _s(): return stdin.readline()[:-1]


MOD = 10**9 + 7
N = _i()
S = list(_s())

s_count = Counter(S)
ans = 1
for _, i in s_count.items():
    ans *= (i+1)
    ans %= MOD
print((ans - 1) % MOD)

Submission status: Accepted

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


prod = 1
for char in set(s):
    num = s.count(char)
    prod *= (num + 1)

print((prod - 1) % (pow(10, 9) + 7))

Submission status: Accepted

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


def char_to_int(c):
    return ord(c) - 97


char_counts = [0 for _ in range(26)]
for c in S:
    i = char_to_int(c)
    char_counts[i] = char_counts[i] + 1

ans = 1
for i in char_counts:
    ans = ans * (i + 1)
ans = (ans - 1) % (10 ** 9 + 7)
print(ans)

Submission status: Accepted

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


prod = 1
for char in set(s):
    num = s.count(char)
    prod *= (num + 1)

print((prod - 1) % (pow(10, 9) + 7))