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:
# _*_ coding:utf-8 _*_
#  Atcoder_Grand_Contest031-A
#  TODO https://atcoder.jp/contests/agc031/tasks/agc031_a
from collections import Counter

def solveProblem(S):
	# Sはサンプル3の[abcab]を取って説明
	# SSorted = sorted(S)
	# SSorted = aabbc
	# Counterクラスを使うと整列もしれくれるのでソートは不要と判断
	stringCounterBox = Counter(S)
	# [(a,2),(b,2),(c,1)]
	maxStrLength = len(stringCounterBox)
	# 文字そのものを並べる文字列長さは 1から3まで
	countList = list(stringCounterBox.values())
	# [2,2,1] と 各文字数だけ取り出した配列になった
	'''
	戦略
	リストに入った数値に1足した物を掛けて行く。最後に1を引いたのが答え。
	根拠
	このabcの時を例に出すとa,b,cの3字について
	a→0回～2回出す
	b→aと同じ
	c→0回～1回出す
	ケースの組み合わせを考えると 3 * 3 * 2 = 18通りある
	しかし 全ての文字0回という選択をすると文字列そのものが無くなってしまう。
	この場合は対象外となるので1減らす。
	'''
	counter = 1
	for i in range(0,len(countList),+1):

		# counter = (counter * (countList[i]+1)) % (10^9+7)
		counter = (counter*(countList[i]+1)) % (pow(10,9)+7)

	answer = counter-1
	return answer


if __name__ == '__main__':
	_ = int(input().strip())
	S = str(input().strip())
	solution = solveProblem(S)
	print("{}".format(solution))

Submission status: Accepted

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

# AtCoder Grand Contest 031
# Problem A: Colorful Subsequence

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

# 各文字の出現数
numOf = {}
for c in S:
    numOf[c] = 1 if c not in numOf else numOf[c] + 1

# 部分列の数
nSeq = 1
for c in numOf:
    nSeq *= numOf[c] + 1  # いずれか1箇所を選択 or いずれも選ばない
nSeq -= 1  # 空列を除く

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

Submission status: Accepted

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_Grand_Contest031-A
#  TODO https://atcoder.jp/contests/agc031/tasks/agc031_a
from collections import Counter

def solveProblem(S):
	# Sはサンプル3の[abcab]を取って説明
	SSorted = sorted(S)
	# SSorted = aabbc
	stringCounterBox = Counter(SSorted)
	# [(a,2),(b,2),(c,1)]
	maxStrLength = len(stringCounterBox)
	# 文字そのものを並べる文字列長さは 1から3まで
	# print("maxStringLength:{}".format(maxStrLength))
	countList = list(stringCounterBox.values())
	# [2,2,1] と 各文字数だけ取り出した配列になった
	# print("countList:{}".format(countList))
	'''
	戦略
	1個の時→1個の配列を取り出した物を足す→2 + 2 + 1 = 5
	2個の時→取り出す文字は文字毎に数字だけパターンが替わる→ 2*2 + 2*1 + 2* 1 = 8
	3個の時 同上→ 2*2*1 = 4
	これ以上の取り出しはもう出来ない:同じ文字が出てくるため
	5 + 8 + 4 = 17 と答えと一致した
	TODO 取り出す配列番号を調べる方法が不明
	この場合なら2個の時0番目と1番目,0番目と2番目,1番目と2番目を洗い出すのはどうするのか？
	偉い人の回答待ち
	'''
	counter = 1
	for i in range(0,len(countList),+1):

		# counter = (counter * (countList[i]+1)) % (10^9+7)
		counter = (counter*(countList[i]+1)) % (pow(10,9)+7)

	answer = counter-1
	return answer


if __name__ == '__main__':
	_ = int(input().strip())
	S = str(input().strip())
	solution = solveProblem(S)
	print("{}".format(solution))

Submission status: Accepted

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

MOD = 1000000007

atoz = list(map(chr,range(97,123)))
cd = dict()
for c in atoz:
    cd[c] = 0

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

ans = 1
for val in cd.values():
    if val == 0: continue
    ans = ans * (val + 1)
    ans %= MOD

ans -= 1
ans %= MOD

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

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

r = 1
for m in Counter(S).values():
    r = r * (m+1) % (10**9+7)

print(r-1)

Submission status: Accepted

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

from collections import Counter

cs = Counter(S)

M = 10**9 + 7

result = 1
for c in cs:
    result = result * (cs[c] + 1)

result = (result - 1) % M

print(result)

Submission status: Accepted

Solution code:
# N,M = map(int, input().split())
N = int(input())
S = input()

from collections import Counter
c = Counter(S)
mod = 10**9 + 7
ans = 1

allc = "abcdefghijklmnopqrstuvwxyz"
for ch in allc:
    ans = ans * (c[ch]+1) % mod
print(ans-1)

Submission status: Accepted

Solution code:
# 2019/03/17
# AtCoder Grand Contest 031 - A

# Input
n = int(input())
s = input()

aprcnt = [1] * 26

# Count up Alphabets
for idx in range(n):
    w_idx = ord(s[idx]) - 97
    aprcnt[w_idx] += 1

# Calc Combination count
ans = 1
for idx in range(26):
    ans = ans * aprcnt[idx]

# Reduces 1 in choose nothing case
ans -= 1
ans = ans % (10**9 + 7)

# Output
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

import scipy.misc as scm

n = int(input())
s = list(input())
tmp = len(set(s))
count_s = Counter(s)
count_s = count_s.most_common()
ans = 1
for i in range(tmp):
  if count_s[i][1] > 1:
    ans *= (count_s[i][1]+1)
    ans = ans % (10**9+7)
  else:
    ans *= 2
    ans = ans % (10**9+7)
ans -= 1
print(ans)

Submission status: Accepted

Solution code:
"""AtCoder"""

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

l = "abcdefghijklmnopqrstuvwxyz"
t = 10**9 + 7

ans = 1

for i in range(len(l)):
    ans *= S.count(l[i]) + 1

print((ans - 1)%t)

Submission status: Accepted

Solution code:

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

def atoi(a):
    alphabet = ['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']
    return alphabet.index(a)

a_list = [0 for i in range(26)]
for i in range(N):
    a_list[atoi(S[i])]+=1
ans = 1
for i in range(26):
    ans *= (a_list[i]+1)
    ans = ans%(10**9 + 7)
if ans>0:
    ans-=1
else:
    ans=10**9 + 6
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
import functools
import operator
input()
print((functools.reduce(operator.mul, [i + 1 for i in list(Counter(input()).values())]) - 1) % (10 ** 9 + 7))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

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

mod = 10 ** 9 + 7
ans = 1
for value in S.values():
    ans *= (value + 1)

print((ans - 1) % mod)

Submission status: Accepted

Solution code:
from sys import exit

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


def get_count():
    count = 1

    m = {}

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

    for k in m:
        count *= m[k] + 1

    count -= 1

    return count


ans = get_count() % (10 ** 9 + 7)

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Mod:
    def __init__(self, m):
        self.m = m
    
    def add(self, a, b):
        return (a + b ) % self.m

    def sub(self, a, b):
        return (a - b) % self.m
    
    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, self.pow(b, self.m-2))

    def pow(self, x, y):
        if y == 0: 
            return 1
        elif y == 1: 
            return x % self.m
        elif y % 2 == 0: 
            return self.pow(x, y//2)**2 % self.m
        else: 
            return self.pow(x, y//2)**2 * x % self.m



@mt
def slv(N, S):
    CC = defaultdict(lambda: 1)
    for c in S:
        CC[c] += 1
    
    m = Mod(10**9+7)
    return reduce(m.mul, CC.values()) - 1


def main():
    N = read_int()
    S = read_str()
    print(slv(N, S))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Mod:
    def __init__(self, m):
        self.m = m
    
    def add(self, a, b):
        return (a + b ) % self.m

    def sub(self, a, b):
        return (a - b) % self.m
    
    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, self.pow(b, self.m-2))

    def pow(self, x, y):
        if y == 0: 
            return 1
        elif y == 1: 
            return x % self.m
        elif y % 2 == 0: 
            return self.pow(x, y//2)**2 % self.m
        else: 
            return self.pow(x, y//2)**2 * x % self.m



@mt
def slv(N, S):
    CC = Counter()
    for c in S:
        CC[c] += 1

    for c in CC:
        CC[c] += 1
    
    m = Mod(10**9+7)
    return reduce(m.mul, CC.values()) - 1


def main():
    N = read_int()
    S = read_str()
    print(slv(N, S))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = 1
for i in D.values() :
    ans *= (i+1)
ans -= 1
ans %= 10**9+7
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 key in d:
  ans*=d[key]+1
  ans%=MOD
print(ans-1)

Submission status: Accepted

Solution code:
from collections import defaultdict


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

M = 10**9 + 7
count_dict = defaultdict(int)

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

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

print(ans - 1)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = input()
answer = 1
counter = Counter(S).most_common()

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

print(answer-1)

Submission status: Accepted

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

M = 10**9 + 7
cnt = [0] * 26

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

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

print(ans - 1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import collections

def main():
	N = int(input())
	S = input()
	tmp = list(S)
	
	strings = collections.Counter(tmp)
	
	ans = 1
	for key in strings:
		ans = ans * (strings[key] + 1)
	
	ans = (ans-1) % (1000000007)
	
	print(ans)
			
if __name__ == "__main__":
	main()

Submission status: Accepted

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

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

ans = 1
for val in s_dict.values():
    ans *= val
print((ans-1)%div)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
charCount = {}
for c in S:
  if c not in charCount:
    charCount[c] = 1
  else:
    charCount[c] += 1

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
alphabet = "abcdefghijklmnopqrstuvwxyz"

ans = 1
for char in alphabet:
    count_char = S.count(char) + 1
    ans *= count_char
ans -= 1
ans %= (10**9+7)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

M = 10**9 + 7
cnt = [0] * 26

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

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

print(ans - 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from string import ascii_lowercase
from functools import reduce
from operator import mul

# 入力
N = int(input())
S = input()

# 解は(各アルファベットの出現回数+1)の総積
ans = (
    reduce(
        mul,
        map(
            lambda c: S.count(c) + 1,
            ascii_lowercase
        )
    ) - 1
) % (10**9 + 7)

# 出力
print(ans)

Submission status: Accepted

Solution code:
from string import ascii_lowercase
from functools import reduce
from operator import mul

# 入力
N = int(input())
S = input()

# 解は(各アルファベットの出現回数+1)の総積
ans = (
    reduce(
        mul,
        map(
            lambda c: S.count(c) + 1,
            ascii_lowercase
        )
    )
    - 1
) % (10**9 + 7)

# 出力
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


N=int(input())
s=input()
def find(s):
    dic={}
    for x in s:
        if x in dic:
            dic[x]+=1
        else:
            dic[x]=1

    MOD=10**9+7
    ans=1
    for x in dic:
        ans*=dic[x]+1
        ans%=MOD
    return (ans-1)%MOD

print(find(s))

Submission status: Accepted

Solution code:
def main():
    input()
    s=input()
    import collections
    c = collections.Counter(s)
    # print(c)
    ans = 1
    MOD = 10**9 + 7
    for n in c.values():
        ans *= (n+1)
        ans %= MOD
    ans -= 1
    ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

A=["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"]
L=[1 for i in range(26)]
#print(len(A))

for i in range(len(S)):
    for j in range(26):
        if S[i]==A[j]:
            L[j]+=1
ans=1            
for i in range(26):
    ans*=L[i]
    ans%=10**9+7
print(ans-1)

Submission status: Accepted

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

dic = {}
for s_i in set(s):
	dic[s_i] = s.count(s_i)+1

p = 10**9+7
res = 1
for v in dic.values():
	res = (res*v)%p

print(res-1)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
a = list('abcdefghijklmnopqrstuvwxyz')
cnt = [0]*26
for i,a_ in enumerate(a):
    cnt[i] += s.count(a_)+1
ans = 1
for cnt_ in cnt:
    ans *= cnt_
print(ans%int(1e9+7)-1)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
a = list('abcdefghijklmnopqrstuvwxyz')
cnt = [0]*26
for i,a_ in enumerate(a):
    cnt[i] += s.count(a_)+1
ans = 1
for cnt_ in cnt:
    ans *= cnt_
print(ans%(10**9+7)-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

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

X = Counter(S)

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

print(ans-1)

Submission status: Accepted

Solution code:
from collections import Counter
from sys import stdin

def main():
    N = int(input())
    S = input()

    cnt = Counter(S)
    ans = 1
    for i in cnt.values():
        ans *= i + 1
        ans %= 1000000007
    print(ans - 1)

input = lambda: stdin.readline().rstrip()
main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

c = Counter(s)
res = 1
for e in c.values():
    res = res*(e+1)%mod
print(res-1)

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)


N = I()
s = S()

inf = 10**9+7

counts = collections.Counter(s)
result = 1
for i in counts.values():
    result *= i+1
result -= 1
print(result%inf)
exit()

Submission status: Accepted

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

MOD = 1000000007  # type: int


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

    seki = 1
    for c in abc:
        seki *= 1+S.count(c)
    print((seki-1) % MOD)
    return


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
s = input()
MOD = 10 ** 9 + 7
a = ord('a')
rec = [0] * 26
for i in range(n):
    rec[ord(s[i]) - a] += 1

num = 1
for i in range(26):
    if rec[i] != 0:
        num *= rec[i] + 1
        num %= MOD

print(num - 1)

Submission status: Accepted

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

ans = 1
for c in [chr(x) for x in range(97, 97 + 26)]:
    ans *= S.count(c) + 1
print((ans - 1) % (pow(10, 9) + 7))

Submission status: Accepted

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

Submission status: Accepted

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

mod = 10**9 + 7
alphabet = [chr(i) for i in range(97,97+26)]

ans = 1
for letter in alphabet:
    ans *= S.count(letter) + 1
    ans =  ans%mod
ans -= 1

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
from functools import reduce
 
def counter(list_1):
	return ((reduce(lambda a,b:a*b,map(lambda x:x+1,list_1))-1)%(10**9+7))
  
N=input()
S=input()
answer=counter(Counter(S).values())
print(answer)

Submission status: Accepted

Solution code:
import operator as op
from collections import Counter
from functools import reduce, partial

add1 = partial(op.add, 1)

def count(counts):
    return reduce(op.mul, map(add1, counts)) - 1

# main
N = int(input())
S = input()
print(count(Counter(S).values())%(10**9+7))

Submission status: Accepted

Solution code:
def a_colorful_subsequence(N, S):
    from collections import Counter
    from functools import reduce
    from operator import mul
    return (reduce(mul, map(lambda x: x + 1, Counter(S).values())) - 1) % (10**9 + 7)

N = int(input())
S = input()
print(a_colorful_subsequence(N, S))

Submission status: Accepted

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

n = 10**9 + 7
for i in set(S):
    counter = counter * (S.count(i)+1) % n

print(counter-1)

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 *= (x + 1)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin
import math
import itertools


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# これだと、O(n*n)
"""
temp_ans = []


def problem_a(input_string):
    S = int(input_string[0].rstrip())
    N = input_string[1].rstrip()
    N_l = len(N)
    global temp_ans
    for i in range(N_l)[::-1]:
        temp_ans += N[i]
        #print(temp_ans)
        for s in temp_ans:
            #print(s)
            if N[i] not in s:
                temp_ans.append(N[i]+s)
    #print(temp_ans)
    return len(temp_ans) % (10**9 + 7)
"""


def problem_a(input_string):
    S = int(input_string[0].rstrip())
    N = input_string[1].rstrip()
    #print(S)
    dic = {}
    c = 0
    for i in range(S)[::-1]:
        if N[i] not in dic:
            dic[N[i]] = 1
            #c += i+1
        else:
            dic[N[i]] += 1

    c = 1
    for key, value in dic.items():
        c *= (value+1)
    c -= 1
    """
    c += 2**len(dic.keys())-1
    #print(c)
    #c += S
    for key, value in dic.items():
        if value > 1:
            #c -= (value-1)
            c += 2**(len(dic.keys()))-1
            #print(c)
    #for key, value in dic.items():
    for key, value in dic.items():
        if value > 1:
            if len(dic.keys()) != S:
                c -= 2**(S-len(dic.keys())-1)
    """
            #print(c)
        #else:
    #c += (S-len(dic.keys()))
    """
    s_N = sorted(N)
    for i in range(S-1):
        if s_N[i] != s_N[i+1]:
            c += 2**(i+2)
    """
    """
    for key, value in dic.items():
        if value > 1:
            c += 2**(len(dic.items())-value)
        else:
            c += 2**(len(dic.items())-value)
    """
    #combinations_count(len(, r)

    return c % (10**9 + 7)


def main():
    input_line = stdin.readlines()
    answer = problem_a(input_line)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
S=list(map(lambda x: ord(x),input()))
MOD = 10**9 + 7 # 1e9 + 7

# 各文字列について、出現回数+1(1つ取るか、一切とらない)
# それを全部かければ良い

AppearCount = [ 0 for _ in range(26)]

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

ans = 1
bFirst = True

for a in AppearCount:
	if a != 0:
		ans *= (a+1)
		while MOD < ans:
			ans -= MOD

ans -= 1

while MOD <= ans:
	ans -= MOD

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
s = str(input())
c = Counter(s)

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from functools import reduce
from collections import Counter

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

print(
    reduce(lambda x, y: (x * y) % MOD,
           map(lambda x: x + 1,
               Counter(list(S)).values())) - 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
l = [1 for i in range(26)]

for s in S:
    l[ord(s) - ord('a')] += 1

ans = 1
for i in l:
    ans *= i

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

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 LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    s = SI()

    C = Counter(s)
    res = 1
    for c in C.values():
        res *= c + 1
        res %= MOD

    return res - 1 if res else MOD - 1


print(main())

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

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 LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    s = SI()

    cnt = [0] * 27
    res = 0
    for c in s:
        k = ord(c) - 97
        cnt[k] += 1
        tmp = 1
        for i in range(27):
            if not cnt[i]:
                continue
            if i == k:
                continue
            tmp *= cnt[i] + 1
        res += tmp
        res %= MOD

    return res if res else MOD


print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = input()
    ans = {}
    for s in range(ord('a'),ord('z')+1):
        ans[chr(s)] = 0
    for s in S:
        if not ans[s]:
            ans[s] = 1
        else:
            ans[s] += 1
    res = 1
    for _, v in ans.items():
        res *= v+1
    return res - 1


if __name__ == '__main__':
    print(main() % (10**9+7))

Submission status: Accepted

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

    str_list = list()
    for s in S:
        str_list.append(s)

    str_uni_list = {}
    for str in str_list:
        if (str in str_uni_list) is False:
            str_uni_list[str] = 1
        else:
            str_uni_list[str] += 1

    list_val = []
    for i in str_uni_list.values():
        list_val.append(i)

    rem = 1
    for v in list_val:
        rem *= (v + 1)

    ans = rem - 1

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict

MOD = 10 ** 9 + 7

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

d = defaultdict(int)
for ss in s:
    d[ss] += 1

ans = 1
for k, v in d.items():
    ans *= (v + 1)
    ans %= MOD
    # v通りの選び方 + 選ばない1通り
ans -= 1
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
S=input()
d={}
for c in S:
	d[c] = d[c]+1 if d.__contains__(c) else 1
mod=int(1e9+7)
ans=1
for a,b in d.items():
	ans= ans*(b+1)%mod

print(ans-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
s=input()
d={}
for i in range(n):
    if s[i] in d.keys():
        d[s[i]]+=1
    else:
        d[s[i]]=1
w=1
for i in d.values():
    w*=(i+1)
    w=w%(1e9+7)
    #1e9+7より大きかったら引くだけでは次にオーバーフローする可能性あり
    #かといって1e8+7とかにしてもダメ、
    #しかもこれだと最終解を出す時に正になるまで足し続けないといけなくて、オーバーフロー
    #毎回余りを出せば良い
if w==0:
    print(1e9+6)
else:
    print(int(w-1))

Submission status: Accepted

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

import sys

def parse_input(lines_as_string = None):


    lines = []
    if lines_as_string is None:
        lines.append(input())
        lines.append(input())
    else:
        lines = [e for e in lines_as_string.split("\n")][1:-1]
 
    tokens = lines[0].split(" ")
    n = int(tokens[0])
    tokens = lines[1].split(" ")
    s = tokens[0]

    return (n, s)


def solve(n, s):

    d = dict([(c, 0) for c in "abcdefghijklmnopqrstuvwxyz"])

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

    count = 1
    for v in [v for v in d.values() if v > 0]:
        count = count * (v+1)
    

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

def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()

Submission status: Accepted

Solution code:
N=int(input())
S=input()
iD = 10**9+7
aT={}
for s in S:
    if s in aT:
        aT[s]+=1
    else:
        aT[s]=1
iT = 1
for s in aT:
    iT *= aT[s]+1
print((iT - 1)%iD)

Submission status: Accepted

Solution code:
from collections import defaultdict

n = input()
S = input()
p = 10 ** 9 + 7
D = defaultdict(int)

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

ans = 1
for k, v in D.items():
    ans *= (v + 1)
    ans %= p

print(ans - 1)