Buggy python submission (verdict: Runtime Error):
N = int(input())
s = [0] * N
d = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}
for i in range(N):
    s[i] = input()
    if s[i][0] == "M":
        d['M'] += 1
    elif s[i][0] == "A":
        d['A'] += 1
    elif s[i][0] == "R":
        d['R'] += 1
    elif s[i][0] == "C":
        d['C'] += 1
    elif s[i][0] == "H":
        d['H'] += 1

total = 1
count = 0
del_keys = []
for k, v in d.items():
    if v == 0:
        del_keys.append(k)
    else:
        total *= v
        count += 1

for key in del_keys:
    del d[key]

if count < 3:
    print(0)
    exit()
elif count == 3:
    print(total)
    exit()
elif count == 4:
    ans = 0
    for k, v in d.items():
        ans += total / v
    print(int(ans))
    exit()
elif count == 5:
    ans = 0
    d_lst = list(d)
    for i in range(4):
        for j in range(i+1, 5):
            ans += total / (d_lst[i] * d_lst[j])
    print(int(ans))


Fixed submission:
from collections import Counter
from itertools import combinations

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

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)

Buggy python submission (verdict: Runtime Error):
N = int(input())
s = [0] * N
d = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}
for i in range(N):
    s[i] = input()
    if s[i][0] == "M":
        d['M'] += 1
    elif s[i][0] == "A":
        d['A'] += 1
    elif s[i][0] == "R":
        d['R'] += 1
    elif s[i][0] == "C":
        d['C'] += 1
    elif s[i][0] == "H":
        d['H'] += 1

total = 1
count = 0
del_keys = []
for k, v in d.items():
    if v == 0:
        del_keys.append(k)
    else:
        total *= v
        count += 1

print(d)
for key in del_keys:
    del d[key]

if count < 3:
    print(0)
    exit()
elif count == 3:
    print(total)
    exit()
elif count == 4:
    ans = 0
    for k, v in d.items():
        ans += total / v
    print(int(ans))
    exit()
elif count == 5:
    ans = 0
    d_lst = list(d)
    for i in range(4):
        for j in range(i+1, 5):
            ans += total / (d_lst[i] * d_lst[j])
    print(int(ans))


Fixed submission:
from collections import Counter
from itertools import combinations

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

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)

Buggy python submission (verdict: Runtime Error):
N = int(input())
s = [0] * N
d = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}
for i in range(N):
    s[i] = input()
    if s[i][0] == "M":
        d['M'] += 1
    elif s[i][0] == "A":
        d['A'] += 1
    elif s[i][0] == "R":
        d['R'] += 1
    elif s[i][0] == "C":
        d['C'] += 1
    elif s[i][0] == "H":
        d['H'] += 1

total = 1
count = 0
del_keys = []
for k, v in d.items():
    if v == 0:
        del_keys.append(k)
    else:
        total *= v
        count += 1

for key in del_keys:
    del d[key]

if count < 3:
    print(0)
    exit()
elif count == 3:
    print(total)
    exit()
elif count == 4:
    ans = 0
    for k, v in d.items():
        ans += total / v
    print(ans)
    exit()
elif count == 5:
    ans = 0
    d_lst = list(d)
    for i in range(4):
        for j in range(i+1, 5):
            ans += total / (d_lst[i] * d_lst[j])
    print(ans)


Fixed submission:
from collections import Counter
from itertools import combinations

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

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)