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
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def cnt(l):
  num = 1
  for i in l:
    if i != s:
      num *= (i+1)
  return num

N = I()
s = S()

dic = {"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,}

ans = 0
for i in range(N):
  ans += cnt(list(dic.values()))//(dic[s[i]]+1)
  dic[s[i]] += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
 
N=int(input())
S=input()
#list化
T=[0]*N
for i in range(N):
  T[i]=S[i]
T.sort()
 
U=np.ones(30)#26でいいけど余裕を見て30
j=0
for i in range(N):
  if i!=0:
    if T[i]!=T[i-1]:
      j=j+1
  U[j]=U[j]+1
 
res=1
for i in range(30):
  res=res*U[i]
res=(res -1)# % (10**9 + 7)
print(int(res))

Submission status: Wrong Answer

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

MOD = 1e9 + 7
L = {}
for i in S:
  if i in L:
    L[i] += 1
  else:
    L[i] = 1

Ans = 1
for i in range(N):
  Ans = (Ans * 2) % MOD
Ans -= 1

t = 0
k = 1
for i in L.values():
  N -= i
  tt = 1
  for j in range(N):
    tt = (tt * 2) % MOD
  ttt = 1
  for j in range(i):
    ttt = (ttt * 2) % MOD
  if i != 1:
    t += (k * tt * (ttt - (i + 1))) % MOD
  k *= i + 1

Ans -= t

print(int(Ans % MOD))

Submission status: Wrong Answer

Solution code:
import collections
n=int(input())
s=list(str(input()))
c=collections.Counter(s)

testlist=list(c.values())
ans=1
for i in range(len(testlist)):
    ans=ans*(testlist[i]+1)
ans=ans-1

print(int(ans%(1e+9+7)))

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(input())
a=[0]*N
for i in range(N):
    a[i]=ord(S[i])-96
from collections import Counter
b=Counter(a)
c=b.most_common()
ans=0
if c[0][1]>=2:
    print((2**(N-1)+1)%(10**9+7))
else:
    ans=1
    for i in range(len(c)):
        ans*=(c[i][1]+1)
    print((ans-1)%(10**9+7))

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
d={}
for i in range(n):
    if s[i] in list(d.keys()):
        d[s[i]]+=1
    else:
        d[s[i]]=1
w=1
for i in list(d.values()):
    w*=(i+1)
    if w>1e9+7:
        w-=(1e9+7)
print(w-1)

Submission status: Wrong Answer

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

    flags = dict_gen()
    counts = dict_gen()
    for i in S:
        flags[i] = 1
        counts[i] += 1

    counter = flag_counter(flags)
    result = 0
    for i in range(1, counter+1):
        result += conbinations(counter, i)

    if counter != len(S):
        result += len(S) - counter
    print(result)
    
    

def flag_counter(flags):
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    counter = 0
    for i in alphabet:
        counter += flags[i]
    return counter    

def dict_gen():
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    flags = {}
    for i in alphabet:
        flags[i] = 0
    return flags

def permutations(n, r):
    upper = 1
    down = 1
    for i in range(1, n+1):
        upper *= i
    for i in range(1, n-r+1):
        down *= i
    return upper / down

def conbinations(n, r):
    down = 1
    for i in range(1, r+1):
        down *= i
    return permutations(n, r) / down

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
s = str(input())
s = list(s)
cnt = 0
for i in range(n):
  for balls in itertools.combinations(s, i):
      cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
import string

n=int(input())
s=ss=input()
ans=ans1=n**2-1

abc=string.ascii_lowercase
for i in range(26):
    if 1<s.count(abc[i]):
        ss=ss.replace(abc[i],"")
        ans1=ans-(ans-len(ss)**2)/2+1
        break        
print(int(ans1%(10**9+7)))

Submission status: Wrong Answer

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

alphabet_place = dict()
for idx, c in enumerate(s):
    if c in alphabet_place:
        alphabet_place[c].append(idx)
    else:
        alphabet_place[c] = [idx]

ans = 1
for alph, place in alphabet_place.items():
    # +1: unuse
    ans = (len(place) + 1) * ans

# all unuse
ans = ans - 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
str_dict = {}

for s in S:
    if s not in str_dict:
        str_dict[s] = 1
    else:
        str_dict[s] = str_dict[s] + 1

single_char = {k: v for k, v in str_dict.items() if v == 1}
multiple_char = {k: v for k, v in str_dict.items() if v != 1}
single_char_num = len(single_char)

base_permutation = 2 ** single_char_num % (10 ** 9 + 7)
print(base_permutation)

all_permutation = base_permutation
for v in multiple_char.values():
    print(v)
    all_permutation = all_permutation * (v + 1)
    print(all_permutation)
all_permutation = all_permutation - 1

print(all_permutation % (10 ** 9 + 7))

Submission status: Wrong Answer

Solution code:
import string

n=int(input())
s=ss=input()
ans=ans1=n**2-1

abc=string.ascii_lowercase
for i in range(26):
    if 1<s.count(abc[i]):
        ss=ss.replace(abc[i],"")
        ans1=ans-(ans-len(ss)**2)/2+1
        break        
print(int(ans1))

Submission status: Wrong Answer

Solution code:
import math

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

kind = set(S)
each_char =[]

for char in kind:
    each_char.append(S.count(char))

length = len(kind)
over_stock = len(S) - len(kind)

count = 0
for i in range(over_stock + 1):
    count += (2 ** (length - i)) * (math.factorial(over_stock) // (math.factorial(over_stock - i) * math.factorial(i)))

print(count - 1)

Submission status: Wrong Answer

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


def main():
  input()
  string = input().strip()

  count = [0] * 26

  for c in string:
    count[ord(c) - 97] += 1

  table = count[:]
  value = sum(count)

  for _ in range(len(count) - 1):
    for i in range(len(count)):
      table[i] = count[i] * sum(table[i + 1:])

    value += sum(table)

  print(value, flush=True)


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
N=int(stdin.readline().rstrip())
S=(stdin.readline().rstrip())
S=list(S)
subete=2**N-1
sa=N-len(set(S))
sasa=2**len(set(S))-1
ans=subete-sa*sasa
print(ans%(10**9+7))

Submission status: Wrong Answer

Solution code:
from itertools import combinations
n=int(input())
s=input()
ans=0
set_s=len(set([i for i in s]))
for i in range(1,set_s+1):
    koho=list(combinations((j for j in s),i))
    for j in koho:
        if len(j)==len(list(set(j))):
            ans+=1
        else:
            koho.remove(j)
print(ans%(10**9+7))

Submission status: Wrong Answer

Solution code:
N = input()
s = input()
hoge = []
charlist = list(s)
result = 1
Alist = ["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m"]
for i in Alist:
    hoge.append(charlist.count(i))
for j in hoge:
    result = result * (j + 1)
print(result -1 )

Submission status: Wrong Answer

Solution code:
import bisect
import itertools
N = int(input())
S = input()

cache = {}
for i in range(N):
    if S[i] in cache:
        cache[S[i]].append(i)
    else:
        cache[S[i]] = [i]

result = 0

route = []
for k,v in cache.items():
    route.append(len(v) - bisect.bisect_left(v, 0))
for i in range(1,28):
    xxx = result
    #i種類取り出して掛け算した値を足し込む
    for cb in itertools.combinations(route, i):
        num = 1
        for x in cb:
            num = num * x
        result += num
    if xxx == result:
        break
print(result)

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
s = input()
count = 0
unique = len(set(s))
for i in range(1, len(s)+1):
    cand = list(itertools.combinations(s, i))
    cand2 = list(itertools.permutations(set(s),i))
    if i<= unique:
        count += len(cand) - len(list(set(cand) -set(cand2)))
print(count % (10**9 + 7))

Submission status: Wrong Answer

Solution code:
from itertools import permutations

N = int(input())
S = list(input())
uniq_S = list(set(S))
len_uniq_S = len(uniq_S)

print(uniq_S)

ans = 0

for i in range(1, len_uniq_S+1):
    ans += len(list(permutations(uniq_S, i)))
    print(ans)

print(ans/1000000007)

Submission status: Wrong Answer

Solution code:
import numpy as np
 
N=int(input())
S=input()
#list化
T=[0]*N
for i in range(N):
  T[i]=S[i]
T.sort()
 
U=np.ones(100)#26でいいけど余裕を見て30
j=0
for i in range(N):
  if i!=0:
    if T[i]!=T[i-1]:
      j=j+1
  U[j]=U[j]+1

res=1
for i in range(100):
  res=res*U[i]
res=(res -1) % (10**9 + 7)
print(int(res))

Submission status: Wrong Answer

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

MOD = 1e9 + 7
L = {}
for i in S:
  if i in L:
    L[i] += 1
  else:
    L[i] = 1

Ans = (2 ** N - 1)
t = 0
k = 1
for i in L.values():
  N -= i
  if i != 1:
    t += (k * (2 ** N) * ((2 ** i) - (i + 1)))
  k *= i + 1

Ans -= t

print(Ans)

Submission status: Wrong Answer

Solution code:
import string

n=int(input())
s=ss=input()
ans=ans1=n**2

abc=string.ascii_lowercase
for i in range(26):
    if 1<s.count(abc[i]):
        ss=ss.replace(abc[i],"")
        ans1=ans-(ans-len(ss)**2)/2
        break        
print(int(ans1))

Submission status: Wrong Answer

Solution code:
import itertools
n = input()
N = int(n[0])

st = input()
S = list(st)

count = 0
for i in range(N):
    slist = list(itertools.combinations(S, i+1))
    for ls in slist:
        seq = list(ls)
        if len(seq) == len(set(seq)):
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import sys,itertools
input = sys.stdin.readline
N = int(input().strip())
S = input().strip()
Sset=set(S)

def isUnique(a):
    return len(a) == len(set(a))

cnt=0
for i in range(N):
    for j in itertools.combinations(Sset,i+1):
        if isUnique(j):
            cnt+=1
            for jj in j:
                cnt+=S.count(jj)-1
        else:
            continue

print(cnt%((10**9)+7))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
S = input()
result = 1
sub = []
for i in S:
    num = sub.count(i)
    sub.append(i)
    if num == 0:
        result *= 2
    elif num == 1:
        result *= 1.5
    elif num > 1:
        result = result*(-1/(2**(num-2))+1/(2**(num))+1/(2**(num+1)))

    if result-result//1 < 0.1:
        result //= 1
    elif result-result//1 > 0.9:
        result = result//1 + 1

result %= (10**9 + 7)
print("{}".format(int(result)-1))

Submission status: Wrong Answer

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

D = {}
for s in S :
    if s not in D :
        D[s] = 1
    else :
        D[s] += 1

L = sorted(list(D.values()))

ans = 1
if N == 1 :
    ans = 0
elif len(L) == 1 :
    ans = L[0]
elif L[0] == L[-1] :
    ans = 2**N-2
else :
    for i in range(len(L)) :
        ans *= (1+L[i])
        ans %= (10**9+7)
    ans -= 1
ans %= (10**9+7)
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations

N = int(input())
S = input()
Su = sorted(set(S), key=S.index)
cnt = 0
Nu = len(Su)

for i in range(1,Nu+1,1):
    for v in combinations(Su, i):
        tempcnt = 1
        for j in range(len(v)):
            tempcnt *= S.count(v[j])
        cnt += tempcnt

print(cnt)

Submission status: Wrong Answer

Solution code:
#AGC031A
N=int(input())
S=input()
c={}
for s in S:
    c[s]=c.get(s,0)+1
ans=0
for s in S:
    c[s]-=1
    t=1
    for k in c.keys():
        if c[k]>0 and k!=s:
            t*=c[k]+1
    ans+=t
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
S = input()

alp = "abcdefghijklmnopqrstuvwxyz"
x = [1] * 26
for i in range(N):
    x[alp.find(S[i])] += 1

print((np.prod(x)-1)%(10**9+7))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 16 21:00:45 2019

@author: iwata
"""
import itertools

N = input()
S = input()

Sset = list(set(S)) 
Sset1 = []

a = 0
b = 0

for i in range(len(Sset)):
    num = S.count(Sset[i])
    Sset1.append(num)

for j in range(len(Sset)):
    com =  list(itertools.combinations(Sset1, j+1))
    for k in range(len(com)):
        for l in range(j+1):
            if l == 0:
                a = a + com[k][l]
            else:
                a = a * com[k][l]
        b = b + a
        a = 0

print(b)

Submission status: Wrong Answer

Solution code:
import itertools

N = int(input())
S = [s for s in input()]
ans = 0
for n in range(1,N+1):
    a = list(itertools.combinations(S,min(n,(N-n))))
    a = [i for i in a if len(i) == len(set(i))]
    ans += len(a)
    
print(ans%(10**9 + 7))

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
score=1
mozis='abcdefghijklmnopqrstuvwxyz'
for i in mozis:
    point=S.count(i)+1
    score*=point

print(score-1)

Submission status: Wrong Answer

Solution code:
from collections import Counter
from itertools import product

N = int(input())
S = input().strip()
dic = Counter(S)
mod = 10**9 + 7

ans = 0
ls =list(product([0, 1], repeat=len(dic)))
ls.pop(0)

for x in ls:
    num = 1
    for z, y in zip(dic, x):
        if y == 1:
            num = dic[z]*num
            num = num%mod
    ans += num
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
str_dict = {}

for s in S:
    if s not in str_dict:
        str_dict[s] = 1
    else:
        str_dict[s] = str_dict[s] + 1

single_char = {k: v for k, v in str_dict.items() if v == 1}
multiple_char = {k: v for k, v in str_dict.items() if v != 1}
single_char_num = len(single_char)

base_permutation = (2 ** single_char_num - 1) % (10 ^ 9 + 7)

all_permutation = base_permutation + 1
for v in multiple_char.values():
    all_permutation = all_permutation * (v + 1) % (10 ^ 9 + 7)
all_permutation = all_permutation - 1

print(all_permutation % (10 ^ 9 + 7))

Submission status: Wrong Answer

Solution code:
import string

n=int(input())
s=ss=input()
ans=n**2

abc=string.ascii_lowercase
for i in range(26):
    if 1<s.count(abc[i]):
        ss=ss.replace(abc[i],"")
        
ans1=ans-(ans-len(ss)**2)/2        
print(int(ans1))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import collections
line = int(input())
string = list(input())
data = collections.Counter(string)
sum = 1
for word in data:
    sum *= (data[word] + 1)
print(sum - 1)

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
S=input()
#list化
T=[0]*N
for i in range(N):
  T[i]=S[i]
T.sort()

U=np.ones(30)#26でいいけど余裕を見て30
j=0
for i in range(N):
  if i!=0:
    if T[i]!=T[i-1]:
      j=j+1
  U[j]=U[j]+1

res=1
for i in range(30):
  res=res*U[i]
res=(res -1) % (10**9 + 7)
print(int(res))

Submission status: Wrong Answer

Solution code:
from collections import Counter
from itertools import product

N = int(input())
S = input().strip()
dic = Counter(S)

ans = 0
ls =list(product([0, 1], repeat=len(dic)))
ls.pop(0)

for x in ls:
    num = 1
    for z, y in zip(dic, x):
        if y == 1:
            num = dic[z]*num
    ans += num
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
line = int(input())
string = list(input())
print(string)
data = collections.Counter(string)
sum = 1
for word in data:
    sum *= (data[word] + 1)
print(sum - 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = list(set(s))
alpha = {}
for i in range(len(t)):
    alpha[t[i]] = s.count(t[i])

count = 1
for k, v in alpha.items():
    count *= (v + 1)
count -= 1
print(count)

Submission status: Wrong Answer

Solution code:
import string

n=int(input())
s=ss=input()
ans=n**2

abc=string.ascii_lowercase
for i in range(26):
    if 1<s.count(abc[i]):
        ss=ss.replace(abc[i],"")
        
ans1=ans-(ans-len(ss)**2)/2        
print(ans1)

Submission status: Wrong Answer

Solution code:
import itertools

length = int(input())
string = input()

count = length

def cheaker(seq):
	max = len(seq)
	unique = len(set(seq))
	if(max!=unique):
		return False
	else:
		return True

for strlen in range(2,length):
	partstr_l = list(itertools.combinations(string,strlen))
	for partstr in partstr_l:
		if(cheaker(partstr)):
			count+=1

if(cheaker(string)): count+=1

print(count%1000000007)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
str_dict = {}

for s in S:
    if s not in str_dict:
        str_dict[s] = 1
    else:
        str_dict[s] = str_dict[s] + 1

single_char = {k: v for k, v in str_dict.items() if v == 1}
multiple_char = {k: v for k, v in str_dict.items() if v != 1}
single_char_num = len(single_char)

base_permutation = 2 ** single_char_num - 1

all_permutation = base_permutation + 1
for v in multiple_char.values():
    all_permutation = all_permutation * (v + 1)
all_permutation = all_permutation - 1

print(all_permutation % (10 ^ 9 + 7))

Submission status: Wrong Answer

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

D = {}
for s in S :
    if s not in D :
        D[s] = 1
    else :
        D[s] += 1

L = list(D.values())

ans = 1
if N == 1 :
    ans = 0
elif len(L) == 1 :
    ans = L[0]
else :
    for i in range(len(L)) :
        ans *= (1+L[i])
        ans %= (10**9+7)
    ans -= 1
ans %= (10**9+7)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
t = list(set(s))
alpha = {}
for i in range(len(t)):
    if not t[i] in alpha:
        alpha[t[i]] = 1
    else:
        alpha[t[i]] += 1

count = 1
for k, v in alpha.items():
    count *= (v + 1)
count -= 1
print(count)

Submission status: Wrong Answer

Solution code:
from collections import Counter
c=Counter()
N=int(input())
c=Counter(input())
ans=1
for i,b in c.items():
    if b>1:
        ans*=(b+1)
    else:
        ans*=2
print(ans-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
 
S_s = set(S)
S1 = list(S_s)
m = 1
for i in S1:
  n = S.count(i)
  m = (n + 1)*m
print(m - 1)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
str_dict = {}

for s in S:
    if s not in str_dict:
        str_dict[s] = 1
    else:
        str_dict[s] = str_dict[s] + 1

single_char = {k: v for k, v in str_dict.items() if v == 1}
multiple_char = {k: v for k, v in str_dict.items() if v != 1}
single_char_num = len(single_char)

base_permutation = 2 ** single_char_num - 1

all_permutation = base_permutation + 1
for v in multiple_char.values():
    all_permutation = all_permutation * (v + 1)
all_permutation = all_permutation - 1

print(all_permutation)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(input())
ans=0
z=list(set(s))
m=len(z)
for i in range(m):
    ans+=s.count(z[i])*(2**(m-1))
print(ans-m+1)

Submission status: Wrong Answer

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

D = {}
for s in S :
    if s not in D :
        D[s] = 1
    else :
        D[s] += 1

L = list(D.values())

ans = 1
if N == 1 :
    ans = 0
elif len(L) == 1 :
    ans = L[0]
else :
    for i in range(len(L)) :
        ans *= (1+L[i])
    ans -= 1
ans %= (10**9+7)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
 
S_s = set(S)
S1 = list(S_s)
m = 1
for i in S1:
  n = S.count(i)
  m = (n + 1)*m
  print(m)
print(m - 1)

Submission status: Wrong Answer

Solution code:
import itertools
n=int(input())
s=input()
k=list(set(s))

counta=0

for i in range(1,len(k)+1):
    li=list(itertools.combinations(k,i))

    
    for h in li:
        q=1
        for l in h:
            q*=s.count(l)
     
        counta+=q
    
print(counta)

Submission status: Wrong Answer

Solution code:

n = int(input())

s = input()

x = []

for i in range(n):
    x.append(s[i])

import collections

clist = collections.Counter(x)

y = list(clist.values())

cnt = 1

for item in y:
    cnt = cnt * (item + 1)

print(cnt - 1)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
iD = 10**9+7
aT={}
for s in S:
    if s in aT:
        aT[s]+=1
    else:
        aT[s]=1
iRes = 2**N - 1

iC = 0
for s in aT:
    iT = aT[s]
    if 1 < iT:
        iRes -= 2**(N-iT)
        iC += 1
if iC == 0:
    print(iRes % iD)
else:
    iRes += (2**iC - 1 - iC)
    iC -=1
    print((iRes + iC) % iD )

Submission status: Wrong Answer

Solution code:
n = input()
S = input()
L = [1] * 26
ans = 0
for c in S:
    n = ord(c) - 97
    ans += L[n]
    for i in range(26):
        if i != n:
            L[i] *= 2
            L[i] %= (10**9+7)
    ans %= (10**9+7)
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    s = input()
    diff_chars = {}
    for i in s:
        if i not in diff_chars.keys():
            diff_chars[i] = 1
        else:
            diff_chars[i] += 1
    p = (int)(1e9+7)
    total = pow(2,n,p)
    val = 0

    for i in diff_chars:
        if diff_chars[i] > 1:
            val += diff_chars[i]
    total -= pow(2,val,p)

    if val > 0:
        total += 1

    print(total%p)
            

main()

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
iD = 10**9+7
aT={}
for s in S:
    if s in aT:
        aT[s]+=1
    else:
        aT[s]=1
iRes = 2**N - 1

iC = 0
for s in aT:
    iT = aT[s]
    if 1 < iT:
        iRes -= 2**(N-iT)
        iC += 1
if iC == 0:
    print(iRes)
else:
    iRes += (2**iC - 1 - iC)
    iC -=1
    print(iRes + iC )

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
Dict = {}

import itertools

for i in range(N):
	if S[i] in Dict:
		Dict[S[i]] = Dict[S[i]] + 1
	else:
		Dict[S[i]] = 1

count = 0

L = len(Dict)
seq = Dict.keys()

for i in range(L):
	for lis in list(itertools.combinations(seq,i+1)):
		add = 1
		for key in lis:
			add = add * Dict[key]
		count = count + add

print(count)

Submission status: Wrong Answer

Solution code:
n = input()
S = input()
L = [1] * 26
ans = 0
for c in S:
    n = ord(c) - 97
    ans += L[n]
    for i in range(26):
        if i != n:
            L[i] *= 2 % (10**9+7)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
L = [chr(ord('a') + i) for i in range(26)]
cnt = [0]*26
for i in range(len(S)):
  cnt[ord(S[i])-97] += 1
D = []
for i in range(26):
  if cnt[i] != 0:
    D.append(cnt[i])
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
ans = 0
n = 2
for X in range(1,2**len(D)):
  k = Base_10_to_n(X, n).zfill(len(D))
  cur = 1
  for i in range(len(k)):
    if k[i] == '1':
      cur *= D[i]
  ans += cur
print(ans)

Submission status: Wrong Answer

Solution code:
n = input()
S = input()
L = [1] * 26
ans = 0
for c in S:
    n = ord(c) - 97
    ans += L[n]
    for i in range(26):
        if i != n:
            L[i] *= 2 // (10**9+7)
print(ans)

Submission status: Wrong Answer

Solution code:
_=input()
S=input()

"""
S=""
import random
AL=["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
for i in range(10):
    t=int(random.random()*20)
    S+=AL[t]
    print(AL[t])
    print(S)
print(S)
"""
obj={}
L=[]
r=1
for i in S:
    if i in L:
        obj[i]+=1
        r=int(r*(1+1/(2**obj[i])))
    else:
        r*=2
        obj[i]=0
        L.append(i)

    if r>(10**9+7):
        r-=(10**9+7)
        
print(r-1)

Submission status: Wrong Answer

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

n = int(input())
s = input()
d =  0
answer = (2**n -1)

for i in range(n):
  for j in range(n-i):
    if s[i:i+1] == s[i+j+1 : i+1+j+1]:
      d += 1
    
for k in range(d):
    answer -=  (2**(n-2)-d+1)
print(answer)

Submission status: Wrong Answer

Solution code:
import sys
from  collections import deque
sys.setrecursionlimit(10**7)
def dfs(base, n, s, cur):
  if cur == n:
    return 1
  else:
    return (dfs(base, n, s, cur+1)+(0 if base[cur] in s else dfs(base, n, s+base[cur], cur+1)))%(10^9+7)

N = int(input())
S = list(input().strip())
print(dfs(S,N,"",0)-1)

Submission status: Wrong Answer

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

import itertools

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

alphabet_map = {}
for i in range(n):
    if s[i] in alphabet_map.keys():
        alphabet_map[s[i]] += 1
    else:
        alphabet_map[s[i]] = 1

sum = 0
for i in range(len(alphabet_map.keys())):
    for comb in itertools.combinations(list(alphabet_map.keys()), i + 1):
        tmp = 1
        for x in comb:
            tmp *= alphabet_map[x]
        sum += tmp
print(sum)

Submission status: Wrong Answer

Solution code:
input()
S = input().strip()
type = len(set(list(S)))

def DP(i,s):
  # 葉
  if len(s) <= i:
    return 1 if len(s) > 0 else 0
  if len(s) >= type:
    return 1
  
  # S[i]を採用しない枝
  notadopt = DP(i+1, s)
  
  # S[i]を採用する枝
  if S[i] not in s:
    s += S[i]
    adopt = DP(i+1, s)
  else:
    adopt = 0

  return adopt + notadopt

print(DP(0, '')%(10**9+7))

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
s = list(map(str,input()))
count = 0
unique = len(set(s))
for i in range(1, len(s)+1):
    cand = list(itertools.combinations(s, i))
    print(cand)
    if i ==1:
        count += len(cand)
    elif i<= unique:
        for j in range(len(cand)):
            if len(set(cand[j])) == i:
                count +=1
print(count % (10**9 + 7))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
listS = list(S)
set = list(set(listS))
countS=1
for i in range(len(set)):
  count = listS.count(set[i])
  countS *= count+1
countS -= 1
print(countS%(10^9+7))

Submission status: Wrong Answer

Solution code:
from collections import Counter

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


unique = 0
not_unique = 1
for v in Counter(S).values():
    if 1 == v:
        unique += 1
    else:
        not_unique *= v + 1

print(2 ** unique * not_unique - 1)

Submission status: Wrong Answer

Solution code:
n = input()
S = input()
L = [1] * 26
ans = 0
for c in S:
    n = ord(c) - 97
    ans += L[n]
    for i in range(26):
        if i != n:
            L[i] *= 2
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
Slice =[]
SliceSet = []
count = 0
for i in range(len(S)):
  for j in range(len(S)-i+1):
    if j >26 :
      break
    Slice = S[i:i+j]
    SliceSet = set(Slice)
    if len(Slice) == len(SliceSet):
      count += 1
print(count%(1000000000 + 7))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
 
S_s = set(S)
S1 = list(S_s)
m = 1
for i in S1:
  n = S.count(i)
  m = (n + 1)*m
print((m - 1) % (10^9 + 7))

Submission status: Wrong Answer

Solution code:
from collections import Counter
from itertools import combinations
import numpy as np
n = int(input())
s = input()
counter = Counter()
counter.update(s)
counter.values()
counts = 0
for x in range(1, len(counter) + 1):
    for pairs in combinations(counter, x):
        values = np.array([counter[index] for index in pairs])
        counts += np.prod(values)
print(int(counts % (1e9 + 7)))

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
S=set(s)
ss=len(s)
SS=len(S)
A=2**SS-1
a=2**(SS-1)
a=a*(ss-SS)
b=a+A
print(b%100000007)

Submission status: Wrong Answer

Solution code:
n = input()
S = input()
L = [0]*(1<<26)
L = [1] * 26
ans = 0
for c in S:
    n = ord(c) - 97
    ans += L[n]
    for i in range(26):
        if i != n:
            L[i] *= 2
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
a = [0] * 26
c = 1

for i in range(0, n):
    a[ord(s[i]) - ord("a")] += 1
    p = a[ord(s[i]) - ord("a")]
    c = c // p * (p + 1)
    
print(c - 1)

Submission status: Wrong Answer

Solution code:
_=input()
S=input()

"""
S=""
import random
AL=["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
for i in range(10):
    t=int(random.random()*20)
    S+=AL[t]
    print(AL[t])
    print(S)
print(S)
"""
obj={}
L=[]
r=1
for i in S:
    if i in L:
        obj[i]+=1
        r=r*int((1+1/(2**obj[i])))
    else:
        r*=2
        obj[i]=0
        L.append(i)

    if r>(10**9+7):
        r-=(10**9+7)
        
print(r-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
Slice =[]
SliceSet = []
count = 0
for i in range(len(S)):
  for j in range(len(S)-i+1):
    if j >26 :
      break
    Slice = S[i:i+j]
    print(Slice)
    SliceSet = set(Slice)
    if len(Slice) == len(SliceSet):
      count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import collections
n=int(input())
l=list(input())
c=collections.Counter(l)
s=set(l)
ans=1
for i in s:
    ans*=(c[i]+1)
ans=ans-1
print(ans%(10**2+7))

Submission status: Wrong Answer

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

l = list(S)

ans = 1
for c in range(ord('a'), ord('z') + 1):
    c = chr(c)
    ans *= (l.count(c) + 1)
ans -= 1
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
S = input()

alp = "abcdefghijklmnopqrstuvwxyz"
x = [1] * 26
for i in range(N):
    x[alp.find(S[i])] += 1

print((np.prod(x)-1)%10**9+7)

Submission status: Wrong Answer

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

D = {}
for s in S :
    if s not in D :
        D[s] = 1
    else :
        D[s] += 1

L = list(D.values())

ans = 1

if len(L) == 1 :
    ans = L[0]
else :
    for i in range(len(L)) :
        ans *= (1+L[i])
    ans -= 1
print(ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce


def product(a, b):
    return a*b


N = int(input())
S = input()
count = 0
alpha = [1] * 26
left = 0
for s in S:
    #print(ord(s) - ord("a"), s)
    alpha[ord(s) - ord("a")] += 1
ans = reduce(product, alpha)
print(ans - 1)


"""
for i in range(len(S)):
    if alpha[ord(S[i]) - ord("a")] == -1:
        alpha[ord(S[i]) - ord("a")] == i
        continue
    else:
        count += sum_(i-left)
        count %= 10**9+7
        # 書き換える
        left = alpha[ord(S[i]) - ord("a")] + 1
        alpha[ord(S[i]) - ord("a")] = i
count += sum_((N - 1)-left)
count %= 10**9+7
print(count)
"""

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(input())
 
S_s = set(S)
S1 = list(S_s)
m = 1
for i in S1:
  n = S.count(i)
  m = (n + 1)*m
print(m - 1)

Submission status: Wrong Answer

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

s=[]
a=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(26):
    s.append(0)

for i in S:
    s[a.index(i)]+=1

result=1

for j in s:
    result=result*(j+1)

print result-1