ZhenlongDai/ACPR huggingface dataset:
Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections
N = int(input())
S = [input() for i in range(N)]
print(S)
SI = [S[i][0] for i in range(N)]
cnt = collections.Counter(SI)
n = [cnt["M"],cnt["A"],cnt["R"],cnt["C"],cnt["H"]]
ans = 0
for i in range(3):
    for j in range(i+1,5):
        for k in range(j+1,5):
          ans += n[i]*n[j]*n[k]
print(ans)

Failing test case input:
5
CHOKUD@I
RNG
MAKOTO
AOKI
RINGN

Expected output:
7


Actual output:
['CHOKUD@I', 'RNG', 'MAKOTO', 'AOKI', 'RINGN']
7


Fixed submission (verdict: Accepted):
import collections
N = int(input())
S = [input() for i in range(N)]
SI = [S[i][0] for i in range(N)]
cnt = collections.Counter(SI)
n = [cnt["M"],cnt["A"],cnt["R"],cnt["C"],cnt["H"]]
ans = 0
for i in range(3):
    for j in range(i+1,5):
        for k in range(j+1,5):
            ans += n[i]*n[j]*n[k]
print(ans)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

d = {"M":0,"R":0,"A":0,"C":0,"H":0}
S = []
num = 0

for i in range(n):
    S.append(input())


for s in S:
    
    if s[0] in list(d.keys()):
        d[s[0]] += 1



for al1 in list(d.keys()):
    for al2 in list(d.keys()):
        for al3 in list(d.keys()):
            if al1 != al2 and al1 != al3 and al2 != al3:
                print(al1,al2,al3)
                num += d[al1]*d[al2]*d[al3]

print(int(num/6))
        

Failing test case input:
5
EKIHSAM
IOMUR
OCIRA
HABOQN
IANAKOROH

Expected output:
0


Actual output:
M R A
M R C
M R H
M A R
M A C
M A H
M C R
M C A
M C H
M H R
M H A
M H C
R M A
R M C
R M H
R A M
R A C
R A H
R C M
R C A
R C H
R H M
R H A
R H C
A M R
A M C
A M H
A R M
A R C
A R H
A C M
A C R
A C H
A H M
A H R
A H C
C M R
C M A
C M H
C R M
C R A
C R H
C A M
C A R
C A H
C H M
C H R
C H A
H M R
H M A
H M C
H R M
H R A
H R C
H A M
H A R
H A C
H C M
H C R
H C A
0


Fixed submission (verdict: Accepted):
n = int(input())

d = {"M":0,"R":0,"A":0,"C":0,"H":0}
S = []
num = 0

for i in range(n):
    S.append(input())


for s in S:
    
    if s[0] in list(d.keys()):
        d[s[0]] += 1



for al1 in list(d.keys()):
    for al2 in list(d.keys()):
        for al3 in list(d.keys()):
            if al1 != al2 and al1 != al3 and al2 != al3:
                num += d[al1]*d[al2]*d[al3]

print(int(num/6))

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N= int(input())
S = ['M','A','R','C','H']
C = [0]*5
for _ in range(N):
  X = (input())[0]
  if X in S:
    C[S.index(X)] += 1
print(C)

from itertools import permutations, combinations,combinations_with_replacement,product
L = list(combinations(range(5), 3))   
ans = 0
for i in L:
  ans += C[i[0]]*C[i[1]]*C[i[2]]
print(ans)

Failing test case input:
5
E@HKUOCI
GNR
PKOATM
NIAK
RNNFI

Expected output:
0


Actual output:
[0, 0, 1, 0, 0]
0


Fixed submission (verdict: Accepted):
N= int(input())
S = ['M','A','R','C','H']
C = [0]*5
for _ in range(N):
  X = (input())[0]
  if X in S:
    C[S.index(X)] += 1
from itertools import permutations, combinations,combinations_with_replacement,product
L = list(combinations(range(5), 3))   
ans = 0
for i in L:
  ans += C[i[0]]*C[i[1]]*C[i[2]]
print(ans)
Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S ="MARCH"
S2 = [0]*len(S)
n=0

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


Failing test case input:
5
MASHILE
IOUMR
ACIOR
HABOQO
JAN@LOROH

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
S ="MARCH"
S2 = [0]*len(S)
n=0

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

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
5
MASHIKE
IOMUR
ARIBO
HABORN
IANAKOROH

Expected output:
1


Actual output:
6


Fixed submission (verdict: Accepted):
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)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from itertools import combinations
N=int(input())
L = [str(input()) for i in range(N)]
count_M=0
count_A=0
count_R=0
count_C=0
count_H=0
for i in L:
    if i[0]=='M':count_M+=1
    elif i[0]=='A':count_A+=1
    elif i[0]=='R':count_R+=1
    elif i[0]=='C':count_C+=1
    elif i[0]=='H':count_H+=1
name_list=[count_M,count_A,count_R,count_C,count_H]
sum_list=list(combinations(name_list,3))
s_list=[i[0]*i[1]*i[2] for i in sum_list]
sum(s_list)

Failing test case input:
5
I@DUKOGE
HNR
MKAOTP
IKNA
RINGN

Expected output:
1


Actual output:

Fixed submission (verdict: Accepted):
from itertools import combinations
N=int(input())
L = [str(input()) for i in range(N)]
count_M=0
count_A=0
count_R=0
count_C=0
count_H=0
for i in L:
    if i[0]=='M':count_M+=1
    elif i[0]=='A':count_A+=1
    elif i[0]=='R':count_R+=1
    elif i[0]=='C':count_C+=1
    elif i[0]=='H':count_H+=1
name_list=[count_M,count_A,count_R,count_C,count_H]
sum_list=list(combinations(name_list,3))
s_list=[i[0]*i[1]*i[2] for i in sum_list]
print(sum(s_list))
Problem: p03425
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import Counter
import math

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

n = int(input())
s = [input()[:1] for _ in range(n)]
s = Counter([i for i in s if i in ['M', 'A', 'R', 'C', 'H']])

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

ans = combinations_count(len(s), 3)
j = combinations_count((len(s)-1), 2)
for i in s.values():
    ans += (i-1)*j
print(ans)

Failing test case input:
5
CHOKUD@I
RNG
MAKOTO
AOKI
RINGO

Expected output:
7


Actual output:
30


Fixed submission (verdict: Accepted):
from collections import Counter
import itertools

n = int(input())
s = [input()[:1] for _ in range(n)]
s = Counter([i for i in s if i in ['M', 'A', 'R', 'C', 'H']])

li = list(itertools.combinations(['M', 'A', 'R', 'C', 'H'], 3))

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

ans = 0
for i, j, k in li:
    ans += s[i]*s[j]*s[k]
print(ans)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
ans = [0]*5
x = 1

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

if ans.count(0) == 5:
    print(0)

else:
    for i in ans:
        if i != 0:
            x *= i
    print(x)


Failing test case input:
5
MASIHLE
IOTMR
ACIOR
QACOHO
JAN@LOROH

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
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)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections
import itertools

N = int(input())
s = [input()[0] for _ in range(N)]
c = collections.Counter(s)



l = list(itertools.combinations(c,3))



ans = sum([c[i[0]] * c[i[1]] * c[i[2]] for i in l])

print(ans)

Failing test case input:
5
MASIHLE
IOTMR
ACIOR
RACOHO
JAN@LOROH

Expected output:
1


Actual output:
10


Fixed submission (verdict: Accepted):
import collections
import itertools

N = int(input())
ss = [input() for _ in range(N)]
s = [i[0] for i in ss if i[0] in ["M", "A", "R", "C", "H"]]
c = collections.Counter(s)



l = list(itertools.combinations(c,3))



ans = sum([c[i[0]] * c[i[1]] * c[i[2]] for i in l])

print(ans)
Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
S=list(input().split())
m,a,r,c,h = 0,0,0,0,0
for s in S:
  if 'M' == s[0]:
    m+=1
  elif 'A' == s[0]:
    a+=1
  elif 'R' == s[0]:
    r+=1
  elif 'C' == s[0]:
    c+=1
  elif 'H' == s[0]:
    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)

Failing test case input:
5
I@DUKOGE
GNR
MAKOTP
AOKI
RINGN

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N=int(input())
S=[input() for i in range(N)]
m,a,r,c,h = 0,0,0,0,0
for s in S:
  if 'M' == s[0]:
    m+=1
  elif 'A' == s[0]:
    a+=1
  elif 'R' == s[0]:
    r+=1
  elif 'C' == s[0]:
    c+=1
  elif 'H' == s[0]:
    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)

Problem: p03425
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
S=[input() for _ in range(N)]

cnt=[]
ans=0
for i in range(N):
    if S[i][0]=='M':
        cnt.append('M')
    elif S[i][0]=='A':
        cnt.append('A')
    elif S[i][0]=='R':
        cnt.append('R')
    elif S[i][0]=='C':
        cnt.append('C')
    elif S[i][0]=='H':
        cnt.append('H')
        
import math
import itertools
c_list = list(itertools.combinations(cnt, 3))

for v in itertools.combinations(cnt, 3):
    print(set(v))
    if len(set(v))==3:
        ans+=1

print(ans)

Failing test case input:
5
MASIHLE
IOTMR
ACIOR
RACOHO
JAN@LOROH

Expected output:
1


Actual output:
{'R', 'A', 'M'}
1


Fixed submission (verdict: Accepted):
N=int(input())
S=[input() for _ in range(N)]
cnt=[0]*N
cnt2=[]
flag=0

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

for i in range(N):
    if cnt[i]!=0:
        cnt2.append(cnt[i])
        
import math
import itertools
ans=0

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

print(ans)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
5
IGDUKO@E
RNH
MTAOKP
AINK
RINFN

Expected output:
2


Actual output:
1 1 2 0 0
2


Fixed submission (verdict: Accepted):
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)
Problem: p03425
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
cnt = [0]*5
for i 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
for i in range(5):
    if cnt[i] == 0:
        cnt[i] = 1
print(cnt[0]*cnt[1]*cnt[2]*cnt[3]*cnt[4])

Failing test case input:
5
MASHIKE
RUMOI
AOICR
HABOQN
IAN@LOROH

Expected output:
4


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
cnt = [0]*5
for i 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
res = 0
for i in range(4):
    for j in range(i+1,5):
        for k in range(j+1,5):
            res += cnt[i]*cnt[j]*cnt[k]
print(res)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
from itertools import combinations

n = int(input())
l = [input()[0] for _ in range(n)]
lc = Counter(l)
print(lc)

con = []
for c in "MARCH":
    if c in lc:
        con.append(lc[c])
ans = 0
for a, b, c in combinations(con, 3):
    ans += a * b * c
print(ans)


Failing test case input:
5
I@DUKOGD
RNG
MAKOTP
AOKI
RINGN

Expected output:
2


Actual output:
Counter({'R': 2, 'I': 1, 'M': 1, 'A': 1})
2


Fixed submission (verdict: Accepted):
from collections import Counter
from itertools import combinations

n = int(input())
l = [input()[0] for _ in range(n)]
lc = Counter(l)

con = []
for c in "MARCH":
    if c in lc:
        con.append(lc[c])
ans = 0
for a, b, c in combinations(con, 3):
    ans += a * b * c
print(ans)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
m=[0,0,0,0,0]
for i in range(n):
  s=input()
  if s[0]=="M":
    m[0]+=1
  elif s[0]=="A":
    m[1]+=1
  elif s[0]=="R":
    m[2]+=1
  elif s[0]=="C":
    m[3]+=1
  elif s[0]=="H":
    m[4]+=1
ans=0
for i in range(3):
  for j in range(i,4):
    for k in range(j,5):
      ans+=m[i]*m[j]*m[k]
print(ans)

Failing test case input:
5
I@DUKOGE
GNR
MKAOTP
AOKI
RINGN

Expected output:
1


Actual output:
10


Fixed submission (verdict: Accepted):
n=int(input())
m=[0,0,0,0,0]
for i in range(n):
  s=input()
  if s[0]=="M":
    m[0]+=1
  if s[0]=="A":
    m[1]+=1
  if s[0]=="R":
    m[2]+=1
  if s[0]=="C":
    m[3]+=1
  if s[0]=="H":
    m[4]+=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)
Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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+1)%5]
print(result)

Failing test case input:
5
MASHILE
IOUMR
ACIOR
HACOQO
JAN@LOROH

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
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)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

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

res = 0

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

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

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

res += R * C * H;

print(res)

Failing test case input:
5
MASHILE
RMUOI
ACIOR
HABOQO
JAN@LOROH

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
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)
Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools
n = int(input())
sl = []

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

lst = []
for com in itertools.combinations(dic.keys(),3):
    lst.append(com)
print(lst)

ans = 0
for v in lst:
    ans += dic[v[0]] * dic[v[1]] * dic[v[2]]
print(ans)

Failing test case input:
4
ZZ
ZYZ
X
ZYZZZZZZZZ

Expected output:
0


Actual output:
[('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')]
0


Fixed submission (verdict: Accepted):
import itertools
n = int(input())
sl = []

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

lst = []
for com in itertools.combinations(dic.keys(),3):
    lst.append(com)

ans = 0
for v in lst:
    ans += dic[v[0]] * dic[v[1]] * dic[v[2]]
print(ans)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)


Failing test case input:
4
YW
Z[Z
X
YXZZZZZZZZ

Expected output:
0


Actual output:
[0, 0, 0, 0, 0]
0


Fixed submission (verdict: Accepted):
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)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from math import factorial

def main():
    N = int(input())
    S = tuple(input() for _ in [0] * N)

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

    lst = [i for i in name.values() if i]
    n = len(lst)
    if n < 3:
        print(0)
        return

    x = factorial(n) 
    for l in lst:
        if l > 1:
            x = (x * l) - (n - 3)
    print(x)

main()


Failing test case input:
5
I@DUKOGE
HNR
MKAOTP
IKNA
RINGN

Expected output:
1


Actual output:
6


Fixed submission (verdict: Accepted):
from itertools import combinations

def main():
    N = int(input())
    S = tuple(input() for _ in [0] * N)

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

    lst = [i for i in name.values() if i]
    n = len(lst)
    if n < 3:
        print(0)
        return

    i = 0
    for a, b, c in combinations(name.keys(), 3):
        if all((name[a], name[b], name[c])):
            i += name[a] * name[b] * name[c]

    print(i)

main()
Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
5
MASHIKE
IOMUR
ARIBO
HABORN
IANAKOROH

Expected output:
1


Actual output:
['M', 'I', 'A', 'H', 'I']
[1, 1, 0, 0, 1]
1


Fixed submission (verdict: Accepted):
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)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools

n = int(input())
M=0
A=0
R=0
C=0
H=0
cnt=0
for _ in range(n):
    newstr = str(input())
    if newstr[0] == "M":
        M+=1
    elif  newstr[0] == "A":
        A+=1
    elif  newstr[0] == "R":
        R+=1
    elif  newstr[0] == "C":
        C+=1
    elif  newstr[0] == "H":
        H+=1
lis = [M,A,R,C,H]

lis2 = [_ for _ in lis if _ != 0]

if len(lis2) < 3:
    print(0)
else:
    for i in itertools.combinations(lis2, r=3):
        cnt += i[0] * i[1] * i[2]
print(cnt)

Failing test case input:
5
EKIHSAM
IOMUR
ARIBO
HABORN
IANAKOROH

Expected output:
0


Actual output:
0
0


Fixed submission (verdict: Accepted):
import itertools

n = int(input())
M=0
A=0
R=0
C=0
H=0
cnt=0
for _ in range(n):
    newstr = str(input())
    if newstr[0] == "M":
        M+=1
    elif  newstr[0] == "A":
        A+=1
    elif  newstr[0] == "R":
        R+=1
    elif  newstr[0] == "C":
        C+=1
    elif  newstr[0] == "H":
        H+=1
lis = [M,A,R,C,H]

lis2 = [_ for _ in lis if _ != 0]

if len(lis2) < 3:
    print(0)
    exit()
else:
    for i in itertools.combinations(lis2, r=3):
        cnt += i[0] * i[1] * i[2]
print(cnt)
Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
cntM, cntA, cntR, cntC, cntH = 0, 0, 0, 0, 0
for i in range(N):
    s = input()
    if s[0] == "M":
        cntM += 1
    elif s[0] == "A":
        cntA += 1
    elif s[0] == "R":
        cntR += 1
    elif s[0] == "C":
        cntC += 1
    elif s[0] == "H":
        cntH += 1
Names = [cntM,cntA,cntR,cntC,cntH]
ans = 0
for i in range(3):
    for j in range(i+1,i+3):
        for k in range(j+1,j+3):
            if k <= 4:
                ans += Names[i]*Names[j]*Names[k]
print(ans)

Failing test case input:
5
MASIHLE
IOTMR
ACIOR
QACOHO
HOROL@NAJ

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
cntM, cntA, cntR, cntC, cntH = 0, 0, 0, 0, 0
for i in range(N):
    s = input()
    if s[0] == "M":
        cntM += 1
    elif s[0] == "A":
        cntA += 1
    elif s[0] == "R":
        cntR += 1
    elif s[0] == "C":
        cntC += 1
    elif s[0] == "H":
        cntH += 1
Names = [cntM,cntA,cntR,cntC,cntH]
ans = 0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            if k <= 4:
                ans += Names[i]*Names[j]*Names[k]
print(ans)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())

l=[]
for i in range(n):
    l+=[input()[0]]

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

from itertools import combinations
ans=0
for x,y,z in combinations(march, 3):
    ans+=x*y*z

print(ans)



Failing test case input:
4
ZY
ZZZ
W
YYZZZZZ[ZZ

Expected output:
0


Actual output:
[0, 0, 0, 0, 0]
0


Fixed submission (verdict: Accepted):
n=int(input())

l=[]
for i in range(n):
    l+=[input()[0]]

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

from itertools import combinations
ans=0
for x,y,z in combinations(march, 3):
    ans+=x*y*z

print(ans)
Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
sd = {}
hl = ["M","A","R","C","H"]
for i in range(n):
    s = input()
    head = s[0]
    
    if not head in hl:
        continue
        
    if head in sd:
        sd[head] += 1
    else:
        sd[head] = 1
        
values = list(sd.values())

length = len(values)
counts = 0
if length < 3:
    print(0)
else:
    for i in range(length-2):
        for j in range(i+1,length-1):
            for k in range(j+1,length):

                counts += values[i]*values[j]*values[k]

print(counts)

Failing test case input:
4
ZY
ZYZ
Y
ZYZZZZZZZZ

Expected output:
0


Actual output:
0
0


Fixed submission (verdict: Accepted):
n = int(input())
sd = {}
hl = ["M","A","R","C","H"]
for i in range(n):
    s = input()
    head = s[0]
    
    if not head in hl:
        continue
        
    if head in sd:
        sd[head] += 1
    else:
        sd[head] = 1
        
values = list(sd.values())

length = len(values)
counts = 0
if length < 3:
    print(0)
else:
    for i in range(length-2):
        for j in range(i+1,length-1):
            for k in range(j+1,length):

                counts += values[i]*values[j]*values[k]

    print(counts)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)



Failing test case input:
5
MASHIKE
RUMOI
AOICR
HABOQN
IAN@LOROH

Expected output:
4


Actual output:
0


Fixed submission (verdict: Accepted):
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)
Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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))
  

Failing test case input:
4
ZY
[YZ
Y
ZYZZZZZZZZ

Expected output:
0


Actual output:
[0, 0, 0, 0, 0] 0
0


Fixed submission (verdict: Accepted):
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))

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools 
n = int(input())
s = [input() for _ in range(n)]

march = [0]*5
ans = 0
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(march)

for j in itertools.combinations(march,3):
    comb_multi = 1
    for k in range(3):
      comb_multi *= j[k]
    ans += comb_multi
print(ans)

Failing test case input:
4
YX
ZZZ
X
YXZZZZZ[ZZ

Expected output:
0


Actual output:
[0, 0, 0, 0, 0]
0


Fixed submission (verdict: Accepted):
import itertools 
n = int(input())
s = [input() for _ in range(n)]

march = [0]*5
ans = 0
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

for j in itertools.combinations(march,3):
    comb_multi = 1
    for k in range(3):
      comb_multi *= j[k]
    ans += comb_multi
print(ans)

Problem: p03425
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
march="MARCH"
c=[0 for _ in range(5)]
for i in range(n):
    s=str(input())
    for j in range(5):
        if s[0]==march[j]:
            c[j]+=1

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


Failing test case input:
5
MASIHLE
IOTMR
ACIOR
RACOHO
JAN@LOROH

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n=int(input())
march="MARCH"
c=[0 for _ in range(5)]
for i in range(n):
    s=str(input())
    for j in range(5):
        if s[0]==march[j]:
            c[j]+=1

ans=0
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            ans+=c[i]*c[j]*c[k]
print(ans)
Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
s=[]
for i in range(N):
  S=input()
  s.append(S)
m=0
a=0
r=0
c=0
h=0
for i in range(N):
  if s[i][0]=="M":
    m+=1
  if s[i][0]=="A":
    a+=1
  if s[i][0]=="R":
    r+=1
  if s[i][0]=="C":
    c+=1
  if s[i][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)

Failing test case input:
5
IGDUKO@E
HNR
MTAOKP
AINK
RINGN

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
N=int(input())
s=[]
for i in range(N):
  S=input()
  s.append(S)
m=0
a=0
r=0
c=0
h=0
for i in range(N):
  if s[i][0]=="M":
    m+=1
  if s[i][0]=="A":
    a+=1
  if s[i][0]=="R":
    r+=1
  if s[i][0]=="C":
    c+=1
  if s[i][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)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from itertools import combinations
n, *S = open(0).read().split()
n = int(n)
march = []
for c in 'MARCH':
    march.append(len([s for s in S if s[0] == c]))
print(march)
ans = 0
for a, b, c in combinations(march, 3):
    if a*b*c != 0:
        print(a,b,c)
    ans += a*b*c
print(ans)

Failing test case input:
5
MASHIKE
IOMUR
ARIBO
HABORO
HOROKANAI

Expected output:
2


Actual output:
[1, 1, 0, 0, 2]
1 1 2
2


Fixed submission (verdict: Accepted):
from itertools import combinations
n, *S = open(0).read().split()
n = int(n)
march = []
for c in 'MARCH':
    march.append(len([s for s in S if s[0] == c]))
ans = 0
for a, b, c in combinations(march, 3):
    ans += a*b*c
print(ans)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import itertools
def myAnswer(N:int,S:list) -> int:
   ans = 0
   dic = {}
   for s in S:
      if(s[0] in dic.keys()):
         dic[s[0]] += 1
      else:
         dic[s[0]] = 1
   for c in itertools.combinations(dic.values(),3):
      ans += c[0]*c[1]*c[2]
      
   return ans

def modelAnswer():
   return
def main():
   N = int(input())
   S = [input() for _ in range(N)]
   print(myAnswer(N,S[:]))
if __name__ == '__main__':
   main()

Failing test case input:
4
WY
Z[Z
Y
YXZZZZZZZZ

Expected output:
0


Actual output:
2


Fixed submission (verdict: Accepted):
import itertools
def myAnswer(N:int,S:list) -> int:
   ans = 0
   dic = {"M":0,"A":0,"R":0,"C":0,"H":0}
   for s in S:
      if(s[0] in dic.keys()):
         dic[s[0]] += 1
   for c in itertools.combinations(dic.values(),3):
      ans += c[0]*c[1]*c[2]
   return ans

def modelAnswer():
   return
def main():
   N = int(input())
   S = [input() for _ in range(N)]
   print(myAnswer(N,S[:]))
if __name__ == '__main__':
   main()
Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
num = [0,0,0,0,0]
for i in range(N):
    name = list(input())
    if name[0] == "M":
        num[0] = num[0]+1
    elif name[0] == "A":
        num[1] = num[1]+1
    elif name[0] == "R":
        num[2] = num[2]+1
    elif name[0] == "C":
        num[3] = num[3]+1
    elif name[0] == "H":
        num[4] = num[4]+1

for n in range(len(num)):
    if num[n] == 0:
        num[n] = 1
out = num[0] * num[1] *num[2] * num[3] * num[4]
print(out)

Failing test case input:
5
EKIHSAM
IOMUR
OCIRA
HABOQN
IAN@KOROH

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
import itertools
N = int(input())
out = 0
num = [0, 0, 0, 0, 0]
for i in range(N):
    name = list(input())
    if name[0] == "M":
        num[0] = num[0] + 1
    elif name[0] == "A":
        num[1] = num[1] + 1
    elif name[0] == "R":
        num[2] = num[2] + 1
    elif name[0] == "C":
        num[3] = num[3] + 1
    elif name[0] == "H":
        num[4] = num[4] + 1
b = 0
e = ()
for n in range(5):
    if num[n] == 0:
        b +=1
    else:
        e += (n,)
if  b >= 3:
    print(0)
else:
    combi = list(itertools.combinations(e,3))
    for c in combi:
        out += num[c[0]]*num[c[1]]*num[c[2]]
    print(out)

Problem: p03425
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = []
for _ in range(n):
    s.append(input())

march=[0]*5
string="MARCH"

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

if march.count(0)>=3:
    print(0)
    exit()

while march.count(0):
    march.remove(0)

ans=1
for i_0 in range(len(march)):
    for i_1 in range(i_0+1,len(march)):
        for i_2 in range(i_1+1,len(march)):
            ans =  march[i_0]*march[i_1]*march[i_2]
print(ans)


Failing test case input:
5
CHOKUDAI
RNG
MAKOTO
AOKI
RINGO

Expected output:
7

Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
s = []
for _ in range(n):
    s.append(input())

march=[0]*5
string="MARCH"

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

if march.count(0)>=3:
    print(0)
    exit()

while march.count(0):
    march.remove(0)

ans=0
for i_0 in range(len(march)):
    for i_1 in range(i_0+1,len(march)):
        for i_2 in range(i_1+1,len(march)):
            ans = ans + march[i_0]*march[i_1]*march[i_2]
print(ans)
Problem: p03425
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import Counter
import math

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

n = int(input())
s = [input()[:1] for _ in range(n)]
s = Counter([i for i in s if i in ['M', 'A', 'R', 'C', 'H']])

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

ans = combinations_count(len(s), 3)
j = combinations_count((len(s)-1), len(s)-3)
for i in s.values():
    ans += (i-1)*j
print(ans)

Failing test case input:
5
I@DUKOGE
HNR
MTAOKP
KINA
RINGN

Expected output:
1


Actual output:
6


Fixed submission (verdict: Accepted):
from collections import Counter
import itertools

n = int(input())
s = [input()[:1] for _ in range(n)]
s = Counter([i for i in s if i in ['M', 'A', 'R', 'C', 'H']])

li = list(itertools.combinations(['M', 'A', 'R', 'C', 'H'], 3))

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

ans = 0
for i, j, k in li:
    ans += s[i]*s[j]*s[k]
print(ans)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
al=list('MARCH')
d=[0]*5
for i in range(n):
    s=list(input())
    if s[0] in al:
        d[al.index(s[0])]+=1
op=[[0],[1]]
for i in range(4):
    tmp=[]
    for j in op:
        j.append(0)
        tmp.append(j)
        j.pop(-1)
        j.append(1)
        tmp.append(j)
    op=tmp
k=[]
for i in op:
    if sum(i)==3:
        k.append(i)
ans=0
for i in k:
    t=1
    for j in range(5):
        if i[j]==1:
            t*=d[j]
    ans+=t
print(ans)
            

Failing test case input:
5
MASHIKE
IOMUR
ARIBO
HABORN
IANAKOROH

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n=int(input())
al=list('MARCH')
d=[0]*5
for i in range(n):
    s=list(input())
    if s[0] in al:
        d[al.index(s[0])]+=1
op=['0','1']
for i in range(4):
    tmp=[]
    for j in op:
        tmp.append(j+'0')
        tmp.append(j+'1')
    op=tmp
k=[]
for i in op:
    g=list(i)
    c=0
    for j in g:
        if j=='1':
            c+=1
    if c==3:
        k.append(i)
ans=0
for i in k:
    t=1
    for j in range(5):
        if i[j]=='1':
            t*=d[j]
    ans+=t
print(ans)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
import itertools

n = int(input())

s = [str(input()) for _ in range(n)]
initial = [''] * n

for i in range(n):
    initial[i] = s[i][0]

reg = Counter(initial)
ele = []

for i, j in reg.items():
    ele.append(i)
ans = 0
for A in itertools.combinations(ele, 3):
    
    cnt = 1
    for s in A:
        cnt *= reg[s]
    ans += cnt

print(ans)

Failing test case input:
5
EKIHSAM
IOMUR
OCIRA
HABOQN
IANAKOROH

Expected output:
0


Actual output:
7


Fixed submission (verdict: Accepted):
from collections import Counter
import itertools

n = int(input())

s = [str(input()) for _ in range(n)]
initial = []
d = ['M', 'A', 'R', 'C', 'H']

for i in range(n):
    if s[i][0] in d:
        initial.append(s[i][0])

reg = Counter(initial)
ele = []

for i, j in reg.items():
    ele.append(i)
ans = 0
for A in itertools.combinations(ele, 3):
    
    cnt = 1
    for s in A:
        cnt *= reg[s]
    ans += cnt

print(ans)
Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
5
MASHILE
RMUOI
ROICA
HABOQN
JAN@LOROH

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
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)

Problem: p03425
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import itertools
import collections

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

    array = ['M','A','R','C','H']
    S_after = []
    for s in S:
        if s in array:
            S_after.append(s)
    if len(S_after) < 3:
        print(0)
    combs = itertools.combinations(set(S_after), 3)
    coll = collections.Counter(S_after)

    ans = 0
    for comb in combs:
        if comb[0] != comb[1] != comb[2]:
            ans += coll[comb[0]]*coll[comb[1]]*coll[comb[2]]
    print(ans)


if __name__ == '__main__':
    main()


Failing test case input:
4
ZY
YZZ
Y
ZZZZZZZZZZ

Expected output:
0


Actual output:
0
0


Fixed submission (verdict: Accepted):
import itertools
import collections

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

    array = ['M','A','R','C','H']
    S_after = []
    for s in S:
        if s in array:
            S_after.append(s)
    if len(S_after) < 3:
        print(0)
        return
    S_after_set = set(S_after)
    combs = itertools.combinations(S_after_set, 3)
    coll = collections.Counter(S_after)

    ans = 0
    for comb in combs:
        if comb[0] != comb[1] != comb[2]:
            ans += coll[comb[0]]*coll[comb[1]]*coll[comb[2]]
    print(ans)


if __name__ == '__main__':
    main()
Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from itertools import combinations
n, *S = open(0).read().split()
n = int(n)
march = []
for c in 'MARCH':
    march.append(len([s for s in S if s[0] == c]))
print(march)
ans = 0
for a, b, c in combinations(march, 3):
    ans += a*b*c
print(ans)

Failing test case input:
4
ZY
ZYZ
Y
ZZZZZZZZZZ

Expected output:
0


Actual output:
[0, 0, 0, 0, 0]
0


Fixed submission (verdict: Accepted):
from itertools import combinations
n, *S = open(0).read().split()
n = int(n)
march = []
for c in 'MARCH':
    march.append(len([s for s in S if s[0] == c]))
ans = 0
for a, b, c in combinations(march, 3):
    ans += a*b*c
print(ans)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)


Failing test case input:
5
EKIHSAM
IOMUR
ARIBO
HABORN
IANAKOROH

Expected output:
0


Actual output:
[0, 1, 0, 0, 1]
0


Fixed submission (verdict: Accepted):
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)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
m,a,r,c,h=0,0,0,0,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
x=[m,a,r,c,h]
cnt=x.count(0)
for i in range(cnt):
    x.remove(0)

l=len(x)
if l<3:
    print(0)
elif l==3:
    print(x[0]*x[1]*x[2])
elif l==4:
    print(4)
else:
    print(5)


Failing test case input:
5
CHOKUD@I
RNG
MAKOTO
AOKI
RINGN

Expected output:
7


Actual output:
4


Fixed submission (verdict: Accepted):
n=int(input())
m,a,r,c,h=0,0,0,0,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
x=[m,a,r,c,h]
cnt=x.count(0)
for i in range(cnt):
    x.remove(0)

l=len(x)
if l<3:
    print(0)
elif l==3:
    print(x[0]*x[1]*x[2])
elif l==4:
    a,b,c,d=x[0],x[1],x[2],x[3]
    print(a*b*c+a*b*d+a*c*d+b*c*d)
else:
    a,b,c,d,e=x[0],x[1],x[2],x[3],x[4]
    print(a*b*c+a*b*d+a*c*d+b*c*d\
         +e*a*b+e*a*c+e*a*d+e*b*c+e*b*d\
         +e*c*d)
Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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['r'], 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)

Failing test case input:
5
MASHIKE
RUMOI
OBIRA
OROBAH
HOROKANAI

Expected output:
1


Actual output:
4


Fixed submission (verdict: Accepted):
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)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
from math import factorial
N = int(input())
S = [input()[0:1:] for i in range(N)]

march = ["M","A","R","C","H"]
list = []
c = Counter(S)
for k,v in c.items():
    if k in march:
        list.append(v)

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

print(ans)


Failing test case input:
5
CHOKUD@I
RNG
MAKOTO
AOKI
RINGO

Expected output:
7


Actual output:
2 0 1 2
4 0 1 3
5 0 2 3
7 1 2 3
7


Fixed submission (verdict: Accepted):
from collections import Counter
from math import factorial
N = int(input())
S = [input()[0:1:] for i in range(N)]

march = ["M","A","R","C","H"]
list = []
c = Counter(S)
for k,v in c.items():
    if k in march:
        list.append(v)

ans = 0
if len(list) >= 3:
    for i in range(len(list)):
        for j in range(len(list)-1):
            for k in range(len(list)-2):
                if (i != j+1) and (j+1 != k+2) and (k+2 != i) and (i<j+1) and (j<k+1):
                    ans += list[i] * list[j+1] * list[k+2]

print(ans)
Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
data = [0 for i in range(5)]
for i in range(n):
    k = input()
    if k[0] == 'M':
        data[0] += 1
    elif k[0] == 'A':
        data[1] += 1
    elif k[0] == 'R':
        data[2] += 1
    elif k[0] == 'C':
        data[3] += 1
    elif k[0] == 'H':
        data[4] += 1
total = 0
print(data)
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            total += data[i] * data[j] * data[k]
print(total)


Failing test case input:
5
I@DUKOGE
HNR
MTAOKP
AINK
RINGN

Expected output:
4


Actual output:
[1, 1, 1, 0, 1]
4


Fixed submission (verdict: Accepted):
n = int(input())
data = [0 for i in range(5)]
for i in range(n):
    k = input()
    if k[0] == 'M':
        data[0] += 1
    elif k[0] == 'A':
        data[1] += 1
    elif k[0] == 'R':
        data[2] += 1
    elif k[0] == 'C':
        data[3] += 1
    elif k[0] == 'H':
        data[4] += 1
total = 0
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            total += data[i] * data[j] * data[k]
print(total)

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from itertools import combinations
import collections

N = int(input()) 

A = []
for i in range(N):
    A.append(input()[0])

AA = set(A)
C = collections.Counter(A)
print(sum(C[a]*C[b]*C[c] for a, b, c in combinations(AA, 3)))

Failing test case input:
5
MASHIKE
IOMUR
OBIRA
OROBAH
HOROKANAI

Expected output:
0


Actual output:
7


Fixed submission (verdict: Accepted):
from itertools import combinations
import collections

N = int(input()) 

A = []
for i in range(N):
    A.append(input()[0])

C = collections.Counter(A)
print(sum(C[a]*C[b]*C[c] for a, b, c in combinations("MARCH", 3)))

Problem: p03425
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)



Failing test case input:
5
IGDUKO@E
HNR
MTAOKP
AINK
RINGN

Expected output:
4


Actual output:
0


Fixed submission (verdict: Accepted):
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)