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

Solution (Python):
import itertools
N = int(input())

dic = {"M":0, "A":0, "R":0, "C":0, "H":0}
S = set([])
for i in range(N):
  temp = str(input())
  if temp[0] == "M":
    dic["M"] += 1
    S.add("M")
  elif temp[0] == "A":
    dic["A"] += 1
    S.add("A")    
  elif temp[0] == "R":
    dic["R"] += 1  
    S.add("R")
  elif temp[0] == "C":
    dic["C"] += 1  
    S.add("C")
  elif temp[0] == "H":
    dic["H"] += 1
    S.add("H")


L = list(dic.values())
if len(S) <=2:
  print("0")
  exit()
ans = 0
A = list(itertools.combinations(L,3))
for X in A:
  ans += X[0]*X[1]*X[2]
print(ans)

Solution (Python):
n = int(input())

check = {v:0 for v in "MARCH"}

for i in range(n):
    s = input()
    if s[0] in check:
        check[s[0]] += 1
ans = 0
kijyun = "MARCH"

for a in range(5):
    for b in range(a+1,5):
        for c in range(b+1,5):
            ans += check[kijyun[a]] * check[kijyun[b]] * check[kijyun[c]]

print(ans)

Solution (Python):
import itertools

N = int(input())

MARCH = [0]*5
ans = 0
for i in range(N):
  S = input()
  t = S[0]
  if t == "M":
    MARCH[0] += 1
  elif t == "A":
    MARCH[1] += 1
  elif t == "R":
    MARCH[2] += 1
  elif t == "C":
    MARCH[3] += 1
  elif t == "H":
    MARCH[4] += 1

comb = itertools.combinations(MARCH,3)

for j in comb:
  ans += j[0]*j[1]*j[2]
print(ans)

Solution (Python):
def main():
    n = int(input())
    num_m = 0
    num_a = 0
    num_r = 0
    num_c = 0
    num_h = 0
    inlis = set()
    for i in range(n):
        s = input()
        if s in inlis:
            pass
        else:
            inlis.add(s)
            if s[0] == "M":
                num_m += 1        
            if s[0] == "A":
                num_a += 1
            if s[0] == "R":
                num_r += 1
            if s[0] == "C":
                num_c += 1
            if s[0] == "H":
                num_h += 1
    numlis = [num_m, num_a, num_r, num_c, num_h]
    ans = 0
    if sum(numlis) < 3:
        print(0)
    else:
        for i in range(5):
            for j in range(5):
                for k in range(5):
                    if i == j or i == k or j == k:
                        pass
                    else:
                        ans += numlis[i] * numlis[j] * numlis[k]
        print(int(ans/6))
                    


if __name__ == "__main__":
    main()

Solution (Python):
import itertools

N = int(input())
S = [input() for _ in range(N)]

CNT = [0] * 5
iniset = ["M","A","R","C","H"]
s_to_i = {"M":0,"A":1,"R":2,"C":3,"H":4}


for s in S:
  i = s[0]
  if not i in iniset:
    continue
    
  CNT[s_to_i[i]] += 1
  
ans = 0
for x,y,z in itertools.combinations(CNT,3):
  ans += x * y * z

print(ans)

Solution (Python):
from collections import defaultdict
from itertools import combinations
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n = I()
s = SR(n)
d = defaultdict(int)
for c in ['M', 'A', 'R', 'C', 'H']:
    d[c] = 0
for name in s:
    if name[0] in {'M', 'A', 'R', 'C', 'H'}:
        d[name[0]] += 1
combs = list(combinations(['M', 'A', 'R', 'C', 'H'], 3))

ans = 0
for c in combs:
    ans += d[c[0]] * d[c[1]] * d[c[2]]
print(ans)

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]

import itertools

L = [0 for _ in range(5)]

March = 'MARCH'
for s in S:
    for i, m in enumerate(March):
        if s[0] == m:
            L[i] += 1

Itr = itertools.combinations(range(5), 3)

ans = 0
for itr in Itr:
    ans += L[itr[0]]*L[itr[1]]*L[itr[2]]
print(ans)

Solution (Python):
N = int(input())
S = [input() for i in range(N)]
num = [0] * 5
ans = 0

for i in range(N):
    if S[i][0] == 'M':
        num[0] += 1
    elif S[i][0] == 'A':
        num[1] += 1
    elif S[i][0] == 'R':
        num[2] += 1
    elif S[i][0] == 'C':
        num[3] += 1
    elif S[i][0] == 'H':
        num[4] += 1

for i in range(3):
    for j in range(i+1, 4):
        for k in range(j+1, 5):
            ans += num[i]*num[j]*num[k]
    
print(ans)

Solution (Python):
N = int(input())
dic = {}
for c in "MARCH":
    dic[c] = 0
myset = set(list("MARCH"))
for _ in range(N):
    c = input()[0]
    if c in myset:
        dic[c] += 1

res = 0
for i in range(5-2):
    for j in range(i+1, 5-1):
        for k in range(j+1, 5):
            res += dic["MARCH"[i]] * dic["MARCH"[j]] * dic["MARCH"[k]]
print(res)

Solution (Python):
n = int(input())

num = [0] * 5
check_list = ['M','A','R','C','H']
for _ in range(n):
    s = input()
    for i, c in enumerate(check_list):
        if s[0] == c:
            num[i]+=1
            break
ans = 0
for i in range(5-2):
    for j in range(i+1, 5-1):
        for k in range(j+1, 5):
            ans += num[i]*num[j]*num[k]
print(ans)

Solution (Python):
import sys
import itertools
input = sys.stdin.readline


def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def main():
    n = I()
    mylist = ("M", "A", "R", "C", "H")
    mylist2 = [0 for i in range(5)]
    for i in range(n):
        word = input().rstrip()[0]
        for i, k in enumerate(mylist):
            if word == k:
                mylist2[i] += 1
    mylist2 = [i for i in mylist2 if i != 0]
    
    
    if len(mylist2) <= 2:
        print(0)
        sys.exit()
    result = 0
    for a, b, c in itertools.combinations(mylist2, 3):
        result += a * b * c
    print(result)
    
main()

Solution (Python):
import sys
import itertools
input = sys.stdin.readline


def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def main():
    n = I()
    mylist = ("M", "A", "R", "C", "H")
    mylist2 = [0 for i in range(5)]
    for i in range(n):
        word = input().rstrip()[0]
        for i, k in enumerate(mylist):
            if word == k:
                mylist2[i] += 1
    mylist2 = [i for i in mylist2 if i != 0]
    
    
    if len(mylist2) <= 2:
        print(0)
        sys.exit()
    result = 0
    for a, b, c in itertools.combinations(mylist2, 3):
        result += a * b * c
    print(result)
    
main()

Solution (Python):
n = int(int(input()))
s = [0]*n
t = [0]*5
for i in range(n):
    s[i] = input()
    if s[i][0] == "M":
        t[0] += 1
    elif s[i][0] == "A":
        t[1] += 1
    elif s[i][0] == "R":
        t[2] += 1
    elif s[i][0] == "C":
        t[3] += 1
    elif s[i][0] == "H":
        t[4] += 1
import itertools
data = list(range(5))
r = 3
C = list(itertools.combinations(data, r))
ans = 0
for L in C:
    ans += t[L[0]] * t[L[1]] * t[L[2]]
print(ans)

Solution (Python):
import itertools

n = int(input())
li = [0]*5
ans = 0

for i in range(n):
    s = input()
    if s[0] == "M":
        li[0] = li[0] + 1
    if s[0] == "A":
        li[1] = li[1] + 1
    if s[0] == "R":
        li[2] = li[2] + 1
    if s[0] == "C":
        li[3] = li[3] + 1
    if s[0] == "H":
        li[4] = li[4] + 1

for l in itertools.combinations(li, 3):
    ans += l[0] * l[1] * l[2]    

print(ans)

Solution (Python):
from itertools import combinations

count_dict = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}

n = int(input())
for _ in range(n):
    s = input()
    if s[0] in count_dict:
        count_dict[s[0]] += 1

ans = 0
for a, b, c in list(combinations(count_dict.keys(), 3)):
    ans += count_dict[a] * count_dict[b] * count_dict[c]
print(ans)

Solution (Python):
n = int(input())
cs = ['M', 'A', 'R', 'C', 'H']
nums = dict()
for c in cs:
    nums.setdefault(c, 0)

for i in range(n):
    s = input()
    try:
        nums[s[0]] += 1
    except:
        pass

from itertools import combinations
ans = 0
for c1, c2, c3 in combinations(cs, 3):
    ans += nums[c1] * nums[c2] * nums[c3]
print(ans)

Solution (Python):
import sys
from itertools import combinations

input = sys.stdin.readline


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

    count = dict(M=0, A=0, R=0, C=0, H=0)
    for s in S:
        if s[0] in "MARCH":
            count[s[0]] += 1

    ans = 0
    for c in combinations("MARCH", 3):
        ans += count[c[0]] * count[c[1]] * count[c[2]]

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
from collections import Counter
from itertools import combinations

N = int(input())
cheack = list('MARCH')
S = []
for _ in range(N):
    s = input()
    if s[0] in cheack:
        S.append(s[0])

C = Counter(S)
ans = 0
keys = C.keys()
if len(C.values()) >= 3:
    for comb in combinations(keys, 3):
        tmp = 1
        for i in comb:
            tmp *= C[i]
        ans += tmp
else:
    ans = 0
print(ans)

Solution (Python):
N = int(input())

march = 'MARCH'
mdict = {s:0 for s in march}

for i in range(N):
  S = input()
  if S[0] in march:
    mdict[S[0]] += 1
  
lst = [mdict[key] for key in mdict]
ans = 0
for i in range(3):
  for j in range(i+1, 4):
    for k in range(j+1, 5):
      ans += lst[i] * lst[j] * lst[k]
      
print(ans)

Solution (Python):
import itertools

n = int(input())
a = []
for _ in range(n):
    b = list(map(str,input()))
    a.append(b)

ans = [0]*5

for i in range(n):
    tmp = a[i][0]
    if tmp == "M":
        ans[0] += 1
    elif tmp == "A":
        ans[1] += 1
    elif tmp == "R":
        ans[2] += 1
    elif tmp == "C":
        ans[3] += 1
    elif tmp == "H":
        ans[4] += 1
    else:
        continue

cnt = 0
for l in itertools.combinations(ans,3):
    cnt += l[0]*l[1]*l[2]

print(cnt)

Solution (Python):
from itertools import combinations
from collections import Counter
n = int(input())
s = []
ans = 0

for i in range(n):
    name = input()
    if name[0] in 'MARCH':
        s.append(name[0])

count = Counter(s)
for i, j, k in combinations(count, 3):
    ans += count[i] * count[j] * count[k]
print(ans)

Solution (Python):
n = int(input())
p = [list(str(input())) for _ in range(n)]
m = 0
a = 0
r = 0
c = 0
h = 0
for i in p:
    if i[0] == 'M':
        m += 1
    if i[0] == 'A':
        a += 1
    if i[0] == 'R':
        r += 1
    if i[0] == 'C':
        c += 1
    if i[0] == 'H':
        h += 1
ln = [m, a, r, c, h]
import itertools
ans = 0
for j in itertools.combinations(ln, 3):
    ans += j[0] * j[1] * j[2]
print(ans)

Solution (Python):
import itertools
n = int(input())
m = 0
a = 0
r = 0
c = 0
h = 0
for i in range(n):
    dum = input()
    if dum[0] == "M":
        m += 1
    elif dum[0] == "A":
        a += 1
    elif dum[0] == "R":
        r += 1
    elif dum[0] == "C":
        c += 1
    elif dum[0] == "H":
        h += 1
march = [m,a,r,c,h]
ans = 0
for i in itertools.combinations(march,3):
    if i.count(0) == 0:
        ans += i[0]*i[1]*i[2]
print(ans)

Solution (Python):
n=int(input())
a=[0,0,0,0,0]
for i in range(n):
  s=input()
  if s[0]=='M':
    a[0]+=1
  elif s[0]=='A':
    a[1]+=1
  elif s[0]=='R':
    a[2]+=1
  elif s[0]=='C':
    a[3]+=1
  elif s[0]=='H':
    a[4]+=1
ans=0
for i in range(0,3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      ans+=a[i]*a[j]*a[k]
print(ans)

Solution (Python):
n=int(input())
dic={}
M,A,R,C,H=0,0,0,0,0
for i in range(n):
    S=input()
    if S[0]=="M":
        M+=1
    if S[0]=="A":
        A+=1
    if S[0]=="R":
        R+=1
    if S[0]=="C":
        C+=1
    if S[0]=="H":
        H+=1
        
l=[M,A,R,C,H]

p=[[0,1,2],[0,1,3],[0,1,4],[0,2,3],[0,2,4],[0,3,4],[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
cnt=0
for i in range(10):
    cnt+=l[p[i][0]]*l[p[i][1]]*l[p[i][2]]
print(cnt)

Solution (Python):
import itertools

n = int(input())

MARCH = [0]*5
for _ in range(n):
    s = input()
    if s[0] == "M":
        MARCH[0] += 1
    elif s[0] == "A":
        MARCH[1] += 1
    elif s[0] == "R":
        MARCH[2] += 1
    elif s[0] == "C":
        MARCH[3] += 1
    elif s[0] == "H":
        MARCH[4] += 1

ans = 0
for l in itertools.combinations(MARCH,3):
    ans += l[0]*l[1]*l[2]

print(ans)

Solution (Python):
from itertools import combinations
import sys
n=int(input())
m=0
a=0
r=0
c=0
h=0
tmp=set()
for i in range(n):
    s=input()
    if s[0]=="M":
        m+=1
        tmp.add("m")
    elif s[0]=="A":
        a+=1
        tmp.add("a")
    elif s[0]=="R":
        r+=1
        tmp.add("r")
    elif s[0]=="C":
        c+=1
        tmp.add("c")
    elif s[0]=="H":
        h+=1
        tmp.add("h")
if len(tmp)<3:
    print(0)
    sys.exit()
tt=[]
for i in [m,a,r,c,h]:
    if i>0:
        tt.append(i)
ans=0
for i,j,k in combinations(tt,3):
    ans+=i*j*k
print(ans)

Solution (Python):
import itertools

n = int(input())
s = [input() for _ in range(n)]
march = list("MARCH")
marchlist = [0 for _ in range(5)]

for i in range(n):
	for j in range(5):
		if s[i][0] == march[j]:
			marchlist[j] += 1

ans = 0
for i in itertools.combinations(marchlist, 3):
	tmpans = 1
	for j in range(3):
		tmpans *= i[j]
	ans += tmpans

print(ans)

Solution (Python):
import itertools

N = int(input())

MARCH = [0, 0, 0, 0, 0]

for i in range(N):
    S = input()
    if S[0] == 'M':
        MARCH[0] += 1
    elif S[0] == 'A':
        MARCH[1] += 1
    elif S[0] == 'R':
        MARCH[2] += 1
    elif S[0] == 'C':
        MARCH[3] += 1
    elif S[0] == 'H':
        MARCH[4] += 1

total = 0
for a, b, c in itertools.combinations(MARCH, 3):
    total += a * b * c
    
print(total)

Solution (Python):
n=int(input())
S=[input() for _ in range(n)]
s=[0]*5

for i in range(n):
    if S[i][0]=="M":
        s[0]+=1
    elif S[i][0]=="A":
        s[1]+=1
    elif S[i][0]=="R":
        s[2]+=1
    elif S[i][0]=="C":
        s[3]+=1
    elif S[i][0]=="H":
        s[4]+=1

ans=0
for i in range(3):
    for j in range(i+1,4):
        ans+=s[i]*s[j]*sum(s[j+1:])
print(ans)

Solution (Python):
from itertools import combinations

n = int(input())
s = [input() for _ in range(n)]

cnt = dict({'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0})
for name in s:
    if name[0] in cnt:
        cnt[name[0]] += 1

ans = 0
for i, j, k in combinations(cnt,3):
    ans += cnt[i] * cnt[j] * cnt[k]
print(ans)

Solution (Python):
import itertools
n = int(input())
count ={'M':0,'A':0,'R':0,'C':0,'H':0}

for _ in range(n):
  temp = input()
  init = temp[0]
  if init in ('M','A','R','C','H'):
    count[init]+=1

ans=0

for x,y,z in list(itertools.combinations(count,3)):
  ans+=count[x]*count[y]*count[z]
else:
  print(ans)

Solution (Python):
from itertools import combinations

n = int(input())

march = ['M', 'A', 'R', 'C', 'H']
d = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}
for _ in range(n):
    s = input()
    if s[0] in march:
        d[s[0]]= d.get(s[0], 0) + 1

cnt = 0

for a, b, c in combinations('MARCH', 3):
    cnt += d[a] * d[b] * d[c]

print(cnt)

Solution (Python):
from itertools import combinations


N, *S = open(0).read().split()
MARCH = ("M", "A", "R", "C", "H")
cnt = {c: 0 for c in MARCH}
for s in S:
    if s[0] in MARCH:
        cnt[s[0]] += 1
print(sum(cnt[a] * cnt[b] * cnt[c] for a, b, c in combinations(MARCH, 3)))

Solution (Python):
n = int(input())
cnt = [0] * 5
ans = 0
for _ in range(n):
    s = input()
    if s[0] == 'M':
        cnt[0] += 1
    elif s[0] == 'A':
        cnt[1] += 1
    elif s[0] == 'R':
        cnt[2] += 1
    elif s[0] == 'C':
        cnt[3] += 1
    elif s[0] == 'H':
        cnt[4] += 1
    else:
        continue

for i in range(3):
    for j in range(i+1, 4):
        for k in range(j+1, 5):
            ans += cnt[i] * cnt[j] * cnt[k]
            
print(ans)

Solution (Python):
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *

from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction



mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]








n=l()[0]
A=[input() for i in  range(n)]
d={"M":0,"A":0,"R":0,"C":0,"H":0}
for i in range(n):
    if A[i][0] in d:
        d[A[i][0]]+=1
s="MARCH"
ans=0
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            ans+=(d[s[i]]*d[s[j]]*d[s[k]])
print(ans)

Solution (Python):
from collections import defaultdict
from itertools import combinations


def main():
    N = int(input())
    S = [input() for _ in range(N)]

    name = defaultdict(int)
    march = ['M', 'A', 'R', 'C', 'H']

    for s in S:
        if s[0] in march:
            name[s[0]] += 1

    ans = 0
    for c in combinations(march, 3):
        tmp = 1
        for cc in c:
            tmp *= name[cc]
        ans += tmp

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
n= int(input())
from itertools import combinations
d=[0,0,0,0,0]

f={}
f['M']=0
f['A']=1
f['R']=2
f['C']=3
f['H']=4

e={}
e['M']=0
e['A']=0
e['R']=0
e['C']=0
e['H']=0


for _ in range(n):

    s = input()[0]
    if s in ['M','A','R','C','H']:
        e[s]=1
        d[f[s]]+=1


k = e['M']+e['A']+e['R']+e['C']+e['H']

cnt=0
if k>=3:
    c = list(combinations(d,3))

    for j in c:
        tmp=1
        for l in j:
            tmp*=l
        
        cnt+=tmp

print(cnt)

Solution (Python):

n = int(input())
L = 'MARCH'
S = []
for i in range(n):
    s = input()
    if s[0] in L:
        S.append(s[0]) 

import collections
c = collections.Counter(S)
 
ans = 0
import itertools
for i,j,k in itertools.combinations(c.values(), 3):
    ans += i*j*k
print(ans)

Solution (Python):
n = int(input())
a = []
m,a,r,c,h = 0,0,0,0,0

for i in range(n):
  s = input()
  if s[0] is 'M':
    m += 1
  if s[0] is 'A':
    a += 1
  if s[0] is 'R':
    r += 1
  if s[0] is 'C':
    c += 1
  if s[0] is 'H':
    h += 1
    
list = [m,a,r,c,h]

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

Solution (Python):
import collections
import itertools
def solve(n, s_list):

    counter = collections.Counter()
    for s in s_list:
        if s[0] in "MARCH":
            counter[s[0]] += 1

    ans = 0
    for i, j, k in itertools.combinations("MARCH",3):
        ans += counter[i]*counter[j]*counter[k]

    return ans


if __name__ == "__main__":
    n = int(input())
    s_list = [input() for i in range(n)]
    print(solve(n, s_list))

Solution (Python):

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)








n=n0()
S=s2(n)

d={"M":0,"A":0,"R":0,"C":0,"H":0}
for s in S:
    if s[0] in "MARCH":
        d[s[0]]+=1

l=list(d.values())

ans=0
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            ans+=l[i]*l[j]*l[k]
print(ans)

Solution (Python):
import math

N = int(input())
names = []
for i in range(N):
  names.append(input()[0])
  
conbi = []  
count = 0
ans = 0

while count< 2** 5:
  twodig = bin(count)
  list_td = list(twodig)
  list_tdc = list_td[2:]
  while len(list_tdc) < 5:
    list_tdc.insert(0, "0")
  conbi.append(list_tdc)
  count+= 1
  
conbi2 = list(filter(lambda x: x.count("1") == 3, conbi))

m = names.count("M")
a = names.count("A")
r = names.count("R")
c = names.count("C")
h = names.count("H")

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

for x in conbi2:
  p = x.index("1")
  x[p] = "0"
  q = x.index("1")
  x[q] = "0"
  r = x.index("1")
  x[r] = "0"
  
  ans+= MARCH[p]* MARCH[q]* MARCH[r]

print(int(ans))

Solution (Python):
import collections
N = int(input())
C = collections.Counter([input()[0] for _ in range(N)]).most_common()
CC = {c[0]:c[1] for c in C if c[1] != 0 and c[0] in ['M','A','R','C','H']}
count = 0
s = []
for k1,v1 in CC.items():
    for k2,v2 in CC.items():
        for k3,v3 in CC.items():
            key = ''.join(sorted([k1,k2,k3]))
            if k1 != k2 and k2 != k3 and k1 != k3 and key not in s:
                s.append(key)
                count += v1*v2*v3
print(count)

Solution (Python):
n = int(input())
L = 'MARCH'
S = []
for i in range(n):
    s = input()
    if s[0] in L:
        S.append(s[0])

import collections
c = collections.Counter(S)

ans = 0
import itertools
for i,j,k in itertools.combinations(c.values(), 3):
    ans += i*j*k
print(ans)

Solution (Python):
from collections import Counter
from itertools import combinations

n = int(input())
s = [input()[0] for _ in range(n)]
counter = Counter([initial for initial in s if initial in 'MARCH'])

ans=0
for x,y,z in combinations(counter.values(), 3):
    ans+=x*y*z
    
print(ans)

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
names = [name for name in s if name[0] in 'MARCH']
counter = Counter([name[0] for name in names])

from itertools import combinations
ans=0
for x,y,z in combinations(counter.values(), 3):
    ans+=x*y*z
    
print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

N = INT()
S = [input() for _ in range(N)]
march = ["M", "A", "R", "C", "H"]

cnt = defaultdict(int)

for s in S:
	if s[0] in march:
		cnt[s[0]] += 1


ans = 0




for x, y, z in combinations(cnt.values(), 3):
	
	ans += x*y*z
print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

N = INT()
S = [input() for _ in range(N)]
march = ["M", "A", "R", "C", "H"]
march_lis = [0]*5

for s in S:
	if s[0].upper() in march:
		march_lis[march.index(s[0].upper())] += 1


ans = 0
for x, y, z in combinations(march_lis, 3):
	
	ans += x*y*z
print(ans)

Solution (Python):
n=int(input())
s=[]
M,A,R,C,H=0,0,0,0,0
for i in range(n):
    s.append(input())

for i in range(n):
    S=''
    S=s[i]
    if S[0]=='M':
        M+=1
    elif S[0]=='A':
        A+=1
    elif S[0]=='R':
        R+=1
    elif S[0]=='C':
        C+=1
    elif S[0]=='H':
        H+=1
    else:
        pass
print(M*A*R+M*A*C+M*A*H+M*R*C+M*R*H+M*C*H+A*R*C+A*R*H+A*C*H+R*C*H)

Solution (Python):
from collections import Counter
from itertools import combinations
n = int(input())
S = [input()[0] for _ in range(n)]
C = Counter(S)
ans = 0
for i, j, k in combinations(['M', 'A', 'R', 'C', 'H'], 3):
    ans += C[i] * C[j] * C[k]
print(ans)

Solution (Python):


import sys









from collections import defaultdict          













from itertools import combinations, combinations_with_replacement






def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n = ii()
    d = defaultdict(int)
    for _ in range(n):
        name = input()
        d[name[0]] += 1
    
    buf = []
    for char in "M A R C H".split():
        if char in d:
            buf.append(d[char])
    
    
    if len(buf) < 3:
        print(0)
    else:
        ans = 0
        for pattern in combinations(buf, r=3):
            tmp = 1
            for num in pattern:
                tmp *= num
            ans += tmp
        print(ans)
    


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
S =[]
for n in range(N):
    s = input()
    S.append(s[0])
S=sorted(S)
NAME = sorted(["M","A","R","C","H"])
from itertools import combinations
from collections import Counter
pattern = list(combinations(NAME,3))
LEN = len(S)
cnt=0
Counter_S =Counter(S)
cnt = 0
for p in pattern:
    cnt +=(Counter_S[p[0]] * Counter_S[p[1]] * Counter_S[p[2]])
print(cnt)

Solution (Python):
import itertools

n = int(input())

l = [0]*5
for i in range(n):
    s = input()
    if s[0] == "M":
        l[0] += 1
    if s[0] == "A":
        l[1] += 1
    if s[0] == "R":
        l[2] += 1
    if s[0] == "C":
        l[3] += 1
    if s[0] == "H":
        l[4] += 1 

ans = 0
for a,b,c in itertools.combinations(l,3):
    ans += a*b*c

print(ans)

Solution (Python):
from itertools import combinations
n = int(input())
l = [0]*5
ans = 0

for i in range(n):
  s = input()
  if s[0] == "M":
    l[0] += 1
  elif s[0] == "A":
    l[1] += 1
  elif s[0] == "R":
    l[2] += 1 
  elif s[0] == "C":
    l[3] += 1
  elif s[0] == "H":
    l[4] += 1
    
for a,b,c in combinations(l, 3):
  ans += a* b* c
  
print(ans)

Solution (Python):
n = int(input())
head = ["M","A","R","C","H"]
num = [0] * 5
ans = 0

for _ in range(n):
    s = input()[0]
    
    for i in range(5):
        if s == head[i]:
            num[i] += 1
            break
            
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            ans += num[i] * num[j] * num[k]
            
print(ans)

Solution (Python):
from collections import defaultdict
import itertools

d = defaultdict(int)
N = int(input())
for i in range(N):
  s = input()[0].lower()
  d[s] += 1

n = [d['m'], d['a'], d['r'], d['c'], d['h']]
ans = 0

a = itertools.combinations(n, 3)
for aa in a:
  t = 1
  for aaa in aa:
    t *= aaa
  ans += t

print(ans)

Solution (Python):
n=int(input())
m=[]
a=[]
r=[]
c=[]
h=[]

for i in range(n):
    s=input()
    if s[0]=='M':
        m.append(s)
    elif s[0]=='A':
        a.append(s)
    elif s[0]=='R':
        r.append(s)
    elif s[0]=='C':
        c.append(s)
    elif s[0]=='H':
        h.append(s)

num=[0]*5
num[0]=len(m)
num[1]=len(a)
num[2]=len(r)
num[3]=len(c)
num[4]=len(h)

ans=0
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            ans+=num[i]*num[j]*num[k]
print(ans)

Solution (Python):
from itertools import combinations
from collections import Counter
N=int(input())
S=Counter()
for i in range(N):
    s=input()
    S[s[0]]+=1
print(sum([S[a]*S[b]*S[c] for a,b,c in combinations("MARCH",3)]))

Solution (Python):
import itertools

my_dict = dict()
my_dict['m'] = 0
my_dict['a'] = 0
my_dict['r'] = 0
my_dict['c'] = 0
my_dict['h'] = 0
n = int(input())
for i in range(n):
    s = input()
    if s.startswith("M"):
        my_dict['m'] += 1
    elif s.startswith("A"):
        my_dict['a'] += 1
    elif s.startswith("R"):
        my_dict['r'] += 1
    elif s.startswith("C"):
        my_dict['c'] += 1
    elif s.startswith("H"):
        my_dict['h'] += 1

seq = ('m', 'a', 'r', 'c', 'h')
ret = 0

for item in itertools.combinations(seq, 3):
    tmp = 1
    for val in item:
        tmp *= my_dict[val]
    ret += tmp

print(ret)

Solution (Python):
n = int(input())
m = 0
a = 0
r = 0
c = 0
h = 0
for i in range(n):
  s = input()
  if s[0] == "M":
    m += 1
  if s[0] == "R":
    r += 1
  if s[0] == "A":
    a += 1
  if s[0] == "C":
    c += 1
  if s[0] == "H":
    h += 1
    
from itertools import combinations
march = [m,a,r,c,h]
base = list(combinations(march,3))

result = 0
for b in base:
  result += b[0] * b[1] * b[2]
  
print(result)

Solution (Python):
import itertools

n=int(input())

num=[0]*5
for i in range(n):
    s=input()
    if s[0]=='M':
        num[0]+=1
    elif s[0]=='A':
        num[1]+=1
    elif s[0]=='R':
        num[2]+=1
    elif s[0]=='C':
        num[3]+=1
    elif s[0]=='H':
        num[4]+=1

ans=0
for comb in itertools.combinations(num,3):
    ans+=comb[0]*comb[1]*comb[2]
print(ans)

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
n = ii()
sm = set()
sa = set()
sr = set()
sc = set()
sh = set()

for _ in range(n):
    tmp = input()
    d = tmp[0]
    if d == 'M':
        sm.add(tmp)
    elif d == 'A':
        sa.add(tmp)
    elif d == 'R':
        sr.add(tmp)
    elif d == 'C':
        sc.add(tmp)
    elif d == 'H':
        sh.add(tmp)

d = {}
d['m'] = len(sm)
d['a'] = len(sa)
d['r'] = len(sr)
d['c'] = len(sc)
d['h'] = len(sh)
A = 'march'
ans = 0
for i in range(1<<5):
    output = []
    for j in range(5):
        if ((i>>j)&1)==1:
            output.append(A[j])
    if len(output) == 3:
        ans += d[output[0]]*d[output[1]]*d[output[2]]
print(ans)