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 sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N = II()
    S = input()
    MOD = 1000000007

    d = defaultdict(lambda: 0)
    for s in S:
        d[s] += 1

    ans = 1
    for n in d.values():
        if n == 0: continue
        ans *= (n+1)
    print((ans-1) % MOD)
    # print(ans - 1)
if __name__ == '__main__':
    solve()

Submission status: Accepted

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

c = Counter(S)
l = list(c.values())

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

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    S = INPUT()

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

    print((ans - 1) % mod)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
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
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
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 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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()

S_list = []
for s in S:
    S_list.append(s)

c = Counter(S)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    n = int(input().strip())
    S = input().strip()
    cnts = Counter(S)

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

    MOD = 10**9 + 7

    print(ans % MOD)
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())
s=input()
d=dict(zip([chr(97+i) for i in range(26)],[1]*26))
mod=10**9+7
for i in s:
  d[i]+=1
ans=1
for i in d.values():
  ans*=i
  ans%=mod
print((ans-1)%mod)

Submission status: Accepted

Solution code:
import sys
import math
from collections import Counter

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

MOD = 1000000007

# baba
# a(2), b(2), ab(1), ba(3)

# baab
# a(2), b(2), ab(2), ba(2)

# 1文字の時は分かる、それは単に数えるだけ
# 2文字の時は?
# 'ab' 'a'どれ選ぶ? → その後ろにある'b'は…

# 全部やるなら2^100000、ムリー

# dpいけるか?

# dpを設計しよう
# dp[n] : n文字目まで見た時の答え
# dp[n] = dp[n-1]

# baab
# dp[0] = 1 (b)
# dp[1] = dp[0]((b)のみ選ぶ) + 1(aのみ選ぶ) + dp[0] * 1 (ab)
# それが新しい文字なら?
# dp[n] = dp[n-1](追加で選ばない) + dp[n-1](選ぶ) + 1

# それが見たことある文字なら?
# 1文字単位では増えない
# n文字単位なら、pickする選択肢が増える
# ba (3)
# baa → 3 + 1?
# dp[n] = dp[n] (そのまま) + 最後の文字を使う
# 最後の文字を使うならどうなるか? → それ以外の種類の文字でつくるんだけど大変じゃない????

# baba
# babで5 a, b(2), ab(1) ba(1)
# 最後の文字を使うなら、bをどちらか選ぶ (か、何も選ばない)
# bをpickするか? * どれをpickするか?
# bをpickしない場合(1) + bをpickする場合(どれを選ぶ?)
# (1 + 2)

# abca
# abcで6 a, b, c, ab, ac, bc
# 最後の文字を使うなら、残りのbcの組み合わせ
# bをpickする/しない * cをpickする/しない 4通り?

ans = 1
counter = Counter()
counter[S[0]] += 1

for ch in S[1:]:
    if ch in counter:
        tmp = 1
        for k, cnt in counter.items():
            if k == ch:
                continue

            tmp = (tmp * (1 + cnt)) % MOD

        ans = (ans + tmp) % MOD
        counter[ch] += 1
    else:
        ans = (2 * ans) % MOD
        ans = (ans + 1) % MOD
        counter[ch] += 1

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter


def main():
    MOD = 10**9 + 7
    N = int(input())
    counter = Counter(input())
    ans = 1
    for c in counter.values():
        ans *= c + 1
        ans %= MOD
    print(ans - 1)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
S = input()
al = [0 for _ in range(26)]
for i in range(N):
    al[ord(S[i])-97] += 1
count = 1
for j in range(26):
    count *= al[j]+1
    count %= 10**9+7
print((count-1)%(10**9+7))

Submission status: Accepted

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

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

val = 1
for i in chars.values():
    val = (val * (i+1)) % CONST
print(val-1)

Submission status: Accepted

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

Submission status: Accepted

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

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()

    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
N = int(input())
S = list(input())
mod = pow(10, 9)+7
X = Counter(S)
ans = 1
for i in X.values():
    ans = (ans*(i+1)) % mod
print(ans-1)

Submission status: Accepted

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

mod = 10 ** 9 + 7
ans = 1
for v in C.values():
    ans *= (v + 1)  # 使う:v通り、使わない1通り
    ans %= mod

ans -= 1
print(ans % mod)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
s = input()
c = Counter(s)
# print(c)
res = 1
for v in c.values():
    # print(v)
    res *= v+1
    res %= mod
print(res-1)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
S = list(input())
mod = 10**9+7
from collections import Counter
c = Counter(S)
lis = []
ans = 1
for _, cnt in c.most_common():
    ans *= (cnt+1)
    ans %= mod
print((ans-1)%mod)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

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

ans, C = 0, Counter(S)
for i in range(N):
    sub_ans = 1
    for x in C:
        if x != S[i]:
            sub_ans = ((C[x] + 1) * sub_ans) % MOD
    ans = (ans + sub_ans) % MOD
    C[S[i]] -= 1
print(ans)

Submission status: Accepted

Solution code:
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def lowmod(a, b, mod):
    a -= b
    if a >= mod:
        a -= mod
    return a

def solve():
    n = int(input())
    s = input()
    c = collections.Counter(s)
    mod = 10**9+7
    ans = 1
    for i in c:
        ans *= (c[i]+1)
        ans %= mod
    ans = lowmod(ans, 1, mod)
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
from collections import Counter

MOD = 10**9+7

N = int(input())
s = input()
d = Counter(s)
res = 1
for value in d.values():
  res *= value + 1
  res %= MOD
res -= 1
print(res)

Submission status: Accepted

Solution code:
from collections import Counter

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

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

Submission status: Accepted

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

# aを含む -> 個数通り 含まない-> 1
# bを含む -> 個数通り 含まない-> 1
from collections import defaultdict
d = defaultdict(int)
for s in S:
    d[s] += 1
ans = 1
mod = 10**9 + 7
for k in d.keys():
    ans *= (d[k]+1)
    ans %= mod
ans -= 1
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

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

mod = 10**9+7

cnt = Counter(S)

res = 1
for v in cnt.values():
    res *= v+1
    res %= mod

print((res-1)%mod)

Submission status: Accepted

Solution code:
from collections import Counter

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

ac = Counter(S)
ans = 0
for value in ac.values():
    if ans == 0:
        ans = value+1
    else:
        ans = ans*(value+1)

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

Submission status: Accepted

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

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

print(ans-1)

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret


def solve():
    n = getN()
    s = getS()
    c = Counter(s)
    ans = 1
    for v in c.values():
        # print(v)
        ans *= v + 1
        ans %= MOD

    print(ans-1)


def main():
    n = getN()
    for _ in range(n):
        solve()


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

Submission status: Accepted

Solution code:
import sys,collections
input = sys.stdin.readline
m=10**9+7

N=int(input())
S=input().rstrip()
Sc = collections.Counter(S)
cnt = 1
for s in Sc.values():
    cnt *= (s+1)
print((cnt-1)%m)

Submission status: Accepted

Solution code:
import collections
N = int(input())
S = input()
A = collections.Counter(S)
B = list("qwertyuiopasdfghjklzxcvbnm")
C = []
for i in B:
    C.append(A[i])
D = [i+1 for i in C if i != 0]
ans = 1
for i in range(len(D)):
    ans *= D[i]
print((ans-1)%(10**9 + 7))

Submission status: Accepted

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
s = input()
a = [0]*26

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

ans = 1
for x in a:
    ans *= x + 1

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

Submission status: Accepted

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

Submission status: Accepted

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

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

X=1
for a in T:
    X=(X*T[a])%K
print((X-1)%K)

Submission status: Accepted

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

from collections import*
C=Counter(S)

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

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


if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter
    from string import ascii_lowercase

    n = int(readline())
    s = input()
    ans = 0
    counter = Counter()

    for char in s:
        counter[char] += 1
        t = 1
        for char2 in ascii_lowercase:
            if char == char2:
                continue
            t *= (counter[char2] + 1)
            t %= MOD
        ans += t
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

# In[2]:


import collections


# In[11]:


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


# In[13]:


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


# In[ ]:

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
MOD = 10 ** 9 + 7
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    S = SS()

    # 各アルファベットに対して、どこか1個以下使うパターンがある
    ans = 1
    cnt = collections.Counter(S)
    for i in cnt.values():
        ans *= (i + 1)
        ans %= MOD
    ans -= 1

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
import collections

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

Submission status: Accepted

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N = getN()
S = input()

ans = 1
# 各i[1]について掛ける/掛けないがあるため
# (1 + i1[1]) * (1 + i2[1])...
# 約数の個数の求め方と同じ
for i in Counter(S).items():
    ans *= (i[1] + 1) % mod
print((ans - 1) % mod)

Submission status: Accepted

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
s=list(input())
c=Counter(s)
c=c.values()
ans=1
mod=10**9+7
for i in c:
    ans*=(i+1)
    ans%=mod
print(ans-1)

Submission status: Accepted

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

X = {}

for s in S:
    if not(s in X):
        X[s] = 0

    X[s] += 1

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

print((ans-1)%MOD)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
S = input()[: -1]
table = [S.count(chr(ord("a") + x)) for x in range(26)]
res = 1
mod = 10 ** 9 + 7
for x in range(26):
  res *= table[x] + 1
  res %= mod
print(res - 1)

Submission status: Accepted

Solution code:
from collections import Counter

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

d = Counter(S)

m = 10 ** 9 + 7
# print(d)
ans = 1
for k, v in d.items():
    ans = ans * (v + 1) % m
print((ans - 1) % m)

Submission status: Accepted

Solution code:
from collections import Counter

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

Submission status: Accepted

Solution code:
from collections import Counter

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

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

print((ans-1)%MOD)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
S = input()
R = 1000000007

#%%
count = Counter(S)
ans = 1
for c in count.values():
    ans = ans * (c + 1) % R

print(ans - 1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    # n, m = [int(x) for x in input().split()]
    n = int(input())
    s = input()
    cnt = defaultdict(int)
    for e in s:
        cnt[e] += 1
    ans = 0
    for i in range(n):
        e = s[i]
        x = n - i - cnt[e]
        xd = 1
        cnt[e] -= 1
        for c in cnt:
            if cnt[c] and c != e:
                xd *= (cnt[c]+1)
        ans += xd
        ans %= MOD
    
    print(ans%MOD)

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
S = input()
mod = pow(10,9)+7
cS = Counter(list(S))
ans = 1
for key in cS.keys():
    ans *= (cS[key]+1)%mod
print((ans-1)%mod)

Submission status: Accepted

Solution code:
def count(l):
    res = {}
    for d in l:
        if d in res:
            res[d] += 1
        else:
            res[d] = 1
    return res

n = int(input())
string = input()
cnt = count(string)
mod = 10**9 + 7
ans = 1
for v in cnt.values():
    ans *= v + 1
    ans %= mod 
print(ans - 1)

Submission status: Accepted

Solution code:
import sys
from collections import Counter
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    s = input()
    D = Counter(s)
    res = 1
    for v in D.values():
        res = res * (v + 1) % mod
    print(res - 1)


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
from collections import defaultdict
mod = 10**9+7
n = int(input())
s = list(input())
ans = 1
dd = defaultdict(lambda:0)
for i in s:
    dd[i] += 1
for key in dd:
    ans *= dd[key]+1
    ans %= mod
ans -= 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=str(input())
s=list(s)
import collections
c=collections.Counter(s)
values, counts = zip(*c.most_common())
temp=list(counts)
l=len(temp)
ans=1
for i in range(l):
  ans=ans*(temp[i]+1)
print((ans-1)%(10**9+7))

Submission status: Accepted

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

c=list(Counter(s).values())

ans=1

for i in c:
    ans*=(i+1)

print((ans-1)%mod)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

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

C = Counter(S)

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

print(res - 1)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
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
from decimal import *
 
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, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
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
from decimal import *
 
N = INT()
S = list(input())

cnt = Counter(S).values()

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

print((ans-1%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, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
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
from decimal import *
 
N = INT()
S = list(input())

cnt = list(Counter(S).values())

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

print((ans-1%mod))

Submission status: Accepted

Solution code:
from collections import Counter
def main():
    n = int(input())
    s = input()
    mod = 1000000007
    c = Counter(s)
    ans = 1
    for v in c.values():
        ans = ans * (v + 1) % mod
    print(ans - 1)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    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)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

    print(ans - 1)


    

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
s = list(input())
mod = 10**9 + 7

cnt = Counter(s)

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

print((ans - 1) % mod)

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N = in_n()
    S = in_s()

    mod = 10**9 + 7
    orda = ord('a')
    ordz = ord('z')
    ans = 1
    for c in range(orda, ordz + 1):
        ans *= (S.count(chr(c)) + 1)
        ans %= mod

    print(ans - 1)


if __name__ == '__main__':
    main()