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
n=int(input())
S=[i for i in input()]
c=collections.Counter(S)
ans=1
for s in set(S):
  ans*=c[s]+1
print((ans-1)%(10**9+7))

Submission status: Accepted

Solution code:
n = int(input())
s = str(input())
l = []
for x in s:
    if x not in l:
        l.append(x)
ans = 1
for x in l:
    ans = ans*(s.count(x)+1)
ans -= 1
ans = ans%(10**9 + 7)
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
S=input()
MOD=10**9+7
count_char={}
for s in S:
    if s not in count_char:
        count_char[s]=1
    else:
        count_char[s]+=1
ans=1
for k,ct in count_char.items():
    ans*=ct+1
    ans%=MOD
ans+=MOD-1
ans%=MOD
print(ans)

Submission status: Accepted

Solution code:

from collections import defaultdict

def main():
    num = int(input())
    data = list(input())

    count_dic = defaultdict(int)

    for i in range(num):
        count_dic[data[i]] += 1

    count_list = list(count_dic.values())

    ans = 1
    for ele in count_list:
        ans *= ele + 1

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





if __name__ == '__main__':
    main()

Submission status: Accepted

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

print((ans - 1) % mod)

Submission status: Accepted

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

print((ans - 1) % mod)

Submission status: Accepted

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

c = [1 for i in range(26)]

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

ans = 1
for i in range(len(c)):
    ans *= c[i]
    ans %= 10**9+7

print(ans-1)

Submission status: Accepted

Solution code:
from collections import Counter
c=Counter()
N=int(input())
c=Counter(input())
ans=1
for i,b in c.items():
    if b>1:
        ans*=(b+1)
    else:
        ans*=2
print(int((ans-1)%(10**9+7)))

Submission status: Accepted

Solution code:
input();s=input();a=set(s)
c=1
for i in a:c=c*(s.count(i)+1)%(10**9+7)
print(c-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

dic = {}

for i in range(N):
    dic.setdefault(S[i], 0)
    dic[S[i]] += 1
s = list(dic.values())
ans = 1
for i in s:
    ans = ans * (i + 1) % (10 ** 9 + 7)

print(ans - 1)

Submission status: Accepted

Solution code:
n=int(input())
dic={}
l=list(input())
for i in range(n):
    dic.setdefault(l[i],0)
    dic[l[i]]+=1
s=list(dic.values())
ans=1
mod=10**9+7
for i in s:
    ans*=(i+1)%mod
print((ans-1)%mod)

Submission status: Accepted

Solution code:
def colorful_subsequence(N: int, S: str)->int:
    MOD = (10 ** 9) + 7
    cum = {}
    for c in S:
        cum.setdefault(c, 0)
        cum[c] += 1

    values = list(cum.values())
    count = 1
    for v in values:
        count *= (1 + v)
        count %= MOD

    return (count-1) % MOD


if __name__ == "__main__":
    N = int(input())
    S = input()
    ans = colorful_subsequence(N, S)
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
l = list(set(S))
ans = 1
for v in l:
  ans *= S.count(v) + 1
print((ans-1) % (pow(10, 9) + 7))

Submission status: Accepted

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

appear={}

for i in range(N):
  appear.setdefault(S[i],0)
  appear[S[i]]+=1

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
alphabet = "abcdefghijklmnopqrstuvwxyz"
ans = 1

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

Submission status: Accepted

Solution code:
n=int(input())
s=input()
cnt=[0]*26
cnt2=[]
ans=1
check='abcdefghijklmnopqrstuvwxyz'
for i in range(n):
  for j in range(26):
    if s[i]==check[j]:
      cnt[j]+=1
      break
for i in range(26):
  if cnt[i]!=0:
    cnt2.append(cnt[i])
for i in range(len(cnt2)):
  ans*=(cnt2[i]+1)
  ans=ans%(10**9+7)
print(ans-1)

Submission status: Accepted

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

mod = 10**9+7
query = "abcdefghijklmnopqrstuvwxyz"
ans = 1

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

Submission status: Accepted

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

nums = {}
for s in S:
    if not s in nums:
        nums[s] = 0
    nums[s] += 1
ans = 1
for n in nums.values():
    ans *= (n + 1)
    ans %= int(1e9 + 7)
ans = (ans + int(1e9 + 7 - 1)) % int(1e9 + 7)

print(ans)

Submission status: Accepted

Solution code:
num=int(input())
string=input()
string=list(string)
mod=10**9+7
alpha=[0]*26
res=1
for s in string:
  alpha[ord(s)-97]+=1
for k in alpha:
  res*=(k+1)
print((res-1)%mod)

Submission status: Accepted

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

c = collections.Counter(s)

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

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

Submission status: Accepted

Solution code:
input()
s=input()
d={}
for i in s:
    if i in d:
        d[i]+=1
    else:
        d[i]=2
ans=1
for i in d:
    ans*=d[i]
print((ans-1)%1000000007)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = list(input())
box = []
alfa = [chr(ord('a') + i) for i in range(26)]
ans = 1

for hoge in alfa:
    if hoge in s:
        box.append([hoge, s.count(hoge)])

for hoge in range(len(box)):
    ans *= box[hoge][1] + 1

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

Submission status: Accepted

Solution code:
_,s=open(0);a=1
for i in set(s):a*=s.count(i)+1
print(a//2%(10**9+7)-1)

Submission status: Accepted

Solution code:
N = int(input())
mod = 10**9+7
s = input()
from collections import Counter
c = Counter(s)
ans = 1
for i in c:
    ans *= (c[i]+1)%mod

print((ans-1)%mod)

Submission status: Accepted

Solution code:
n=int(input())
l=input()
d=dict()
for a in l:
  if not a in d:
    d[a]=1
  else:
    d[a]+=1
ans=1
for a in d.values():
  ans*=a+1
print((ans-1)%(10**9+7))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N = int(input())
S = input()
MOD = 1000000007

ans = 1
for e in set(S):
    cnt = 0
    
    for i in range(N):
        if S[i] == e:
            cnt += 1
    ans *= cnt+1
    
print((ans-1) % MOD)

Submission status: Accepted

Solution code:
cnt = [0] * 26
n = int(input())
s = input()
for c in s:
    cnt[ord(c) - ord('a')] += 1
res = 1
for i in cnt:
    res *= i + 1
print((res - 1) % (10 ** 9 + 7))

Submission status: Accepted

Solution code:
def solve():
  mod = 10**9+7
  query = 'abcdefghijklmnopqrstuvwxyz'
  n = int(input())
  s = input()
  ans = 1
  for i in range(26):
    if s.count(query[i])>= 1:
     ans *= 1+s.count(query[i])
     ans %= mod
  print((ans-1)%mod)
solve()

Submission status: Accepted

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

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
S=input()

C=Counter(S)
ans=1
for v in C.values():
    # 各文字は1回しか使えないので、文字毎の場合の数は出現回数+1(使わない分)
    ans*=v+1
    ans%=MOD
# 最後に空文字列の分を引く
ans-=1
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
N, = list(map(int, input().split()))
S = input()
m = 10**9+7
c = Counter(S)
r = 1
for k in c:
  r = (r*(c[k]+1)) % m
print((r-1)%m)

Submission status: Accepted

Solution code:
MOD = 10**9+7

n = int(input())

s = input()

dic = {}

for i in s:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

ans = 1

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

print(ans-1)

Submission status: Accepted

Solution code:
from collections import defaultdict
dd=defaultdict(int)
N=int(input())
S=input()
for s in S:
    dd[s]+=1
ans=1
mod=10**9+7
for a,n in dd.items():
    ans*=(n+1)
    ans%=mod
print((ans-1)%mod)

Submission status: Accepted

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

memo=[1]*26

for i in range(N):
    k=ord(s[i])-ord('a')
    memo[k]+=1

ans=1
for i in range(26):
    ans=ans*memo[i]%(1000000007)

print(ans-1)

Submission status: Accepted

Solution code:
mod = 10**9 + 7

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

dic = {}
for s in "abcdefghijklmnopqrstuvwxyz":
    dic[s] = 0

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

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

Submission status: Accepted

Solution code:
from collections import Counter
n,s=int(input()),input();c=[s[i]for i in range(n)];a=Counter(c);ans=1
for i in a:ans*=a[i]+1
print((ans-1)%(10**9+7))

Submission status: Accepted

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import sys


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

cnt = {}
for c in s:
  if c not in cnt:
    cnt[c] = 1
  else:
    cnt[c] += 1

ans = 1
for i in cnt.values():
  ans = ans*(i+1) % (10**9+7)

print(ans-1)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter

n = ni()
s = ns()

cnt = Counter(s)

ans = 1
mod = 10**9+7

for k,v in cnt.items():
    ans *= (v+1)
    ans %= mod
    
ans -= 1
if ans < 0:
    ans += mod
    
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

alp = 'abcdefghijklmnopqrstuvwxyz'
count_alp = [0 for i in range(26)]
count = 1

for s in S:
    count_alp[alp.find(s)]+=1

for i in count_alp:
    count*= (i+1)
print((count-1)%MOD)

Submission status: Accepted

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)


def main():
    n = I()
    s = S()
    c = collections.Counter(s)
    r = 1
    for k,v in c.items():
        r *= v + 1
        r %= mod

    return (r-1) % mod


print(main())

Submission status: Accepted

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

chars = [1] * 30

for s in S:
    chars[ord(s)-97] += 1
    
#print(chars)

res = 1
for c in chars:
    res = (res*c)%MOD
res = (res-1)%MOD

print(res)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
s_set = set(s)
S = []
for i in s_set:
    S.append(s.count(i))

ans = 1
for i in S:
    ans *= i + 1
    ans %= 10 ** 9 + 7

print(ans - 1)

Submission status: Accepted

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

s_set = list(set(S))
num = 1

for i in s_set:
  num *= S.count(i)+1
print((num-1)%(10**9+7))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
charCnt = []
flag = {}
for c in S:
  if not c in flag:
    flag[c] = 1
    charCnt.append([c,1])
  else :
    flag[c] += 1
    for i in range(len(charCnt)):
      if charCnt[i][0] == c:
        charCnt[i][1] += 1
        break

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

Submission status: Accepted

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

mod = 10**9+7
R = 1
for w in set(S):
	#print(w, S.count(w))
	R *= S.count(w) + 1
	R %= mod
print(R - 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
s = input()
c = Counter(s)
cum = list(dict(c).values())
ans = 1
for ele in cum:
    ans *= (ele+1)
print((ans-1) % (10**9+7))

Submission status: Accepted

Solution code:
n=int(input())
s=input()
cnt=[1 for i in range(26)]

for c in s:
    cnt[ord(c) - ord('a')]+=1
res=1

MOD=10**9+7
for num in cnt:
    res = (res*num)%MOD
res = (res-1+MOD)%MOD
print(res)

Submission status: Accepted

Solution code:
N = input()
S = input()
m = 1

for i in set(S):
    m *= S.count(i)+1
#     print(m, S.count(i))
print( (m-1) % (10**9+7) )

Submission status: Accepted

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

l = list(s)
abc = list('abcdefghijklmnopqrstuvwxyz')
ans = 1
for i in range(len(abc)):
    cnt = l.count(abc[i])
    if cnt > 0:
        ans = ans*(((cnt + 1))%(10**9 + 7))
ans -= 1
ans = ans %(10**9 + 7)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
 
N = int(input())
S = input()
 
unique_list = list(np.unique(S))
 
ans = 1
 
for s in unique_list:
  tmp = S.count(s)
  ans = ans * (tmp + 1)
  
print((ans-1) % int((1e9 + 7)))

Submission status: Accepted

Solution code:
import numpy as np

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

unique_list = list(np.unique(S))

ans = 1

for s in unique_list:
  tmp = S.count(s)
  ans = ans * (tmp + 1)
  
print(int((ans-1) % (10**9 + 7)))

Submission status: Accepted

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

hist = {}
out = 0
for c in "abcdefghijklmnopqrstuvwxyz":
    hist[c] = 1
for c in S:
    hist[c] += 1

tmp = 1
for a in hist.values():
    tmp *= a
out = (tmp -1) % (10**9 + 7)
print(out)

Submission status: Accepted

Solution code:
N=int(input())
S=input()
D=[0]*26
mod=10**9+7
a=ord('a')
for s in S:
    D[ord(s)-a]+=1
ans=1
for a in D:
    ans*=(a+1)
    ans%=mod
print((ans-1)%mod)

Submission status: Accepted

Solution code:
N = int(input())
S = input().rstrip()
dic = {}

for i in range(len(S)):
    if S[i] in dic.keys():
        dic[S[i]] += 1
    else:
        dic[S[i]] = 2

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

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

Submission status: Accepted

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

li = [1]*26
for i in S:
    li[ord(i)-97]+=1
ans=1
for i in li:
    ans*=i
print((ans-1)%(10**9+7))

Submission status: Accepted

Solution code:
n = int(input())
 
s = input()
 
x = []
 
for i in range(n):
    x.append(s[i])
 
import collections
 
clist = collections.Counter(x)
 
y = list(clist.values())
 
cnt = 1
 
for item in y:
    cnt = cnt * (item + 1)
 
cnt = cnt - 1
cnt = cnt % (10 ** 9 + 7)
print(cnt)

Submission status: Accepted

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

sum = 1
for s in set(S):
    sum *= S.count(s) + 1
    sum %= 10**9 + 7
sum -= 1
sum %= 10**9 + 7
print(sum)

Submission status: Accepted

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

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']
count = [1]*26

for n  in range(N):
    for a in range(26):
        if S[n] == alp[a]:
            count[a] += 1

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

ans -= 1

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

Submission status: Accepted

Solution code:
from collections import defaultdict

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

A=defaultdict(int)
mod = 10**9+7

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

ans=1
for d,i in A.items():
    ans *= (i+1)
    ans %= mod

print(ans-1)

Submission status: Accepted

Solution code:
M= 10**9+7
ans = 1

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

for i in S_set:
    ans *= (S.count(i)+1)

print((ans-1) % M)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

alphabet = "abcdefghijklmnopqrstuvwxyz"
indmap = {}
for i, c in enumerate(alphabet):
    indmap[c] = i

MOD = 10**9 + 7

def main():
    n = int(input())
    s = input()

    counts = [0]*26
    for c in s:
        counts[indmap[c]] += 1

    #print(counts)
    total = 1
    for k in counts:
        total *= (k+1)

    print((total-1) % MOD)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import Counter

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

count = 1
for value in Counter(S).values():
  count *= (value+1)
count -= 1

print(int(count % (10**9+7)))

Submission status: Accepted

Solution code:
"""Colorful Subsequence"""
N=int(input())
S=input()
result = 1
"""英小文字は26個あるのでaをord()でUnicode変換し、26文字分繰り返す。
        その後chr()でUnicodeから文字に変換し直しているのをcに入れている"""
for c in [chr(ord('a') + i) for i in range(26)]:
    result = (result * (S.count(c) + 1)) % (10**9 + 7)
result = (result - 1) % (10**9 + 7)
print(result)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
count_list=[]
for i in list(set(S)):
    count_list.append(S.count(i))
product=1
for i in count_list:
    product = (product*(i+1))%(1000000007)
print(int(product-1))

Submission status: Accepted

Solution code:
from collections import Counter

n=int(input())
s=input()
cnts = list(Counter(s).values())
ans = 1
for i in cnts:
    ans*=i+1
print(ans-1 if (ans-1)<(10**9+7) else (ans-1)%(10**9+7))

Submission status: Accepted

Solution code:
input()
string = input()
ans = 1
for n in set(string):
    ans *= string.count(n) + 1
print((ans - 1) % (1000000007))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from functools import reduce
from operator  import mul

N = int(input())
S = input()
assert N == len(S)

# 各文字の出現数
C = set(S)
numOf = {c: sum(1 for s in S if s == c) for c in C}

# 部分列の数 (各文字について, いずれか1箇所を選択 or いずれも選ばない)
nSeq = reduce(mul, (n + 1 for n in numOf.values()))
nSeq -= 1  # 空列を除く

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

Submission status: Accepted

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


ans = 1
C = Counter(S)
for v in C.values():
    ans = ans * (v + 1) % MOD

print(ans - 1)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
lis = list(S)
k = 1
se = set(lis)
for item in se:
  l = lis.count(item)
  k = k*(l + 1)
print((k - 1)%(10**9 + 7))

Submission status: Accepted

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

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

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

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

print((ans - 1) % int(1e9 + 7))

Submission status: Accepted

Solution code:
N = input()
S = input()
L = list(set(S))
cnt = 1
for k in L:
  cnt *= (S.count(k) + 1)
print((cnt - 1) % (10**9 + 7))

Submission status: Accepted

Solution code:
from collections import Counter

mod = 10**9 + 7
n = int(raw_input())
s = raw_input()
cc = Counter(s)

rs = 1
for x in cc:
  rs = rs * (cc[x] + 1) % mod
rs = (rs + mod - 1) % mod
print rs

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    S = lines.pop(0)
    res = 1
    for c in [chr(i) for i in range(97,97+26)]:
        n = S.count(c)
        if n > 0:
            res *= n + 1
    print((res - 1) % 1000000007)


lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Accepted

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

C = Counter(S).items()

ans = 1
modulo = 10**9+7
for ck,cv in C:
    ans *= cv+1
    ans %= modulo

print(ans-1)

Submission status: Accepted

Solution code:
KIND = 26
l=int(input())
s=input()

alpha_list = []
for i in range(0, KIND):
    alpha_list.append(0)

for i in s:
    alpha_list[ord(i)-ord('a')] += 1

ret = 1
for num in alpha_list:
    ret *= (num + 1)
print((ret-1)%(1000000000+7))

Submission status: Accepted

Solution code:
N = int(input())
S = input()
  
co = 0
index =0
n =[]
str = ""

for i in range(N):
  index=str.find(S[i])
  if index == -1 :
    str += S[i]
    n.append(2)
  else :
    n[index] += 1

co = 1
for i in range(len(n)):
  co = co * n[i]
co -= 1

print(co % 1000000007)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
count = 1
for i in range(ord('a'),ord('a') + 26):
    count *= S.count(chr(i)) + 1
print((count - 1) % (10**9 + 7))

Submission status: Accepted

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

count = 1

for i in range(ord('a'),ord('a')+26):
    count *= s.count(chr(i)) + 1

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

Submission status: Accepted

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

ans = 1

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

ans -= 1

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

Submission status: Accepted

Solution code:
#encoding: utf-8

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

ans = 1

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

ans -= 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import exit
MOD = 10**9 + 7
L = int(input())
# a = [int(input()) for _ in range(N)]
S = str(input())
dic = {}
for s in S:
    if not s in dic:
        dic[s] = 1
    else:
        dic[s]+=1
ans =1
for d in dic.keys():
    ans*=dic[d]+1
print((ans-1)%MOD)

Submission status: Accepted

Solution code:
input()

S=input()

a=set(S)
m=1
for i in a:
    m*=S.count(i)+1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
N=int(input())
S=list(input().strip())
ans=1
for i in set(S):
    ans=ans*(S.count(i)+1)
ans-=1
print(ans%(10**9+7))

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    S = input_raw[0]
    dic = {}
    for s in S:
        if s not in dic:
            dic[s] = 1
        else:
            dic[s] += 1

    count = 1L
    for s in dic:
        count =  (count * long(dic[s] + 1)) % 1000000007L

    count = (count - 1) % 1000000007L
    print count


if __name__ == '__main__':
    main()

Submission status: Accepted

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

MOD = 1000000007  # type: int

def solve(n, s):
    counts = {}
    for c in s:
        if c in counts:
            counts[c] += 1
        else:
            counts[c] = 1
    nums = counts.values()
    ret = 1
    for num in nums:
        ret *= num + 1
        ret %= MOD
    ret -= 1
    print(ret)
    return

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

Solution code:
import sys
import pprint

N = sys.stdin.readline()
S = sys.stdin.readline()

N = int(N.strip())
S = S.strip()

#print (N)
#print (S)

mydict = {}

for x in range(N):
	if S[x] in mydict:
		mydict[S[x]] += 1
	else:
		mydict[S[x]] = 1

#pprint.pprint(mydict)

count_1 = 0
c = 1

for k in mydict:
		c *= mydict[k] + 1


print((c - 1) % (10**9 + 7), end="")

Submission status: Accepted

Solution code:
n = int(input())
st = input()
di = {}
for i in range(len(st)):
    if st[i] in di:
        di[st[i]] = di.get(st[i]) + 1
    else:
        di[st[i]] = 2
from functools import reduce
print((reduce(lambda x,y:x*y,di.values())-1)%1000000007)

Submission status: Accepted

Solution code:
import collections
n=int(input())
S=input()
alphabet=[chr(ord('a') + i) for i in range(26)]
kaisu=collections.Counter(S)
ans=1
for i in alphabet:
	if kaisu[i]!=0:
		ans*=kaisu[i]+1
	ans=ans%(10**9+7)
ans-=1
print(ans)

Submission status: Accepted

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

words = {}

for s in S:
    if s in words.keys():
        words[s] += 1
    else:
        words[s] = 2

res = 1
for k in words.keys():
    res *= words[k]

print((res - 1) % 1000000007)

Submission status: Accepted

Solution code:
from sys import stdin
N=int(stdin.readline().rstrip())
S=(stdin.readline().rstrip())
S=list(S)
ans=1
for i in set(S):
    ans=ans*(S.count(i)+1)
ans-=1
print(ans%(10**9+7))

Submission status: Accepted

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

a={}
for i in s:
  if i in a:
    a[i]+=1
  else:
    a[i]=1
j=1
for k in a:
  i=a[k]
  j*=i+1
print((j-1)%(10**9+7))

Submission status: Accepted

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

d = {}
for c in s:
  if c not in d.keys():
    d[c] = 2
  else:
    d[c] += 1

ret = 1
for key in d.keys():
  ret *= d[key]

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

Submission status: Accepted

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

count=[]
for i in range(26):
	count.append(1)

for i in s:
	if i == "a":
		count[0]=count[0]+1
	elif i == "b":
		count[1]=count[1]+1
	elif i == "c":
		count[2]=count[2]+1
	elif i == "d":
		count[3]=count[3]+1
	elif i == "e":
		count[4]=count[4]+1
	elif i == "f":
		count[5]=count[5]+1
	elif i == "g":
		count[6]=count[6]+1
	elif i == "h":
		count[7]=count[7]+1
	elif i == "i":
		count[8]=count[8]+1
	elif i == "j":
		count[9]=count[9]+1
	elif i == "k":
		count[10]=count[10]+1
	elif i == "l":
		count[11]=count[11]+1
	elif i == "m":
		count[12]=count[12]+1
	elif i == "n":
		count[13]=count[13]+1
	elif i == "o":
		count[14]=count[14]+1
	elif i == "p":
		count[15]=count[15]+1
	elif i == "q":
		count[16]=count[16]+1
	elif i == "r":
		count[17]=count[17]+1
	elif i == "s":
		count[18]=count[18]+1
	elif i == "t":
		count[19]=count[19]+1
	elif i == "u":
		count[20]=count[20]+1
	elif i == "v":
		count[21]=count[21]+1
	elif i == "w":
		count[22]=count[22]+1
	elif i == "x":
		count[23]=count[23]+1
	elif i == "y":
		count[24]=count[24]+1
	elif i == "z":
		count[25]=count[25]+1

result=1
for i in count:
	result=result*i

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
dic = {}
MOD = 10 ** 9 + 7
for s in S:
    dic.setdefault(s, 1)
    dic[s] += 1
all = 1
for k, v in dic.items():
    all = all * v
print((all -1) % MOD)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

mod = int(1e9+7)

c_map = defaultdict(int)
for c in s:
    c_map[c] += 1

ans = 1
for cnt in c_map.values():
 	if cnt == 1:
 		ans *= 2
 	else:
 		ans *= (cnt+1)

 	if ans > mod:
 		ans %= mod

print(ans-1)

Submission status: Accepted

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)):
  cnt[ord(S[i])-97] += 1
D = []
for i in range(26):
  if cnt[i] != 0:
    D.append(cnt[i])
ans = 1
for i in range(len(D)):
  ans *= (D[i]+1)
  ans = ans%(10**9+7)
print((ans-1)%(10**9+7))

Submission status: Accepted

Solution code:
from collections import *
input()
r = 1
for v in Counter(input()).values():
    r = r * (v+1) % (10**9+7)
print(r-1)

Submission status: Accepted

Solution code:
input()
s = input()
ans = 1
for i in range(97, 123):
    ans *= s.count(chr(i)) + 1
print((ans-1) % (10**9+7))

Submission status: Accepted

Solution code:
input()
s = list(input())
d = {chr(i):1 for i in range(97, 123)}
for c in s:
    d[c] += 1
ans = 1
for i in d.values():
    ans *= i
print((ans-1) % (10**9+7))

Submission status: Accepted

Solution code:
#coding: utf-8
N = int(input())
S = input()
mod = 1000000000 + 7
alpha = list(map(chr,range(97,123)))
ans = 1
for i in alpha:
    ans *= S.count(i) + 1
print(int((ans-1) % mod))