Buggy python submission (verdict: Runtime Error):
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)


Fixed submission:
def main():
    N = int(input())

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

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

    print(ans)


main()

Buggy python submission (verdict: Runtime Error):
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    N = int(readline())
    S = list(map(lambda x: x.decode("UTF-8"), readlines()))
    S = list(map(lambda x: x.rstrip('\n'), S))
    march = list("MARCH")

    cnt = [0] * 5
    for i in range(N):
        for j in range(5):
            if S[i][0] == march[j]:
                cnt[j] += 1

    ans = 0

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

        print(ans)


main()


Fixed submission:
def main():
    N = int(input())

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

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

    print(ans)


main()

Buggy python submission (verdict: Runtime Error):
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    N = int(readline())
    S = list(map(lambda x: x.decode("UTF-8"), readlines()))
    S = list(map(lambda x: x.rstrip('\n'), S))
    march = list("MARCH")

    cnt = [0] * 5
    for i in range(N):
        for j in range(5):
            if S[i][0] == march[j]:
                cnt[j] += 1

    ans = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            for k in range(j+1, N):
                ans += cnt[i] * cnt[j] * cnt[k]

    print(ans)


main()


Fixed submission:
def main():
    N = int(input())

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

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

    print(ans)


main()