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

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

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

Submission status: Wrong Answer

Solution code:
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    s = input()

    c = collections.Counter(s)

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

    print(ans - 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

c = collections.Counter(S)

ls = list(c.values())

ans = 1
for l in ls:
  ans *= (l+1)

print(ans-1)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
s = list(input())
C = Counter(s)
p = 1
for v in C.values():
    p = p * (v+1) % (10**9)

print(p-1)

Submission status: Wrong Answer

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

import collections

"""
ss=[s[0]]

for i in range(1,n):
    if s[i]!=s[i-1]:
        ss.append(s[i])
"""
#print(ss)

c = collections.Counter(ss)

result=1
for k in c.keys():
    result=result*(c[k]+1)

print(result-1)

Submission status: Wrong Answer

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

import collections

ss=[s[0]]

for i in range(1,n):
    if s[i]!=s[i-1]:
        ss.append(s[i])

#print(ss)

c = collections.Counter(ss)

result=1
for k in c.keys():
    result=result*(c[k]+1)

print(result-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
MOD = 10**9 + 7
from collections import defaultdict
cnt = defaultdict(int)
for si in s:
    cnt[si] += 1

dup = []
for ci in cnt:
    if cnt[ci] > 1:
        dup.append(cnt[ci])
#print(dup)

ans = pow(2, n, MOD) - 1
for di in dup:
    ans -= (pow(2, n-di, MOD) - 1)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
MOD = 10**9 + 7
from collections import defaultdict
cnt = defaultdict(int)
for si in s:
    cnt[si] += 1

dup = []
for ci in cnt:
    if cnt[ci] > 1:
        dup.append(cnt[ci])

ans = pow(2, n, MOD) - 1
from functools import reduce
import itertools
for i in itertools.product([0, 1], repeat=len(dup)):
    sum_i = sum(i)
    if sum_i > 0:
        dup_i = 0
        for j in range(len(dup)):
            if i[j] == 1:
                dup_i += dup[j]
        t = (-1)**(sum_i % 2) * pow(2, (n - dup_i), MOD)
        ans += t
print(ans % MOD)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
MOD = 10**9 + 7
from collections import defaultdict
cnt = defaultdict(int)
for si in s:
    cnt[si] += 1

dup = []
for ci in cnt:
    if cnt[ci] > 1:
        dup.append(cnt[ci])

ans = pow(2, n, MOD) - 1
from functools import reduce
import itertools
for i in itertools.product([0, 1], repeat=len(dup)):
    sum_i = sum(i)
    if sum_i > 0:
        dup_i = 0
        for j in range(len(dup)):
            if i[j] == 1:
                dup_i += dup[j]
        t = (-1)**(sum_i % 2) * pow(2, (n - dup_i), MOD)
        ans += t
print(ans)

Submission status: Wrong Answer

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

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

n_c = len(s_c)

ans = 0
for i in range(1,2**n_c):
    tmp = 1
    for j in range(n_c):
        if ((i>>j)&1):
            tmp=tmp*s_c[j]%mod
    ans+=tmp
print(ans)

Submission status: Wrong Answer

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

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

n_c = len(s_c)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
s = input().rstrip()

from collections import Counter
c = Counter(s)
ans = 0
for i in s:
  chk = 1
  for j,v in c.items():
    if j == i:
      continue
    chk *= v+1
  ans += chk
  c.update({i:-1})
  
print(ans)

Submission status: Wrong Answer

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(26):
    ans *= (count[i]+1)

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

Submission status: Wrong Answer

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(26):
    ans *= (count[i]+1)

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
_=input()
s=list(Counter(list(input())).values())
dp=[0]*len(s)
dp[0]=s[0]
for i in range(1,len(s)):
  dp[i]=dp[i-1]*(s[i]+1)+s[i]
print(dp[-1])

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
S = input()
c = Counter(S)
# print('c', c)

ans = 1
for v in c.values():
    ans *= v + 1
ans -= 1
print(ans)
# 4C4 = 1
# 4C3 = 4
# 4C2 = 6
# 4C1 = 4

# b
#  a
#   a
# ba
# b a

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import collections
c=collections.Counter(s)
c=c.most_common()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

d = defaultdict(int)

ans = 0
for s in S:
    d_tmp = d.copy()
    for k, v in d.items():
        if (k >> (ord(s)-ord('a'))) & 1 == 0:
            ans += v
            ans %= mod
            d_tmp[k+(1 << ord(s)-ord('a'))] += 1
    d = d_tmp.copy()
    d[1 << ord(s)-ord('a')] += 1
    ans += 1
    ans %= mod
print(ans)

Submission status: Wrong Answer

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

d = defaultdict(int)

ans = 0
for s in S:
    d_tmp = d.copy()
    for k, v in d.items():
        if s not in k:
            ans += v
            ans %= mod
            d_tmp[k+s] += 1
    d = d_tmp.copy()
    d[s] += 1
    ans += 1
    ans %= mod
print(ans)

Submission status: Wrong Answer

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

print(ans-1)

Submission status: Wrong Answer

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

print(ans-1)

Submission status: Wrong Answer

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

from collections import Counter

c = Counter(s)

ans = 1
for k,v in c.items():
    ans *=(v+1)

ans -=1
print(ans)

Submission status: Wrong Answer

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

from collections import Counter

c = Counter(list(s))

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

print(res - 1)

Submission status: Wrong Answer

Solution code:
from _collections import defaultdict
n=int(input())
S=input()
X=defaultdict(int)
for s in S:
    X[s]+=1
ans=1
for v in X.values():
    ans*=(v+1)
print(ans-1)

Submission status: Wrong Answer

Solution code:
from _collections import defaultdict
from itertools import combinations
n=int(input())
S=input()
X=defaultdict(int)
for s in S:
    X[s]+=1
A=1
for x in X.values():
    A*=x
ANS=A
for i in range(1,len(X.keys())//2+1):
    for comb in combinations(X.keys(),i):
        for c in comb:
            ANS+=X[c]+A//X[c]
print(ANS%(10**9+7))

Submission status: Wrong Answer

Solution code:
from _collections import defaultdict
from itertools import combinations
n=int(input())
S=input()
X=defaultdict(int)
for s in S:
    X[s]+=1
A=0
for i in range(1,len(X.keys())+1):
    for comb in combinations(X.keys(),i):
        ans=1
        for c in comb:
            ans*=X[c]
        A+=ans
print(A)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
S = input()
counts = Counter(S)
ans = 1
for count in counts.values():
    ans *= (count + 1)
ans -= 1
print(ans)

Submission status: Wrong Answer

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

    cc = collections.Counter(S)
    output = 1
    for k in cc.keys():
        output *= (cc[k] + 1)
        output %= MOD
    print(output)
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

    cc = collections.Counter(S)
    output = 1
    for k in cc.keys():
        output *= (cc[k] + 1)
    print(output-1)
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
mod = 1e9+7
ans = [1]*30
for c in s:
    ans[ord(c)-ord('a')]+=1
res = 1
for i in range(29):
    res *= ans[i]
    res %= mod
print((res-1)%mod)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
ans = [1]*30
for c in s:
    ans[ord(c)-ord('a')]+=1
res = 1
for i in range(29):
    res *= ans[i]
print(res-1)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
mod=1e9+7
tmp = [0]*30
l=r=0
ans = 0
while r < n:
    idx = ord(s[r])-ord('a')
    tmp[idx] = 1
    ans += r-l+1
    ans %= mod
    r += 1
    if r == n:
        continue
    while tmp[ord(s[r])-ord('a')]:
        tmp[ord(s[l])-ord('a')] = 0
        l += 1
print(ans)

Submission status: Wrong Answer

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

def main():
    N = int(input())
    S = input()
    L = Counter(S)
    ans = 1
    for l in L.items():
        ans *= l[1] + 1
    print(ans - 1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# AGC 031: A – Colorful Subsequence
N = int(input())
S = input()
s = set(S)
s_count = [S.count(c) + 1 for c in s]

tmp = 1
for i in s_count:
    tmp *= i

print(tmp - 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
from collections import Counter
c = dict(Counter(s))
ans = 0
for i in c:
    if ans==0:ans=c[i]
    else:
        ans *= c[i]+1
        ans += c[i]
print(ans)

Submission status: Wrong Answer

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

import collections
c = collections.Counter(li_s)
cci = c.items()
tmp = 1
for cc in cci:
    #print(cc[1])
    tmp *= (cc[1]+1)
print(tmp-1)

Submission status: Wrong Answer

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

import collections
c = collections.Counter(li_s)
cci = c.items()
tmp = 1
for cc in cci:
    #print(cc[1])
    tmp *= (cc[1]+1)
if tmp >1:
    print(tmp-1)
else:
    print(tmp)

Submission status: Wrong Answer

Solution code:
n = int(input())

A = list(input())

import collections

C = collections.Counter(A)

t = 1

for i in C.values():
    t *= (i+1)
print(t - 1)

Submission status: Wrong Answer

Solution code:
mod = 10**9+7
n = int(input())
s = input()
dic = [0 for _ in range(26)]
for i in range(n):
    dic[ord(s[i])-97] += 1
dic = [i for i in dic if i > 0]
result = 0
for i in range(1, 2**len(dic)):
    c = 1
    num = i
    for j in dic:
        if num%2==1:
            c *= j
            c %= mod
        num >>= 1
    result += c
print(result)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

c = Counter(S)
ans = 1

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

print(ans-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter, deque # https://note.nkmk.me/python-scipy-connected-components/
# from copy import copy, deepcopy
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    S=str(input())

    SS=Counter(S)

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

resolve()

Submission status: Wrong Answer

Solution code:
# import bisect
from collections import Counter, deque # https://note.nkmk.me/python-scipy-connected-components/
# from copy import copy, deepcopy
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    S=str(input())

    SS=Counter(S)

    ans=1
    for i in SS.values():
        ans*=(i+1)
    print(ans-1)

resolve()

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
# 数値(1〜26)→アルファベット(a〜z)
n2a = lambda c: chr(c+64).lower()
al=[]
for i in range(1,27):
  c=s.count(n2a(i))
  if c!=0:
    al.append(c)
def func(nums):
  if len(nums)==1:
    return nums[0]
  elif len(nums)==2:
    return nums[0]+nums[1]+nums[0]*nums[1]
  else:
    num=func(nums[1:])
    return nums[0]+num+nums[0]*num
print(func(al))

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
# 数値(1〜26)→アルファベット(a〜z)
n2a = lambda c: chr(c+64).lower()
al=[]
for i in range(1,27):
  c=s.count(n2a(i))
  if c!=0:
    al.append(c)
base=2**len(al)
ans=base-1
for i in range(len(al)):
  if al[i]==1:
    continue
  a=base//2
  ans+=a
  ans%=10**9+7
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
# 数値(1〜26)→アルファベット(a〜z)
n2a = lambda c: chr(c+64).lower()
al=[]
for i in range(1,27):
  c=s.count(n2a(i))
  if c!=0:
    al.append(c)
ans=0
for i in range(1,2**len(al)):
  b=str(bin(i))
  a=1
  j=1
  while b[-j]!='b':
    if b[-j]=='1':
      a*=al[j-1]
    j+=1
  ans+=a
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations


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

chars = set()
cnt = {}
for s in S:
    if s not in chars:
        chars.add(s)
        cnt[s] = 1
    else:
        cnt[s] += 1

ans = N
r = 2
chars = list(chars)
while r <= len(chars):
    combs = combinations(chars, r)
    for comb in combs:
        res = 1
        for c in comb:
            res *= cnt[c]
        ans += res
    r += 1

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import collections
n = int(input())
s = list(input())

ans = 1
c = collections.Counter(s)
for i in set(s):
    if c[i] == 1:
        ans *= 2
    else:
        ans *= (c[i] + 1)
print((ans - 1) % (pow(10, 9) + 1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

from collections import Counter
N = ii()
S = input()
l = Counter(S)
mod = 1e9+7

if len(l) == 1:
    print(N)
    exit()

ans = 1
for v in l.values():
    ans *= (v + 1)
    ans %= mod

print((ans-1) % mod)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

from collections import Counter
N = ii()
S = input()
l = Counter(S)
mod = 10**9+7

if len(l) == 1:
    print('1')
    exit()

ans = 1
for v in l.values():
    ans *= (v + 1)
    ans %= mod

print((ans-1)%mod)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

from collections import Counter
N = ii()
S = input()
l = Counter(S)
mod = 10**9+7

if len(l) == 1:
    print('1')
    exit()

ans = 1
for v in l.values():
    ans *= (v + 1)
    ans %= mod

print(ans - 1)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

from collections import Counter
N = ii()
S = input()
l = Counter(S)

ans = 1
for v in l.values():
    ans *= (v + 1)

print(ans - 1)

Submission status: Wrong Answer

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

from collections import Counter

c = Counter(S)

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
c = Counter(input())
ans = 1
for k,v in c.items():
  ans *= (v+1)
  
print(ans-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

S = Counter(s)
a = 1
for v in S.values():
    a *= (1+v) % mod

print(a-1)

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    import sys
    N = int(input())
    S = sys.stdin.readline().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: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    各文字について、個数+1（使わない）の選択肢がある
    全ての場合は選択肢の個数の積である
    全て使わないも含まれてしまうので-1する
    '''

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

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

Solution code:
import collections

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

MOD = 10 ** 9
c = collections.Counter(S)
ans = 1
for k, v in c.items():
    ans *= v + 1
    ans %= MOD

ans -= 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
from functools import reduce


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

    c = Counter(s)
    print(reduce(lambda x, y: x * y, map(lambda x: x + 1, c.values())) - 1)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import collections
N=int(input())
S=list(input())
l=[]
c=collections.Counter(S)
num=1
values=list(c.values())	#aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
key=list(c.keys())	#先のvalue値に相当する要素のリスト(要素1,要素2,…)
for i in range(len(key)):
    l.append([key[i],values[i]])#lは[要素i,n_i]の情報を詰めたmatrix
#print(l)
for i in range(len(l)):
    num=num*(l[i][1]+1)
print(num-1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import Counter
n = int(input())
a = Counter(input())
ans = 1
for v,c in a.items(): ans *= (1+c)%1000000007
print(ans-1)

Submission status: Wrong Answer

Solution code:
# Problem A - Colorful Subsequence

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

# initialization
word_dic = {}
ans = 1

# word count
for s in S:
    if not s in word_dic:
        word_dic[s] = 1
    else:
        word_dic[s] += 1

# output
for w in word_dic:
    tmp = word_dic[w]
    ans = ans * (tmp + 1)
ans -= 1
print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():
    N = int(input())
    S = list(input())
    SS=set(S)
    cnt=1
    for i in SS:
        cnt*=(S.count(i)+1)

    print(cnt-1)

resolve()

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

for v in a.values():
    ans *= (v+1)

print(ans-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
mod = 10**9+7
alp = [0] * 26

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

ans = 1
for c in alp:
    if (c != 0):
        ans *= (c+1) % mod

print(ans - 1)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
S=[s[i] for i in range(n)]
l=list(set(S))
a=1
for i in l:
  a *= S.count(i)+1
print(a-1)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

c = Counter(s)
ans = 1

for i in range(ord("a"), ord("z")+1):
    ans *= (c[chr(i)] + 1)

print(ans - 1)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
li=[i for i in s]
al = [chr(i) for i in range(97, 97+26)]
a=1
for i in al:
  a *= (li.count(i)+1)
print(a-1)

Submission status: Wrong Answer

Solution code:
from collections import Counter
from itertools import combinations

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

cnter = Counter(S)
alpha = set(cnter)

ans = 0

for i in range(1, len(alpha) + 1):
    if i == 1:
       ans += len(S)
    else:
        for pat in combinations(alpha, i):
            tmp = 1
            for v in pat:
                tmp *= cnter[v]
            ans += tmp

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

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

a = []
for i in range(1, N):
    for v in itertools.combinations(S, i):
        c = set(v)
        if len(c) == len(v):
            a.append(v)
        
print(len(a))

Submission status: Wrong Answer

Solution code:
from collections import Counter
mod = 10**9 + 7
n = int(input())
s = [i for i in input()]
cnt = Counter(s)
l = len(cnt)
val = list(cnt.values())
val = [i + 1 for i in val if i != 1]
ans = 2**(l-len(val)) % mod
for vi in val: ans *= vi % mod
print(ans - 1)

Submission status: Wrong Answer

Solution code:
import collections
N=int(input())
S=list(input())
c = collections.Counter(S)

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
s = [i for i in input()]
cnt = Counter(s)
l = len(cnt)
val = list(cnt.values())
val = [i + 1 for i in val if i != 1]
ans = 2**(l-len(val))
for vi in val: ans *= vi
print(ans - 1)

Submission status: Wrong Answer

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

ans = 1
for c in char:
    ans *= S.count(c) + 1
ans -=1
print(ans)

Submission status: Wrong Answer

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

from collections import Counter
c = Counter()

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

print(c.values())

ans = 1
for n in c.values():
    ans *= n + 1

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

Submission status: Wrong Answer

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

from collections import Counter
c = Counter()

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

ans = 1
for n in c.values():
    ans *= n + 1

ans -= 1
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
S = input()

import collections
n_frq_dict = collections.defaultdict(int)
for s in S:
    n_frq_dict[s] += 1

ret = 1
for frq in n_frq_dict.values():
    ret *= frq + 1

print(ret - 1)

Submission status: Wrong Answer

Solution code:
mod = 10**9 + 7

def main():
    N = int(input())
    S = input()
    num_chars = 0
    A = {}
    for s in S:
        if s not in A:
            A[s] = 0
            num_chars += 1
        A[s] += 1
    # print(num_chars, A)
    B = [(a, A[a]) for a in A]

    ans = 1
    for b in B:
        ans = (ans * (b[1] + 1)) % mod
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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[i]))

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

print(ans-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
#文字ごとの累積和を取っておく
acc_char = [0 for i in range(26)]
ans = 0
for i in range(n):
    #今回の数字は使うの確定
    char = s[i]
    plus = 1
    for j in range(len(acc_char)):
        if (ord(char) - ord('a')) != j:
            plus *= acc_char[j] + 1
    ans += plus
    acc_char[ord(char) - ord('a')] += 1
print(ans)

Submission status: Wrong Answer

Solution code:
a=int(input())
b=input()
b=list(b)
c=[0]*26
ans=0
t=0
for i in range(a):
	c[ord(b[i])-97]=c[ord(b[i])-97]+1

for j in range(26):
	t=c[j]
	for k in range(j+1,26):
		t=t*(c[k]+1)
	ans=ans+t
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

n = int(input())
S = input()
d = defaultdict(int)

for s in S:
  d[s] += 1
  
ans = 1
for v in d.values():
  ans *= v+1
print(ans-1)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

n = Counter(S)
ans = 1
for i, j in n.items():
  ans *= (j+1)
print(ans-1)