qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N = input()

d = {'M':0,'A':0,'R':0,'C':0,'H':0}

for i in range(N):
    s = input()
    if s[0] in 'MARCH':
        d[s[0]]+=1

v = list(d.values())
ans = 0

for i in range(5):
    for j in range (i+1,5):
        for k in range (j+1,5):
            ans += v[i]*v[j]*v[k]

print(ans)

Fixed code:
N = int(input())

d = {'M':0,'A':0,'R':0,'C':0,'H':0}

for i in range(N):
    s = input()
    if s[0] in 'MARCH':
        d[s[0]]+=1

v = list(d.values())
ans = 0

for i in range(5):
    for j in range (i+1,5):
        for k in range (j+1,5):
            ans += v[i]*v[j]*v[k]

print(ans)
Buggy code:
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)

Fixed code:
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)
Buggy code:
import itertools
N = int(input())
SK = {"M":0,"A":1,"R":2,"C":3,"H":4}
SD = [0]*5
del_list = []
A = ["M","A","R","C","H"]
for x in range(N):
    tmp = str(input())
    if tmp[0] in A:
        SD[SK[tmp[0]]] +=1
C = 0
for x in range(5)
    if SD[x] == 0 :
        del_list.append(x)
        C +=1
del_list.reverse()
for x in del_list:
    SD.pop(x)
    
if C >2:
    print(0)
else:
    Z = 5-C
    k = itertools.combinations(range(Z), 3)
    ans = 0
    for x in k:
        ans += SD[x[0]]*SD[x[1]]*SD[x[2]]
    print(ans)

Fixed code:
import itertools
N = int(input())
SK = {"M":0,"A":1,"R":2,"C":3,"H":4}
SD = [0]*5
del_list = []
A = ["M","A","R","C","H"]
for x in range(N):
    tmp = str(input())
    if tmp[0] in A:
        SD[SK[tmp[0]]] +=1
C = 0
for x in range(5):
    if SD[x] == 0 :
        del_list.append(x)
        C +=1
del_list.reverse()
for x in del_list:
    SD.pop(x)
    
if C >2:
    print(0)
else:
    Z = 5-C
    k = itertools.combinations(range(Z), 3)
    ans = 0
    for x in k:
        ans += SD[x[0]]*SD[x[1]]*SD[x[2]]
    print(ans)
Buggy code:
#encoding:utf-8

import math
import itertools

n = int(input())
s = []
for i in range(n):
    s.append(str(input()))

chosen_names = {"m":0,"a":0,"r":0,"c":0,"h":0}

for name in s:
    if name[0] == "M":
        chosen_names["m"] += 1
    elif name[0] == "A":
        chosen_names["a"] += 1
    elif name[0] == "R":
        chosen_names["r"] += 1
    elif name[0] == "C":
        chosen_names["c"] += 1
    elif name[0] == "H":
        chosen_names["h"] += 1

answer = 0
capitals = list("march")
capital_set = itertools.com
binations(capitals,3)
for capital in capital_set:
    answer += chosen_names[capital[0]] * chosen_names[capital[1]] * chosen_names[capital[2]]


print(answer)



# def combinations_count(n,r):
#     return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))


Fixed code:
#encoding:utf-8

import math
import itertools

n = int(input())
s = []
for i in range(n):
    s.append(str(input()))

chosen_names = {"m":0,"a":0,"r":0,"c":0,"h":0}

for name in s:
    if name[0] == "M":
        chosen_names["m"] += 1
    elif name[0] == "A":
        chosen_names["a"] += 1
    elif name[0] == "R":
        chosen_names["r"] += 1
    elif name[0] == "C":
        chosen_names["c"] += 1
    elif name[0] == "H":
        chosen_names["h"] += 1

answer = 0
capitals = list("march")
capital_set = itertools.combinations(capitals,3)
for capital in capital_set:
    answer += chosen_names[capital[0]] * chosen_names[capital[1]] * chosen_names[capital[2]]


print(answer)



# def combinations_count(n,r):
#     return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))
Buggy code:
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)


Fixed code:
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)
Buggy code:
from scipy.special import comb
import itertools
N=int(input())
S=[input() for _ in range(N)]
M=0
A=0
R=0
C=0
H=0
alives=0
march=['M','A','R','C','H']
for i in S:
    if i.startswith('M'):
        M+=1
    elif i.startswith('A'):
        A+=1
    elif i.startswith('R'):
        R+=1
    elif i.startswith('C'):
        C+=1
    elif i.startswith('H'):
        H+=1

if M==0:
    march.pop(march.index('M'))
if A==0:
    march.pop(march.index('A'))
if R==0:
    march.pop(march.index('R'))
if C==0:
    march.pop(march.index('C'))
if H==0:
    march.pop(march.index('H'))

if len(march)<3:
    print(0)

seq=list(itertools.combinations(march,3))

ans=0
for i in seq:
    temp=1
    for ch in i:
        if ch=='M':
            temp*=M
        if ch=='A':
            temp*=A
        if ch=='R':
            temp*=R
        if ch=='C':
            temp*=C
        if ch=='H':
            temp*=H
    ans+=temp

print(ans)

Fixed code:
import itertools
N=int(input())
S=[input() for _ in range(N)]
M=0
A=0
R=0
C=0
H=0
alives=0
march=['M','A','R','C','H']
for i in S:
    if i.startswith('M'):
        M+=1
    elif i.startswith('A'):
        A+=1
    elif i.startswith('R'):
        R+=1
    elif i.startswith('C'):
        C+=1
    elif i.startswith('H'):
        H+=1

if M==0:
    march.pop(march.index('M'))
if A==0:
    march.pop(march.index('A'))
if R==0:
    march.pop(march.index('R'))
if C==0:
    march.pop(march.index('C'))
if H==0:
    march.pop(march.index('H'))

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

seq=list(itertools.combinations(march,3))

ans=0
for i in seq:
    temp=1
    for ch in i:
        if ch=='M':
            temp*=M
        if ch=='A':
            temp*=A
        if ch=='R':
            temp*=R
        if ch=='C':
            temp*=C
        if ch=='H':
            temp*=H
    ans+=temp

print(ans)
Buggy code:
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)

Fixed code:
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))
Buggy code:
n = int(input())
names = []
for i in range(n):
  names.appen(input())
names = [i[0] for i in names]
nm = ["M","A","R","C","H"]
ks = [names.count(nm[i]) for i in range(5)]
ans = 0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      ans += i*j*k
print(ans)

Fixed code:
n = int(input())
names = []
for i in range(n):
  names.append(input())
names = [i[0] for i in names]
nm = ["M","A","R","C","H"]
ks = [names.count(nm[i]) for i in range(5)]
ans = 0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      ans += ks[i] * ks[j] * ks[k]
print(ans)
Buggy code:
s = [input() for _ in range(n)]
prefix = ['M', 'A', 'R', 'C', 'H']
cnt = [0] * 5
ans = 0
for i in range(n):
    for j in range(5):
        if s[i][0] == prefix[j]:
            cnt[j] += 1
for i in range(2 ** 5):
    flag = [False] * 5
    for j in range(5):
        if (i >> j) & 1:
            flag[j] = True
    if flag.count(True) == 3:
        tmp = 1
        for k in range(5):
            if flag[k]:
                tmp *= cnt[k]
        ans += tmp
print(ans)

Fixed code:
n = int(input())
s = [input() for _ in range(n)]
prefix = ['M', 'A', 'R', 'C', 'H']
cnt = [0] * 5
ans = 0
for i in range(n):
    for j in range(5):
        if s[i][0] == prefix[j]:
            cnt[j] += 1
for i in range(2 ** 5):
    flag = [False] * 5
    for j in range(5):
        if (i >> j) & 1:
            flag[j] = True
    if flag.count(True) == 3:
        tmp = 1
        for k in range(5):
            if flag[k]:
                tmp *= cnt[k]
        ans += tmp
print(ans)
Buggy code:
n = int(input())
count = [0]*5
d = {'M': 0, 'A': 1, 'R': 2, 'C':3, 'H': 4}

for i in range(n):
  s = input()
  if s[0] in 'MARCH':
    count[d[s[0]]] += 1

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

Fixed code:
n = int(input())
count = [0]*5
d = {'M': 0, 'A': 1, 'R': 2, 'C':3, 'H': 4}

for i in range(n):
  s = input()
  if s[0] in 'MARCH':
    count[d[s[0]]] += 1

ans = 0
for i in range(5):
  for j in range(i+1, 5):
    for k in range(j+1, 5):
      ans += count[i] * count[j] * count[k]
print(ans)
Buggy code:
l=[0]*5
n=int(input())
for i in range(n):
  s=input()
  a=s[0]
  if a=='M':
    l[0]+=1
  elif a=='A':
    l[1]+=1
  elif a=='R':
    l[2]+=1
  elif a=='C':
    l[3]+=1
  elif a=='H':
    l[4]+=1
if n==4 and sum(l)==0:
  exit()
print(l[0]*l[1]*l[2]
  +l[0]*l[1]*l[3]
  +l[0]*l[1]*l[4]
  +l[0]*l[2]*l[3]
  +l[0]*l[2]*l[4]
  +l[0]*l[3]*l[4]
  +l[1]*l[2]*l[3]
  +l[1]*l[2]*l[4]
  +l[1]*l[3]*l[4]
  +l[2]*l[3]*l[4])

Fixed code:
l=[0]*5
n=int(input())
for i in range(n):
  s=input()
  a=s[0]
  if a=='M':
    l[0]+=1
  elif a=='A':
    l[1]+=1
  elif a=='R':
    l[2]+=1
  elif a=='C':
    l[3]+=1
  elif a=='H':
    l[4]+=1
print(l[0]*l[1]*l[2]
  +l[0]*l[1]*l[3]
  +l[0]*l[1]*l[4]
  +l[0]*l[2]*l[3]
  +l[0]*l[2]*l[4]
  +l[0]*l[3]*l[4]
  +l[1]*l[2]*l[3]
  +l[1]*l[2]*l[4]
  +l[1]*l[3]*l[4]
  +l[2]*l[3]*l[4])
Buggy code:
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)


Fixed code:
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)
Buggy code:
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)

Fixed code:
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)
Buggy code:
N = int(input())
member = [0,0,0,0,0]
ans = 0
for _ in range(N):
    a = input().split()
    if a[0] == "M":
        member[0] += 1
    elif a[1] == "A":
        member[1] += 1
    elif a[2] == "R":
        member[2] += 1
    elif a[3] == "C":
        member[3] += 1
    elif a[4] == "H":
        member[4] += 1
 
for i in range(3):
    for j in range(i+1, 4):
        for k in range(i+2, 5):
            ans += member[i]*member[j]*member[k]

print(ans)



Fixed code:
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)
Buggy code:
import itertools
import math

N = int(input())
S_list = []
for i in range(N):
    S_list.append(input())

count_M = 0
count_A = 0
count_R = 0
count_C = 0
count_H = 0

for l in S_list:
    if l.startswith('M'):
        count_M += 1
    elif l.startswith('A'):
        count_A += 1
    elif l.startswith('R'):
        count_R += 1
    elif l.startswith('C'):
        count_C += 1
    elif l.startswith('H'):
        count_H += 1

count = [count_M,count_A,count_R,count_C,count_H]
c = list(itertools.combinations(count,3))
print(c)
x = 0
for i in c:
    i_list = list(i)
    x += i_list[0]*i_list[1]*i_list[2]
print(x)


Fixed code:
import itertools
import math

N = int(input())
S_list = []
for i in range(N):
    S_list.append(input())

count_M = 0
count_A = 0
count_R = 0
count_C = 0
count_H = 0

for l in S_list:
    if l.startswith('M'):
        count_M += 1
    elif l.startswith('A'):
        count_A += 1
    elif l.startswith('R'):
        count_R += 1
    elif l.startswith('C'):
        count_C += 1
    elif l.startswith('H'):
        count_H += 1

count = [count_M,count_A,count_R,count_C,count_H]
c = list(itertools.combinations(count,3))
x = 0
for i in c:
    i_list = list(i)
    x += i_list[0]*i_list[1]*i_list[2]
print(x)
Buggy code:
import sys
N=int(input())
S=[]
for i in range(N):
    S.append(input()[0])
    
Count=[]
Count.append(S.count("M"))
Count.append(S.count("A"))
Count.append(S.count("R"))
Count.append(S.count("C"))
Count.append(S.count("H"))

Zero=Count.count(0)
if(Zero>=3):print(0)
elif(Zero==2):
    Count.remove(0)
    Count.remove(0)
    pat=1
    for i in Count:pat*=i
    print(pat)
elif(Zero==1):
    Count.remove(0)
    patA=1
    for i in Count:patA*=i
    pat=0
    for i in Count:pat+=patA//i
    print(pat)
elif(Zero==0):
    patA=1
    for i in Count:patA*=i
    pat=0
    for i in range(5):
        for j in range(5):
            if(i==j):continue
            else:
                pat+=patA//Count[i]//Count[j]
    print(pat//2)
print(Count)

Fixed code:
import sys
N=int(input())
S=[]
for i in range(N):
    S.append(input()[0])
    
Count=[]
Count.append(S.count("M"))
Count.append(S.count("A"))
Count.append(S.count("R"))
Count.append(S.count("C"))
Count.append(S.count("H"))

Zero=Count.count(0)
if(Zero>=3):print(0)
elif(Zero==2):
    Count.remove(0)
    Count.remove(0)
    pat=1
    for i in Count:pat*=i
    print(pat)
elif(Zero==1):
    Count.remove(0)
    patA=1
    for i in Count:patA*=i
    pat=0
    for i in Count:pat+=patA//i
    print(pat)
elif(Zero==0):
    patA=1
    for i in Count:patA*=i
    pat=0
    for i in range(5):
        for j in range(5):
            if(i==j):continue
            else:
                pat+=patA//Count[i]//Count[j]
    print(pat//2)
Buggy code:
import sys
import itertools

input = sys.stdin.readline

def main():
    common = common_function()
    N = int(input())
    l = ['M', 'A', 'R', 'C', 'H']
    m = [0]*5
    for _ in range(N):
        S = input()[:-1]
        Shead = S[0]
        for i, s0 in enumerate(l):
            if Shead == s0:
                m[i] += 1
                break
    ll = []
    for i, n in enumerate(m):
        if n >= 1:
            ll.append(l[i])
    if len(ll) <= 2:
        print(0)
        return
    ans = 0
    for i, j, k in itertools.combinations(ll, 3):
        ans += m[l.index(i)] * m[l.index(j)] * m[l.index(k)]

    print(ans)

if __name__ == "__main__":
    main()


Fixed code:
import sys
import itertools

input = sys.stdin.readline

def main():
    N = int(input())
    l = ['M', 'A', 'R', 'C', 'H']
    m = [0]*5
    for _ in range(N):
        S = input()[:-1]
        Shead = S[0]
        for i, s0 in enumerate(l):
            if Shead == s0:
                m[i] += 1
                break
    ll = []
    for i, n in enumerate(m):
        if n >= 1:
            ll.append(l[i])
    if len(ll) <= 2:
        print(0)
        return
    ans = 0
    for i, j, k in itertools.combinations(ll, 3):
        ans += m[l.index(i)] * m[l.index(j)] * m[l.index(k)]

    print(ans)

if __name__ == "__main__":
    main()
Buggy code:
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)]))


Fixed code:
from itertools import combinations
N = int(input())
d = [0]*128
for _ in range(N): d[ord(input()[0])] += 1
print(sum([d[ord(p0)]*d[ord(p1)]*d[ord(p2)] for p0,p1,p2 in combinations('MARCH', 3)]))
Buggy code:
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)]))

Fixed code:
from itertools import combinations
from collections import Counter
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)]))
quit()
Buggy code:
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)


Fixed code:
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)
Buggy code:
N = int(input())
name_list = [input() for name in range(N)]
char_list = ['M', 'A', 'R', 'C', 'H']
count_list = [0 for _ in range(N)]

for name in name_list:
    if name[0] in char_list:
        count_list[char_list.index(name[0])] += 1
score=0
for x in range(5):
    for y in range(x+1,5):
        for z in range(y+1,5):
            score+=count_list[x]*count_list[y]*count_list[z]

print(score)


Fixed code:
N = int(input())
name_list = [input() for name in range(N)]
char_list = ['M', 'A', 'R', 'C', 'H']
count_list = [0 for _ in range(len(char_list))]

flag = False

for name in name_list:
    if name[0] in char_list:
        count_list[char_list.index(name[0])] += 1
score = 0
for x in range(5):
    for y in range(x + 1, 5):
        for z in range(y + 1, 5):
            score += count_list[x] * count_list[y] * count_list[z]

print(score)
Buggy code:
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)

Fixed code:
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)
Buggy code:
n=int(input())
cnt=[0]*5
check='MARCH'
for i in range(n):
  s=input()
  for j in range(5):
    if s[0]==check[j]:
      cnt[j]+=1
      break
ans=0
for i in range(5):
  for j in range(i+1,5):
    for k in range(j+1,5):
      ans+=cnt[i]*cnt[j]*cnt[k]

Fixed code:
n=int(input())
cnt=[0]*5
check='MARCH'
for i in range(n):
  s=input()
  for j in range(5):
    if s[0]==check[j]:
      cnt[j]+=1
      break
ans=0
for i in range(5):
  for j in range(i+1,5):
    for k in range(j+1,5):
      ans+=cnt[i]*cnt[j]*cnt[k]
print(ans)
Buggy code:
n = int(input())
l = [0]*5
for i in range(n):
  if input()[0] == "M":
    l[0] += 1
  elif input()[0] == "A":
    l[1] += 1
  elif input()[0] == "R":
    l[2] += 1
  elif input()[0] == "C":
    l[3] += 1
  elif input()[0] == "H":
    l[4] += 1
ans = 0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      ans += l[i]*l[j]*l[k]
print(ans)
  
  

Fixed code:
n = int(input())
l = [0]*5
for i in range(n):
    a = input()
    if a[0] == "M":
        l[0] += 1
    elif a[0] == "A":
        l[1] += 1
    elif a[0] == "R":
        l[2] += 1
    elif a[0] == "C":
        l[3] += 1
    elif a[0] == "H":
        l[4] += 1
    
    
ans = 0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            ans += l[i]*l[j]*l[k]
print(ans)
Buggy code:
import numpy as np
N = int(input())
S = [None]*5
for i in range(N):
    S[i] = input()

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

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

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

    print(souwa)

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

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

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

for i in range(len(kahi)-2):
    for j in range(i+1, len(kahi)-1):
        for k in range(j+1, len(kahi)):
            souwa += kahi[i]*kahi[j]*kahi[k]
print(souwa)
Buggy code:
n = int(input().strip())
s = [input().strip() for _ in range(n)]
num = [0 for _ in range(5)]
num[0] = len([True for _s in s if _s[0] == "M"])
num[1] = len([True for _s in s if _s[0] == "A"])
num[2] = len([True for _s in s if _s[0] == "R"])
num[3] = len([True for _s in s if _s[0] == "C"])
num[4] = len([True for _s in s if _s[0] == "H"])
ans = 0
for i in range(5):
    for j in range(i, 5):
        for k in range(j, 5):
            ans += num[i] * num[j] * num[k]
print(ans

Fixed code:
n = int(input().strip())
s = [input().strip() for _ in range(n)]
num = [0 for _ in range(5)]
num[0] = len([True for _s in s if _s[0] == "M"])
num[1] = len([True for _s in s if _s[0] == "A"])
num[2] = len([True for _s in s if _s[0] == "R"])
num[3] = len([True for _s in s if _s[0] == "C"])
num[4] = len([True for _s in s if _s[0] == "H"])
ans = 0
for i in range(5):
    for j in range(i + 1, 5):
        for k in range(j + 1, 5):
            ans += num[i] * num[j] * num[k]
print(ans)