TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
N=int(input())
S=set()

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

L=len(S)

print(L*(L-1)*(L-2)//6)

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

for i in range(N):
  s=input()
  if s[0] in ['M','A','R','C','H']:
    S.add(s)

L=len(S)

print(L*(L-1)*(L-2)//6)


N=int(input())
chars=['M','A','R','C','H']
dict={}
for c in chars:
  dict[c]=0
  
ans=0
  
for i in range(N):
  s=input()
  if (s[0] in chars):
    dict[s[0]]+=1

L=list(dict.values())
    
for i in range(2**5):
  usedchars=[]
  for j in range(5):
    if i>>j&1==1:
      usedchars.append(L[j])
    
  if len(usedchars)==3:
    ans+=usedchars[0]*usedchars[1]*usedchars[2]

print(ans)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a=int(input())
lis=[input()[0] for i in range(a)]
lis2=[0,0,0,0,0]
dellist=[]
for m in lis:
  if m=="M":
    lis2[0]+=1
  elif m=="A":
    lis2[1]+=1
  elif m=="R":
    lis2[2]+=1
  elif m=="C":
    lis2[3]+=1
  elif m=="H":
    lis2[4]+=1
a=sum(lis2)
print(lis2,a)
def c3(a):
  return a*(a-1)*(a-2)/6
def c2(a):
  return  a*(a-1)/2
ans=c3(a)
for i in lis2:
  ans=ans-c3(i)-c2(i)*(a-i)
print(int(ans))
  

a=int(input())
lis=[input()[0] for i in range(a)]
lis2=[0,0,0,0,0]
dellist=[]
for m in lis:
  if m=="M":
    lis2[0]+=1
  elif m=="A":
    lis2[1]+=1
  elif m=="R":
    lis2[2]+=1
  elif m=="C":
    lis2[3]+=1
  elif m=="H":
    lis2[4]+=1
a=sum(lis2)
def c3(a):
  return a*(a-1)*(a-2)/6
def c2(a):
  return  a*(a-1)/2
ans=c3(a)
for i in lis2:
  ans=ans-c3(i)-c2(i)*(a-i)
print(int(ans))
  

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from itertools import*;print(sum(p*q*r for p,q,r in combinations([list(s[0]for s in open(0).readlines()).count(s)for s in"MARCH"],3)))

import itertools as i,collections as c;print(sum(p*q*r for p,q,r in i.combinations(c.Counter(s[0]*(s[0]in"MARCH")for s in open(0).readlines()[1:]).values(),3)))


from itertools import*;print(sum(p*q*r for p,q,r in list(combinations([len(list(v))for k,v in groupby(sorted(s[0]for s in open(0).readlines()[1:]))],3))))

from itertools import*
n,*a=open(0).read().split()
print(sum(p*q*r for p,q,r in combinations(map([i[0]for i in a].count,"MARCH"),3)))

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
l = [0]*5
for i in range(n):
  if input()[0] == "M":
    l[0] += 1
  elif input()[0] == "A":
    l[1] += 1
  elif input()[0] == "R":
    l[2] += 1
  elif input()[0] == "C":
    l[3] += 1
  elif input()[0] == "H":
    l[4] += 1
ans = 0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      ans += l[i]*l[j]*l[k]
print(ans)
  
  

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


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())
s={"M":0,"A":0,"R":0,"C":0,"H":0}
for i in range(n):
    v=input()
    if v[0] in s:
        s[v[0]]+=1
l=s.values()
sum=0
for a in range(5):
    for b in range(a+1,5):
        for c in range(b+1,5):
            sum+=l[a]*l[b]*l[c]         
print(sum)

n=int(input())
s={"M":0,"A":0,"R":0,"C":0,"H":0}
for i in range(n):
    v=input()
    if v[0] in s:
        s[v[0]]+=1
l=list(s.values())
print(l)
sum=0
for a in range(5):
    for b in range(a+1,5):
        for c in range(b+1,5):
            sum+=l[a]*l[b]*l[c]         
print(sum)


n=int(input())

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


for i in range(n):
    v=input()
    if v[0] in s:
        s[v[0]]+=1
sum=0
for a in s.keys():
    for b in s.keys():
        for c in s.keys():
            if a==b or a==c or b==c:
                continue
            sum+=s[a]*s[b]*s[c]
           
print(sum)

n=int(input())
s={"M":0,"A":0,"R":0,"C":0,"H":0}
for i in range(n):
    v=input()
    if v[0] in s:
        s[v[0]]+=1
l=list(s.values())
ans=0
for a in range(5):
    for b in range(a+1,5):
        for c in range(b+1,5):
            ans+=l[a]*l[b]*l[c]         
print(ans)


Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
# n = int(input())
# arr = []

#     arr += [list(input())]
n = 5
arr = [['Z','H'],['Z','N'],['Z','A'],['Z','O'],['Z','I']]

MARCH = [0] * 5    
    
for j in range(n):
    if arr[j][0] == 'M':
        MARCH[0] += 1
    elif arr[j][0] == 'A':
        MARCH[1] += 1
    elif arr[j][0] == 'R':
        MARCH[2] += 1
    elif arr[j][0] == 'C':
        MARCH[3] += 1
    elif arr[j][0] == 'H':
        MARCH[4] += 1

def C(a,b):
    aa = 1
    bb = 1
    for k in range(a-b+1, a+1):
        aa *= k
    for l in range(1, b+1):
        bb *= l
    return int(aa/bb)
        
ans = C(sum(MARCH), 3)

for m in range(5):
    if MARCH[m] == 2:
        ans -= C(sum(MARCH)-MARCH[m],1)
    elif MARCH[m] >= 3:
        ans -= C(MARCH[m],2) * C(sum(MARCH)-MARCH[m],1)
        ans -= C(MARCH[m],3)

print(ans)
    

n = int(input())
arr = []
for i in range(n):
    arr += [list(input())]

MARCH = [0] * 5    
    
for j in range(n):
    if arr[j][0] == 'M':
        MARCH[0] += 1
    elif arr[j][0] == 'A':
        MARCH[1] += 1
    elif arr[j][0] == 'R':
        MARCH[2] += 1
    elif arr[j][0] == 'C':
        MARCH[3] += 1
    elif arr[j][0] == 'H':
        MARCH[4] += 1

def C(a,b):
    aa = 1
    bb = 1
    for k in range(a-b+1, a+1):
        aa *= k
    for l in range(1, b+1):
        bb *= l
    return int(aa/bb)
        
ans = C(sum(MARCH), 3)

for m in range(5):
    if MARCH[m] == 2:
        ans -= C(sum(MARCH)-MARCH[m],1)
    elif MARCH[m] >= 3:
        ans -= C(MARCH[m],2) * C(sum(MARCH)-MARCH[m],1)
        ans -= C(MARCH[m],3)

print(ans)
    

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import defaultdict
from itertools import combinations

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

c = defaultdict(int)

for i in range(N):
  if S[i][0] in {'M','A','R','C','H'}:
    c[S[i][0]] += 1

if len(c) < 3:
  print(0)
  exit()

if len(c)==3:
  ans=0
  for k in c.keys():
    ans *= c[k]
  print(ans)
  exit()

else:
  ans = 0
  l = len(c)
  keys = list(c.keys())
  for C in combinations(range(l),3):
    tmp = c[keys[C[0]]]*c[keys[C[1]]]*c[keys[C[2]]]
    ans += tmp
  print(ans)

from collections import defaultdict
from itertools import combinations

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

c = defaultdict(int)

for i in range(N):
  if S[i][0] in {'M','A','R','C','H'}:
    c[S[i][0]] += 1

if len(c) < 3:
  print(0)
  exit()

if len(c)==3:
  ans=1
  for k in c.keys():
    ans *= c[k]
  print(ans)
  exit()

else:
  ans = 0
  l = len(c)
  keys = list(c.keys())
  for C in combinations(range(l),3):
    tmp = c[keys[C[0]]]*c[keys[C[1]]]*c[keys[C[2]]]
    ans += tmp
  print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
#60 C - March
import collections
N = int(input())
S = [input() for _ in range(N)]
S = [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']

cnt = collections.Counter(S)
n = len(cnt)

ans = ((n*(n-1)*(n-2))//(3*2))
if ans == 1:
    for i in cnt.values():
        if i>=2:
            ans * i
else:
    for i in cnt.values():
        if i>=2:
            ans += (n- (((n-1)*(n-2)*(n-3))//(3*2)))*(i-1)
print(ans)

#60 C - March
import collections
import itertools
N = int(input())
S = [input() for _ in range(N)]
S = [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']

cnt = collections.Counter(S)

comb = itertools.combinations(cnt.keys(),3)

ans = 0
for a,b,c in comb:
    ans += cnt[a]*cnt[b]*cnt[c]
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
name_count = [0 for _ in range(5)]
for i in s:
    if i[0] == "M":
        name_count[0] += 1
    elif i[0] == "A":
        name_count[1] += 1
    elif i[0] == "R":
        name_count[2] += 1
    elif i[0] == "C":
        name_count[3] += 1
    elif i[0] == "H":
        name_count[4] += 1

result = 0
for i in range(5):
    result += name_count[i]*name_count[(i+1)%5]*name_count[(i+2)%5]
print(result)

from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
name_count = [0 for _ in range(5)]
for i in s:
    if i[0] == "M":
        name_count[0] += 1
    elif i[0] == "A":
        name_count[1] += 1
    elif i[0] == "R":
        name_count[2] += 1
    elif i[0] == "C":
        name_count[3] += 1
    elif i[0] == "H":
        name_count[4] += 1

result = 0
for s in range(3):
    for t in range(s+1, 4):
        for u in range(t+1, 5):
            result += name_count[s]*name_count[t]*name_count[u]
print(result)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import collections
N = int(input())
a = ['']*N
for i in range(N):
    a[i] = list(input())[0]
print(a)
c_list = [0]*5
MARCH = ['M','A','R','C','H']
c_list = [a.count(i) for i in MARCH]
print(c_list)
summation = 0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            summation += c_list[i]*c_list[j]*c_list[k]
print(summation)

import collections
N = int(input())
a = ['']*N
for i in range(N):
    a[i] = list(input())[0]
c_list = [0]*5
MARCH = ['M','A','R','C','H']
c_list = [a.count(i) for i in MARCH]
summation = 0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            summation += c_list[i]*c_list[j]*c_list[k]
print(summation)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
S = []
for i in range(N):
    S.append(input())
march = [0, 0, 0, 0, 0]

for i in range(N):
    if S[i][0] == "M":
        march[0] += 1
    if S[i][0] == "A":
        march[1] += 1
    if S[i][0] == "R":
        march[2] += 1
    if S[i][0] == "C":
        march[3] += 1
    if S[i][0] == "H":
        march[4] += 1
ans = 0
print(march)
for i in range(5):
    for j in range(i+1, 5):
        for k in range(j+1, 5):
            ans += march[i] * march[j] * march[k]
print(ans)


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

for i in range(N):
    if S[i][0] == "M":
        march[0] += 1
    if S[i][0] == "A":
        march[1] += 1
    if S[i][0] == "R":
        march[2] += 1
    if S[i][0] == "C":
        march[3] += 1
    if S[i][0] == "H":
        march[4] += 1
ans = 0
print(march)
for i in range(5):
    for j in range(i+1, 5):
        for k in range(j+1, 5):
            ans += march[i] * march[j] * march[k]
print(ans)


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

for i in range(N):
    if S[i][0] == "M":
        march[0] += 1
    if S[i][0] == "A":
        march[1] += 1
    if S[i][0] == "R":
        march[2] += 1
    if S[i][0] == "C":
        march[3] += 1
    if S[i][0] == "H":
        march[4] += 1
ans = 0
for i in range(5):
    for j in range(i+1, 5):
        for k in range(j+1, 5):
            ans += march[i] * march[j] * march[k]
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from itertools import combinations as c
n=int(input())
s=[input() for _ in range(n)]
m=[m1 for m1 in s if s.startswith('M')]
a=[a1 for a1 in s if s.startswith('A')]
r=[r1 for r1 in s if s.startswith('R')]
c=[c1 for c1 in s if s.startswith('C')]
h=[h1 for h1 in s if s.startswith('H')]
march=[len(m),len(a),len(r),len(c),len(h)]
print(sum(i*j*k for i, j, k in c(march, 3)))

from itertools import combinations as c
n=int(input())
s=[input() for _ in range(n)]
march=[0]*5
for i in range(n):
    if s[i][0]=='M':march[0]+=1
    elif s[i][0]=='A':march[1]+=1
    elif s[i][0]=='R':march[2]+=1
    elif s[i][0]=='C':march[3]+=1
    elif s[i][0]=='H':march[4]+=1
print(sum(i*j*k for i, j, k in c(march, 3)))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())
S = {"M":0,"A":0,"R":0,"C":0,"H":0}
for i in range(N):
    s = input()
    if s[0] in ["M","A","R","C","H"]
        S[s[0]] += 1

print(S["M"] * S["A"] * (S["R"]+S["C"]+S["H"]) + S["M"] * S["R"] * (S["C"] + S["H"]) + S["M"] * S["C"] * S["H"] + S["A"] * S["R"] * (S["C"] + S["H"]) + S["C"] * S["A"] * S["H"] +  S["R"] * S["C"] * S["H"])


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

print(S["M"] * S["A"] * (S["R"] + S["C"] + S["H"])
      + S["M"] * S["R"] * (S["C"] + S["H"])
      + S["M"] * S["C"] * S["H"]
      + S["A"] * S["R"] * (S["C"] + S["H"])
      + S["A"] * S["C"] * S["H"]
      + S["R"] * S["C"] * S["H"])


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
l = ['M','A','R','C','H']
m = []
a = []
r = []
c = []
h = []
for i in range(n):
    s = input()
    if not s[0] in l: continue
    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)
    else:
        h.append(s)

n = sum([len(i) for i in [m,a,r,c,h]])
all = n * (n - 1) * (n - 2) // 6
print(r)
for t in [m,a,r,c,h]:
    i = len(t)
    if i >= 2:
        k = i * (i -1) // 2
        all -= k*(n-2)
    if i >= 3:
        k = i * (i - 1) * (i - 2) // 6
        all -= k
print(all)

n = int(input())
l = ['M','A','R','C','H']
m = []
a = []
r = []
c = []
h = []
for i in range(n):
    s = input()
    if not s[0] in l: continue
    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)
    else:
        h.append(s)

n = sum([len(i) for i in [m,a,r,c,h]])
all = n * (n - 1) * (n - 2) // 6
for t in [m,a,r,c,h]:
    i = len(t)
    if i >= 3:
        k = i * (i - 1) * (i - 2) // 6
        all -= k
    if i >= 2:
        k = i * (i - 1) // 2
        all -= k * (n - i)
print(all)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from itertools import combinations
n=int(input())
s=[input()[0] for _ in range(n)]
a=[]
for i in ['M','A','R','C','H']:
  a+=[s.count(i)]
print(a)
ans=0
for i in combinations(a,3):
  ans+=i[0]*i[1]*i[2]
print(ans)

from itertools import combinations
n=int(input())
s=[input()[0] for _ in range(n)]
a=[]
for i in ['M','A','R','C','H']:
  a+=[s.count(i)]
ans=0
for i in combinations(a,3):
  ans+=i[0]*i[1]*i[2]
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
h,w,d = map(int,input().split(" "))
board = [input().split(" ") for i in range(h)]

q = int(input())
for i in range(q):
    l,r = map(int,input().split(" "))
    n = int((r-l)/d)
    count = 0
    x = []
    y = []
    for k in range(h):
        if str(l) in board[k]:
            x.append(board[k].index(str(l)))
            y.append(k)
    for j in range(n):
        for k in range(h):
            if str(l+(j+1)*d) in board[k]:
                x.append(board[k].index(str(l+(j+1)*d)))
                y.append(k)
        count = count + abs(int(x[j+1])-int(x[j])) + abs(y[j+1]-y[j])
    print(count)

n = int(input())
m=0
a=0
r=0
c=0
h=0
name = [list(str(input().split())) for i in range(n)]
for i in range(n):
    if name[i][2] == "M":
        m = m+1
    elif name[i][2] == "A":
        a = a+1
    elif name[i][2] == "R":
        r = r+1
    elif name[i][2] == "C":
        c = c+1
    elif name[i][2] == "H":
        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)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys
import numpy as np
import itertools

N = int(sys.stdin.readline().strip())
dct = {}
dct["M"] = 0
dct["A"] = 0
dct["R"] = 0
dct["C"] = 0
dct["H"] = 0
char_list = ["M", "A", "R", "C", "H"]

for _ in range(N):
    name = sys.stdin.readline().strip()
    first = name[0]
    dct[first] += 1

count = 0
for a, b, c in list(itertools.combinations(char_list, 3)):
    count += dct[a] * dct[b] * dct[c]
print(count)


import sys
import numpy as np
import itertools

N = int(sys.stdin.readline().strip())
dct = {}
dct["M"] = 0
dct["A"] = 0
dct["R"] = 0
dct["C"] = 0
dct["H"] = 0
char_list = ["M", "A", "R", "C", "H"]

for _ in range(N):
    name = sys.stdin.readline().strip()
    first = name[0]
    if first not in dct:
        continue
    dct[first] += 1

count = 0
for a, b, c in list(itertools.combinations(char_list, 3)):
    count += dct[a] * dct[b] * dct[c]
print(count)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
    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 * R * H;
    res += A * C * H;
     
    res += R * C * H;
     
    print(res)

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 * R * H;
res += A * C * H;
 
res += R * C * H;
 
print(res)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import itertools
N = int(input())
MARCH = [0, 0, 0, 0, 0]
final_ans = 0
for i in range(N):
    a = input()
    if a[0] =='M':
        MARCH[0] += 1
    elif a[0] =='A':
        MARCH[1] += 1
    elif a[0] =='R':
        MARCH[2] += 1
    elif a[0] =='C':
        MARCH[3] += 1
    elif a[0] =='H':
        MARCH[4] += 1

MARCH = list(itertools.combinations(MARCH,3))

for i in ans:
    final_ans += i[0]*i[1]*i[2]
print(final_ans)

import itertools

N = int(input())
S = [0] * N
ans = 0
for i in range(N):
    s = input()
    if s[0] in ['M', 'A', 'R', 'C', 'H']:
        S[i] = s
S = list(set(S))
if 0 in S:
    S.remove(0)
march = [0] * 5
for i in S:
    if i[0] == 'M':
        march[0] += 1
    elif i[0] == 'A':
        march[1] += 1
    elif i[0] == 'R':
        march[2] += 1
    elif i[0] == 'C':
        march[3] += 1
    else:
        march[4] += 1

for i, j, k in list(itertools.combinations([0, 1, 2, 3, 4], 3)):
    ans += march[i] * march[j] * march[k]
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())
l=[0]*5
m='MARCH'
for i in range(n):
  s=input()
  f=s[0]
  for i in range(5):
    if f==m[i]:
      l[i]+=1
      break
x=0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      x+=a[i]*a[j]*a[k]
print(x)

n=int(input())
l=[0]*5
m='MARCH'
for i in range(n):
  s=input()
  f=s[0]
  for i in range(5):
    if f==m[i]:
      l[i]+=1
      break
x=0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      x+=l[i]*l[j]*l[k]
print(x)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())
s=[input() for i in range(n)]
cnt=[0]*5
for t in s:
  if t[0]=='M':
    cnt[0]+=1
  elif t[0]=='A':
    cnt[1]+=1
  elif t[0]=='R':
    cnt[2]+=1
  elif t[0]=='C':
    cnt[3]+=1
  elif t[0]=='H':
    cnt[4]+=1
ans=0
for v in itertools.combinations([0,1,2,3,4],3):
  ans+=cnt[v[0]]*cnt[v[1]]*cnt[v[2]]
print(ans)

import itertools
n=int(input())
s=[input() for i in range(n)]
cnt=[0]*5
for t in s:
  if t[0]=='M':
    cnt[0]+=1
  elif t[0]=='A':
    cnt[1]+=1
  elif t[0]=='R':
    cnt[2]+=1
  elif t[0]=='C':
    cnt[3]+=1
  elif t[0]=='H':
    cnt[4]+=1
ans=0
for v in itertools.combinations([0,1,2,3,4],3):
  ans+=cnt[v[0]]*cnt[v[1]]*cnt[v[2]]
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import numpy as np
from scipy.special import comb

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 = []
for j in range(len(ans)):
    if ans[j] == 0:
        continue
    else:
        cnt.append(ans[j])
l = 0
for k in range(len(cnt)):
    if cnt[k] > 1:
        l += cnt[k] - 1

cnt.sort()
print(cnt)
if len(cnt) <= 2:
    print(0)
elif len(cnt) == 3:
    print(np.prod(cnt))
elif len(cnt) == 4:
    print((cnt[0]*cnt[1]*cnt[2])+(3*cnt[3]))
else:
    print((cnt[0]*cnt[1]*cnt[2])+(3*cnt[3])+(6*cnt[4]))

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)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
s = [list(input())  for i in range(n)]


ans = 0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      p = s[i][0]
      q = s[j][0]
      r = s[k][0]
      if (p=='M'or'A'or'C'or'R'or'H') and (q=='M'or'A'or'C'or'R'or'H') and (r=='M'or'A'or'C'or'R'or'H') and (p!=q) and (q!=r) and (r!=p):
        ans += 1
        
print(ans)

n=int(input())
dict={'M':0,'A':0,'R':0,'C':0,'H':0}
for i in range(n):
  s=input()
  if s[0] in dict:
    dict[s[0]]+=1
data=['M','A','R','C','H']
ans=0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      ans+=dict[data[i]]*dict[data[j]]*dict[data[k]]
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())

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

for i in range(N):
  S = input()
  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)


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)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from collections import Counter
march = "MARCH"
n = int(input())
initial = Counter([input()[0] for _ in range(n)])
ans = []
for i, num in initial.items():
    if i in march:
        ans.append(num)

x = len(ans)
if x < 3:
    print(0)
elif x >= 3:
    y = 0
    for i in range(1, x-1):
        for j in range(i+1, x):
            for k in range(j+1, x+1):
                y += ans[i] * ans[j] * ans[k]
    print(y)




from collections import Counter
march = "MARCH"
n = int(input())
initial = Counter([input()[0] for _ in range(n)])
ans = []
for i, num in initial.items():
    if i in march:
        ans.append(num)

x = len(ans)
if x < 3:
    print(0)
elif x >= 3:
    y = 0
    for i in range(0, x-2):
        for j in range(i+1, x-1):
            for k in range(j+1, x):
                y += ans[i] * ans[j] * ans[k]
    print(y)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys
import itertools

n = int(input())
a = [i.rstrip() for i in sys.stdin.readlines() if i.rstrip()[0] in ['M','A','R','C','H'] ]

print(len(list(itertools.combinations(a, 3))))


import sys
import itertools

n = int(input())
l = {}
for i in sys.stdin.readlines():
    i = i.rstrip()
    if i[0] in ['M','A','R','C','H']:
        l.setdefault(i[0], []).append(i)

s = list(itertools.combinations(l.keys(), 3))
ans = 0
for v in s:
    tmp = 1
    for k in v:
        tmp *= len(l[k])
    ans += tmp
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import numpy as np
N = int(input())
S = [None]*5
for i in range(N):
    S[i] = input()

S_M = [S[i] for i in range(N) if S[i][0] == 'M']
S_A = [S[i] for i in range(N) if S[i][0] == 'A']
S_R = [S[i] for i in range(N) if S[i][0] == 'R']
S_C = [S[i] for i in range(N) if S[i][0] == 'C']
S_H = [S[i] for i in range(N) if S[i][0] == 'H']

souwa = 0
kahi = [0]*5
kahi[0] = len(S_M)
kahi[1] = len(S_A)
kahi[2] = len(S_R)
kahi[3] = len(S_C)
kahi[4] = len(S_H)

kahi_not0 = kahi[kahi != 0]
if len(kahi_not0) <= 2:
    print(0)
else:
    for i in range(len(kahi_not0)-2):
        for j in range(i+1, len(kahi_not0)-1):
            for k in range(j+1, len(kahi_not0)):
                souwa += kahi_not0[i]*kahi_not0[j]*kahi_not0[k]

    if souwa >= 2**32:
        print(souwa/(2**32), end='')
        print(souwa-(souwa/(2**32))*(2**32))
    else:
        print(souwa)

import numpy as np
N = int(input())
S = [None]*5
for i in range(N):
    S[i] = input()

S_M = [S[i] for i in range(N) if S[i][0] == 'M']
S_A = [S[i] for i in range(N) if S[i][0] == 'A']
S_R = [S[i] for i in range(N) if S[i][0] == 'R']
S_C = [S[i] for i in range(N) if S[i][0] == 'C']
S_H = [S[i] for i in range(N) if S[i][0] == 'H']

souwa = 0
kahi = [0]*5
kahi[0] = len(S_M)
kahi[1] = len(S_A)
kahi[2] = len(S_R)
kahi[3] = len(S_C)
kahi[4] = len(S_H)

kahi_not0 = kahi[kahi != 0]
if len(kahi_not0) <= 2:
    print(0)
else:
    for i in range(len(kahi_not0)-2):
        for j in range(i+1, len(kahi_not0)-1):
            for k in range(j+1, len(kahi_not0)):
                souwa += kahi_not0[i]*kahi_not0[j]*kahi_not0[k]

    print(souwa)

import numpy as np
N = int(input())
S = [None]*N
for i in range(N):
    S[i] = input()

S_M = [S[i] for i in range(N) if S[i][0] == 'M']
S_A = [S[i] for i in range(N) if S[i][0] == 'A']
S_R = [S[i] for i in range(N) if S[i][0] == 'R']
S_C = [S[i] for i in range(N) if S[i][0] == 'C']
S_H = [S[i] for i in range(N) if S[i][0] == 'H']

souwa = 0
kahi = [0]*5
kahi[0] = len(S_M)
kahi[1] = len(S_A)
kahi[2] = len(S_R)
kahi[3] = len(S_C)
kahi[4] = len(S_H)

for i in range(len(kahi)-2):
    for j in range(i+1, len(kahi)-1):
        for k in range(j+1, len(kahi)):
            souwa += kahi[i]*kahi[j]*kahi[k]
print(souwa)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N=int(input())
M,A,R,C,H=0,0,0,0,0
for i in range(N):
    s=input()[0]
    if s=='M':
        M+=1
    elif s=='A':
        A+=1
    elif s=='R':
        R+=1
    elif s=='C':
        C+=1
    elif s=='H':
        H+=1

print(M,A,R,C,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)

N=int(input())
M,A,R,C,H=0,0,0,0,0
for i in range(N):
    s=input()[0]
    if s=='M':
        M+=1
    elif s=='A':
        A+=1
    elif s=='R':
        R+=1
    elif s=='C':
        C+=1
    elif s=='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)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import re
from itertools import groupby

def nCr(n, r):
    """
    Calculate the number of combination (nCr = nPr/r!).
    The parameters need to meet the condition of n >= r >= 0.
    It returns 1 if r == 0, which means there is one pattern
    to choice 0 items out of the number of n.
    """

    # 10C7 = 10C3
    r = min(r, n-r)

    # Calculate the numerator.
    numerator = 1
    for i in range(n, n-r, -1):
        numerator *= i

    # Calculate the denominator. Should use math.factorial?
    denominator = 1
    for i in range(r, 1, -1):
        denominator *= i

    return numerator // denominator

pattern = r"^(M|A|R|C|H).*"
checker = re.compile(pattern)

N = int(input())
names = [None]*N
hasMarch = [None]*N
for i in range(N):
    name = input()
    if checker.match(name):
        names[i] = name
        
groups = [n for n in groupby(names, lambda x:x[0] if x is not None else 0)]
n_groups = len(groups) - 1
comb = nCr(n_groups, 3) if n_groups >=3 else 0
print(comb)

import re
from itertools import groupby
from itertools import groupby, combinations
import functools
import operator

pattern = r"^(M|A|R|C|H).*"
checker = re.compile(pattern)

N = int(input())
names = []
for i in range(N):
    name = input()
    if checker.match(name):
        names.append(name)
        
counts = {}
for group, item in groupby(names, lambda x:x[0]):
    counts[group] = counts[group]+(len(list(item))) if group in counts.keys() else (len(list(item)))
# print(counts)
total = 0
for comb in combinations(counts.keys(), 3):
    tmp = []
    for letter in comb:
        tmp.append(counts[letter])
#     print(comb)
    n_comb = functools.reduce(operator.mul, tmp)
    total += n_comb
    
print(total)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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[1] == "A":
        member[1] += 1
    elif a[2] == "R":
        member[2] += 1
    elif a[3] == "C":
        member[3] += 1
    elif a[4] == "H":
        member[4] += 1
 
for i in range(3):
    for j in range(i+1, 4):
        for k in range(i+2, 5):
            ans += member[i]*member[j]*member[k]

print(ans)



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)



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[1] == "A":
        member[1] += 1
    elif a[2] == "R":
        member[2] += 1
    elif a[3] == "C":
        member[3] += 1
    elif a[4] == "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)



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)



N = int(input())
member = [0,0,0,0,0]
ans = 0
for _ in range(N):
    a = list(input())
    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)



Verdicts: Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import itertools

n=int(input())
list1=[]
ss=['M', 'A', 'R', 'C', 'H']

for j in range(n):
  s=input()
  for k in range(5):
    if s[0]==ss[k]:
      list1.append(s[0])

#list1.sort()

list2=list(itertools.combinations(list1, 3))

cnt=0
#for j in range(len(list2)):
#  if len(list2[j])==len(set(list2[j])):
#    cnt+=1

print(cnt)



import itertools

n=int(input())
list1=[]
for j 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':
    list1.append(s[0])

list1.sort()

list2=list(itertools.combinations(list1, 3))

cnt=0
#for j in range(len(list2)):
#  if len(list2[j])==len(set(list2[j])):
#    cnt+=1

print(cnt)



import itertools

n=int(input())
list1=[]
ss=['M', 'A', 'R', 'C', 'H']

for j in range(n):
  s=input()
  for k in range(5):
    if s[0]==ss[k]:
      list1.append(s[0])

#list1.sort()

list2=list(itertools.combinations(list1, 3))

cnt=0
#for j in range(len(list2)):
#  if len(list2[j])==len(set(list2[j])):
#    cnt+=1

print(cnt)



import itertools

n=int(input())
list1=[]
ss=['M', 'A', 'R', 'C', 'H']

for j in range(n):
  s=input()
  for k in range(5):
    if s[0]==ss[k]:
      list1.append(s[0])

#list1.sort()

#list2=list(itertools.combinations(list1, 3))

cnt=0
#for j in range(len(list2)):
#  if len(list2[j])==len(set(list2[j])):
#    cnt+=1

print(cnt)



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
  elif s[0]=='A':
    a+=1
  elif s[0]=='R':
    r+=1      
  elif s[0]=='C':
    c+=1      
  elif s[0]=='H':
    h+=1

#print(m,a,r,c,h)
ans=0
ans+=m*a*r
ans+=m*a*c
ans+=m*a*h
ans+=m*r*c
ans+=m*r*h
ans+=m*c*h
ans+=a*r*c
ans+=a*r*h
ans+=a*c*h
ans+=r*c*h

print(ans)



Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import itertools
from collections import Counter
n = int(input())
s = [input()[0] for _ in range(n)]
cnt = Counter(s)
print(cnt)

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

import sys
import math
n = int(input())
s = [input() for m in range(n)]
march = ['M','A','R','C','H']
ans = []

for i in range(n):
	if s[i][0] in march:
		ans.append(s[i][0])
s_set = set(ans)
sl = len(s_set)
if sl == 0:
	print(0)
	sys.exit()
double_num = len(ans) - len(s_set)
factorial_num = math.factorial(sl) // (math.factorial(sl - 3) * math.factorial(3))
if sl <= 2:
	print(0)
	sys.exit()
elif sl == 3:
	print(factorial_num + 2*double_num)
	sys.exit()
elif sl == 4:
	print(factorial_num + 2*(double_num) -(1*double_num))
	sys.exit()
else:
	print(factorial_num + 2*double_num -(4 *double_num))
	sys.exit()

import itertools
from collections import Counter
n = int(input())
s = [input()[0] for _ in range(n)]
cnt = Counter(s)
#print(cnt)

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

Verdicts: Wrong Answer

Runtime Error

Accepted