Problem:


Score : 300 points

Problem Statement

There are N people. The name of the i-th person is S_i.

We would like to choose three people so that the following conditions are met:

The name of every chosen person begins with M, A, R, C or H.

There are no multiple people whose names begin with the same letter.

How many such ways are there to choose three people, disregarding order?

Note that the answer may not fit into a 32-bit integer type.

Constraints

1 \leq N \leq 10^5

S_i consists of uppercase English letters.

1 \leq |S_i| \leq 10

S_i \neq S_j (i \neq j)

Input

Input is given from Standard Input in the following format:

N
S_1
:
S_N

Output

If there are x ways to choose three people so that the given conditions are met, print x.

Sample Input 1

5
MASHIKE
RUMOI
OBIRA
HABORO
HOROKANAI

Sample Output 1

2

We can choose three people with the following names:

MASHIKE, RUMOI, HABORO

MASHIKE, RUMOI, HOROKANAI

Thus, we have two ways.

Sample Input 2

4
ZZ
ZZZ
Z
ZZZZZZZZZZ

Sample Output 2

0

Note that there may be no ways to choose three people so that the given conditions are met.

Sample Input 3

5
CHOKUDAI
RNG
MAKOTO
AOKI
RINGO

Sample Output 3

7



Sample input:
5
MASHIKE
RUMOI
OBIRA
HABORO
HOROKANAI


Sample output:
2

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [list(input())[0] for i in range(n)]
ans = 0
for i, j in enumerate(s):
    if j not in list('MARCH'):
        del s[i]
s = sorted([[i, s.count(i)] for i in set(s) if s.count(i) >= 1])
for i in range(len(s)):
    for j in range(i + 1, len(s)):
        for k in range(j + 1, len(s)):
            ans += s[i][1] * s[j][1] * s[k][1]
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=[]
for i in range(N):
    a.append(input())

import numpy as np
s=np.zeros(5)

for i in a:
    if i[0]=="M":
        s[0]+=1
    elif i[0]=="A":
        s[1]+=1
    elif i[0]=="R":
        s[2]+=1
    elif i[0]=="C":
        s[3]+=1
    elif i[0]=="H":
        s[4]+=1
    else:
        continue
b=np.unique(s)
c=0
if len(b)<3:
    print(0)
else:
    for i in range(0,3):
        for j in range(i+1,4):
            for k in range(j+1,5):
                c+=s[i]*s[j]*s[k]
    print(int(c))

Submission status: Wrong Answer

Solution code:
N=int(input())
a=[]
for i in range(N):
    a.append(input())

import numpy as np
s=np.zeros(5)

for i in a:
    if i[0]=="M":
        s[0]+=1
    elif i[0]=="A":
        s[1]+=1
    elif i[0]=="R":
        s[2]+=1
    elif i[0]=="C":
        s[3]+=1
    elif i[0]=="H":
        s[4]+=1
    else:
        continue
b=np.unique(s)
c=0
if len(b)<3:
    print(0)
else:
    for i in range(0,3):
        for j in range(i+1,4):
            for k in range(j+1,5):
                c+=s[i]*s[j]*s[k]
    print(int(c))

Submission status: Wrong Answer

Solution code:
N=int(input())
a=[]
for i in range(N):
    a.append(input())

import numpy as np
s=np.zeros(5)

for i in a:
    if i[0]=="M":
        s[0]+=1
    elif i[0]=="A":
        s[1]+=1
    elif i[0]=="R":
        s[2]+=1
    elif i[0]=="C":
        s[3]+=1
    elif i[0]=="H":
        s[4]+=1
    else:
        continue
b=np.unique(s)
c=0
if len(b)<3:
    print(0)
else:
    for i in range(0,3):
        for j in range(i+1,4):
            for k in range(j+1,5):
                c+=s[i]*s[j]*s[k]
print(int(c))

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    M = A = R = C = H = 0
    for i in range(N):
        name = input()
        if name[0] == "M":
            M = M + 1
        elif name[0] == "A":
            A = A + 1
        elif name[0] == "R":
            R = R + 1
        elif name[0] == "C":
            C = C + 1
        elif name[0] == "H":
            H = H + 1

    ans = M*A*R
    ans = ans + M*A*C
    ans = ans + M*A*H
    ans = ans + M*R*C
    ans = ans + M*R*H
    ans = ans + A*R*C
    ans = ans + A*R*H
    ans = ans + R*C*H

    print(ans)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
ips = []
ips.append(input())
while True:
    try:
        ips.append(input())
    except (EOFError):
        break
def mar(ips):
    march = ["M","A","R","C","H"]
    cnt = [0,0,0,0,0]
    num = int(ips[0])
    names = [s for s in ips[1:] if s[0] in march]
    if len(names) ==0:
        return 0
    for n in names:
        if n[0]=="M": cnt[0]+=1
        elif n[0]=="A": cnt[1]+=1
        elif n[0]=="R": cnt[2]+=1
        elif n[0]=="C": cnt[3]+=1
        elif n[0]=="H": cnt[4]+=1
    m = cnt[0]*(cnt[1]*(sum(cnt[2:]))+cnt[2]*(sum(cnt[3:]))+cnt[3]*cnt[4])
    a = cnt[1]*(cnt[2]*(sum(cnt[3:]))+cnt[3]*cnt[4])
    r = cnt[2]*(cnt[3]*(cnt[4]))
    c = cnt[3]*cnt[4]
    return m+a+r+c
print(mar(ips))

Submission status: Wrong Answer

Solution code:
ips = []
ips.append(input())
while True:
    try:
        ips.append(input())
    except (EOFError):
        break
def mar(ips):
    march = ["M","A","R","C","H"]
    cnt = [0,0,0,0,0]
    num = int(ips[0])
    names = [s for s in ips[1:] if s[0] in march]
    if len(names) ==0:
        return 0
    for n in names:
        if n[0]=="M": cnt[0]+=1
        elif n[0]=="A": cnt[1]+=1
        elif n[0]=="R": cnt[2]+=1
        elif n[0]=="C": cnt[3]+=1
        elif n[0]=="H": cnt[4]+=1
    m = cnt[0]*(cnt[1]*(sum(cnt[2:]))+cnt[2]*(sum(cnt[3:]))+cnt[3]*cnt[4])
    a = cnt[1]*(cnt[2]*(sum(cnt[3:]))+cnt[3]*cnt[4])
    r = cnt[2]*(cnt[3]*(cnt[4]))
    c = cnt[3]*cnt[4]
    return sum([m,a,r,c])
print(mar(ips))

Submission status: Wrong Answer

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


N = int(input())
S = []
for i in range(N):
    S.append(input())

m = sum([name[0] == 'M' for name in S])
a = sum([name[0] == 'A' for name in S])
r = sum([name[0] == 'R' for name in S])
c = sum([name[0] == 'C' for name in S])
h = sum([name[0] == 'H' for name in S])

print(m * (a * (r + c + h) + r * (c + h) + c * h) + a * (r * c + c * h) + r * c * h)

Submission status: Wrong Answer

Solution code:
x = input()
count = [0 for i in range(5)]
for i in x:
    name = input()
    if name[0] == 'M':
        count[0] += 1
    elif name[0] == 'A':
        count[1] += 1
    elif name[0] == 'R':
        count[2] += 1
    elif name[0] == 'C':
        count[3] += 1
    elif name[0] == 'H':
        count[4] += 1

p = [0, 0, 0, 0, 0, 0, 1, 1, 1, 2]
q = [1, 1, 1, 2, 2, 3, 2, 2, 3, 3]
r = [2, 3, 4, 3, 4, 4, 3, 4, 4, 4]
res = 0
for i in range(10):
    res += count[p[i]]*count[q[i]]*count[r[i]]

print(res)

Submission status: Wrong Answer

Solution code:
import itertools

N = int(input())
_M = [] 
_A = [] 
_R = [] 
_C = [] 
_H = [] 

for i in range(N):
    x = input()
    if x[0] == 'M':
        _M.append(x)
    elif x[0] == 'A':
        _A.append(x)
    elif x[0] == 'R':
        _R.append(x)
    elif x[0] == 'C':
        _C.append(x)
    elif x[0] == 'H':
        _H.append(x)

m = len(_M)
a = len(_A)
r = len(_R)
c = len(_C)
h = len(_H)

numbers = [m,a,r,c,h]


coms = list(itertools.combinations(numbers,3))
coms_ = []

x = len(coms) - 1

for n in range(0,x):
    coms_.append(list(coms[n]))


for f in range(0,x):
    coms_[f] = coms_[f][0] * coms_[f][1] * coms_[f][2]

print(sum(coms_))

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())

n = 0

for i in range(N):
    st = str(input())
    if {list(st)[0]} <= {'M','A','R','C','H'}:
        n += 1

print(n)

Submission status: Wrong Answer

Solution code:
N = int(input())
member = [0,0,0,0,0]
ans = 0
for _ in range(N):
    a = input().split()
    if a[0] == "M":
        member[0] += 1
    elif a[0] == "A":
        member[1] += 1
    elif a[0] == "R":
        member[2] += 1
    elif a[0] == "C":
        member[3] += 1
    elif a[0] == "H":
        member[4] += 1
 
for i in range(3):
    for j in range(i+1, 4):
        for k in range(j+1, 5):
            ans += member[i]*member[j]*member[k]

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
member = [0,0,0,0,0]
ans = 0
for _ in range(N):
    a = input().split()
    if a[0] == "M":
        member[0] += 1
    elif a[0] == "A":
        member[1] += 1
    elif a[0] == "R":
        member[2] += 1
    elif a[0] == "C":
        member[3] += 1
    elif a[0] == "H":
        member[4] += 1
 
for i in range(3):
    for j in range(i+1, 4):
        for k in range(j+2, 5):
            ans += member[i]*member[j]*member[k]

print(ans)

Submission status: Wrong Answer

Solution code:
# https://abc089.contest.atcoder.jp/tasks/abc089_c

import copy

n = int(input())
s = [input().replace("\n", "") for i in range(n)]
march_num_list = [0, 0, 0, 0, 0]

for name in s:
    for i, head in enumerate(("M", "A", "R", "C", "H")):
        if name[0] == head:
            march_num_list[i] += 1

pattern_num = 0

for i in range(len(march_num_list)):
    two_list = copy.copy(march_num_list)
    two_list.pop(i)
    for j in range(len(two_list)):
        three_list = copy.copy(two_list)
        three_list.pop(j)
        for k in range(len(three_list)):
            pattern_num += three_list[0] * three_list[1] * three_list[2]

print(pattern_num)

Submission status: Wrong Answer

Solution code:
N = int(input())
S ="MARCH"
S2 = [0]*len(S)
n=0

for i in range(N):
    s = input()
    for k, j in enumerate(S2):
        if s[0] == j:
            S2[k]+=1
            
for i in range(len(S2)):
    for j in range(i+1,len(S2)):
        for k in range(j+1,len(S2)):
            n +=S2[i]*S2[j]*S2[k]
    
print(n)

Submission status: Wrong Answer

Solution code:

import copy

n = int(input())
s = [input().replace("\n", "") for i in range(n)]
march_num_list = [0, 0, 0, 0, 0]

for name in s:
    for i, head in enumerate(("M", "A", "R", "C", "H")):
        if name[0] == head:
            march_num_list[i] += 1

pattern_num = 0

for i, one in enumerate(march_num_list):
    two_list = copy.copy(march_num_list)
    two_list.pop(i)
    for j, two in enumerate(two_list):
        three_list = copy.copy(two_list)
        three_list.pop(j)
        for k, three in enumerate(three_list):
            pattern_num += one * two * sum(three_list)

print(pattern_num)

Submission status: Wrong Answer

Solution code:
def kaijou(a):
    kai = 1
    for i in range(a):
        kai = kai * (i+1)
    return kai

def main():
    N = int(input())
    S = []
    for i in range(N):
        S.append(input())

    count = [0,0,0,0,0]
    initial = "MARCH"

    for i in range(5):
        for s in S:
            if s[0] == initial[i]:
                count[i] += 1

    k = 3
    kumiawase = 0
    for i in range(5):
        n = sum(count) - count[i]
        if n < 3:
            continue
        else:
            kumiawase += (kaijou(count[i]+k-1)) / (kaijou(k) * kaijou(count[i]-1))

    return int(kumiawase)

if __name__ == "__main__":
    print(main())

Submission status: Wrong Answer

Solution code:
from collections import Counter
from itertools import combinations

n = int(input())
l = Counter(input()[0] for _ in range(n))
con = [l[c] for c in 'MARCH' if c in l]
print(sum(a * b * c) for a, b, c in combinations(con, 3))

Submission status: Wrong Answer

Solution code:
n = int(input().strip())
s = [input().strip() for _ in range(n)]
num = [0 for _ in range(5)]
num[0] = len([True for _s in s if _s[0] == "M"])
num[1] = len([True for _s in s if _s[0] == "A"])
num[2] = len([True for _s in s if _s[0] == "R"])
num[3] = len([True for _s in s if _s[0] == "C"])
num[4] = len([True for _s in s if _s[0] == "H"])
ans = 0
for i in range(5):
    for j in range(i, 5):
        for k in range(j, 5):
            ans += num[i] * num[j] * num[k]
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[input()for i in range(n)]
count_m=count_a=count_r=count_c=count_h=0
for i in s:
    if i[0]=="M":
        count_m+=1
    if i[0]=="A":
        count_a+=1
    if i[0]=="R":
        count_r+=1
    if i[0]=="C":
        count_c+=1
    if i[0]=="H":
        count_h+=1
v=max(count_m*count_a*count_r,count_m*count_a*count_c,count_m*count_a*count_h,count_m*count_r*count_c,count_m*count_r*count_h)
x=max(count_m*count_c*count_h,count_a*count_r*count_c,count_a*count_r*count_h)
y=max(count_a*count_c*count_h,count_r*count_c*count_h)
print(max(v,x,y))

Submission status: Wrong Answer

Solution code:
m_count = 0
a_count = 0
r_count = 0
c_count = 0
h_count = 0

n = input()

for i in range(n):
    name = raw_input()
    if name[0] == 'M':
        m_count += 1
    elif name[0] == 'A':
        a_count += 1
    elif name[0] == 'R':
        r_count += 1
    elif name[0] == 'C':
        c_count += 1
    elif name[0] == 'H':
        h_count += 1

count = 0
count += m_count * a_count * r_count
count += m_count * r_count * c_count
count += m_count * c_count * h_count
count += a_count * r_count * c_count
count += a_count * c_count * h_count
count += r_count * c_count * h_count
count += m_count * a_count * c_count
count += m_count * a_count * h_count
count += m_count * r_count * h_count

print count

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
 
 
N = int(input())
name = []
for i in range(0,N):
    data = input()
    name.append(data)
 
check = 0
check_m = 0
check_a = 0
check_r = 0
check_c = 0
check_h = 0
 
for i in name:
    if i[0] == "M":
        if check_m == 0:
            check += 1
        check_m += 1
    elif i[0] == "A":
        if check_a == 0:
            check += 1
        check_a += 1
    elif i[0] == "R":
        if check_r == 0:
            check += 1
        check_r += 1
    elif i[0] == "C":
        if check_c == 0:
            check += 1
        check_c += 1
    elif i[0] == "H":
        if check_h == 0:
            check += 1
        check_h += 1
 
if check < 3:
    print(0) 
elif check == 3:
    s = []
    if check_m != 0:
        s.append(check_m)
    if check_a != 0:
        s.append(check_a)
    if check_r != 0:
        s.append(check_r)
    if check_c != 0:
        s.append(check_c)
    if check_h != 0:
        s.append(check_h)
    se = 1
    for i in s:
        se = se*i
    print(int(se))
    
elif check == 4:
    s = []
    if 1 < check_m:
        s.append(check_m)
    if 1 < check_a:
        s.append(check_a)
    if 1 < check_r:
        s.append(check_r)
    if 1 < check_c:
        s.append(check_c)
    if 1 < check_h:
        s.append(check_h)
    n = (check*(check-1)*(check-2))/6
    if len(s) == 0:
        print(int(n))
    else:
        se = 1
        for i in s:
            se += i*(n-1)
        print(int(se))
 
elif check == 5:
    s = []
    if 1 < check_m:
        s.append(check_m)
    if 1 < check_a:
        s.append(check_a)
    if 1 < check_r:
        s.append(check_r)
    if 1 < check_c:
        s.append(check_c)
    if 1 < check_h:
        s.append(check_h)
    n = (check*(check-1)*(check-2))/6
    if len(s) == 0:
        print(int(n))
    else:
        se = n - sum(s) + 1
        for i in s:
            se += i*(n-1)
        print(int(se))

Submission status: Wrong Answer

Solution code:
import math

N = int(input())

S = [input() for i in range(N)]

M=0
A=0
R=0
C=0
H=0

cont1=0
cont2=0
cont3=0
cont4=0
cont5=0
count=0

for i in range(N):
    if S[i] == 'M':
        M+=1
    elif S[i] == 'A':    
        A+=1    
    elif S[i] == 'C':
        C+=1
    elif S[i] == 'R':
        R+=1
    elif S[i] == 'H':
        H+=1
#print(M,A,R,C,H)
num = M+A+R+C+H
if num>3:
    num1 = math.factorial(num)
    num11=math.factorial(num-3)*3*2
    num2= num1//num11
    
    if M>1:
        cont1=M
    elif A>1:
        cont2=A
    elif R>1:
        cont3=R
    elif C>1:
        cont4=C
    elif H>1:
        cont5=H
        
    cont =cont1+cont2+cont3+cont4+cont5
    count=num-cont
    print(num2-count)
 #   print(num2,num,cont)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
pp=1
pt=0
ptpt=1
ss=[]
def fact(n):
    if n==0:
        print(1)
    return n*fact(n-1)    
for i in range(N):
    s=list(input())
    ss.append(s[0])
for j in "MARCH":
    if j in ss:
        pt+=1
        pp *= ss.count(j)
if pt>=3:
    for k in range(pt - 3):
        ptpt *= pt-k
    print(ptpt*pp)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
 
 
N = int(input())
name = []
for i in range(0,N):
    data = input()
    name.append(data)
 
check = 0
check_m = 0
check_a = 0
check_r = 0
check_c = 0
check_h = 0
 
for i in name:
    if i[0] == "M":
        if check_m == 0:
            check += 1
        check_m += 1
    elif i[0] == "A":
        if check_a == 0:
            check += 1
        check_a += 1
    elif i[0] == "R":
        if check_r == 0:
            check += 1
        check_r += 1
    elif i[0] == "C":
        if check_c == 0:
            check += 1
        check_c += 1
    elif i[0] == "H":
        if check_h == 0:
            check += 1
        check_h += 1
 
if check < 3:
    print(0) 
elif check == 3:
    s = []
    if check_m != 0:
        s.append(check_m)
    if check_a != 0:
        s.append(check_a)
    if check_r != 0:
        s.append(check_r)
    if check_c != 0:
        s.append(check_c)
    if check_h != 0:
        s.append(check_h)
    se = 1
    for i in s:
        se = se*i
    print(int(se))
    
elif check == 4:
    s = []
    if 1 < check_m:
        s.append(check_m)
    if 1 < check_a:
        s.append(check_a)
    if 1 < check_r:
        s.append(check_r)
    if 1 < check_c:
        s.append(check_c)
    if 1 < check_h:
        s.append(check_h)
    n = (check*(check-1)*(check-2))/6
    if len(s) == 0:
        print(int(n))
    else:
        se = 1
        for i in s:
            se += i*(n-1)
        print(int(se))
 
elif check == 5:
    s = []
    if 1 < check_m:
        s.append(check_m)
    if 1 < check_a:
        s.append(check_a)
    if 1 < check_r:
        s.append(check_r)
    if 1 < check_c:
        s.append(check_c)
    if 1 < check_h:
        s.append(check_h)
    n = (check*(check-1)*(check-2))/6
    if len(s) == 0:
        print(int(n))
    else:
        se = 2
        for i in s:
            se += i*(n-1)
        print(int(se))

Submission status: Wrong Answer

Solution code:
n = int(input())
coum = 0
coua = 0
cour = 0
couc = 0
couh = 0
for i in range(n):
  a = input()
  if a[0] == "M":
    coum +=1
  if a[0] == "A":
    coua +=1
  if a[0] == "R":
    cour += 1
  if a[0] == "C":
    couc += 1
  if a[0] == "H":
    couh += 1
an = coum + coua + cour + couc + couh
su = 0

  # print(coum,coua,cour,couc,couh)
mm = 0
aa = 0
rr = 0
cc = 0
hh = 0

for m in range(an):
    su += m
if coum > 1:
    if coua + cour + couc + couh < 3:
        mm = coua + cour + couc + couh
        mm *= coum
    else:
        for m in range(coum):
            mm += m+1
if coua > 1:
    if coum + cour + couc + couh < 3:
        aa = coum + cour + couc + couh
        aa *= coua
    else:
        for m in range(coua):
            aa += m+1
if cour > 1:
    if coum + coua + couc + couh < 3:
        rr = coum + coua + couc + couh
        rr *= cour
    else:
        for m in range(cour):
            rr += m+1
if couc > 1:
    if coum + coua + cour + couh < 3:
        cc = coum + coua + cour + couh
        cc *= couc
    else:
        for m in range(couc):
            cc += m+1
if couh > 1:
    if coum + coua + cour + couc < 3:
        hh = coum + coua + cour + couc
        hh *= couh
    else:
        for m in range(couh):
            hh += m+1

print(su-(mm + aa + rr + cc + hh))

Submission status: Wrong Answer

Solution code:
n = int(input())

M = 0
A = 0
R = 0
C = 0
H = 0

res = 0

for i in range(n):
    char = input()[0]
    if char == "M":
        M += 1
    elif char == "A":
        A += 1
    elif char == "R":
        R += 1
    elif char == "C":
        C += 1
    elif char == "H":
        H += 1

res += M * A * R;
res += M * A * C;
res += M * A * H;
res += M * R * C;
res += M * R * H;
res += M * C * H;

res += A * R * C;
res += A * C * H;

res += R * C * H;

print(res)

Submission status: Wrong Answer

Solution code:
m_count = 0
a_count = 0
r_count = 0
c_count = 0
h_count = 0

n = input()

for i in range(n):
    name = raw_input()
    if name[0] == 'M':
        m_count += 1
    elif name[0] == 'A':
        a_count += 1
    elif name[0] == 'R':
        r_count += 1
    elif name[0] == 'C':
        c_count += 1
    elif name[0] == 'H':
        h_count += 1

count = 0
count += m_count * a_count * r_count
count += m_count * r_count * c_count
count += m_count * c_count * h_count
count += a_count * r_count * c_count
count += a_count * c_count * h_count
count += r_count * c_count * h_count
count += m_count * a_count * c_count
count += m_count * a_count * h_count
count += m_count * r_count * h_count
count += m_count * c_count * h_count


print count

Submission status: Wrong Answer

Solution code:
import math

N = int(input())

S = [input() for i in range(N)]

M=0
A=0
R=0
C=0
H=0

cont1=0
cont2=0
cont3=0
cont4=0
cont5=0

for i in range(N):
    if S[i] == 'M':
        M+=1
    elif S[i] == 'A':    
        A+=1    
    elif S[i] == 'C':
        C+=1
    elif S[i] == 'R':
        R+=1
    elif S[i] == 'H':
        H+=1
#print(M,A,R,C,H)
num = M+A+R+C+H
if num>3:
    num1 = math.factorial(num)
    num11=math.factorial(num-3)*3*2
    num2= num1//num11
    
    if M>1:
        cont1=M
    elif A>1:
        cont2=A
    elif R>1:
        cont3=R
    elif C>1:
        cont4=C
    elif H>1:
        cont5=H
        
    cont =cont1+cont2+cont3+cont4+cont5
        
    print(num2-cont)
else:
    print(0)

Submission status: Wrong Answer

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


N = int(input())
name = []
for i in range(0,N):
    data = input()
    name.append(data)

check = 0
check_m = 0
check_a = 0
check_r = 0
check_c = 0
check_h = 0

for i in name:
    if i[0] == "M":
        if check_m == 0:
            check += 1
        check_m += 1
    elif i[0] == "A":
        if check_a == 0:
            check += 1
        check_a += 1
    elif i[0] == "R":
        if check_r == 0:
            check += 1
        check_r += 1
    elif i[0] == "C":
        if check_c == 0:
            check += 1
        check_c += 1
    elif i[0] == "H":
        if check_h == 0:
            check += 1
        check_h += 1

if check < 3:
    print(0) 
elif check == 3:
    s = []
    if check_m != 0:
        s.append(check_m)
    if check_a != 0:
        s.append(check_a)
    if check_r != 0:
        s.append(check_r)
    if check_c != 0:
        s.append(check_c)
    if check_h != 0:
        s.append(check_h)
    se = 1
    for i in s:
        se = se*i
    print(int(se))
    
elif check == 4:
    s = []
    if 1 < check_m:
        s.append(check_m)
    if 1 < check_a:
        s.append(check_a)
    if 1 < check_r:
        s.append(check_r)
    if 1 < check_c:
        s.append(check_c)
    if 1 < check_h:
        s.append(check_h)
    n = (check*(check-1)*(check-2))/6
    if len(s) == 0:
        print(int(n))
    else:
        se = 1
        for i in s:
            se += i*(n-1)
        print(int(se))

elif check == 5:
    s = []
    if 1 < check_m:
        s.append(check_m)
    if 1 < check_a:
        s.append(check_a)
    if 1 < check_r:
        s.append(check_r)
    if 1 < check_c:
        s.append(check_c)
    if 1 < check_h:
        s.append(check_h)
    n = 4
    n_1 = 5
    if len(s) == 0:
        print(int(n))
    else:
        se = n
        for i in s:
            se += i*(n_1)
        print(int(se))

Submission status: Wrong Answer

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


N = int(input())
name = []
for i in range(0,N):
    data = input()
    name.append(data)

check = 0
check_m = 0
check_a = 0
check_r = 0
check_c = 0
check_h = 0

for i in name:
    if i[0] == "M":
        if check_m == 0:
            check += 1
        check_m += 1
    elif i[0] == "A":
        if check_a == 0:
            check += 1
        check_a += 1
    elif i[0] == "R":
        if check_r == 0:
            check += 1
        check_r += 1
    elif i[0] == "C":
        if check_c == 0:
            check += 1
        check_c += 1
    elif i[0] == "H":
        if check_h == 0:
            check += 1
        check_h += 1

if check < 3:
    print(0) 
elif check == 3:
    s = []
    if check_m != 0:
        s.append(check_m)
    if check_a != 0:
        s.append(check_a)
    if check_r != 0:
        s.append(check_r)
    if check_c != 0:
        s.append(check_c)
    if check_h != 0:
        s.append(check_h)
    se = 1
    for i in s:
        se = se*i
    print(int(se))
    
elif check == 4:
    s = []
    if 1 < check_m:
        s.append(check_m)
    if 1 < check_a:
        s.append(check_a)
    if 1 < check_r:
        s.append(check_r)
    if 1 < check_c:
        s.append(check_c)
    if 1 < check_h:
        s.append(check_h)
    n = (check*(check-1)*(check-2))/6
    if len(s) == 0:
        print(int(n))
    else:
        se = 1
        for i in s:
            se += i*(n-1)
        print(int(se))

elif check == 5:
    s = []
    if 1 < check_m:
        s.append(check_m)
    if 1 < check_a:
        s.append(check_a)
    if 1 < check_r:
        s.append(check_r)
    if 1 < check_c:
        s.append(check_c)
    if 1 < check_h:
        s.append(check_h)
    n = 10
    n_1 = 5
    if len(s) == 0:
        print(int(n))
    else:
        se = n
        for i in s:
            se += i*(n_1)
        print(int(se))

Submission status: Wrong Answer

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


N = int(input())
name = []
for i in range(0,N):
    data = input()
    name.append(data)

check = 0
check_m = 0
check_a = 0
check_r = 0
check_c = 0
check_h = 0

for i in name:
    if i[0] == "M":
        if check_m == 0:
            check += 1
        check_m += 1
    elif i[0] == "A":
        if check_a == 0:
            check += 1
        check_a += 1
    elif i[0] == "R":
        if check_r == 0:
            check += 1
        check_r += 1
    elif i[0] == "C":
        if check_c == 0:
            check += 1
        check_c += 1
    elif i[0] == "H":
        if check_h == 0:
            check += 1
        check_h += 1

if check < 3:
    print(0) 
elif check == 3:
    s = []
    if check_m != 0:
        s.append(check_m)
    if check_a != 0:
        s.append(check_a)
    if check_r != 0:
        s.append(check_r)
    if check_c != 0:
        s.append(check_c)
    if check_h != 0:
        s.append(check_h)
    se = 1
    for i in s:
        se = se*i
    print(int(se))
    
elif check == 4:
    s = []
    if 1 < check_m:
        s.append(check_m)
    if 1 < check_a:
        s.append(check_a)
    if 1 < check_r:
        s.append(check_r)
    if 1 < check_c:
        s.append(check_c)
    if 1 < check_h:
        s.append(check_h)
    n = (check*(check-1)*(check-2))/6
    if len(s) == 0:
        print(int(n))
    else:
        se = 1
        for i in s:
            se += i*(n-1)
        print(int(se))

elif check == 5:
    s = []
    if 1 < check_m:
        s.append(check_m)
    if 1 < check_a:
        s.append(check_a)
    if 1 < check_r:
        s.append(check_r)
    if 1 < check_c:
        s.append(check_c)
    if 1 < check_h:
        s.append(check_h)
    n = 4
    n_1 = 6
    if len(s) == 0:
        print(int(n))
    else:
        se = n
        for i in s:
            se += i*(n_1)
        print(int(se))

Submission status: Wrong Answer

Solution code:
m_count = 0
a_count = 0
r_count = 0
c_count = 0
h_count = 0

n = input()

for i in range(n):
    name = raw_input()
    if name[0] == 'M':
        m_count += 1
    elif name[0] == 'A':
        a_count += 1
    elif name[0] == 'R':
        r_count += 1
    elif name[0] == 'C':
        c_count += 1
    elif name[0] == 'H':
        h_count += 1

count = 0
count += m_count * a_count * r_count
count += m_count * r_count * c_count
count += m_count * c_count * r_count
count += a_count * r_count * c_count
count += a_count * c_count * h_count
count += r_count * c_count * h_count
count += m_count * a_count * c_count
count += m_count * a_count * h_count
count += m_count * r_count * h_count
count += m_count * c_count * h_count


print count

Submission status: Wrong Answer

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


N = int(input())
name = []
for i in range(0,N):
    data = input()
    name.append(data)

check = 0
check_m = 0
check_a = 0
check_r = 0
check_c = 0
check_h = 0

for i in name:
    if i[0] == "M":
        if check_m == 0:
            check += 1
        check_m += 1
    elif i[0] == "A":
        if check_a == 0:
            check += 1
        check_a += 1
    elif i[0] == "R":
        if check_r == 0:
            check += 1
        check_r += 1
    elif i[0] == "C":
        if check_c == 0:
            check += 1
        check_c += 1
    elif i[0] == "H":
        if check_h == 0:
            check += 1
        check_h += 1

if check < 3:
    print(0) 
elif check == 3:
    s = []
    if check_m != 0:
        s.append(check_m)
    if check_a != 0:
        s.append(check_a)
    if check_r != 0:
        s.append(check_r)
    if check_c != 0:
        s.append(check_c)
    if check_h != 0:
        s.append(check_h)
    se = 1
    for i in s:
        se = se*i
    print(int(se))
    
elif check == 4:
    s = []
    if 1 < check_m:
        s.append(check_m)
    if 1 < check_a:
        s.append(check_a)
    if 1 < check_r:
        s.append(check_r)
    if 1 < check_c:
        s.append(check_c)
    if 1 < check_h:
        s.append(check_h)
    n = (check*(check-1)*(check-2))/6
    if len(s) == 0:
        print(int(n))
    else:
        se = 1
        for i in s:
            se += i*(n-1)
        print(int(se))

elif check == 5:
    s = []
    if 1 < check_m:
        s.append(check_m)
    if 1 < check_a:
        s.append(check_a)
    if 1 < check_r:
        s.append(check_r)
    if 1 < check_c:
        s.append(check_c)
    if 1 < check_h:
        s.append(check_h)
    n = (check*(check-1)*(check-2))/6
    if len(s) == 0:
        print(int(n))
    else:
        se = 1
        for i in s:
            se += i*(n-1)
        print(int(se))

Submission status: Wrong Answer

Solution code:
import itertools
import math

N = int(input())
S_list = []
for i in range(N):
    S_list.append(input())

count_M = 0
count_A = 0
count_R = 0
count_C = 0
count_H = 0

for l in S_list:
    if l.startswith('M'):
        count_M += 1
    elif l.startswith('A'):
        count_A += 1
    elif l.startswith('R'):
        count_R += 1
    elif l.startswith('C'):
        count_C += 1
    elif l.startswith('H'):
        count_H += 1

count = [count_M,count_A,count_R,count_C,count_H]
c = list(itertools.combinations(count,3))
print(c)
x = 0
for i in c:
    i_list = list(i)
    x += i_list[0]*i_list[1]*i_list[2]
print(x)