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 math
import bisect
import collections
import itertools
import heapq
import string
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return math.gcd #最大公約数
def lcm(a,b):return (a*b) // math.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()
c = collections.Counter(input())
mod = 10**9+7
ans = 1
for v in c.values():
    ans *= (v+1)
    ans %= mod
print((ans-1)%mod)

Submission status: Accepted

Solution code:
import collections

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

d = collections.Counter(S)
ans = 1
for key in d:
  ans = ans * (d[key] + 1)
print((ans-1) % (10**9 +7))

Submission status: Accepted

Solution code:
import collections

n = int(input())
S = list(input())

c = collections.Counter(S)

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

ans -= 1

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

Submission status: Accepted

Solution code:
# 最終的な倒叙回数だけで決まりそうな気がした(登場回数+1を掛けて最後に空文字ぶん1を引く)
# なんでかというと、同じ文字は含まないので、結局登場する順番は関係ないから。ある文字が複数あったとき、ひとつだけ選ぶ（あるいは選ばない）というのは、「どの時点で登場した文字を採用するか」と同義。
# などとドヤったけど6WAくらいだしましたしにます
# と思ったらMODしてなかった件


from functools import reduce

n = int(input())
s = input()
d = {}
for sv in s:
    if sv not in d:
        d[sv] = 1
    else:
        d[sv] += 1
ans = reduce(lambda x, y: x * y, list(map(lambda x: x[1] + 1, d.items()))) - 1
print(ans % (10**9+7))

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
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 I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# a〜z -- START --
l=['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']
# a〜z --- END ---

lc=[0]*26

def main():
  n=I()
  s=S()

  ans=1

  for x in s:
    lc[l.index(x)]+=1

  for x in lc:
    ans*=(x+1)
    ans%=mod

  return ans-1

# main()
print(main())

Submission status: Accepted

Solution code:
n=int(input())
s=input()
d=dict()
ans=1
for i in range(n):
  if s[i] not in d:
    d[s[i]]=1
  else:
    d[s[i]]+=1
ld=list(d.values())
for i in range(len(ld)):
  if ld[i]==1:
    ans*=2
  else:
    ans*=ld[i]+1
print((ans-1)%(10**9+7))

Submission status: Accepted

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

def main():
	N = int(input())
	S = input().rstrip()
	M = 10**9 + 7
	
	# a     (0)+1
	# ab    (1)+1+1
	# abc   (3)+3+1
	# abca  (7)+1+2+1
	# abcab (11)+1+3+2
	# abcabc (17)+1+4+3
	A = ord("a")
	res = 1
	for i in range(26):
		q = chr(i+A)
		qc = S.count(q)
		res = res * (qc+1) % M
		
	print((res-1) % M)
	
main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    s = S()
    d = defaultdict(int)
    for i in s:
        d[i] += 1
    ans = 1
    for di in d.values():
        ans *= di + 1
        ans %= mod
    print((ans - 1) % mod)
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
from collections import defaultdict

iCnt = int(input())
S = input()
M = 10**9 + 7

vCntDct = defaultdict(int)

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

ans = 1
for v in vCntDct.values():
    ans *= (v + 1)
    ans %= M

print(ans - 1)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:utf-8
from collections import Counter
n = int(input())
s = input()
c = Counter(s)
ans = 1
for v in c.values():
    ans *= (v+1)
    ans %= int(1e+9+7)
    
print (ans-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
l = list(input())
l = list(Counter(l).values())

ans = 1

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
total = (2**N-1)%(10**9+7)
dicta = {}
for i in range(N):
    if S[i] not in dicta:
        dicta[S[i]] = 1
    else:
        dicta[S[i]] += 1
dup = [v for v in dicta.values()]
dc = 1
for i in dup:
    dc *= i+1
print((dc -1)%(10**9+7))

Submission status: Accepted

Solution code:
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def main():
    n = int(input())
    s = input()
    c = Counter(s)
    ansm=1
    for i in range(26):
        v = chr(ord("a") + i)
        ansm *= (c[v] + 1)
        ansm%=MOD
    print((ansm -1 + MOD)%MOD)





if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)

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

mod = 10**9+7

import collections
c = collections.Counter(s)
#print(c)
c_value_lst = list(c.values())
#print(c_value_lst)

ans = 1

for i in c_value_lst:
    ans = ans * (i+1)
    #print(ans)
    ans = ans%mod
print(ans-1)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import Counter

N = int(readline())
S = read().rstrip()

MOD = 10 ** 9 + 7

counter = Counter(S)

x = 1
for y in counter.values():
    x *= (y + 1)

x -= 1
answer = x % MOD
print(answer)

Submission status: Accepted

Solution code:
MOD = 10 ** 9 + 7

plist = [-1] * 65
def p(x):
    if plist[x] != -1:return plist[x]
    if x == 0:
        plist[x] = 1
        return 1
    if x % 2 == 0:
        plist[x] = p(x//2)*p(x//2)%MOD
        return plist[x]
    plist[x] = 2*(p(x//2)*p(x//2)%MOD)%MOD
    return plist[x]

def add(x,y):
    return (x+y) % MOD
def mul(x,y):
    return x*y % MOD

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

cnt = [0] * 26
for i in range(N):
    cnt[ord(S[i])-97] += 1

flag = True
for i in range(26):
    if cnt[i] > 1:
        flag = False

if flag:
     print(add(-1,p(N)))
else:
    ans = 1
    for i in range(26):
        ans = mul(ans,1+cnt[i])
    print(add(-1,ans))

Submission status: Accepted

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

alphabet='abcdefghijklmnopqrstuvwxyz'
nums=[1]*26
for i in range(N):
  ind=alphabet.index(S[i])
  nums[ind]+=1
out=1
for i in nums:
  out*=i
print((out-1)%(10**9+7))

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:
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int
from collections import Counter
from itertools import product
def solve(N: int, S: str):
    counter = dict(Counter(S))
    values = list(counter.values())
    LEN = len(values)
    answer = values[0]+1
    if LEN >= 2:
        for i in range(1,LEN):
            answer *= values[i]+1
            answer%=MOD
    print(answer-1)
    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:
from collections import defaultdict

N = int(input())
S = input()
dd = defaultdict(int)

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

ans =1
mod = 10**9+7
for key,n in dd.items():
    ans=ans*(n+1)%mod

print(ans-1)

Submission status: Accepted

Solution code:
# 異なる一から取り出された部分列は区別して数えるから、特定の文字の場所による関係は考慮しなくてよい
from collections import Counter
N = int(input())
S = input()
mod = 10**9+7
# 同じ文字を使うことはできないので、"b"を使える回数は1回までで、どのbを使うかだけを考慮する
count = Counter(S)
ans = 1
for k, v in count.items():
    ans *= (v+1) % mod
print((ans-1) % mod)

Submission status: Accepted

Solution code:
# 同じ文字を異なる位置から取り出すのは区別する
# 与えられた文字列の並び順は関係ない
from collections import Counter
N = int(input())
S = input()

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

Submission status: Accepted

Solution code:
from collections import Counter
MOD = 10**9 + 7
def solve(n, s):
    res = 1
    for num in Counter(s).values():
        res = (res * (num+1)) % MOD
    return res - 1

n = int(input())
s = input()
print(solve(n, s))

Submission status: Accepted

Solution code:
n = int(input())
s = input()
mod = 10**9 + 7
"""
a~zの全てのアルファベットが1回以下使われる組み合わせ(複数ある場合は区別される)
を求めれば良い。
なお、部分列であるので、連続である必要はない。
Ex.
aが文字列に２つ含まれる場合。
どちらか片方を使う　で2通り
どちらも使わない　　で1通り
　　　　　　　　　　計3通りある。
なお、全ての組み合わせを求めた後、それには「全てを使わない」選択肢が含まれているので
全ての組み合わせ-1が答えとなる。
"""

import collections

c = collections.Counter(s)

c_value_lst = list(c.values())

ans = 1

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
mod = 10 ** 9 + 7
ans = 1
alfa = [chr(i) for i in range(97, 97+26)]
count = [0 for i in range(26)]
for i in range(n):
    x = s[i]
    y = alfa.index(x)
    count[y] += 1

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

Submission status: Accepted

Solution code:
from collections import Counter

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

mod = 10 ** 9 + 7
s = list(Counter(S).values())

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

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(S)
ret = 1
for v in c.values() :
  ret *= v + 1
  ret %= mod
  
print(ret - 1)

Submission status: Accepted

Solution code:
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    s = str(readline().rstrip().decode('utf-8'))
    s = collections.Counter(s)
    t = 1
    for k, v in s.items():
        t *= (v + 1)
        t %= mod
    print(t - 1)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
def examA(mod):
    N = I(); S = SI()
    d = defaultdict(int)
    ans = 1
    for s in S:
        d[s] +=1
    for i in d.values():
        ans *=(i+1)
    print((ans-1)%mod)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examA(mod)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = input()
ct = Counter(s)
MOD = 10 ** 9 + 7
res = 1
for k, v in ct.items():
    res = res * (v + 1) % MOD
print(res - 1)

Submission status: Accepted

Solution code:
num = int(input())
words = input()
mod = 10**9+7

words_count = {}
for key in words:
    if key in words_count:
        words_count[key] += 1
    else:
        words_count[key] = 1

ans = 1
for key, val in words_count.items():
    ans *= (val + 1)

print((ans - 1) % mod)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n=int(input())
    string=input()
    string_set=set(string)
    div=10**9+7
    count=1
    for s in string_set:
        count*=string.count(s)+1
    count-=1
    print(count%div)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import collections

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
S = list(rs())
MOD = 10 ** 9 + 7
answer = 1
c = collections.Counter(S)
for k, v in c.items():
    answer = (answer * (v + 1)) % MOD

print(answer-1 if answer != 0 else MOD - 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    s = str(readline().rstrip().decode('utf-8'))
    s = collections.Counter(s)
    t = 1
    for k, v in s.items():
        t = (t * (v + 1)) % mod
    print(t - 1)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
# 2019-11-25 22:51:53(JST)
import sys
from collections import Counter

MOD = 10 ** 9 + 7

def main():
    n, s = sys.stdin.read().split()
    n = int(n)
    
    res = 1
    for c in Counter(s).values():
        res = res * (c + 1) % MOD

    res = (res - 1) % MOD

    print(res) 

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

MOD = 10**9 + 7
N = int(input())
S = input()
ans = 1
for key, num in Counter(S).items():
  ans *= num+1

print((ans-1)%MOD)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

n = int(input())
s = input().rstrip()
MOD = 10**9 + 7

counter = collections.Counter(s)
res = 1
for v in counter.values():
    res *= v + 1
res -= 1
print(res % MOD)

Submission status: Accepted

Solution code:

import sys

input = sys.stdin.readline

# input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


def calc_next(N, S):
    dp = [[0 for i in range(26)] for i in range(N+1)]

    for i in range(N-1, -1, -1):
        for j in range(26):
            dp[i][j] = dp[i+1][j]
        dp[i][ord(S[i])-ord('a')] = i

    return dp


def main():
    N = int(input())
    S = input()
    a = [0 for i in range(26)]
    ans = 1

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

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

    print(ans - 1)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict

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

d = defaultdict(int)
for key in S:
    d[key] += 1

ans = 1
for i in d.items():
    ans *= (i[1] + 1)
    ans %= INF

print((ans - 1))

Submission status: Accepted

Solution code:
from collections import defaultdict

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

d = defaultdict(int)
for key in S:
    d[key] += 1

ans = 1
for i in d.items():
    ans *= (i[1] + 1)

print((ans - 1) % INF)

Submission status: Accepted

Solution code:
# AGC031
import collections
mod = 10 ** 9 + 7
N = int(input())
S = list(input())
c = collections.Counter(S)
c = c.most_common()
ans = 1
##print(c)
for i in range(len(c)):
    ans *= (c[i][1]+1) % mod
ans -= 1
ans %= mod
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
s=list(input())
mod=10**9+7
s.sort()
k=1
lst=[]
for i in range(1,n):
    if s[i]==s[i-1]:
        k+=1
    else:
        lst.append(k)
        k=1
lst.append(k)
m=len(lst)
ans=1
for u in lst:
    ans=(ans*(u+1))%mod
print(ans-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
mod = 1e9 + 7
cnt = [1]*27
for c in S:
   cnt[ord(c) - ord('a')]+=1
ans = 1
for c in cnt:
   ans *= c
   ans %= mod
print(int(ans-1))

Submission status: Accepted

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

L = []
for i in range(len(S)):
  if len(L) == 0:
    L.append([S[i], 2])
  else:
    u = 0
    for j in range(len(L)):
      if S[i] == L[j][0]:
        L[j][1] += 1
        u += 1
    if u == 0:
      L.append([S[i], 2])
p = 1    
for l in range(len(L)):
  p *= L[l][1]
print(int((p - 1) % 1000000007))

Submission status: Accepted

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

N = int(input().split()[0])
S = input()
counter = collections.Counter(S)
count = 1
mod = 10 ** 9 + 7
for _, v in counter.items():
    # その文字数の数 + 1ケース（選ばないケース)
    count = count * (v + 1) % mod

# 空文字列も含まれるので1引く
ans = (count - 1) % mod
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
INF = 10**9+7

n = int(input())
s = str(input())
d = defaultdict(int)
ans = 0
for i in s:
    d[i]+=1
    t = 1
    for ch, cn in d.items():
        if ch ==i:
            continue
        t *= cn +1
    ans = (ans+t)%INF
print(ans)

Submission status: Accepted

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

mod = 10 ** 9 + 7


def my_mul(a, b):
    return a * b % mod


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

cnt = Counter(s)

print(reduce(my_mul, (v + 1 for v in cnt.values())) - 1)

# 同じ文字列でも、異なる位置から作られたものは区別するため、2
# N − 1 通りのすべての部分列が区別され
# ることになります。
# 条件より、同じ文字を 2 度使ってはいけないため、ある文字 c について colorful の条件を壊さないとり方
# は (c の出現回数 + 1) となります (どれか 1 つを取るケース及び文字 c を一切取らないケース)
# すべての文字 c についてのこのとり方の積を求め、空文字列の分の 1 を引いた数が答えとなります。

Submission status: Accepted

Solution code:
from collections import defaultdict

mod = 10 ** 9 + 7

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

d = defaultdict(int)

ans = 0
for c in s:
    d[c] += 1
    t = 1
    for chr_, cnt in d.items():
        if chr_ == c:
            continue
        t *= cnt + 1
    ans = (ans + t) % mod
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter


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

    mod = 10 ** 9 + 7

    c = Counter(s)

    ans = 1
    for k, v in c.items():
        ans *= v + 1

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

cha = {}

for i in range(n):
    if s[i] in cha:
        cha[s[i]] += 1
    else:
        cha[s[i]] = 1

cnt = []

for k in cha:
    cnt.append(cha[k])

ans = 1

for c in cnt:
    ans *= (c+1)
    ans %=10**9+7

print(ans-1)

Submission status: Accepted

Solution code:
N=int(input())
S=input()
a=0
l=[0]*26
for i in S:
    t=1
    for j in range(26):
        if j!=ord(i)-97:
            t*=(l[j]+1)%(10**9+7)
    a=(a+t)%(10**9+7)
    l[ord(i)-97]+=1
print(a)

Submission status: Accepted

Solution code:
n = int(input())
s = input().strip()
cnt = {k:0 for k in list(s)}
for k in s:
  cnt[k] = cnt[k] + 1
  
mod = 10 ** 9 + 7
ans = 1
for v in cnt.values():
  ans = (ans * (v+1)) % mod
ans = (ans + mod-1) % mod
print (ans)

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
s = list(input())
c = Counter(s)
m = 10**9 + 7

ans = 1
for i in c:
    ans *= (c[i] + 1)
    ans %= m
ans -= 1

print(ans)

Submission status: Accepted

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

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

print((ans-1) % MOD)

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
S = list(input())
mod = 10 ** 9 + 7
s = list(Counter(S).values())
answer = 1
for i in s:
    answer = answer * (i + 1) % mod

print(answer - 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
s=str(input())
a=Counter(s)
aa=list(a.values())
#print(aa)
ans=1
for i in aa:
    ans*=(i+1)%(10**9+7)
print((ans-1)%(10**9+7))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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')))
    t = 1
    for k, v in s.items():
        t = (t * (v + 1)) % (10 ** 9 + 7)
    print(t - 1)


if __name__ == '__main__':
    slove()

Submission status: Accepted

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

ans = 1
import string
A = [chr(i) for i in range(ord('a'), ord('z')+1)]
B = {}
for i in range(len(A)):
    B[A[i]] = i
C = [1] * 26

for i in range(n):
    C[B[s[i]]] += 1

for i in range(len(C)):
    ans = (ans * C[i]) % mod

print(ans-1)

# for i in range(n):
#     for j in range(26):
#         if j != B[s[i]]:
#             C[j] = ans * 2
#     ans += (ans - C[B[s[i]]])
#     print(C[:5],ans)

# print(ans-1)

Submission status: Accepted

Solution code:
from collections import Counter 
n = int(input())
s = list(input())
count = Counter(s)
ans = 1
for k in count.values():
  ans *= k+1
  ans %= 1000000007
print(ans-1)

Submission status: Accepted

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

d={}
alphabet_s=[chr(i) for i in range(97,97+26)]
for c in alphabet_s:
    d[c]=0

for c in S:
    d[c]+=1

ans=1
for c in alphabet_s:
    ans=(ans*(d[c]+1))%p

# 空文字列を引く
ans-=1

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
mod=10**9+7
t=dict()
for c in s:
    t.setdefault(c,1)
    t[c]+=1
ans=1
for v in t.values():
    ans=ans*v%mod
print(ans-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter


def resolve():
    n = int(input())
    s = input()
    c = Counter(s)
    ans = 1
    mod = 10 ** 9 + 7
    for v in c.values():
        ans *= v + 1
        ans %= mod
    print(ans - 1)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict

n = int(input())
d = defaultdict(int)

for s in input():
    d[s] += 1

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

dic = {}

N = int(input())

S = input()

for i in range(N):

    if S[i] not in dic:
        dic[S[i]] = 1

    else:
        dic[S[i]] += 1
        
ans = 1

for i in dic:

    ans *= dic[i] + 1

print ((ans-1) % (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 *= (v + 1)
    ans %= mod

ans = mod - 1 if ans == 0 else ans - 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
ch = {}
for c in s:
  if c in ch:
    ch[c] += 1
  else:
    ch[c] = 1

ans = 1

for c in ch:
  ans *= 1 + ch[c]
  
  while ans >= 1000000007:
    ans -= 1000000007

ans += 1000000007
ans -= 1
while ans >= 1000000007:
  ans -= 1000000007

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ns = {}
for c in S:
  if c not in ns: ns[c] = 0
  ns[c] += 1
r = 1
for c in ns:
  n = ns[c]
  r = r*(n+1)%1000000007
r -= 1
print(r)

Submission status: Accepted

Solution code:
from collections import Counter
input()
c=Counter(input())
a=1
for i in c.items():
    a*=(1+i[1])
    a%=10**9+7
print(a-1)

Submission status: Accepted

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


if __name__ == '__main__':
    slove()

Submission status: Accepted

Solution code:
from collections import Counter

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

cntS = Counter(S)

ans = 1
for c in cntS.values():
    ans *= (c + 1)
    ans %= MOD

print((ans - 1) % MOD)

Submission status: Accepted

Solution code:
import collections as c

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

S=list(c.Counter(S).items())
#print(S)

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
s = str(input())
b = 10 ** 9 + 7 
# print(n);
# print(s);

sum=0
alphabet=['a', 'b', 'c', 'd' ]
alphabet=[chr(i) for i in range(97, 97 + 26)]
for i in alphabet:
    count=s.count(i)
    sum = (sum * (count + 1) + count ) % b     
    # print (s,i,count,sum)
print(sum)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
from collections import Counter
c = Counter(s)
ans = 0
mod = 10**9+7
for k, v in c.items():
  if ans == 0:
    ans = v+1
  else:
    ans = (ans * (v+1)) % mod
print(ans-1)

Submission status: Accepted

Solution code:
N=int(input())
S=input()
C=set(S)
m=1
for c in C:
  m*=S.count(c)+1
print((m-1)%(10**9+7))