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:
n = int(input())
s = input()
mod = 10 ** 9 + 7
cnt = [0] * 26  # それぞれの文字に対してfreqを数える
for i in s:
    cnt[ord(i) - 97] += 1
ans = 1
for i in cnt:
    ans *= i + 1
    ans %= mod
print(ans - 1)

Submission status: Accepted

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

dd = defaultdict(int)
for c in s:
    dd[c] += 1
ans = 0
for c in s:
    dd[c] -= 1
    tmp = 1
    for k, v in dd.items():
        if k == c:
            continue
        else:
            tmp *= v + 1
    ans = (ans + tmp) % MOD

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

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

ans = 1
for s,c in C.items():
  ans *= c + 1
  ans %= MOD

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

Submission status: Accepted

Solution code:
MOD = 10**9 + 7

N = int(input())
S = input()
lis = [1] * 26
for i in range(N):
    lis[ord(S[i])-ord('a')] += 1
ans = 1
for i in range(26):
    ans *= lis[i]
    ans %= MOD
print(ans - 1)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/agc031/tasks/agc031_a

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()
M = 10**9 + 7

from collections import Counter

cs = Counter(S)
ans = 1
for key, val in cs.items():
    ans *= (val + 1)
ans %= M
ans -= 1
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())
S = input()
d = defaultdict(int)
for char in S:
    d[char] += 1

temp = 1
for key in d:
    # print(key, d[key])
    temp *= d[key] + 1
    temp %= 10**9 + 7

ans = temp - 1
print(ans)

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())
    x = input()
    dict = {}
    for i in range(len(x)):
        if x[i] in dict:
            dict[x[i]] += 1
        else:
            dict[x[i]] = 1
    dictvalue = list(dict.values())
    ans = 1
    for i in dictvalue:
        ans *= (i+1)
        ans %= 10**9+7
    print(ans-1)
resolve()

Submission status: Accepted

Solution code:
from collections import Counter

def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n = ii()
s = input()
d = Counter(s)

ans = 1
mod = 1000_000_007

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

print(ans-1)

Submission status: Accepted

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

from collections import defaultdict
D=defaultdict(int)
num=0
ans=0
dp=[0]*N
dp[0]=2
D[S[0]]+=1
for i in range(1,N):
    s=S[i]
    if D[s]>=1:
        dp[i]=(dp[i-1]+dp[i-1]*pow(D[s]+1,p-2,p))%p
        #print(D[s])
        D[s]+=1
    else:
        dp[i]=dp[i-1]*2%p
        D[s]+=1
#print(dp)
print((dp[-1]-1)%p)

Submission status: Accepted

Solution code:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

cnt=Counter(s)
ans=1
for i in al:
    ans*=cnt[i]+1
    ans%=mod
ans-=1
print(ans%mod)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
mod = 1000000007
alphacnt = [0]*26
ans = 0
for c in s:
    idx = ord(c)-ord("a")
    alphacnt[idx] += 1
    cnt = 1
    for i in range(26):
        if i == idx: continue
        cnt = (cnt*(alphacnt[i]+1))%mod
    ans = (ans+cnt)%mod
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
mod = 1000000007
alphacnt = [0]*26
ans = 0
for c in s[::-1]:
    idx = ord(c)-ord("a")
    alphacnt[idx] += 1
    cnt = 1
    for i in range(26):
        if i == idx: continue
        cnt = (cnt*(alphacnt[i]+1))%mod
    ans = (ans+cnt)%mod
print(ans)

Submission status: Accepted

Solution code:
mod=10**9+7

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

d={}
for s in S:
    if s in d:
        d[s]+=1
    else:
        d[s]=1
ans=1
for D in d:
    ans*=d[D]+1
    ans%=mod
print((ans-1)%mod)

Submission status: Accepted

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from math import factorial, sqrt, ceil, gcd
from functools import lru_cache, reduce
from decimal import Decimal
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
n = int(input())
s = input()
cnt = [0 for i in range(26)]
for i in s:
    cnt[ord(i) - ord("a")] += 1
ans = 0
for i in s:
    cnt[ord(i) - ord("a")] -= 1
    total = 1
    for j in range(26):
        if j == ord(i) - ord("a"):
            continue
        total *= cnt[j] + 1
    ans += total
print(ans % MOD)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
ss=set(s)
ls={}
csp=0
for j in ss:
  ls[j]=csp
  csp+=1

iis=[]
for i in s:
  iis.append(ls[i])

mod=10**9+7
d=[0 for i in range(csp)]
for i in iis:
  d[i]+=1
c=1
for i in d:
  c=(c*(i+1))%mod

print((c+mod-1)%mod)

Submission status: Accepted

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

m = 1000000007

d = {}
for c in S:
    if c in d:
        d[c] += 1
    else:
        d[c] = 1

result = 1
for x in d.values():
    result *= x + 1
    result %= m
result += m - 1
result %= m

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = list(input())
mod = 10 ** 9 + 7
alpha = "abcdefghijklmnopqrstuvwxyz"
cnt = []
for a in alpha:
    tmp = s.count(a)
    cnt.append(tmp + 1)
ans = 1
for num in cnt:
    ans *= num
    ans %= mod
print(ans - 1)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,gcd
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
'''
#Pythonを用いる場合
#numpy 1.18.0, scipy 1.4.1, scikit-learn 0.22, numba 0.47.0, networkx 2.4
 
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
'''
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
n=ii()

arr = Counter(list(input())).values()
ans = 1
for i in arr:
  ans *= (i+1)%mod
print((ans-1)%mod)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
S = input()
L = [0]*26

for s in S:
    L[ord(s)-97] += 1

ans = 1
for i in range(26):
    if L[i] != 0:
        ans = (ans * (L[i]+1)) % (10**9+7)

print(ans-1)

Submission status: Accepted

Solution code:
from collections import Counter

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

dic = Counter(S)
rlt = 1

for k in dic:
  rlt = rlt*(dic[k]+1) % P
  
print(rlt-1)

Submission status: Accepted

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# a^n
def power(a,n,mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod

# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n-1
    while(tmp >= l):
        a = a*tmp%mod
        tmp -= 1
    return a

inf = 10**18
mod = 10**9+7

n = ir()
s = list(sr())
a = Counter(s)
ans = 1
for _,v in a.items():
    ans = (ans*(v+1))%mod
print((ans-1)%mod)

Submission status: Accepted

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

d = [0]*26
for s in S:
    d[ord(s)-97] += 1

ans = 1
for num in d:
    ans *= (num+1)
    ans %= P
print((ans-1)%P)

Submission status: Accepted

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

from collections import Counter

def main():
    mod = 10**9+7
    N = int(input())
    S = list(input())
    S = Counter(S)
    ret = 1
    for i,c in S.items():
        ret *= (c+1)
        ret %= mod
    print((ret-1)%mod)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter
N=int(input())
S=input()
ans=1
s=Counter(S)
for key,value in s.items():
    ans*=value+1
print((ans-1)%(10**9+7))

Submission status: Accepted

Solution code:
from collections import Counter

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

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

Submission status: Accepted

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

cnt = [0] * 26
for i in range(26):
    cnt[i] = s.count(chr(i+97)) + 1

ans = 1
for i in cnt:
    ans *= i
    ans %= mod

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

Submission status: Accepted

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

ans = 0
cnt = [1] * 26
for i,ch in enumerate(s):
    tmp = 1
    for j in range(26):
        if(j==(ord(ch) - 97)):
            continue
        tmp *= cnt[j]
        tmp %= mod
    ans += tmp
    ans %= mod
    cnt[ord(ch) - 97] += 1

print(ans)

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

print(ans-1)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = list(str(input()))
mod = 10**9+7
count = 1
cs = Counter(S)

for key,value in cs.items():
  count *= (value+1)

print((count-1)%mod)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
alpha = [0]*123
mod = 10**9+7

for n in S:
    num = ord(n)
    alpha[num] += 1
    
ans = 1
for i in range(97,123):
    ans *= (alpha[i]+1)%mod

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

Submission status: Accepted

Solution code:
#AGC031 A Colorful Subsequence
# Answer
N = int(input())
S = input()
alpha = [0]*26
mod = 10**9+7

for n in S:
    num = ord(n)-97
    alpha[num] += 1
    
ans = 1
for i in range(26):
    ans *= (alpha[i]+1)

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

Submission status: Accepted

Solution code:
#AGC031 A Colorful Subsequence
# Answer
N = int(input())
S = input()
alpha = [0]*26
mod = 10**9+7

for n in S:
    num = ord(n)-97
    alpha[num] += 1
    
ans = 1
for i in range(26):
    ans *= (alpha[i]+1)

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

Submission status: Accepted

Solution code:
#AGC031 A Colorful Subsequence
# Answer
N = int(input())
S = input()
alpha = [0]*26
mod = 10**9+7

for n in S:
    num = ord(n)-97
    alpha[num] += 1
    
ans = 1
for i in range(26):
    ans *= (alpha[i]+1)

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

Submission status: Accepted

Solution code:
#AGC031 A Colorful Subsequence
# Answer
N = int(input())
S = input()
alpha = [0]*26
mod = 10**9+7

for n in S:
    num = ord(n)-97
    alpha[num] += 1
    
ans = 1
for i in range(26):
    ans *= (alpha[i]+1)

ans %= mod
print(ans-1)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
alpha = [0]*26
mod = 10**9+7

for n in S:
    num = ord(n)-97
    alpha[num] += 1
    
ans = 1
for i in range(26):
    ans *= (alpha[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
cnt = Counter(S)
ans = 1
for i in cnt.values():
    ans *= (i + 1)
    ans %= MOD
print(ans-1)

Submission status: Accepted

Solution code:
n=int(input())

s=input()

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

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


pr=1
for i in range(26):
    pr=pr*l[i]
    pr=pr%(10**9+7)

print(pr-1)

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_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

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
N = I()
S = S()

dic = DD(int)
for s in S:
  dic[s] += 1
L = "abcdefghijklmnopqrstuvwxyz"
ans = 1
for l in L:
  ans *= dic[l]+1
  ans %= MOD
print(ans-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import itertools as it
input = sys.stdin.readline


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


def main():
    n = int(input())
    ss = list(input().strip())
    m = {}
    for c in ss:
        if c not in m:
            m[c] = 0
        m[c] += 1
    ans = 1
    for k in m:
        ans *= m[k] + 1
        ans %= 10**9 + 7
    print(ans - 1)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

TEISUU = 1000000007

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

Submission status: Accepted

Solution code:
import sys
import collections
import itertools
import math

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

    MOD = 10 ** 9 + 7

    c = collections.Counter(S)

    ans = 1
    for i in range(0, 27):
        ans *= c[chr(i + ord('a'))] + 1

    ans -= 1

    print(ans % MOD)


if __name__ == '__main__':
    main()

Submission status: Accepted

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


def plus_one(n):
    return n + 1


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

print((reduce(mul, map(plus_one, S.values())) - 1) % (10 ** 9 + 7))

Submission status: Accepted

Solution code:
import sys
from collections import Counter

input = sys.stdin.readline
P = 10**9 + 7


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

    # Editorial AC
    c = Counter(S)
    ans = 1
    for v in c.values():
        ans = (ans * (v + 1)) % P
    ans = (ans - 1) % P

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
mod = 10**9+7
data = {}
for i in s:
    if i in data:
        data[i] += 1
    else:
        data[i] = 1
ans = 1
for i in data.values():
    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)

point = 1

for i,j in c.items():
    point *= j+1
    point %= mod

point -= 1
print(point)

Submission status: Accepted

Solution code:
from collections import Counter
from functools import reduce
MOD = 10 ** 9 + 7

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

c = Counter(s)

ans = reduce(lambda total, x: total * (x+1) % MOD, c.values(), 1)

print(ans-1)

Submission status: Accepted

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
S = input()
dic = defaultdict(int)
for i in range(len(S)):
    dic[S[i]] += 1
#print(dic)
res = 1
for k,v in dic.items():
    res *= (v+1)
    res %= mod
print(res % mod -1)

Submission status: Accepted

Solution code:
from collections import Counter


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

Submission status: Accepted

Solution code:
from collections import Counter

MOD = 10**9 + 7

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

c = Counter(S)

ans = 1
for k in c.keys():
    ans *= c[k]+1
    ans %= MOD

ans -= 1

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
S = input()
mod = int(1e9+7)
c = Counter(S)

ans = 1

for i in c.values():
    ans *= (i+1)
    ans %= mod

print(ans-1)

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
mod = 10**9 + 7

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

Submission status: Accepted

Solution code:
n = int(input())
S = str(input())

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

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()

ans = 1
for x in Counter(S).values():
	ans *= x+1
	ans %= mod
print((ans-1)%mod)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
S = input()[:-1]
cnt = Counter(list(S))
ans = 1
MOD = 10**9+7

for v in cnt.values():
    ans *= v+1
    ans %= MOD

print((ans-1)%MOD)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
s = ins()
p = 1
for i in range(26):
    c = s.count(chr(ord('a')+i))
    p = (p*(c+1))%R
print(p-1)

Submission status: Accepted

Solution code:
MOD=10**9+7
N=int(input())
S=input()
cnt=[0]*26
for x in S:
    cnt[ord(x)-97]+=1
res=1
for i in range(26):
    res=res*(cnt[i]+1)%MOD
print(res-1)

Submission status: Accepted

Solution code:

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
from collections import Counter,deque,defaultdict
import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
s=s0()

c=Counter(s)
d=list(c.values())
MOD=10**9+7

def prod(line):
    r=1
    for i in line:
        r*=i
#         r%=MOD
    return r


ans=prod([i+1 for i in d])
print((ans-1)%MOD)

Submission status: Accepted

Solution code:

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
from collections import Counter,deque,defaultdict
import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
s=s0()

c=Counter(s)
d=list(c.values())
MOD=10**9+7

def prod(line):
    r=1
    for i in line:
        r*=i
        r%=MOD
    return r


ans=prod([i+1 for i in d])
print((ans-1)%MOD)

Submission status: Accepted

Solution code:
N=int(input())
S=input()
count=1
for i in range(97,123):
    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 char in set(S):
    count*=S.count(char)+1
print((count-1)%(10**9+7))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import*
MOD = 10**9+7
input();i = 1
for c in Counter(input()).values():i *= c+1
print(~-i % MOD)