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
DBG = True
BIG = 1000000007
n = int(input())
s = input()
cnt = { 'a':0, 'b':0, 'c':0, 'd':0, 'e':0, 'f':0, 'g':0, 'h':0, 'i':0, 'j':0, 'k':0, 'l':0, 'm':0, 'n':0, 'o':0, 'p':0, 'q':0, 'r':0, 's':0, 't':0, 'u':0, 'v':0, 'w':0, 'x':0, 'y':0, 'z':0 }
for i in range(n):
    cnt[s[i]] += 1

prod = 1
for key in cnt:
    prod = (prod * (cnt[key] + 1)) % BIG
print((prod-1)%BIG)

Submission status: Accepted

Solution code:
#Counter
n=int(input())
s=input()
from collections import Counter
cs=Counter(list(s))
a=list(cs.values())
t=a[0]
for i in range(1,len(a)):
    t+=a[i]*(1+t)
print(t%(10**9+7))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

import collections 

n=input()
s=input()

d=collections.Counter(s)

#print(d)

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

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

Submission status: Accepted

Solution code:
from collections import Counter

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

mod = 10**9 + 7

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

Submission status: Accepted

Solution code:
from collections import Counter
mod = 10**9+7
x = int(input())
s = input()
t = Counter(s).most_common()

ans = 1
for c, n in t:
    ans *= (n+1)%mod

print((ans-1)%mod)

Submission status: Accepted

Solution code:
from functools import reduce
n=int(input())
s=input()
count=[1 for i in range(26)]
for i in range(n):
    count[ord(s[i])-ord('a')]+=1
print((reduce(lambda a,b:a*b ,count)-1)%(10**9+7))

Submission status: Accepted

Solution code:
n = int(raw_input())
s = str(raw_input())
count = [0]*(26)
result = 1
for i in xrange(n):
	count[ord(s[i])-97]+=1
for i in count:
	result = result * (i+1)
	result = result % 1000000007
print result - 1

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
s = input()
cnt = Counter(s)
ans = 1
MOD = 10 ** 9 + 7
for c, v in cnt.items():
    ans = ans * (v + 1) % MOD
print(ans - 1)

Submission status: Accepted

Solution code:
import collections
import functools

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

c = [x + 1 for x in dict(collections.Counter(s)).values()]
#print(c)
ans = functools.reduce(lambda a, b: a * b, c) - 1
print(ans % md)

Submission status: Accepted

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

MOD = 10**9+7

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

ans = 1
for a in L:
    if a:
        ans *= (a+1)
        ans %= MOD

print(ans-1)

Submission status: Accepted

Solution code:
#AGC031-A
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n=I()
S=S()
Sd={}
for s in S:
    if s in Sd:
        Sd[s]+=1
    else:
        Sd[s]=1
one=0
for key in Sd.keys():
    if Sd[key]==1:
        one+=1
ans=2**one-1
for key in Sd.keys():
    if Sd[key]>=2:
        ans+=(ans+1)*Sd[key]
ans=ans%(10**9+7)
print(ans)

Submission status: Accepted

Solution code:
import collections

N = int(input())
S = str(input())
S_ = [str(x) for x in S]
c = collections.Counter(S_)

p = 1
for c_ in list(c.values()):
  p *= c_+1
print((p-1)%(10**9+7))

Submission status: Accepted

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

cnt = [0] * 26

for ss in S:
    cnt[ord(ss) - 97] += 1

sum = 1
mmd = 10 ** 9 + 7
for c in cnt:
    sum = (sum * (c + 1)) % mmd
print(sum - 1)

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(S)
r = 1
for _,n in c.items():
    r *= (n+1)
    r %= MOD

print(r-1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from collections import defaultdict

def solve():
    N = int(input())
    S = input()
    M = defaultdict(int)
    for s in S:
        M[s] += 1
    M = dict(M)
    res = 1
    for m in M.values():
        res *= (m+1)
        res %= (10**9+7)
    res -= 1
    return str(res)
if __name__ == '__main__':
    print(solve())

Submission status: Accepted

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

ans = 1
for i in range(26):
    c = chr(ord('a')+i)
    n = S.count(c)
    if n > 0:
        ans = (ans * (n+1)) % M

ans -= 1
print(ans)

Submission status: Accepted

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

ans = 1
for i in setS:
    cnt = S.count(i)
    # print(cnt)
    ans = ans * (cnt + 1) % (10 ** 9 + 7)
    # print(ans)

print(ans-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
alpha = [0 for _ in range(ord("z") - ord("a") + 1)]

for i in range(len(s)):
    alpha[ord(s[i]) - ord("a")] += 1
# print(alpha)
_sum = alpha[0] + 1
for i in range(1, len(alpha)):
    _sum *= alpha[i] + 1
print((_sum - 1) % (10 ** 9 + 7))

Submission status: Accepted

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

_dict = {}

for s in S:
  _dict[s] = _dict.get(s, 0) + 1

ans = 1
for y in [x+1 for x in _dict.values()]:
  ans = (ans * y)%(10**9 +7)

print(ans -1)

Submission status: Accepted

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

a = {}
for i in range(n):
    if s[i] not in a:
        a[s[i]] = 1
    else:
        a[s[i]] += 1
count = 1
for i in a.keys():
    count *= a[i] + 1
    count %= 10 ** 9 + 7
print(count-1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from collections import defaultdict, Counter
from itertools import permutations, product, combinations
from bisect import bisect, bisect_left
from fractions import gcd
MOD = 10**9 + 7

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

N = int(input())
S = input()
C = Counter(S)
ans = 1
for v in C.values():
    ans = (ans*(v+1))%MOD
print(ans-1)

Submission status: Accepted

Solution code:
n = int(raw_input())
s = raw_input().strip()
mod = 1000000007
ret = 1
for c in "abcdefghijklmnopqrstuvwxyz":
    ret = (ret * (s.count(c) + 1)) % mod
print (ret + mod - 1) % mod

Submission status: Accepted

Solution code:
from collections import Counter

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

mod = 10**9 + 7

c = Counter(s)

ans = 1
for i in range(26):
    w = chr(ord('a')+i)
    ans *= c[w] + 1
    ans %= mod

print(ans-1)

Submission status: Accepted

Solution code:
n=int(input())
s=input()
l=list(s)
sl=set(l)

import collections

c=collections.Counter(l)
ans=1
for i in sl:
    ans*=(c[i]+1)

print((ans-1)%1000000007)

Submission status: Accepted

Solution code:
n = int(input())
S = str(input())
ss = sorted((set(list(S))))
k = []
for i in range(len(ss)):
	k.append(S.count(ss[i])+1)
tmp = 1
for i in range(len(k)):
	tmp *= k[i]
ans = tmp - 1
anss = ans % (10**9+7)
print(anss)

Submission status: Accepted

Solution code:
n = int(input())
s = input()
count = {}
for c in s:
    if c not in count:
        count[c] = 1
    else:
        count[c] += 1
ret = 1
for _, c in count.items():
    ret *= c + 1
print((ret - 1) % (10**9 + 7))

Submission status: Accepted

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

Submission status: Accepted

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

L = [chr(i) for i in range(97, 123)]

X = []
for i in L:
    X.append(S.count(i))

s = 1
for i in X:
    s = (i + 1) * s
    s = s % 1000000007

print(s - 1)

Submission status: Accepted

Solution code:
from collections import Counter


def main():
    # n,m = [int(z) for z in input().split()]
    # table =[
    #     [int(z) for z in input().split()]
    #     for _ in range(n)
    # ]
    input()
    s = input()

    a = Counter(s)
    AL = "abcdefghijklmnopqrstuvwxyz"

    v = [a[b] + 1 for b in AL if a[b] != 0]

    res = 1
    V = 10 ** 9 + 7
    for a in v:
        res *= a % V
        res %= V
    print(res - 1)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(list(S))

ans = 1
for _, n in c.most_common():
    ans *= (n+1)
    ans %= 1000000007
print(ans-1)

Submission status: Accepted

Solution code:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9 + 7

N=ri()
S=input()

cnt = [1]*26
ord_a = ord('a')

for s in S:
    cnt[ord(s) - ord_a] += 1

ans = 1
for c in cnt:
    ans *= c
    ans %= MOD

ans -= 1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math

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

l=[]
for i in range(26):
	l.append(0)

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

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

ans=ans%p

ans-=1

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict,Counter

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

d=  defaultdict(int)
back = 0
front =1
ans = 1
c= Counter(S)

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


print(ans-1)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
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 LF(): return [float(x) 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()
    global ans
    ans = 1
    from collections import Counter
    cnt = Counter(S)
    for n in cnt.values():
        ans = (ans * (n + 1)) % MOD

    ans -= 1
    return ans

print(main())

Submission status: Accepted

Solution code:
N = int(input())
S = list(input())
p = 10**9 + 7
Count = 1
for i in range(26):
    letter = chr(97+i)
    Count *= S.count(letter) + 1
    Count = Count%p
print(Count-1)

Submission status: Accepted

Solution code:
a=int(input())
b=input()

num=[1]*26

for c in b:
    num[ord(c)-ord('a')]+=1

ans=1
div=1000000007
for i in num:
    ans*=i
    ans%=div
print(ans-1)

Submission status: Accepted

Solution code:
mod = 10**9 + 7

n = int(input())
s = input()
cs = list(s)
cnts = {}
for c in cs:
  if c in cnts:
    cnts[c] += 1
  else:
    cnts[c] = 1

ans = 1
for key in cnts:
  ans = (ans * (cnts[key]+1)) % mod
ans -= 1
print(ans)

Submission status: Accepted

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

from collections import Counter

n = ni()
s = ns()

MOD = 10**9+7

cnt = Counter(s)
ans = 1

for key, val in cnt.items():
    ans *= (val+1)
    ans %= MOD
    
ans -= 1
if ans < 0:
    ans += MOD
    
print(ans)

Submission status: Accepted

Solution code:
INF = 999999999999999999L
EPS = 1e-12

def read():
    return raw_input().strip()

def read_ints():
    return map(int,read().split())

n = int(read())
s = read()
cnts = [0]*26 
for c in s:
    cnts[ord(c)-ord("a")] += 1
# print cnts 

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
d = {}
l = "abcdefghijklmnopqrstuvwxyz"
for i in l:
    d[i] = 0
for i in S:
    d[i] += 1
ans = 1
for i in l:
    ans = (ans * (d[i] + 1)) % 1000000007
print(ans - 1)

Submission status: Accepted

Solution code:
N = int(input())
s = input()
def stoi(s):
    return ord(s)-97
X = [1] * 26
for ss in s:
    X[stoi(ss)] += 1

ans = 1
P = 10**9+7
for x in X:
    ans *= x
    ans %= P
print((ans - 1) % P)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
n = int(input())
s = input()
a = [0]*26
ans = 1
mod = 10**9+7
for i in range(n):
        a[ord(s[i]) - ord("a")] += 1
for i in a:
        ans *= (i+1)
        ans%=mod
print(ans-1)

Submission status: Accepted

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

T = [0]*26
for s in S:
  T[ord(s)-ord("a")] += 1

ans = 1
mod = 10**9+7
for i in range(26):
  ans *= T[i]+1
  ans %= mod
print (ans-1)%mod

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(raw_input())
s = raw_input().strip()
ans = 1
d = defaultdict(int)
for c in s:
    d[c] += 1
for v in d.viewvalues():
    ans = ans * (v + 1) % 1000000007
print (ans - 1) % 1000000007

Submission status: Accepted

Solution code:
import string

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

MOD = 10 ** 9 + 7

d = dict()
for ss in s:
    d[ss] = d.get(ss, 0) + 1
ans = 1
for c in string.ascii_lowercase:
    ans *= (d.get(c, 0) + 1)
    ans %= MOD
ans -= 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
mod = 1e9 + 7
dic =  { i:0  for i in [chr(i) for i in range(97, 97+26)] }
for i in range(N):
    dic[S[i]] += 1

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

Submission status: Accepted

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

Submission status: Accepted

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

AL=[0]*26

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

ANS=1

for al in AL:
    if al>0:
        ANS=ANS*(al+1)%mod

print((ANS-1)%mod)

Submission status: Accepted

Solution code:
#!/usr/bin/env python2
"""
This file is part of https://github.com/cheran-senthil/PyRival
Copyright 2019 Cheran Senthilkumar <hello@cheran.io>

"""
from __future__ import division, print_function

import itertools
import os
import sys
from atexit import register
from cStringIO import StringIO
from collections import Counter

range = xrange

filter = itertools.ifilter
map = itertools.imap
zip = itertools.izip

sys.stdout = StringIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = StringIO(os.read(0, os.fstat(0).st_size)).readline

MOD = 10**9 + 7
MODF = float(MOD)

MAGIC = 6755399441055744.0
SHRT = 65536.0

MODF_INV = 1.0 / MODF
SHRT_INV = 1.0 / SHRT

fround = lambda x: (x + MAGIC) - MAGIC
fmod = lambda a: a - MODF * fround(MODF_INV * a)
fmul = lambda a, b, c=0.0: fmod(fmod(a * SHRT) * fround(SHRT_INV * b) + a * (b - SHRT * fround(b * SHRT_INV)) + c)


def main():
    n = input()
    s = input().rstrip('\r\n')

    res = 1
    for key, value in Counter(s).items():
        res = fmul(res, (value + 1))

    print(int(res - 1) % MOD)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
'''input
3
abb
4
abcd
'''
import collections
n = int(input())
s = input()
MOD = int(1e9 + 7)
d = collections.Counter(s)
ans = 1
for k, v in d.items():
	ans = ans * (v + 1)
print((ans - 1) % MOD)

Submission status: Accepted

Solution code:
N=int(input())
S=input()
from collections import defaultdict
data=defaultdict(int)
for i in range(N):
    data[S[i]]+=1
ans=1
for j in data.values():
    ans=(ans*(j+1))%(10**9+7)
print(ans-1)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from collections import Counter


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

cur_count = 1
for count in ctr_S.values():
    cur_count *= (count + 1)
    cur_count %= MOD

print(cur_count - 1)

Submission status: Accepted

Solution code:
input()
s=input()
d={}
for t in s:d[t]=d.get(t,0)+1
r=1
for k in d.values():r*=k+1;r%=1000000007
print(r-1)

Submission status: Accepted

Solution code:
from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

Submission status: Accepted

Solution code:
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect

setrecursionlimit(10**7)

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

M = 10 ** 9 + 7

N = read()
S = input()

d = Counter(S)
ans = 1
for k, v in d.items():
  ans = ans * (v + 1) % M
print((ans - 1) % M)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    n = I()
    s = S()
    d = defaultdict(int)
    for i in s:
        d[i] += 1
    ans = 1
    for i in d.keys():
        ans *= d[i]+1
        ans %= mod
    print(ans-1)
#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    A()

Submission status: Accepted

Solution code:
N=int(input())
S=input()
count={}
for s in S:
    count[s]=count.get(s,0)+1
retval=1
for c in count:
    retval*=(count[c]+1)
print((retval-1)%(10**9+7))

Submission status: Runtime Error

Solution code:
N = int(input())
S = str(input())
V = 'abcdefghijklmnopqrstuvwzyz'
Lavida = [1]*26
for i in range (0, N):
	Lavida[V.index(S[i])]+=1

count = 1
for i in range (0, 26):
	count*=Lavida[i]
	count=count%(10**9+7)

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

Submission status: Runtime Error

Solution code:
from string import ascii_lowercase
from functools import reduce
from operator import mul
n = int(input())
S = input()
mod = 10**9 + 7
print(reduce(lambda x, y: x*y % mod, S.count(c)+1 for c in ascii_lowercase))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){
  int MOD = 1000000007;
  int n; cin >>n;
  string s; cin >> s;
  vector <ll> num(26);
  rep(i, 26) num[i] = 0;
  for (char c:s){
    num[c-'a'] += 1;
  }
  ll ans = 1;
  rep(i, 26){
    if (num[i] != 0){
      ans *= (num[i]+1);
      ans %= MOD;
    }
  }
  cout << ans-1 << endl;
}

Submission status: Runtime Error

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: Runtime Error

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 = rlr*(dic[k]+1) % P
  
print(rlt-1)

Submission status: Runtime Error

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) %= mod
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
s = str(input())
d = Counter(s)
S = list(set(s))
ans = 1
for t in S:
    ans *= d[t] + 1
print(ans - 1)

Submission status: Runtime Error

Solution code:
from collections import Counter
n = int(input())
s = list(map(str, input().rstrip()))

whole = 2**n - 1


c = Counter(s)

nCr = {}


def cmb(n, r):
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    if (n, r) in nCr:
        return nCr[(n, r)]
    nCr[(n, r)] = cmb(n-1, r) + cmb(n-1, r-1)
    return nCr[(n, r)]


c = [x for x in list(c.values()) if x >= 2]

ans = []
for i in c:
    for j in range(2, i + 1):
        if n - i >= 2:
            ans.append(cmb(i, j) * 2**(n - i) - 1)
        else:
            ans.append(cmb(i, j) * 2**(n - i))

print(whole - sum(ans))

Submission status: Runtime Error

Solution code:
# A - Colorful Subsequence
import numpy as np

N,S = int(input()),input()
count = np.zeros(26)

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

ans = 1
for i in range(N):
    ans *= (count[i]+1)

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

Submission status: Runtime Error

Solution code:
import math, collections

n = int(input())
s = input()
ss = collections.Counter(s)
sss = list(ss.values())

cnt = 1
for i in sss:
    cnt *= (i+1)
print((cnt-1)%(1

Submission status: Runtime Error

Solution code:
use std::io::stdin;
use std::collections::HashMap;

fn main() {
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let n = st.trim().parse::<usize>().unwrap();
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let s:Vec<char> = st.trim().chars().collect();
    let mut map:HashMap<&char, i64> = HashMap::new();
    for i in &s {
        let count = map.entry(i).or_insert(1);
        *count += 1;
    };
    let mo = 100000007;
    let mut result:i64 = 1;
    for (_i, j) in map.iter() {
        result = (result*j)%mo;
    };
    println!("{}", result-1);
}


fn bisec(v:&Vec<i64>, num:&i64) -> usize {
    let mut l:usize = 0;
    let mut r = v.len() as usize;
    let mut m = (l+r)/2 as usize;
    while l < r {
        if num <= &v[m] {
            r = m;
        } else {
            l = m+1;
        };
        m = (l+r)/2;
    };
    l
}

fn max (a:&i64, b:&i64) -> i64 {
    if a < b {
        *b
    } else {
        *a
    }
}

fn min (a:&i64, b:&i64) -> i64 {
    if a > b {
        *b
    } else {
        *a
    }
}

Submission status: Runtime Error

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
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
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(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()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

n = INT()
s = list(STR())
t = list(set(s))
u = Counter(s)
v = []
for i in t:
    v.append(u[i] + 1)
ans = 1
for i in range(len(t)):
    ans *= v[i]
    ans %= mod
ans -= 1
print(ans %= mod)

Submission status: Runtime Error

Solution code:
def resolve():
    '''
    code here
    '''
    import sys
    N = int(input())
    S = sys.stdin.readlines().strip()

    set_S = set([item for item in S])
    res = 1

    for s in set_S:
        cnt = 1
        for letter in S:
            if s == letter:
                cnt += 1
        res *= cnt

    print(res-1)

if __name__ == "__main__":
    resolve()

Submission status: Runtime Error

Solution code:

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

nums = [0 for _ in range(26)]
for s in S:
    nums[ord(s) - ord('a')] += 1

ans = 1
for n in nums:
    ans = ans * (n + 1)
ans -= 1
ans %= 1000_000_007
print(ans)

Submission status: Runtime Error

Solution code:

n = int(input())
s = list(input())
t = []
ans = 1
count= []

t = set(s)
t = list(t)

for i in range(len(t)):
    count.append(s.count(t[1]))

for j in range(len(count)):
    ans *= (count[i] + 1)
print(ans-1)

Submission status: Runtime Error

Solution code:
N=int(input())
S=input()
MOD=10**9+7
x=dict()
for s in S:
    x[s]=s.get(s,0)+1
retval=1
for c in x:
    retval*=(x[c]+1)
print((retval-1)%MOD)

Submission status: Runtime Error

Solution code:
from collection import Counter
n = int(input())
s = input()

mod = 10**9+7

scnt = Counter(s).most_common()
ans = 1

for i in range(len(scnt)):
    ans = ans*scnt[i][1]%p
ans = (ans - 1 + p)%p
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

def main():
  n = int(input())
  a = [[] for row in range(200000)]
  C = [int(input()) for i in range(n)]
  b = 0
  d = [0]
  mod = 10 ** 9 + 7
  mini_ans = 0
  for i,c in enumerate(C):
    if b != c:
      for j in a[c]:
        mini_ans += (d[j] + 1) % mod
      a[c].append(i)
    d.append(mini_ans % mod)
    b = c
  print(d[-1]+1)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
num = int(input())
words = input()

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

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

print(ans - 1)

Submission status: Runtime Error

Solution code:
N = int(input())
S = list(input()+"")
#Dic={}
count=0
MOD = 10 ** 9 + 7

def ff(i,L):
    global count
    global MOD
    
    if(N>i):
        if(S[i] not in L):
            ff(i+1,L+S[i])
        ff(i+1,L)
    else:
        count += 1
        count %= MOD

ff(0,"")
print(count-1)

Submission status: Runtime Error

Solution code:
N = int(input())
S = list(input()+"")
#Dic={}
count=0

def ff(i,L):
    global count

    if(N>i):
        if(S[i] not in L):
            ff(i+1,L+S[i])
        ff(i+1,L)
    else:
        count += 1

ff(0,"")
print(count-1)

Submission status: Runtime Error

Solution code:
N = int(input())
S = list(input())
#Dic={}
count=0

def ff(i,L):
    #global Dic
    global count

    if(len(S)>i):
        if(S[i] not in L):
            ff(i+1,L+S[i])
        ff(i+1,L)
    else:
        #Dic[L]=1
        count += 1

ff(0,"")
#print(len(Dic)-1)
print(count-1)

Submission status: Runtime Error

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

Dic={}

def ff(i,L):
    if(len(S)>i):
        ff(i+1,L+S[i])
        ff(i+1,L)
    else:
        Dic[L]=1
ff(0,"")
print(len(Dic)-1)

Submission status: Runtime Error

Solution code:
n=int(input())

s=input()

s=s+str(X)

counter=1

lists=[]

for i in range(n):

  if s[i]==s[i+1]:

    counter+=1

  else:

    lists.append(counter)

    counter=1

ans=1

for i in lists:

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

print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())

s=input()

s=s+str(X)

counter=1

lists=[]

for i in range(n):

  if s[i]==s[i+1]:

    counter+=1

  else:

    lists.append(counter)

    counter=1

ans=1
13
for i in lists:

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

print(ans)

Submission status: Runtime Error

Solution code:
lis = [1 for i in range(26)]
s = str(input())
for i in range(len(s)):
  lis[ord(s[i])-ord("a")] += 1
ans = 1
for num in lis:
  ans *= num
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
S = input()
listS = list(S)
setS = set(listS)

#異なる文字から2個を選ぶ場合（2項定理の利用）
if len(listS) == len(setS):
    res = 2**len(setS)-1
    print(res)
    sys.exit()
else:
    res = 0
for x in setS:
    n = listS.count(x)
    if n == 1:
        res += 1
    else:
        res += (2**(len(setS)-1))*n
print(res)