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 math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    n = i_input()
    dic = {"M":0,"A":0,"R":0,"C":0,"H":0}
    key = list(dic.keys())
    for _ in range(n):
        i = s_input()
        t = i[0]
        if t in key:
            dic[t] = dic.get(t) + 1
    ans = 0
    check = False
    l = list(dic.values())
    l = list(itertools.combinations(l, 3))
    for i in l:
        a = i[0]
        b = i[1]
        c = i[2]
        if a != 0 and b != 0 and c != 0:
            ans += a*b*c
            check = True
    if check:
        print(ans)
    else:
        print(0)


if __name__=="__main__":
    main()

Solution (Python):
n = int(input())
dic = {}
cnt = 0

for i in range(n) :
    s = input()
    if s[0] == "M" or s[0] == "A" or s[0] == "R" or s[0] == "C" or s[0] == "H" :
        if s[0] in dic :
            dic[s[0]] += 1
        else:
            dic[s[0]] = 1

lis = [x for x in dic.values()]

for j in range(len(lis) - 2) :
    for k in range(j + 1, len(lis) - 1) :
        for l in range(k + 1, len(lis)) :
            
            cnt += lis[j] * lis[k] * lis[l]
    
print(cnt)

Solution (Python):
n = int(input())
dic = {}
cnt = 0

for i in range(n) :
    s = input()
    if s[0] == "M" or s[0] == "A" or s[0] == "R" or s[0] == "C" or s[0] == "H" :
        if s[0] in dic :
            dic[s[0]] += 1
        else:
            dic[s[0]] = 1

lis = [x for x in dic.values()]

for j in range(len(lis) - 2) :
    for k in range(j + 1, len(lis) - 1) :
        for l in range(k + 1, len(lis)) :
            
            cnt += lis[j] * lis[k] * lis[l]
    
print(cnt)

Solution (Python):
import collections
N = int(input())
lsname = []
for i in range(N):
    name = input()
    lsname.append(name[:1])
counterN = collections.Counter(lsname)
lskey = ['M','A','R','C','H']
lsnum = []
for i in lskey:
    if i in counterN.keys():
        lsnum.append(counterN[i])
ans = 0
lenN = len(lsnum)
for i in range(lenN-2):
    for j in range(i+1,lenN-1):
        for k in range(j+1,lenN):
            ans += lsnum[i]*lsnum[j]*lsnum[k]
print(ans)

Solution (Python):
import itertools
n = int(input())
num = [0]*5
name = ['M','A','R','C','H']
for _ in range(n):
    s = str(input())
    for i in range(5):
        if s[0] == name[i]:
            num[i] += 1
            break
num = [k for k in num if k != 0]
c = num.count(0)
if 2 <= c:
    print(0)
else:
    d = 0
    for h,j,l in itertools.combinations(num,3):
        d += (h*j*l)
    print(d)

Solution (Python):
N = int(input())
S = []
ans = 0

for i in range(N):
    S.append(str(input()))

S = list(set(S))

name = [0 for i in range(5)]

for j in range(len(S)):
    t = str(S[j])
    if t[0] == "M":
        name[0] += 1
    elif t[0] == "A":
        name[1] += 1
    elif t[0] == "R":
        name[2] += 1
    elif t[0] == "C":
        name[3] += 1
    elif t[0] == "H":
        name[4] += 1


for x in range(5):
    for y in range(5):
        if x == y:
            break
        for z in range(5):
            if x == z or y == z:
                break
            if name[x]*name[y]*name[z] > 0:
                ans += name[x]*name[y]*name[z]

print(ans)

Solution (Python):
n = int(input())
name_list =[0,0,0,0,0]
alp =  ["M","A","R","C","H"]
for i in range(n):
  s = input()
  if s[0] in alp:
    name_list[alp.index(s[0])] += 1
ans = 0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      ans += name_list[i] * name_list[j] * name_list[k]

print(ans)

Solution (Python):
N = int(input())
Name = [input()[0] for _ in range(N)]
March = {x:Name.count(x) for x in 'MARCH' if Name.count(x) > 0}

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

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

march=[0]*5

march_dic={"M":0,"A":1,"R":2,"C":3,"H":4}

for i in range(n):
    name=input()
    if name[0] in "MARCH":
        march[march_dic[name[0]]]+=1

def count_type(march):
    ans=[]
    for i in march:
        if i!=0:
            ans.append(i)
    ans.sort()
    return len(ans),ans

type_num,each_num=count_type(march)
if type_num<3:
    print(0)
else:
    ans=0
    for i in range(type_num-2):
        for j in range(i+1,type_num-1):
            for k in range(j+1,type_num):
                ans+=each_num[i]*each_num[j]*each_num[k]

    print(ans)

Solution (Python):
from collections import Counter
import itertools

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

cnt = Counter(s)
ans = 0
for x, y, z in itertools.combinations("MARCH", 3):
    ans += cnt[x] * cnt[y] * cnt[z]
print(ans)

Solution (Python):
from itertools import combinations
from functools import reduce

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

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

x = [n for n in x if n != 0]
ans = 0
for c in combinations(x, 3):
    ans += reduce(f, c)

print(ans)

Solution (Python):
n=int(input())
s=[input() for _ in range(n)]
m=sum([1 for i in s if i[0]=='M'])
a=sum([1 for i in s if i[0]=='A'])
r=sum([1 for i in s if i[0]=='R'])
c=sum([1 for i in s if i[0]=='C'])
h=sum([1 for i in s if i[0]=='H'])
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):
import itertools
n = int(input())
march = dict()

a = "MARCH"
for i in range(5):
    march[a[i]] = 0

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

res = 0
for i in itertools.combinations("MARCH", 3):
    tmp = 1
    for j in i:
        tmp *= march[j]
    res += tmp

print(res)

Solution (Python):
'''
Created on 2020/08/31

@author: harurun
'''
def main():
  from itertools import combinations
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  N=int(pin())
  ans=0
  d=[0]*5
  for _ in [0]*N:
    S=pin()[:-1][0]
    if S=="M":
      d[0]+=1
    elif S=="A":
      d[1]+=1
    elif S=="R":
      d[2]+=1
    elif S=="C":
      d[3]+=1
    elif S=="H":
      d[4]+=1
  c=list(combinations([0,1,2,3,4],3))
  for i in c:
    cnt=1
    for j in list(i):
      cnt*=d[j] 
    ans+=cnt 
  print(ans)
  return 
main()

Solution (Python):
n = int(input())
li = [0]*5

for k in range(n):
    s = input()
    if s[0]=="M":
        li[0]+=1
    elif s[0]=="A":
        li[1]+=1
    elif s[0]=="R":
        li[2]+=1
    elif s[0]=="C":
        li[3]+=1
    elif s[0]=="H":
        li[4]+=1
        
ans = 0
for i in range(2**5):
    num = 1
    if str(bin(i)).count("1")==3:
        for j in range(5):
            if (i>>j&1)==1:
                num *= li[j]
        else:
            ans += num
print(ans)

Solution (Python):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    def select(n,k):
        return math.factorial(n)//(math.factorial(k)*math.factorial(n-k))
    n = I()
    dic = collections.defaultdict(int)
    for _ in range(n):
        s = S()
        if s[0] in {"M","A","R","C","H"}:
            dic[s[0]] += 1

    vlst = [i for i in dic.values() if i!=0]
    ans = 0
    lenth = len(vlst)

    for i in range(lenth):
        for j in range(i+1,lenth):
            for k in range(j+1,lenth):
                ans += select(vlst[i],1)*select(vlst[j],1)*select(vlst[k],1)
    print(ans)
main()

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


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()

S = []
ans = 0

for i in range(n):
    s = input()[0]
    if s in ["M","A","R","C","H"]:
        S.append(s)

C = Counter(S)

for w in combinations(["M","A","R","C","H"],3):
    ans += C[w[0]]*C[w[1]]*C[w[2]]

print(ans)

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 x, y, z in combinations("MARCH", 3):
  ans += C[x]*C[y]*C[z]

print(ans)

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

N = int(input())
D = defaultdict(int)

for _ in range(N):
  S = input()
  if S[0] in "MARCH":
    D[S[0]] += 1

ans = 0
for C in combinations(("M", "A", "R", "C", "H"), 3):
  temp = 1
  for c in C:
    temp *= D[c]
  ans += temp

print(ans)

Solution (Python):
from collections import defaultdict
import itertools 

n = int(input())

d = defaultdict(int)

for i in range(n):
    s = input()
    d[s[0]] += 1

l = ["M", "A", "R", "C", "H"]

c = itertools.combinations(l, 3)

s = 0

for x in c:
    s += d[x[0]] * d[x[1]] * d[x[2]]

print(s)

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]=="A":
        a+=1
    if s[0]=="R":
        r+=1
    if s[0]=="C":
        c+=1
    if s[0]=="H":
        h+=1
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):
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]=="A":
        a+=1
    if s[0]=="R":
        r+=1
    if s[0]=="C":
        c+=1
    if s[0]=="H":
        h+=1
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):
import collections
import itertools
n=int(input())
l,s=[],[]
for i in range(n):
    a=input()
    if a[0]=="M" or a[0]=="A" or a[0]=="R" or a[0]=="C" or a[0]=="H":
        l.append(a[0])
        if s.count(a[0])==0:
            s.append(a[0])
l=collections.Counter(l)
ans=0
for j in itertools.combinations(s,3):
    ans+=(l[j[0]]*l[j[1]]*l[j[2]])
print(ans)

Solution (Python):
N=int(input())
li=[0,0,0,0,0]
for i in range(N):
    S=input()
    if S[0]=="M":
        li[0]+=1
    if S[0]=="A":
        li[1]+=1
    if S[0]=="R":
        li[2]+=1
    if S[0]=="C":
        li[3]+=1
    if S[0]=="H":
        li[4]+=1
lim=0
for j in range(5):
    if li[j]!=0:
        lim+=1
temp=1   
li.sort(reverse=True)
ans=0
if lim==3:
    ans=li[0]*li[1]*li[2]
elif lim==4:
    lis=[[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
    for l in range(4):
        for m in range(3):
            temp*=li[lis[l][m]-1]
        ans+=temp
        temp=1
        
elif lim==5:
    lis=[[1,2,3],[1,2,4],[1,2,5],[1,3,4],[1,3,5],[1,4,5],[2,3,4],[2,3,5],[2,4,5],[3,4,5]]
    for l in range(10):
        for m in range(3):
            temp*=li[lis[l][m]-1]
        ans+=temp
        temp=1
        
else:
    ans=0

print(ans)

Solution (Python):
N = int(input())
S = [input()[:1] for _ in range(N)]
c = [S.count(s) for s in 'MARCH' if S.count(s)]
ans = 0
if len(c) > 2:
    ans += c[0]*c[1]*c[2]

if len(c) > 3:
    for i in c[3:]:
        for j in range(3):
            tmp = c[:3]
            tmp[j] = i
            ans += tmp[0]*tmp[1]*tmp[2]
if len(c) > 4:
    tmp = c[3:]
    for j in range(3):
        ans += tmp[0]*tmp[1]*c[j]
print(ans)

Solution (Python):
from collections import Counter

N = int(input())
S = [input()[:1] for _ in range(N)]
c = Counter(S)

first_name = 'MARCH'
c = [c[i] for i in first_name if c[i]]

ans = 0
if len(c) > 2:
    ans += c[0]*c[1]*c[2]

if len(c) > 3:
    for i in c[3:]:
        for j in range(3):
            tmp = c[:3]
            tmp[j] = i
            ans += tmp[0]*tmp[1]*tmp[2]
if len(c) > 4:
    tmp = c[3:]
    for j in range(3):
        ans += tmp[0]*tmp[1]*c[j]
print(ans)

Solution (Python):
N = int(input())
m = [0] * 5
s = "MARCH"
for i in range(N):
    a = input()
    for j in range(5):
        if s[j] == a[0]:
            m[j] += 1

ans = 0

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

print(ans)

Solution (Python):
n = int(input())
s = [input()[0] for _ in range(n)]
c = [s.count("M"), s.count("A"), s.count("R"), s.count("C"), s.count("H")]
ans =  c[0] * c[1] *c [2]
ans += c[0] * c[1] *c [3]
ans += c[0] * c[1] *c [4]
ans += c[0] * c[2] *c [3]
ans += c[0] * c[2] *c [4]
ans += c[0] * c[3] *c [4]
ans += c[1] * c[2] *c [3]
ans += c[1] * c[2] *c [4]
ans += c[1] * c[3] *c [4]
ans += c[2] * c[3] *c [4]
print(ans)

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

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):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial

from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

ddict = defaultdict(lambda: 0)





n = I()
s = CS(n)

for i in s:
    if i[0]=='M':
        ddict['M'] += 1
    elif i[0]=='A':
        ddict['A'] += 1
    elif i[0]=='R':
        ddict['R'] += 1
    elif i[0]=='C':
        ddict['C'] += 1
    elif i[0]=='H':
        ddict['H'] += 1
    else:
        pass

l = list(combinations(['M','A','R','C','H'],3))


x = 0
for t in l:
    x += ddict[t[0]]*ddict[t[1]]*ddict[t[2]]
print(x)

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

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

for i in range(N):
    S[input()[0]] += 1

tmp = []
for a,b,c in combinations('MARCH',3):
    tmp.append(int((S[a] * S[b] * S[c])))

print(sum(tmp))

Solution (Python):
import itertools
from collections import defaultdict

def main():
    name_freq = defaultdict(int)
    N = int(input())
    for _ in range(N):
        name_freq[input()[0]] += 1

    ans = 0
    for comb in itertools.combinations(['M', 'A', 'R', 'C', 'H'], 3):
        ans += name_freq[comb[0]] * name_freq[comb[1]] * name_freq[comb[2]]
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import itertools
n=int(input())
m=list("MARCH")
d=[0]*5
for i in range(n):
  s=input()
  for j in range(len(m)):
    if s[0]==m[j]:
      d[j]+=1
ans=0
for i in list(itertools.combinations(list(range(5)), 3)):
  k=list(i)
  ans+=d[k[0]]*d[k[1]]*d[k[2]]
print(ans)

Solution (Python):
from collections import defaultdict
N = int(input())
defdict = defaultdict(int)
for _ in range(N):
  st = input()
  fst = st[0]
  if fst in "MARCH":
  	defdict[fst]+=1
V = list(defdict.values())
NV =  len(V)
ans = 0
for i in range(NV):
  for j in range(i+1,NV):
    for k in range(j+1,NV):
      ans+=V[i]*V[j]*V[k]
print(ans)

Solution (Python):
import itertools
N = int(input())
S = [input() for _ in range(N)]
n = [0] * 5
for i in range(N):
    for j in range(5):
        if S[i][0] == ['M', 'A', 'R', 'C', 'H'][j]:
            n[j] += 1
ans = 0
for i in itertools.combinations(range(5), 3):
    ans += n[i[0]] * n[i[1]] * n[i[2]]
print(ans)

Solution (Python):
from itertools import combinations
n=int(input())
dp=[0]*5
for i in range(n):
  s=input()
  if s[0]=="M":
      dp[0]+=1
  if s[0]=="A":
      dp[1]+=1
  if s[0]=="R":
      dp[2]+=1
  if s[0]=="C":
      dp[3]+=1
  if s[0]=="H":
      dp[4]+=1
ans=0
for a,b,c in combinations(dp,3):
  ans+=a*b*c
print(ans)

Solution (Python):
from collections import Counter


if __name__ == "__main__":
    N = int(input())
    C = Counter()
    march = ["M", "A", "R", "C", "H"]
    for _ in range(N):
        s = input()
        if s[0] in march:
            C[s[0]] += 1
    ans = 0
    for i in range(3):
        for j in range(i+1, 4):
            for k in range(j+1, 5):
                ans += C[march[i]] * C[march[j]] * C[march[k]]
    print(ans)

Solution (Python):
import itertools

N = int(input())
t = tuple('MARCH')
dic = {}

for _ in range(N):
    s = input()
    x = s[0]

    if x not in t:
        continue

    if x in dic:
        dic[x] += 1
    else:
        dic[x] = 1

count = [v for v in dic.values()]
if len(count) < 3:
    print(0)
    exit()

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

print(ans)

Solution (Python):
from itertools import combinations
n=int(input())
dp=[0]*5
for i in range(n):
  s=input()
  if s[0]=="M":
      dp[0]+=1
  if s[0]=="A":
      dp[1]+=1
  if s[0]=="R":
      dp[2]+=1
  if s[0]=="C":
      dp[3]+=1
  if s[0]=="H":
      dp[4]+=1
ans=0
for a,b,c in combinations(dp,3):
  ans+=a*b*c
print(ans)

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


n = int(input().strip())


d = {
    "M": 0,
    "A": 0,
    "R": 0,
    "C": 0,
    "H": 0
}
top = list("MARCH")


for _ in range(n):
    name = input().strip()
    if name[0] in top:
        d[name[0]] += 1

ans = 0

for a in range(3):
    for b in range(a + 1, 4):
        for c in range(b + 1, 5):
            ans += d[top[a]] * d[top[b]] * d[top[c]]

print(ans)

Solution (Python):
N = int(input())
A = {'M':0,'A':0,'R':0,'C':0,'H':0}
for i in range(N):
    s = input()
    if s[0] in A:
        A[s[0]] += 1
B = [A['M'],A['A'],A['R'],A['C'],A['H']]

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

Solution (Python):
from itertools import combinations

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

ans=0
for i,j,k in combinations('MARCH',3):
  ans+=d[i]*d[j]*d[k]

print(ans)

Solution (Python):
N = int(input())
T = [0]*5
for i in range(N):
    S = input()
    if S[0]=="M":
        T[0]+=1
    elif S[0]=="A":
        T[1]+=1
    elif S[0]=="R":
        T[2]+=1
    elif S[0]=="C":
        T[3]+=1
    elif S[0]=="H":
        T[4]+=1
from itertools import combinations
Ls = list(combinations([0,1,2,3,4],3))
out = 0
for L in Ls:
    out += T[L[0]]*T[L[1]]*T[L[2]]
print(out)

Solution (Python):
n = int(input())
s = [0]*5
ans = 0
for i in range(n):
    x = list(input())[0]
    if x == "M":
        s[0] += 1
    if x == "A":
        s[1] += 1
    if x == "R":
        s[2] += 1
    if x == "C":
        s[3] += 1
    if x == "H":
        s[4] += 1
    
for a in range(5):
    for b in range(a+1,5):
        for c in range(b+1,5):
            ans += s[a]*s[b]*s[c]
            
print(ans)

Solution (Python):
from itertools import combinations

N = int(input())
name_count = {'M': 0,
              'A': 0,
              'R': 0,
              'C': 0,
              'H': 0, }
for i in range(N):
    name = input()

    if name[0] in name_count:
        name_count[name[0]] += 1


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


all_sum = sum(name_count.values())
total = comb(all_sum, 3)

for i in name_count.values():
    if i >= 2:
        total -= comb(i, 2) * (all_sum - i)

    if i >= 3:
        total -= comb(i, 3)

print(total)

Solution (Python):
import sys
import itertools
from collections import Counter
N = int(input())
name = []
for _ in range(N):
    a = input()
    name.append(a[0])
name = Counter(name)
kouho = []
kouho.append(name["M"])
kouho.append(name["A"])
kouho.append(name["R"])
kouho.append(name["C"])
kouho.append(name["H"])
name = []
for i in kouho:
    if i == 0:
        continue
    name.append(i)
total = sum(name)
seki = 1
for i in name:
    seki = seki*i
hikuseki = 1
for i in name:
    if i > 1:
        hikuseki = hikuseki*i

if len(name) < 3:
    print(0)
    sys.exit()

seki = list(itertools.combinations(name, 3))
ans = 0
for i in seki:
    a, b, c = i
    ans += a*b*c
print(ans)

Solution (Python):
n = int(input())
from collections import Counter
c = Counter()
for _ in range(n):
    s = input()[0]
    c[s] += 1

ans = 0
ans += c["M"]*c["A"]*c["R"]
ans += c["M"]*c["A"]*c["C"]
ans += c["M"]*c["A"]*c["H"]
ans += c["M"]*c["R"]*c["C"]
ans += c["M"]*c["R"]*c["H"]
ans += c["M"]*c["C"]*c["H"]
ans += c["A"]*c["R"]*c["C"]
ans += c["A"]*c["R"]*c["H"]
ans += c["A"]*c["C"]*c["H"]
ans += c["R"]*c["C"]*c["H"]

print(ans)

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
m_cnt = 0
a_cnt = 0
r_cnt = 0
c_cnt = 0
h_cnt = 0
for _ in range(n):
    s = input()
    if s[0] == 'M':
        m_cnt += 1
    elif s[0] == 'A':
        a_cnt += 1
    elif s[0] == 'R':
        r_cnt += 1
    elif s[0] == 'C':
        c_cnt += 1
    elif s[0] == 'H':
        h_cnt += 1

lst = [m_cnt, a_cnt, r_cnt, c_cnt, h_cnt]
ans = 0
for i in range(5):
    for j in range(i+1, 5):
        for k in range(j+1, 5):
            ans += lst[i] * lst[j] * lst[k]
print(ans)

Solution (Python):
import itertools
n = int(input())
name = [0]*5
s = []
for i in range(n):
    st = input()
    if st[0] == 'M':
        name[0] += 1
    elif st[0] == 'A':
        name[1] += 1
    elif st[0] == 'R':
        name[2] += 1
    elif st[0] == 'C':
        name[3] += 1
    elif st[0] == 'H':
        name[4] += 1
    s.append(st)

ans = 0
for v in itertools.combinations(name, 3):
    
    ans += v[0]*v[1]*v[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):
    s = list(input())
    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

memo = [M,A,R,C,H]

ans = 0

for v in itertools.combinations(memo, 3):
    tmp = 1
    for vv in v:
        tmp *= vv
    ans += tmp
print(ans)

Solution (Python):
from itertools import combinations
n = int(input())
arr = [input() for _ in range(n)]

li = ["M", "A", "R", "C", "H"]

result = []
for s in li:
    result.append(len(set([x for x in arr if x[0] == s])))

ans = 0

for x, y, z in combinations(result, 3):
    ans += x * y * z

print(ans)

Solution (Python):
import sys
from itertools import combinations

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

N = int(sys.stdin.readline())
for _ in range(N):
    s = sys.stdin.readline().strip()
    if s[0] in index:
        index[s[0]] += 1

ans = 0
for (a, b, c) in combinations(index.items(), 3):
    ans += a[1] * b[1] * c[1]

print(ans)

Solution (Python):
from itertools import combinations
N = int(input())
A = [0 for _ in range(5)]
for _ in range(N):
    a = input().strip()
    if a[0]=="M":
        A[0] += 1
    elif a[0]=="A":
        A[1] += 1
    elif a[0]=="R":
        A[2] += 1
    elif a[0]=="C":
        A[3] += 1
    elif a[0]=="H":
        A[4] += 1
cnt = 0
for x in combinations(range(5),3):
    cnt += A[x[0]]*A[x[1]]*A[x[2]]
print(cnt)

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
res = [0] * 5
ini = 'MARCH'
for i in range(N):
    for j in range(5):
        if S[i][0] == ini[j]:
            res[j] += 1

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

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
d = defaultdict(int)
for _ in range(n):
    s = input() 
    d[s[0]] += 1
res = 0
li = ['M','A','R','C','H']
for i in range(3):
    a = li[i]
    for j in range(i+1,4):
        b = li[j]
        for k in range(j+1,5):
            c = li[k]
            res += d[a] * d[b] * d[c]
print(res)

Solution (Python):
n = int(input())
md = {'M':0, 'A':0 , 'R':0, 'C':0, 'H':0}
for _ in range(n):
    s = input()
    if s[0] in md:
        md[s[0]] += 1

vs = []
for v in md.values():
    vs.append(v)

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

print(ans)

Solution (Python):
N = int(input())
S = [input() for i in range(N)]
from collections import Counter
ctr = Counter([s[0] for s in S])

ans = 0
import itertools
for ptn in itertools.combinations('MARCH',3):
    a,b,c = ptn
    ans += ctr[a] * ctr[b] * ctr[c]
print(ans)

Solution (Python):
N=int(input())
T=set(['M','A','R','C','H'])
d={}

for _ in range(N):
    s=input()[0]
    if s in T:
        d[s]=d.get(s, 0)+1

k=len(d.keys())
ans=0
if 3<=k:
    import itertools
    for x,y,z in itertools.combinations(d.keys(), 3):
        
        ans+=d[x]*d[y]*d[z]
print(ans)

Solution (Python):
from itertools import combinations as C

d = {}
for _ in range(int(input())):
    s = input()[0]
    if s in "MARCH":
        d[s] = d.get(s, 0) + 1
else:
    print(sum([p * q * r for p, q, r in C(d.values(), 3)]))

Solution (Python):
from itertools import combinations as C

d = {}
for _ in range(int(input())):
    s = input()[0]
    d[s] = d.get(s, 0) + 1

dk = set(d.keys()) & set("MARCH")
ans = 0
for p, q, r in C(dk, 3):
    ans += d[p] * d[q] * d[r]
else:
    print(ans)

Solution (Python):
import collections
N = int(input())
S = []
for i in range(N):
    st = str(input())
    S.append(st[0])
    


c = collections.Counter(S)

count = []
for i in c.items():
    if i[0] in 'MARCH':
        count.append(i[1])

ans = 0
for i in range(len(count)):
    for j in range(i+1,len(count)):
        for k in range(j+1,len(count)):
            
            ans += count[i]*count[j]*count[k]
            
if len(count) != 0:
    print(ans)
else:
    print(0)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    S = [INPUT() for _ in range(N)]

    inis = [s[0] for s in S if s[0] == 'M' or s[0] == 'A' or s[0] == 'R' or s[0] == 'C' or s[0] == 'H']
    c = Counter(inis)
    ans = 0
    for tpl in list(combinations(c.values(), 3)):
        ans += list(accumulate(tpl, mul))[-1]

    print(ans)


if __name__ == '__main__':
    main()