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: Wrong Answer

Solution code:
import sys, math, re
from functools import lru_cache
sys.setrecursionlimit(10**9)
import numpy as np
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    S = input()
    d = {}
    for i in range(N):
        if not S[i] in d:
            d[S[i]] = 1
        d[S[i]] += 1

    a = np.array(list(d.values()))
    ans = np.multiply.reduce(a)-1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
dic = {}
for si in s:
  if si not in dic:
    dic[si] = 0
  dic[si] += 1
ans = 1
for k, v in dic.items():
  ans *= (v+1)
print(ans-1)

Submission status: Wrong Answer

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

mod = 10**9+7
char_done = defaultdict(int)
# dp[i] := 左から0文字目(1-idx)まで見たときの答え
# 一旦空文字列も含む
dp = [0] * (N+1)
dp[0] = 1
for i in range(1,N+1):
    #print(i,'---')
    if char_done[S[i-1]] == 0:
        #print("not done",dp[i-1])
        dp[i] = 2*dp[i-1]
    else:
        dp[i] = dp[i-1]//2 + dp[i-1]
        
    #print(dp[i])
    dp[i] %= mod
    char_done[S[i-1]] = 1

print((dp[-1]-1)%mod)

Submission status: Wrong Answer

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

mod = 10**9+7
char_done = defaultdict(int)
# dp[i] := 左から0文字目(1-idx)まで見たときの答え
# 一旦空文字列も含む
dp = [0] * (N+1)
dp[0] = 1
for i in range(1,N+1):
    #print(i,'---')
    if char_done[S[i-1]] == 0:
        #print("not done",dp[i-1])
        dp[i] = 2*dp[i-1]
    else:
        dp[i] = 3*dp[i-1]//2
        
    #print(dp[i])
    dp[i] %= mod
    char_done[S[i-1]] = 1

print(dp[-1]-1)

Submission status: Wrong Answer

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

mod = 10**9+7
char_done = defaultdict(int)
# dp[i] := 左から0文字目(1-idx)まで見たときの答え
# 一旦空文字列も含む
dp = [0] * (N+1)
dp[0] = 1
for i in range(1,N+1):
    #print(i,'---')
    if char_done[S[i-1]] == 0:
        #print("not done",dp[i-1])
        dp[i] = 2*dp[i-1]
    else:
        dp[i] = 3*dp[i-1]//2
    #print(dp[i])

    char_done[S[i-1]] = 1

print(dp[-1]-1)

Submission status: Wrong Answer

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

alp = [chr(i) for i in range(97, 97+26)]

cnt = []
for a in alp:
    cnt.append(S.count(a))

ans = 1
for c in cnt:
    if c:
        ans *= (c+1)

print(ans-1)

Submission status: Wrong Answer

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

print((ans-1)%MOD)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(input())
b = list(set(a))
ans = 1
for i in b:
    ans *= a.count(i)+1
print(ans-1)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
cnt=[1]*26
for i in range(len(S)):
  cnt[ord(S[i])-ord('a')]+=1
ans=1
for i in range(26):
  ans*=cnt[i]
print(ans-1)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
cnt=[1]*26
for i in range(len(S)):
  cnt[ord(S[i])-ord('a')]+=1
ans=1
for i in range(26):
  ans*=cnt[i]
print(ans)

Submission status: Wrong Answer

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

if ans == 0:
    print(MOD-1)
else:
    print((ans-1)%MOD)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
S = input()
count_si = Counter(S)
ans = 1
for v in count_si.values():
    ans *= (v+1)
print(ans-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input()); s = input()
a = [0]*26; b = 1
for i in range(n): a[ord(s[i])-97] += 1
for i in range(26): b *= a[i]+1
print(b-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
S = input()
S_c = Counter(S)
ans = 1
mod = 10 ** 9 + 1
for val in S_c.values():
    ans *= (val + 1)
    ans %= mod

print(ans - 1)

Submission status: Wrong Answer

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

    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)

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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 comb(n, r):
    # if n - r < 0: return 0
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

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

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

    ans = 1
    for n in d.values():
        ans *= (n+1)
    print(ans-1)

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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
print(ans-1)

Submission status: Wrong Answer

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

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

ans = 0
for i in range(1, 2**len(c)):
  tmp = 1
  for j in range(len(c)):
    if (i>>j) & 1:
      tmp *= l[j]
  ans += tmp
print(ans)

Submission status: Wrong Answer

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

ans = 2 ** N - 1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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: Wrong Answer

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

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 -= 1
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
from collections import Counter

MOD = 10**9+7

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

cnt = Counter(S)

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

print(res-1)

Submission status: Wrong Answer

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)

Submission status: Wrong Answer

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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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)
    print(res - 1)


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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)
print(ans - 1)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

d = Counter(S)

# print(d)
ans = 1
for k, v in d.items():
    ans *= v + 1
print(ans - 1)

Submission status: Wrong Answer

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

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

print(ans - 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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)
print(ans-1)

Submission status: Wrong Answer

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)
ans = 1
for v in cnt.values():
    ans *= v + 1

print(ans - 1)

Submission status: Wrong Answer

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=0
for i in range(2**l):
  t=[]
  for j in range(l):
    if ((i >> j) & 1):
      t.append(temp[j])
  tt=1
  for j in range(len(t)):
    tt=tt*t[j]
  ans=ans+tt
print(ans-1)

Submission status: Wrong Answer

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)
print(ans-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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: Wrong Answer

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]//(D[s]+1))%p
        #print(D[s])
        D[s]+=1
    else:
        dp[i]=dp[i-1]*2%p
        D[s]+=1
#print(dp)
print(dp[-1]-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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
print(ans-1)

Submission status: Wrong Answer

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)

Submission status: Wrong Answer

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 *= int(i)
print(an-1)

Submission status: Wrong Answer

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
print(an-1)

Submission status: Wrong Answer

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 *= L[i]+1

print(ans-1)

Submission status: Wrong Answer

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

from collections import Counter

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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)%(10**9+7)
print(ans-1)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(input())
ans=1
s=set(S)
for t in s:
    ans*=(S.count(t)+1)
print(ans-1)

Submission status: Wrong Answer

Solution code:
from itertools import groupby
N=int(input())
S=sorted(input())
s=groupby(S)
ans=1
for key,value in s:
    v=list(value)
    ans*=len(v)+1
print(ans-1)

Submission status: Wrong Answer

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)

Submission status: Wrong Answer

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,122):
    ans *= (alpha[i]+1)%mod

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

Submission status: Wrong Answer

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,122):
    ans *= (alpha[i]+1)%mod

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
alpha = [0]*123

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
alpha = [0]*123

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
alpha = [0]*123

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

print(ans-1)

Submission status: Wrong Answer

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) % MOD
print(ans-1)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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
print(ans%(10**9+7))

Submission status: Wrong Answer

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

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

i=2
ans=sum(d)
while i<=len(d):
    tmp=itertools.combinations(d,i)
    for line in tmp:
        ans+=prod(line)
    i+=1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# あるアルファベットがN個あったとき、
# N個から一つ選ぶ or 選ばないのN + 1通り。これを全て掛け合わせ、1(一つも選ばない)を引く

import sys
readline = sys.stdin.readline

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

from collections import defaultdict
dic = defaultdict(int)

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

ans = 1
for val in dic.values():
  ans *= (val + 1)
print(ans - 1)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n = int(input())
s = list(input())
cnt = defaultdict(int)
for c in s:
    cnt[c] += 1
ans = 1
for k, v in cnt.items():
    ans *= v + 1

print(ans - 1)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
s = str(input())
d = Counter(s)
S = list(set(s))
l = len(S)
ans = 0
for i in range(2**l):
    L = [0] * l
    for j in range(l):
        if ((i >> j) & 1):
            L[j] = 1
    tmp = 0
    for k in range(l):
        if L[k] != 0:
            if tmp == 0:
                tmp = 1
            tmp *= d[S[k]]
    ans += tmp
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

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