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:
N = int(input())
S = input()
cnt = []
ans = 1
alphabet = dict.fromkeys("abcdefghijklmnopqrstuvwxyz",0)

for i in alphabet:
    countable=S.count(i)
    if countable >= 1:
        cnt.append(countable + 1)
        
for i in range(len(cnt)):
    ans *= cnt[i]

print(ans - 1)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(input())
import collections
L=collections.Counter(S).values()
ans=-1
A=1
for i in L:
  A*=(i+1)
print(ans+A)

Submission status: Wrong Answer

Solution code:
for t in range(1):
	n=int(input())
	s=input()
	freq=[0]*(26)
	ct=0
	for i in range(len(s)):
		freq[ord(s[i])-ord('a')]+=1
		if freq[ord(s[i])-ord('a')]==1:
			ct+=1
	ans=1
	for i in range(26):
		if freq[i]>0:
			ans=(ans*freq[i])%1000000007
	print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
cnt = []
ans = 1
alphabet = dict.fromkeys("abcdefghijklmnopqrstuvwxyz",0)

for i in alphabet:
    countable=S.count(i)
    if countable != 0:
        cnt.append(countable + 1)
        
for i in range(len(cnt)):
    ans *= cnt[i]

print(ans - 1)

Submission status: Wrong Answer

Solution code:
from collections import Counter

import scipy.misc as scm

n = int(input())
s = list(input())
tmp = len(set(s))
count_s = Counter(s)
count_s = count_s.most_common()
ans = 1
for i in range(tmp):
  if count_s[i][1] > 1:
    ans *= (count_s[i][1]+1)
    ans = ans % (10**9+7)
  else:
    ans *= 2
    ans = ans % (10**9+7)
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

import scipy.misc as scm

n = int(input())
s = list(input())
tmp = len(set(s))
count_s = Counter(s)
count_s = count_s.most_common()
ans = 1
for i in range(tmp):
  if count_s[i][1] > 1:
    ans *= (count_s[i][1]+1)
    ans %= (10**9+7)
  else:
    ans *= 2
    ans %= (10**9+7)
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

import scipy.misc as scm

n = int(input())
s = list(input())
tmp = len(set(s))
count_s = Counter(s)
count_s = count_s.most_common()
ans = 1
for i in range(tmp):
  if count_s[i][1] > 1:
    ans *= (count_s[i][1]+1)
  else:
    ans *= 2
print(ans-1)

Submission status: Wrong Answer

Solution code:
from collections import Counter

import scipy.misc as scm

n = int(input())
s = list(input())
tmp = len(set(s))
count_s = Counter(s)
count_s = count_s.most_common()
ans = 1
for i in range(tmp):
  if count_s[i][1] > 1:
    ans *= (count_s[i][1]+1)
  else:
    ans *= 2
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
v = [0] * 26
for i in range(0, N):
    v[ord(S[i]) - 97] += 1
wa = 1

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

Submission status: Wrong Answer

Solution code:
input()
S=input()
L=list("abcdefghijklmnopqrstuvwxyz")
C=[1]*26
for s in S:
    C[L.index(s)]+=1
ans=1
for c in C:
    ans*=c
print(ans-1)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
l=[1 for i in range(26)]
L=[chr(i) for i in range(97,97+26)]
for j in range(len(s)):
  l[L.index(s[j])]+=1
ans=1
for k in range(26):
  ans*=l[k]
print(ans-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# colorful subsequence
def check_list(checked, dst, result):
    if dst not in checked:
        result += 1
        checked.append(dst)
    return checked, result

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

result = 0
checked = []
base = []
prg = []
for i in range(N):
    if i == 0:
        for j in range(N):
            dst = S[j]
            prg.append(j)
            checked, result = check_list(checked, dst, result)
        base = checked
        checked = []
    else:
        # choice base
        prg_tmp = []
        for j, b in enumerate(base):
            # baseの次の文字から選択
            k = 1
            while prg[j]+k < len(S):
                dst = b + S[prg[j]+k]
                if dst not in checked:
                    prg_tmp.append(prg[j]+k)
                checked, result = check_list(checked, dst, result)
                k += 1
        prg = prg_tmp
        base = checked
        checked = []

print(result)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
s = input()
z = list(Counter(s).values())
len_z = len(z)
ans = 0
def f(a, ret):
    if a == len_z:
        return ret
    return f(a + 1, ret * z[a]) + f(a + 1, ret)
print(f(0, 1) - 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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

S = sorted(S)  # アルファベット順に並べ替え
U = [0] * 26  # ユニーク数数え上げ
tmp = "0"
count = 0
u_count = 0
for i in range(N):
    if i > 0:
        if tmp == S[i]:
            U[count] += 1
        else:
            tmp = S[i]
            count += 1
            U[count] += 1
    else:
        tmp = S[i]
        U[count] += 1

for u in range(26):
    if U[u] != 0:
        u_count += 1

for i in range(len(U)):
    if U[0] == 0:
        U.pop(0)

U = list(map(lambda x: x + 1, U))
a = 10 ** 9 +7
print((np.array(U).prod() - 1) % a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

S = sorted(S)  #  アルファベット順に並べ替え
U = [0] * 26  #  ユニーク数数え上げ
tmp = "0"
count = 0
u_count = 0
for i in range(N):
    if i > 0:
        if tmp == S[i]:
            U[count] += 1
        else:
            tmp = S[i]
            count += 1
            U[count] += 1
    else:
        tmp = S[i]
        U[count] += 1


for u in range(26):
    if U[u] != 0:
        u_count += 1


for i in range(len(U)):
    if U[0] == 0:
        U.pop(0)

U = list(map(lambda x:x+1, U))
print(np.array(U).prod()-1)

Submission status: Wrong Answer

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

n = int(input())
S = list(input())
dic = {}

for d in S:
    if d not in dic:
        dic[d] = 1
    else:
        dic[d] += 1
tot = 1
for d in dic:
    i = dic[d] + 1
    tot = tot*i % (10**9 + 7)

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

Submission status: Wrong Answer

Solution code:
import math
import copy
from collections import Counter
 
 
 
def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:
 
            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l
 

n=input()
s=input()

mod=7+10**9


def func():
    dp=[]*26
    dic = Counter(s)
    ans = 1
    for x in dic:
        ans = ans*(dic[x]+1)%mod
    return ans
    
print(func())

Submission status: Wrong Answer

Solution code:
#A問題
import collections
N=int(input())
S=str(input())
Slist=list(S)
c = collections.Counter(Slist)
d = c.most_common()
dlen=len(d)
count=-1
for i in range(dlen):
    count+=d[i][1]+1
count%=1000000007
print(count)

Submission status: Wrong Answer

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

from collections import defaultdict
import string
d = defaultdict(int)
let = string.ascii_lowercase

for ele in s:
  d[ele] += 1

ans = 1
for i in range(26):
  if d[let[i]]>0:
    ans *= d[let[i]]+1
print(ans-1)

Submission status: Wrong Answer

Solution code:
import math
def combinations_count(n, r):
    if n<r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N=int(input())
S=input()
v=[0]*26
souwa=-1
minus=0
kaburi=False
for i in range(0,N):
    v[ord(S[i])-97]+=1

    souwa += combinations_count(N, i)

    if i>=2:
        tame = 0
        for j in range(26):
            if v[j] >= 2:
                if i < v[j]:
                    tame += math.factorial(v[j])
                tame += combinations_count(i, v[j])
                print(combinations_count(i, v[j]))

                kaburi = True
        if tame <= combinations_count(N, i):
            souwa -= tame
        else:
            souwa -= combinations_count(N, i)

if not kaburi:
    souwa += 1

print((souwa-minus)%(10**9+7))

Submission status: Wrong Answer

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

char = []
num = 1
while(len(S) > 0):
    num = num * (S.count(S[0]) + 1)
    print(S[0] + " : count = {}, num = {}".format(S.count(S[0]), num))
    S = S.replace(S[0], "")

num = num - 1
print(num % 1000000007)

Submission status: Wrong Answer

Solution code:
input();s=input()
a,*b=[s.count(i)+1for i in set(s)]
for t in b:a*=t
print(a-1)

Submission status: Wrong Answer

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

A = [0] * 256

bf = 0
for i in range(N):
    A[ord(S[i])] = A[ord(S[i])] + 1
    count = A[ord(S[i])]
    bf = bf + int(bf/count) + 1

print(int(bf%1000000007))

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
a = 1
for c in [chr(i) for i in range(97, 123)]:
    a = (a * (S.count(c) + 1)) % (1e9 + 7)
print((a - 1) % (1e9 + 7))

Submission status: Wrong Answer

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

result = 0
route = [x for _,x in collections.Counter(S).items()]

for i in range(1,len(route)+1):
    for cb in itertools.combinations(route, i):
        num = 1
        for x in cb:
            num = num * x
        result += num%(10**9+7)
print(result)

Submission status: Wrong Answer

Solution code:
import numpy as np
import collections
n = int(input())
s = list(str(input()))
c = collections.Counter(s)
num = len([i[0] for i in c.items() if i[1]==1])
value, count = zip(*c.most_common())
count = np.array(count)
count = np.prod(np.array(count[count>1])+1)
ans = (2 ** num) * count - 1
print(ans%(10**9+7))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict


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


N = readln()[0]
S = input()
mod = 10**9+7

dic = defaultdict(lambda: 0)
for s in S:
    dic[s] += 1
ans = 1
for count in dic.values():
    # print(count)
    ans *= (count + 1) % mod

# print(ans)
print((ans-1))

Submission status: Wrong Answer

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

result = 0
route = [x for _,x in collections.Counter(S).items()]

if len(route) == N:
    result = 2**len(route) - 1
else:
    for i in route:
        result += i**len(route)%(10**9+7)
print(result)

Submission status: Wrong Answer

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

dp = [0] * (N+1)
A = [0] * 256

for i in range(N):
    A[ord(S[i])] = A[ord(S[i])] + 1
    count = A[ord(S[i])]
    dp[i+1] = dp[i] + int(dp[i]/count) + 1

print(int(dp[N]%1000000007))

Submission status: Wrong Answer

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_Grand_Contest031-A
#  TODO https://atcoder.jp/contests/agc031/tasks/agc031_a
from collections import Counter

def solveProblem(S):
	# Sはサンプル3の[abcab]を取って説明
	SSorted = sorted(S)
	# SSorted = aabbc
	stringCounterBox = Counter(SSorted)
	# [(a,2),(b,2),(c,1)]
	maxStrLength = len(stringCounterBox)
	# 文字そのものを並べる文字列長さは 1から3まで
	# print("maxStringLength:{}".format(maxStrLength))
	countList = list(stringCounterBox.values())
	# [2,2,1] と 各文字数だけ取り出した配列になった
	# print("countList:{}".format(countList))
	'''
	戦略
	1個の時→1個の配列を取り出した物を足す→2 + 2 + 1 = 5
	2個の時→取り出す文字は文字毎に数字だけパターンが替わる→ 2*2 + 2*1 + 2* 1 = 8
	3個の時 同上→ 2*2*1 = 4
	これ以上の取り出しはもう出来ない:同じ文字が出てくるため
	5 + 8 + 4 = 17 と答えと一致した
	TODO 取り出す配列番号を調べる方法が不明
	この場合なら2個の時0番目と1番目,0番目と2番目,1番目と2番目を洗い出すのはどうするのか？
	偉い人の回答待ち
	'''
	counter = 1
	for i in range(0,len(countList),+1):

		counter = (counter * (countList[i]+1)) % (10^9+7)

	answer = counter-1
	return answer


if __name__ == '__main__':
	_ = int(input().strip())
	S = str(input().strip())
	solution = solveProblem(S)
	print("{}".format(solution))

Submission status: Wrong Answer

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

dp = [0] * (N+1)
A = [0] * 256

for i in range(N):
    A[ord(S[i])] = A[ord(S[i])] + 1
    count = A[ord(S[i])]
    dp[i+1] = dp[i] + dp[i]/count + 1

print(dp[N]%1000000007)

Submission status: Wrong Answer

Solution code:
P=10**9+7
N=int(input())
S=input()
ans=0
dict={}

for s in set(S):
    dict[s]=0

ans=2
dict[S[0]]=2

for i in range(1,N):
    inc=ans-dict[S[i]]
    ans=(ans+inc)%P
    dict[S[i]]=(dict[S[i]]+inc)%P

print(ans-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
keys = set(list(S))
sum = N ** 2
for key in keys :
    if S.count(key) > 1 :
        sum -= S.count(key) ** 2

if sum == N ** 2:
    print( (sum-1) % (10**9 + 7) )
else :
    print(sum % (10**9 + 7) )

Submission status: Wrong Answer

Solution code:
import itertools
import collections

n = int(input())
s = list(input())
c = collections.Counter(s)

a = []
for v in c.values():
    a += [v]
le = list(range(len(a)))
ans = sum(a)
for i in range(len(a),1,-1):
    for c in list(itertools.combinations(le,i)):
        t = 1
        for j in c:
            t *= a[j]
        ans += t%1000000007
print(ans)

Submission status: Wrong Answer

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_Grand_Contest031-A
#  TODO https://atcoder.jp/contests/agc031/tasks/agc031_a
from collections import Counter

def solveProblem(S):
	# Sはサンプル3の[abcab]を取って説明
	SSorted = sorted(S)
	# SSorted = aabbc
	stringCounterBox = Counter(SSorted)
	# [(a,2),(b,2),(c,1)]
	maxStrLength = len(stringCounterBox)
	# 文字そのものを並べる文字列長さは 1から3まで
	print("maxStringLength:{}".format(maxStrLength))
	countList = list(stringCounterBox.values())
	# [2,2,1] と 各文字数だけ取り出した配列になった
	print("countList:{}".format(countList))
	'''
	戦略
	1個の時→1個の配列を取り出した物を足す→2 + 2 + 1 = 5
	2個の時→取り出す文字は文字毎に数字だけパターンが替わる→ 2*2 + 2*1 + 2* 1 = 8
	3個の時 同上→ 2*2*1 = 4
	これ以上の取り出しはもう出来ない:同じ文字が出てくるため
	5 + 8 + 4 = 17 と答えと一致した
	TODO 取り出す配列番号を調べる方法が不明
	この場合なら2個の時0番目と1番目,0番目と2番目,1番目と2番目を洗い出すのはどうするのか？
	偉い人の回答待ち
	'''
	counter = 1
	for i in range(0,len(countList),+1):

		counter = (counter * (countList[i]+1)) % (10^9+7)

	answer = counter-1
	return answer


if __name__ == '__main__':
	_ = int(input().strip())
	S = str(input().strip())
	solution = solveProblem(S)
	print("{}".format(solution))

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

cnt = Counter(list(s))
num = 1
for i in cnt.values():
    num = (num * (i+1)) % (1e09 + 7)

print(num - 1)

Submission status: Wrong Answer

Solution code:
from sys import exit
L = int(input())
# a = [int(input()) for _ in range(N)]
S = str(input())
dic = {}
for s in S:
    if not s in dic:
        dic[s] = 1
    else:
        dic[s]+=1
kind = list(dic.keys())
kind_num = len(kind)
ans = 0
for bit in range(1,(1 << kind_num)):
    tmp = 1
    for i in range(0,kind_num):
        if(bit & (1 << i)):
            tmp*=dic[kind[i]]
    ans+=tmp
print(ans)
exit()

Submission status: Wrong Answer

Solution code:
from collections import Counter
from itertools import combinations
from itertools import accumulate
import operator
def comb(y, x):
    t = 1
    for i in range(1, min(x, y - x) + 1):
        t = t * (y + 1 - i) // i
    return t
n = int(input())
s = input()
z = list(Counter(s).values())
ans = 0
for i in range(1, len(z) + 1):
    for li in combinations(z, i):
        ans += list(accumulate(li, operator.mul))[-1]
print(ans)

Submission status: Wrong Answer

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

    str_list = list()
    for s in S:
        str_list.append(s)

    str_uni_list = {}
    for str in str_list:
        if (str in str_uni_list) is False:
            str_uni_list[str] = 1
        else:
            str_uni_list[str] += 1

    list_val = []
    for i in str_uni_list.values():
        list_val.append(i)

    ans = 0
    for i in range(len(list_val)):
        for j in range(i + 1, len(list_val)):
            for k in range(1, len(list_val) - j + 1):
                temp = list_val[i]
                for m in range(j, j + k):
                    temp *= list_val[m]
                ans += temp

    print(N + ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
import copy
 
 
 
 
def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:
 
            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l
 

n=input()
s=input()

mod=int(math.pow(10, 9)+7)
def help1(a):
    all=0
    a1=1
    b1=1
    while a!=0:
        a1=a1*a;
        a1=a1/b1%mod;
        b1+=1
        a=a-1
        all=(all+a1)%mod
    return int(all)

def func():
    count=help1(len(s))
    dic={}

    for c in s:
        if c in dic:
            dic[c]=dic[c]+1
        else:
            dic[c]=1
    res=len(s)
    l=[]
    for k in dic:
        if dic[k]==1:
            l.append(k)
    for obj in l:
        del dic[obj]
        
    count2=1
    sum1=0
    for k in dic:
        sum1+=dic[k]
        count2=count2*(1+dic[k])



    number3=help1(sum1)-count2+1

    number4=help1(len(s)-sum1)+1

    number3=number3*number4
    return count-number3
  

print(func())

Submission status: Wrong Answer

Solution code:
import itertools

N = int(input())
String_List = list(input())
#print(String_List)
total_number = 2 ** N -1

pair = len(String_List) - len(set(String_List))
if pair != 0:
    global last
    last = 2 ** (len(String_List) - 2) * pair - ((pair-1)* (len(String_List)-pair*2)*2)
else:
    last = 0

print(total_number - last)

Submission status: Wrong Answer

Solution code:
import math
import copy
 
 
 
 
def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:
 
            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l
 

n=input()
s=input()

mod=1000000007
def help1(a):
    all=0
    a1=1
    b1=1
    while a!=0:
        a1=a1*a;
        a1=a1/b1%mod;
        b1+=1
        a=a-1
        all=(all+a1)%mod
    return int(all)

def func():
    count=help1(len(s))
    dic={}

    for c in s:
        if c in dic:
            dic[c]=dic[c]+1
        else:
            dic[c]=1
    res=len(s)
    l=[]
    for k in dic:
        if dic[k]==1:
            l.append(k)
    for obj in l:
        del dic[obj]
        
    count2=1
    sum1=0
    for k in dic:
        sum1+=dic[k]
        count2=count2*(1+dic[k])



    number3=help1(sum1)-count2+1

    number4=help1(len(s)-sum1)+1

    number3=number3*number4
    return count-number3
  

print(func())

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
s = input()
cnt = 0
dictionary = {}

for i in range(n)[::-1]:
  if s[i] in dictionary.keys():
    dictionary[s[i]] += 1
  else:
    dictionary[s[i]] = 1
  ch = s[i:]
  tmp_cnt = 1
  for k,v in dictionary.items():
    if k != s[i]:
      tmp_cnt *= (v+1)
  cnt += tmp_cnt
print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(input())
d=[1]*26
g=ord("a")
for i in range(n):
    d[ord(s[i])-g]+=1
p=1
for i in range(26):
    if d[i]!=0:
        p*=d[i]
else:
    print(p-1)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

cnt = Counter(list(s))
num = 1
for i in cnt.values():
    num = num * (i+1)

print(num - 1)

Submission status: Wrong Answer

Solution code:
import itertools
import re


def cmb(S, i):
    return list(itertools.combinations(S, i))


def A():
    # 部分列をつくる
    # 条件を満たす部分列と満たさない部分列にわける
    # 部分列の数を19^9+7で割る
    # 答えを出す
    N = int(input())
    S = input()
    
    sub = []
    for i in range(len(S) + 1):
        sub = sub + cmb(S, i)
    print(len(sub) -1 )


def main():
    A()

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
from sys import stdin
N=int(stdin.readline().rstrip())
S=(stdin.readline().rstrip())
S=list(S)
if N==len(set(S)):
    ans=2**N-1

else:
    ans=2**len(set(S))-1
    cnt=0
    for i in set(S):
        val=S.count(i)
        if val != 1:
            ans+=2**(len(set(S))-1)*(val-1)
            cnt+=1
    ans+=2*(cnt-1)
    print(ans)

Submission status: Wrong Answer

Solution code:
import math
import copy
 
 
 
 
def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:
 
            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l
 

n=input()
s=input()

mod=1000000007
def help1(a):
    all=0
    a1=1
    a2=1
    
    b1=1
    while a!=0:
        a1=a1*a;
        a1=a1/b1;
        b1+=1
       
        a=a-1
        all=(all+a1)%mod
    return all

def func():
    count=help1(len(s))
    dic={}

    for c in s:
        if c in dic:
            dic[c]=dic[c]+1
        else:
            dic[c]=1
    res=len(s)
    l=[]
    for k in dic:
        if dic[k]==1:
            l.append(k)
    for obj in l:
        del dic[obj]
        
    count2=1
    sum1=0
    for k in dic:
        sum1+=dic[k]
        count2=count2*(1+dic[k])



    number3=help1(sum1)-count2+1

    number4=help1(len(s)-sum1)+1

    number3=number3*number4
    return count-number3
  

print(func())

Submission status: Wrong Answer

Solution code:
import math
import collections
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
S = str(input())
count = 0
l = []
for j in S:
    l.append(j)
l_unique = list(set(l))
for k in l_unique:
    c = l.count(k)
    if c > 1:
        count += 1
if len(l_unique) == 1:
    ans = N
else:
    s = 0
    s_a = 0

    for i in range(N):
        s += combinations_count(N, i+1)
        if i <= N - 2:
            s_a += combinations_count(N-2, i) * count

    if count <= 1:
        ans = s - s_a
    else:
        add = (N-3) * combinations_count(count, 2)
        ans = s - s_a + add
print(ans % (10 ** 9 + 7))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# 自分の得意な言語で
# Let's チャレンジ！！

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

p=10**9+7
ans=0

def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p    
    
for k in range(1,N+1):
    ans+=comb(N,k,p)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
import collections
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
S = str(input())
count = 0
l = []
for j in S:
    l.append(j)
l_unique = list(set(l))
for k in l_unique:
    c = l.count(k)
    if c > 1:
        count += 1
if len(l_unique) == 1 and len(l) != 1:
    ans = 0
else:
    s = 0
    s_a = 0

    for i in range(N):
        s += combinations_count(N, i+1)
        if i <= N - 2:
            s_a += combinations_count(N-2, i) * count

    if count <= 1:
        ans = s - s_a
    else:
        add = (N-3) * combinations_count(count, 2)
        ans = s - s_a + add
print(ans % (10 ** 9 + 7))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from itertools import combinations
N = int(input())
S = list(input())

subsets = []
for i in range(N+1):
    for t in combinations(S, i):
        subsets.append(len(t) == len(set(t)))
        
print((len(subsets) - 1) % (10**9+7))

Submission status: Wrong Answer

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

array = []
for s in set(S):
    array.append(S.count(s))

len_array = len(array)

def recall(cur,t=1,total=0):
    if cur==len_array:
        return t
    for i in [array[cur],1]:
        total += recall(cur+1,t*i)
    return total

print(recall(0)-1)

Submission status: Wrong Answer

Solution code:
import itertools, math
def main():
    N = int(input())
    S = input()

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


    counter = flag_counter(flags)
    result = 0
    if len(S) == counter:
        for i in range(1, counter+1):
            result += combinations_count(counter, i)
        print(result)
        return

    for i in range(counter):
        for i in range(1, counter+1):
            result += comb_counter_dupli(i, S)
        print(result)
        return



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 comb_counter_dupli(num, str_list):
    result = 0
    comb_list = []
    for v in itertools.combinations(str_list, num):
        if str_check(v):
            if v in comb_list:
                continue
            comb_list.append(v)
            result += 1
    return result

def str_check(str_list):
    flags = dict_gen()
    for char in str_list:
        if flags[char] != 0:
            return False
        flags[char] += 1
    return True

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

@author: yuta
"""
from collections import Counter
N = int(input())
S = input()

def main(n,s):
    x = list(s)
    x_uni = list(set(x))
    c = Counter(x)
    max_count = pow(2,n) - 1
    count = 0
    sub_count = 0
    
    for i in x_uni:
        if c[i] != 1:
            count += pow(2,(n-c[i])) - 1
            sub_count += 1
    if sub_count != 0:
        count += 1
    
    print((max_count - count)%(pow(10,9)+7))
main(N,S)

Submission status: Wrong Answer

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

allbit = 2 ** N - 1
char = []
while(len(S) > 0):
    char.append([S[0], S.count(S[0])])
    S = S.replace(S[0], "")

#print("char = {}".format(str(char)))
num = 1
for i in char:
#    print("i = {}".format(str(i)))
    num = num * (i[1] + 1)
num = num - 1
print(num % 100000007)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
keys = set(list(S))
sum = N ** 2
for key in keys :
    if S.count(key) > 1 :
        sum -= S.count(key) ** 2

if sum == N ** 2:
    print(sum-1)
else :
    print(sum)

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10**9 + 7

matching = {"a":0,"b":1,"c":2,"d":3,"e":4,"f":5,"g":6,"h":7,"i":8,"j":9,"k":10,"l":11,"m":12,\
    "n":13,"o":14,"p":15,"q":16,"r":17,"s":18,"t":19,"u":20,"v":21,"w":22,"x":23,"y":24,"z":25}
inv_matching = dict((v, k) for k, v in matching.items())

def add(a,b):
    c = a+b
    if (c >= MOD):
        c = c - MOD
    return c

def calcnext(strings):
    length = len(strings)
    res = np.full((length+1,26),len(strings),dtype=int)
    for i in reversed(range(length)):
        for j in range(26):
            res[i][j] = res[i+1][j]
        res[i][matching[strings[i]]]= i
    return res

def main():
    length = int(input())
    strings = input()

    nexts = calcnext(strings)

    dp = np.zeros(length+1,dtype=int)
    dp[0] = 1
    tmp = nexts
    for i in range(length):
        for j in range(26):
            if (nexts[i][j] >= length):
                continue
            dp[nexts[i][j] + 1] = add(dp[nexts[i][j] + 1], dp[i])
        nexts = tmp
    result = 0
    dp[0] = 0
    for i in range(length+1):
        result = add(result,dp[i])
    print(result)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
Num = int(input()) 
string = input() 


A= string.count('a')
B =string.count('b')
C =string.count('c')
D =string.count('d')
E =string.count('e')
F =string.count('f')
G =string.count('g')
H =string.count('h')
I =string.count('i')
J =string.count('j')
K =string.count('k')
L =string.count('l')
M =string.count('m')
N =string.count('n')
O =string.count('o')
P =string.count('p')
Q =string.count('q')
R =string.count('r')
S =string.count('s')
T =string.count('t')
U =string.count('u')
V =string.count('v')
W =string.count('w')
X =string.count('x')
Y =string.count('y')
Z =string.count('z')




answer = (1+A)% (10^9+7)*(1+B)% (10^9+7)*(1+C)% (10^9+7)*(1+D)% (10^9+7)*(1+E) % (10^9+7) \
*(1+F)% (10^9+7)*(1+G)% (10^9+7)*(1+H)% (10^9+7)*(1+I)% (10^9+7)*(1+J) % (10^9+7) \
*(1+K)% (10^9+7)*(1+L)% (10^9+7)*(1+M)% (10^9+7)*(1+N)% (10^9+7)*(1+O) % (10^9+7) \
*(1+P)% (10^9+7)*(1+Q)% (10^9+7)*(1+R)% (10^9+7)*(1+S)% (10^9+7)*(1+T) % (10^9+7) \
*(1+U)% (10^9+7)*(1+V)% (10^9+7)*(1+W)% (10^9+7)*(1+X)% (10^9+7)*(1+Y)% (10^9+7)*(1+Z) % (10^9+7)

print(answer -1)

Submission status: Wrong Answer

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

ans = 2**N-1

tmp = []
x = set(S)
cnt = 0
for s in x:
  if(S.count(s) != 1):
    cnt += 1
    tmp.append(len(S[S.index(s):]))

for t in tmp:
  ans -= (t*cnt)%mod
  cnt -= 1
print(ans%mod)

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
iC2 = 0
for s in aT:
    iT = aT[s]
    if 1 < iT:
        iRes -= 2**(N-iT)
        if 0 < iC :
            iC2 += 2**(N-iC -iT)
            iRes += iC2
        iC += iT
print(iRes % iD)