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())
names_dic = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}
FIRST = ('M', 'A', 'R', 'C', 'H')
for _ in range(N):
  nams = input()
  if name[0] in FIRST:
    names_dic[name[0]] += 1
ans = 0
for i in range(5):
  for j in range(i+1, 5):
    for k in range(j+1, 5):
      ans += names_dic[FIRST[i]]*names_dic[FIRST[j]]*names_dic[FIRST[k]]
print(ans)

N = int(input())
names = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}
FIRST = ('M', 'A', 'R', 'C', 'H')
for _ in range(N):
  name = input()
  if name[0] in FIRST:
    names[name[0]] += 1
ans = 0
for i in range(5):
  for j in range(i+1, 5):
    for k in range(j+1, 5):
      ans += names[FIRST[i]]*names[FIRST[j]]*names[FIRST[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
from itertools import combinations, reduce

import operator

GOOD_LETTERS = "MARCH"
PEOPLE = 3

n = int(input())
c = Counter()

for _ in range(n):
  first = input()[0]
  if first in GOOD_LETTERS:
    c.update(first)
    
ways = 0
for tup in combinations(GOOD_LETTERS, PEOPLE):
  ways += reduce(operator.mul, [c[ch] for ch in tup], 1)

print(ways)

from collections import Counter
from functools import reduce
from itertools import combinations

import operator

GOOD_LETTERS = "MARCH"
PEOPLE = 3

n = int(input())
c = Counter()

for _ in range(n):
  first = input()[0]
  if first in GOOD_LETTERS:
    c.update(first)

ways = 0
for tup in combinations(GOOD_LETTERS, PEOPLE):
  ways += reduce(operator.mul, [c[ch] for ch in tup], 1)

print(ways)


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 as it

def c(n,k):
  if k>n:
    return 0
  ret = 1
  for i in range(n, n-k, -1):
    ret *= i
  for i in range(k, 1, -1):
    ret /= i
  return ret


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

answer = 0
for a,b,c = it.combinations('MARCH', 3):
  answer += dic[a] * dic[b] * dic[c]
print(answer)

import itertools as it

def c(n,k):
  if k>n:
    return 0
  ret = 1
  for i in range(n, n-k, -1):
    ret *= i
  for i in range(k, 1, -1):
    ret /= i
  return ret


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

answer = 0
for a,b,c in it.combinations('MARCH', 3):
  answer += dic[a] * dic[b] * dic[c]
print(answer)


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 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)

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))

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())
num = [0,0,0,0,0]
for i in range(N):
  a = input()
  if a[0]=='M':
    num[0] += 1
  if a[0]=='A':
    num[1] += 1
  if a[0]=='R':
	num[2] += 1
  if a[0]=='C':
	num[3] += 1
  if a[0]=='H':
	num[4] += 1


num_1 = num[0]*num[1]*num[2]
num_2 = num[0]*num[1]*num[3]
num_3 = num[0]*num[1]*num[4]
num_4 = num[1]*num[2]*num[3]
num_5 = num[1]*num[2]*num[4]
num_6 = num[2]*num[3]*num[4]
num_7 = num[0]*num[2]*num[3]
num_8 = num[0]*num[2]*num[4]
num_9 = num[0]*num[3]*num[4]
num_10 = num[1]*num[3]*num[4]

answer = num_1 + num_2 + num_3 + num_4 + num_5 + num_6 + num_7 + num_8 + num_9 + num_10

print(answer)

N = int(input())
num = [0,0,0,0,0]
answer = 0
for i in range(N):
	a = input()
	if a[0]=='M':
		num[0] += 1
	if a[0]=='A':
		num[1] += 1
	if a[0]=='R':
		num[2] += 1
	if a[0]=='C':
		num[3] += 1
	if a[0]=='H':
		num[4] += 1

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

print(answer)

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())
Sdic = {}
L = ["M","A","R","C","H"]
for i in L:
    Sdic[i] = []

tN = N
for i in range(N):
    s = input()
    if s[0] in L:
        Sdic[s[0]].append(s)
    else:
        tN -= 1

cnt = 0
for val in Sdic.values():
    if len(val) == 0:
        cnt += 1
if cnt >=3:
    print(0)
    exit()

zen = tN*(tN-1)*(tN-2) / 6

one = 0
for i in ["M","A","R","C","H"]:
    c = len(Sdic[i])
    if c >= 3:
        one += c * (c-1) * (c-2)  / 6


lis = []
for i in range(len(L)):
    for j in range(len(L)):
        if i < j:
            lis.append(len(Sdic[L[i]]) + len(Sdic[L[j]]))

two = 0
for c in lis:
    if c >= 3:
        two += c * (c-1) * (c-2)  / 6
print(zen , one , two)
print(int(zen - one - two))


N = int(input())
d = {}
for i in range(N):
    s = input()[0]
    if s not in d.keys():
        d[s] = 0
    d[s] += 1
march = ["M","A","R","C","H"]
lis = []
for a in d.keys():
    if a in march:
        lis.append(a)
import itertools
ans = 0
for l in list(itertools.combinations(lis,3)):
    ans += d[l[0]]*d[l[1]]*d[l[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):
from itertools import combinations
N = int(input())
S = Counter()
for _ in range(N):
  S[input()[0]] += 1
print(sum([S[p0]*S[p1]*S[p2] for p0,p1,p2 in combinations('MARCH', 3)]))

from itertools import combinations
N = int(input())
d = [0]*128
for _ in range(N): dic[ord(input()[0])] += 1
print(sum([d[ord(p0)]*d[ord(p1)]*d[ord(p2)] for p0,p1,p2 in combinations('MARCH', 3)]))


N = int(input())
dic = [0]*128
for _ in range(N): dic[ord(input()[0])] += 1
M,A,R,C,H = [dic[ord(x)] for x in list('MARCH')]
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

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):
m,a,r,c,h = [0,0,0,0,0]
N = int(input())

for i in range(N):


m, a, r, c, h = [0] * 5

N = int(input())

for _ 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: 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):
# coding: utf-8
# Your code here!
import math
from collections import Counter

def P(n, r):
    return math.factorial(n)//math.factorial(n-r)

def C(n, r):
    return P(n, r)//math.factorial(r)

N = int(input())
arr = [input() for i in range(N)]
mar_arr = [j for j in arr if j[0] == "M" or j[0] == "A" or j[0] == "R" or j[0] == "C" or j[0] == "H"]
ini_arr = [k[0] for k in mar_arr]
dic = Counter(ini_arr)
key_num = len(dic)
val_num = sum(v for v in dic.values())
if key_num <= 3:
    print(0)
else:
    total = C(len(ini_arr), 3)
    for i in dic.values():
        if i == 2:
            total -= C(num - i, 1)
        elif i >= 3:
            total -= C(i, 2) * C(num - i, 1)  + C(i, 3)
    print(total)

# coding: utf-8
# Your code here!
import math
from collections import Counter

def P(n, r):
    return math.factorial(n)//math.factorial(n-r)

def C(n, r):
    return P(n, r)//math.factorial(r)

N = int(input())
arr = [input() for i in range(N)]
mar_arr = [j for j in arr if j[0] == "M" or j[0] == "A" or j[0] == "R" or j[0] == "C" or j[0] == "H"]
ini_arr = [k[0] for k in mar_arr]
dic = Counter(ini_arr)
key_num = len(dic)
val_num = sum(v for v in dic.values())
if key_num < 3:
    print(0)
else:
    total = C(len(ini_arr), 3)
    for i in dic.values():
        if i == 2:
            total -= C(num - i, 1)
        elif i >= 3:
            total -= C(i, 2) * C(num - i, 1)  + C(i, 3)
    print(total)

# coding: utf-8
# Your code here!
import sys
input = sys.stdin.readline

n = int(input())
t = [0] * n
for i in range(n):
    t[i] =input()[0]
t2 = [t.count(i) for i in ["M","A","R","C","H"]]
ans = 0
for i in range(5):
    for j in range(5):
        if j == i:
            break
        for k in range(5):
            if k == j:
                break
            ans += t2[i] * t2[j] * t2[k]
print(ans)

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())

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)



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)

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
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 combinations(AA, 3)))

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)))

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)))

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):
#-*- coding:utf-8 -*-

def _is_march(c):
    if (c == "M") or (c == "A") or (c == "R") or (c == "C") or (c == "H"):
        return True
    return False

if __name__ == "__main__":
    N = int(input())
    march = []
    for i in range(N):
        name = input()
        if _is_march(name[0]):
            march.append(name)
    n = len(march)

    bunsi = n * (n-1) * (n-2)
    bunbo = 3 * 2 * 1
    print(int(bunsi/bunbo))


#-*- coding:utf-8 -*-

if __name__ == "__main__":
	N = int(input())
	m = 0
	a = 0
	r = 0
	c = 0
	h = 0
	for i in range(N):
		name = input()
		if name[0] == "M":
			m += 1
		elif name[0] == "A":
			a += 1
		elif name[0] == "R":
			r += 1
		elif name[0] == "C":
			c += 1
		elif name[0] == "H":
			h += 1
	
	ans  = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h
	ans += a*r*c + a*r*h + a*c*h
	ans += r*c*h
	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 sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import Counter
from scipy.misc import comb

n = int(readline())
s = [input()[0] for i in range(n)]
memo = list(Counter(s).items())
check = ['M', 'A', 'R', 'C', 'H']
cnt = 0
ans = 0
for x, y in memo:
    if x in check:
        ans += y
        if y > 1:
            cnt += n - y
print(comb(ans, 3) - cnt)


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import Counter
from scipy.special import comb

n = int(readline())
s = [input()[0] for i in range(n)]
memo = list(Counter(s).items())
check = ['M', 'A', 'R', 'C', 'H']
cnt = 0
ans = 0
for x, y in memo:
    if x in check:
        ans += y
        if y > 1:
            cnt += n - y
print(comb(ans, 3, exact=True) - cnt)


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import Counter
from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


n = int(readline())
s = []
check = ['M', 'A', 'R', 'C', 'H']
for i in range(n):
    ss = readline().rstrip().decode()
    if ss[0] in check:
        s.append(ss[0])
counter = list(Counter(s).values())
if len(counter) < 3:
    print(0)
    exit()
ans = cmb(sum(counter), 3)
for v in counter:
    if v >= 2:
        ans -= cmb(v, 2) * (len(s) - v)
        if v >= 3:
            ans -= cmb(v, 3)
print(ans)


Verdicts: Wrong Answer

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())
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)


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)


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
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)


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)


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 itertools as ite
N=int(input())
C=[0]*N
J="MARCH"
for i in range(N):
    C[J.find(input()[0])]+=1
ans=0
for i,j,k in list(ite.combinations(range(5),3)):
    ans+=C[i]*C[j]*C[k]
print(ans)


import itertools as ite
N=int(input())
C=[0]*6
J="MARCH"
for i in range(N):
    C[J.find(input()[0])]+=1
ans=0
for i,j,k in list(ite.combinations(range(5),3)):
    ans+=C[i]*C[j]*C[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 = [input() for i in range(N)]

S_first = [S[i][0] for i in range(N)]
march = ['M','A','R','C','H']
march_number = [0]*5

for i in range(N):
    march_number[i] = S.count(march[i])

import itertools
ptr = list(itertools.combinations(march_number,3))

ans = 0
seki = 1

for i in range(len(ptr)):
    for j in range(3):
        seki *= ptr[i][j]
    ans += seki
    seki = 1

print(ans)

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

S_first = [S[i][0] for i in range(N)]
march = ['M','A','R','C','H']
march_number = [0]*5

for i in range(5):
    march_number[i] = S_first.count(march[i])

import itertools
ans = 0
for v in itertools.combinations(march_number,3):
    ans += v[0]*v[1]*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 itertools
n = int(input())
names = [input() for i in range(n)]
names = [i for i in names if i[0] in "MARCH"]


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

import itertools
n = int(input())
counters = {"M":0,"A":0,"R":0,"C":0,"H":0}

for _ in range(n):
  s = input()[0]
  
  if s in "MARCH":
  	counters[s] += 1
res = 0
for i in list(itertools.combinations(["M","A","R","C","H"],3)):
  res += counters[i[0]] * counters[i[1]] * counters[i[2]]

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):
n = int(input())
cnt = [0,0,0,0,0]
comp = 'MARCH'
ans = 0

for i in range(N):
    word = input()
    for j in range(len(comp)):
        if word[0] == comp[j]:
            cnt[j] += 1

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

comp='MARCH'
cnt=[0,0,0,0,0]

n=int(input())
for i in range(n):
    word=input()
    for j in range(len(comp)):
        if word[0]==comp[j]: cnt[j]+=1

ans = 0
for i in range(len(cnt)):
    for j in range(i+1, len(cnt)):
        for k in range(j+1, len(cnt)):
            ans += cnt[i]*cnt[j]*cnt[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 itertools import*;d={}
for t in open(0).read().split():d[t]=d.get(t,0)+1
g=d.get;print(sum(g(p,0)*g(q,0)*g(r,0)for p,q,r in combinations('MARCH',3)))

from itertools import*;d={};g=d.get
for t in open(0).read().split():d[t]=g(t,0)+1
print(sum(g(p,0)*g(q,0)*g(r,0)for p,q,r in combinations('MARCH',3)))

from itertools import*;s,*_=zip(*open(0));print(sum(p*q*r for p,q,r in combinations(map(s.count,'MARCH'),3)))

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):
N = int(input())
s = [input() for _ in range(N)]

print(s)

Mx,Ax,Rx,Cx,Hx=0,0,0,0,0

for n in range(N):
  if   s[n][0] =="M":
    Mx += 1
  elif s[n][0] =="A":
    Ax += 1
  elif s[n][0] =="R":
    Rx += 1
  elif s[n][0] =="C":
    Cx += 1
  elif s[n][0] =="H":
    Hx += 1

MAR = Mx * Ax * Rx
MAC = Mx * Ax * Cx
MAH = Mx * Ax * Hx
MRC = Mx * Rx * Cx
MRH = Mx * Rx * Hx
MCH = Mx * Cx * Hx

ARC = Ax * Rx * Cx
ARH = Ax * Rx * Hx
ACH = Ax * Cx * Hx

RCH = Rx * Cx * Hx

print(MAR+MAC+MAH+MRC+MRH+MCH+ARC+ARH+ACH+RCH)

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

Mx,Ax,Rx,Cx,Hx=0,0,0,0,0

for n in range(N):
  if   s[n][0] =="M":
    Mx += 1
  elif s[n][0] =="A":
    Ax += 1
  elif s[n][0] =="R":
    Rx += 1
  elif s[n][0] =="C":
    Cx += 1
  elif s[n][0] =="H":
    Hx += 1

MAR = Mx * Ax * Rx
MAC = Mx * Ax * Cx
MAH = Mx * Ax * Hx
MRC = Mx * Rx * Cx
MRH = Mx * Rx * Hx
MCH = Mx * Cx * Hx

ARC = Ax * Rx * Cx
ARH = Ax * Rx * Hx
ACH = Ax * Cx * Hx

RCH = Rx * Cx * Hx

print(MAR+MAC+MAH+MRC+MRH+MCH+ARC+ARH+ACH+RCH)

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())
M_Dict = {"M":0,"A":0,"R":0,"C":0,"H":0}
for i in range(N):
    moji = str(input())
    if moji[0] in M_Dict.keys():
        M_Dict[moji[0]] += 1
M_Dict = {k: v for k, v in M_Dict.items() if v != 0}    
if len(M_Dict) < 3:
    ans = 0
else:
    ans = 0
    for k in itertools.combinations(list(M_Dict.keys()),3):
        ans += M_Dict[k[0]]*M_Dict[k[1]]*M_Dict[[2]]
    
print(ans)    

import itertools
N = int(input())
M_Dict = {"M":0,"A":0,"R":0,"C":0,"H":0}
for i in range(N):
    moji = str(input())
    if moji[0] in M_Dict.keys():
        M_Dict[moji[0]] += 1
M_Dict = {k: v for k, v in M_Dict.items() if v != 0}    
if len(M_Dict) < 3:
    ans = 0
else:
    ans = 0
    for k in itertools.combinations(list(M_Dict.keys()),3):
        ans += int(M_Dict[k[0]]) * int(M_Dict[k[1]]) * int(M_Dict[k[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):
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)

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)

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)

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*;N,*S=open(0);print(sum(a*b*c for a,b,c in combinations(sum(1for s in S if s[0]==c)for c in"MARCH",3)))

from itertools import*;N,*S=open(0);print(sum(a*b*c for a,b,c in combinations(sum(1for s in S if s[0]==c)for c in"MARCH",3)))

from itertools import*;N,*S=open(0);print(sum(a*b*c for a,b,c in combinations([sum(1for s in S if s[0]==c)for c in"MARCH"],3)))

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())
s = [input() for i in range(n)]

f = [a for a in s if s.startswith('M')]
g = [b for b in s if s.startswith('A')]
h = [c for c in s if s.startswith('R')]
i = [d for d in s if s.startswith('C')]
j = [e for e in s if s.startswith('H')]

k = len(f)*len(g)*len(h)
l = len(f)*len(g)*len(i)
m = len(f)*len(g)*len(j)
n = len(f)*len(h)*len(i)
o = len(f)*len(h)*len(j)
p = len(f)*len(i)*len(j)
q = len(g)*len(h)*len(i)
r = len(g)*len(h)*len(j)
s = len(g)*len(i)*len(j)
t = len(h)*len(i)*len(j)

sum = k+l+m+n+o+p+q+r+s+t
print(sum)

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

f = [a for a in s if a.startswith('M')]
g = [b for b in s if b.startswith('A')]
h = [c for c in s if c.startswith('R')]
i = [d for d in s if d.startswith('C')]
j = [e for e in s if e.startswith('H')]

k = len(f)*len(g)*len(h)
l = len(f)*len(g)*len(i)
m = len(f)*len(g)*len(j)
n = len(f)*len(h)*len(i)
o = len(f)*len(h)*len(j)
p = len(f)*len(i)*len(j)
q = len(g)*len(h)*len(i)
r = len(g)*len(h)*len(j)
s = len(g)*len(i)*len(j)
t = len(h)*len(i)*len(j)

sum = k+l+m+n+o+p+q+r+s+t
print(sum)

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 collections
import itertools

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

# print(c)

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

# print(l)

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

print(ans)

from collections import Counter
from itertools import combinations
from functools import reduce
from operator import mul
n = int(input())
S = [input()[0] for _ in range(n)]
S = [s for s in S if s in {"M","A","R","C","H"}]
cs = Counter(S)
ptn = combinations(cs.keys(), 3)

ans = 0
for p in ptn:
  arr = [cs[i] for i in p]
  ans += reduce(mul, arr)
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())

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))
        

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))
        

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())
tmp_nums = {"M":0, "A":0, "R":0, "C":0, "H":0}
for i in range(n):
    tmp_nums[s[i][0]] += 1
nums=[]
for i in tmp_nums.values():
    nums.append(i)
p = [0,0,0,0,0,0,1,1,1,2]
q = [1,1,1,2,2,3,2,2,3,3]
r = [2,3,4,3,4,4,3,4,4,4]
sum = 0
for i in range(10):
    sum += nums[p[i]]*nums[q[i]]*nums[r[i]]
print(sum)


n = int(input())
s = []
for i in range(n):
    s.append(input())
tmp_nums = {"M":0, "A":0, "R":0, "C":0, "H":0}
for i in range(n):
    if s[i][0] in tmp_nums.keys():
        tmp_nums[s[i][0]] += 1
nums=[]
for i in tmp_nums.values():
    nums.append(i)
p = [0,0,0,0,0,0,1,1,1,2]
q = [1,1,1,2,2,3,2,2,3,3]
r = [2,3,4,3,4,4,3,4,4,4]
sum = 0
for i in range(10):
    sum += nums[p[i]]*nums[q[i]]*nums[r[i]]
print(sum)


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

S = list(set(S))

N = len(S)
selected = [""] * 2
cnt = 0
for i in range(N-2):
    selected = [""] * 2
    selected[0] = S[i][0]
    for k in range(i+1, N-1):
        if S[k][0] in selected:
            continue
        selected[1] = S[k][0]
        for t in range(k+1, N):
            if S[t][0] in selected:
                continue
            cnt += 1
print(cnt)

import numpy as np
import itertools
cnt = 0
N = int(input())
S = {'M':0,'A':0,'R':0,'C':0,'H':0}
march = ['M','A','R','C','H']
for i in range(N):
    s = input()[0]
    if s in march:
        S[s] += 1
seq = S.values()
for i in list(itertools.combinations(seq, 3)):
    i = np.array(i)
    cnt += np.prod(i)

print(cnt)

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 itertools

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

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

ans = 0
for i, j, k in itertools.permutations(cnt, r=3):
    ans += i * j * k

print(ans)


import itertools

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

cnt = [0 for _ in range(5)]
for s in S:
    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

ans = 0
for i, j, k in itertools.combinations(cnt, r=3):
    ans += i * j * 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 defaultdict
from scipy.misc import comb
#ID
b = defaultdict(lambda: len(b))
n = int(input())
hed = ["M","A","R","C","H"]
for i in hed:
    b[i] 
li = [0]*5
for _ in range(n):
    a = input()
    if a[0] in hed:
        li[b[a[0]]] += 1

c = [i for i in li if i != 0]
print(int(comb(len(c),3))*2 -int(comb(len(c)-1,3)))

import itertools
n = int(input())
a = ["M","A","R","C","H"]
b = [0]*5
for i in range(n):
    s = input()
    for j in range(5):
        if a[j] == s[0]:
            b[j] += 1
ans = 0
for k in itertools.combinations(b,3):
    ans += k[0]*k[1]*k[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):
import sys
from itertools import combinations
from collections import Counter
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    n = int(input().rstrip())
    s = [input()[0] for _ in range(n)]
    s = [v for v in range(n)]
    c = Counter(s)
    ans = 0
    for x, y, z in combinations('MARCH', 3):
        ans += c[x] * c[y] * c[z]
    print(ans)


if __name__ == '__main__':
    main()


import sys
from itertools import combinations
from collections import Counter
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    n = int(input().rstrip())
    s = [input()[0] for _ in range(n)]
    c = Counter(s)
    ans = 0
    for x, y, z in combinations('MARCH', 3):
        ans += c[x] * c[y] * c[z]
    print(ans)


if __name__ == '__main__':
    main()


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
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)


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)


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 combinations

n = int(input())

count = {x:0 for x in "MARCH"}

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

sum_count = 0
for a, b, c in combinations("MARCH", 3):
  sum_count += count[a] * count[b] * count[c]

print(sum_count)

from itertools import combinations
 
n = int(input())
 
count = {x:0 for x in "MARCH"}
 
for _ in range(n):
  s = input()[0]
  if s in count:
    count[s] += 1
 
sum_count = 0
for a, b, c in combinations("MARCH", 3):
  sum_count += count[a] * count[b] * count[c]
 
print(sum_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())
l=[0]*10
for i in range(n):
  x=input()
  y=x[0]
  if y=='M':
    l[0]+=1
  elif y=='A':
    l[1]+=1
  elif y=='R':
    l[2]+=1
  elif y=='C':
    l[3]+=1
  elif y=='H':
    l[4]+=1
ans=0
for i in range(3):
  for j in range(i+1,i+4):
    for k in range(j+1,j+4):
      sum+=l[i]*l[j]*l[k]
print(sum)


n=int(input())
l=[0]*5
for i in range(n):
  x=input()
  y=x[0]
  if y=='M':
    l[0]+=1
  elif y=='A':
    l[1]+=1
  elif y=='R':
    l[2]+=1
  elif y=='C':
    l[3]+=1
  elif y=='H':
    l[4]+=1
ans=l[0]*l[1]*l[2]
print(ans)

n=int(input())
l=[0]*10
for i in range(n):
  x=input()
  y=x[0]
  if y=='M':
    l[0]+=1
  elif y=='A':
    l[1]+=1
  elif y=='R':
    l[2]+=1
  elif y=='C':
    l[3]+=1
  elif y=='H':
    l[4]+=1
ans=0
for i in range(3):
  for j in range(i+1,i+4):
    for k in range(j+1,j+4):
      ans+=l[i]*l[j]*l[k]
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):
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=del ([m,a,r,c,h],0)
x.sort()
l=len(x)
if l<3:
    print(0)
elif l==3:
    print(x[0]*x[1]*x[2])
elif l==4:
    print()
else:
    print()

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)


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):
x = input()
count = [0 for i in range(5)]
for i in x:
    name = input()
    if name[0] == 'M':
        count[0] += 1
    elif name[0] == 'A':
        count[1] += 1
    elif name[0] == 'R':
        count[2] += 1
    elif name[0] == 'C':
        count[3] += 1
    elif name[0] == 'H':
        count[4] += 1

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

print(res)

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

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

print(res)

Verdicts: Wrong Answer

Accepted