qyliang/CodeNanoFix huggingface dataset:
Buggy code:
from itertools import*;print(sum(p*q*r for p,q,r in list(combinations([len(list(v))for k,v in groupby(sorted(s[0]for s in open(0).readlines()[1:]))],3))))

Fixed code:
from itertools import*;print(sum(p*q*r for p,q,r in list(combinations([len(list(v))for k,v in groupby(sorted(s[0]for s in open(0).readlines()[1:]))if k in"MARCH"],3))))
Buggy code:
import itertools as i,collections as c;print(sum(p*q*r for p,q,r in i.combinations(c.Counter(s[0]*(s[0]in"MARCH")for s in open(0).readlines()[1:]).values(),3)))


Fixed code:
import itertools as i,collections as c;print(sum(p*q*r for p,q,r in i.combinations(c.Counter(s[0]for s in open(0).readlines()[1:] if s[0]in"MARCH").values(),3)))
Buggy code:
N = int(input())
S = {"M":0,"A":0,"R":0,"C":0,"H":0}
for i in range(N):
    s = input()
    if s[0] in ["M","A","R","C","H"]
        S[s[0]] += 1

print(S["M"] * S["A"] * (S["R"]+S["C"]+S["H"]) + S["M"] * S["R"] * (S["C"] + S["H"]) + S["M"] * S["C"] * S["H"] + S["A"] * S["R"] * (S["C"] + S["H"]) + S["C"] * S["A"] * S["H"] +  S["R"] * S["C"] * S["H"])


Fixed code:
N = int(input())
S = {"M":0,"A":0,"R":0,"C":0,"H":0}
for i in range(N):
    s = input()
    if s[0] in ["M","A","R","C","H"]:
        S[s[0]] += 1

print(S["M"] * S["A"] * (S["R"] + S["C"] + S["H"])
      + S["M"] * S["R"] * (S["C"] + S["H"])
      + S["M"] * S["C"] * S["H"]
      + S["A"] * S["R"] * (S["C"] + S["H"])
      + S["A"] * S["C"] * S["H"]
      + S["R"] * S["C"] * S["H"])
Buggy code:
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)


Fixed code:
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)
Buggy code:
from itertools import combinations
n=int(input())
s=[input()[0] for _ in range(n)]
a=[]
for i in ['M','A','R','C','H']:
  a+=[s.count(i)]
print(a)
ans=0
for i in combinations(a,3):
  ans+=i[0]*i[1]*i[2]
print(ans)

Fixed code:
from itertools import combinations
n=int(input())
s=[input()[0] for _ in range(n)]
a=[]
for i in ['M','A','R','C','H']:
  a+=[s.count(i)]
ans=0
for i in combinations(a,3):
  ans+=i[0]*i[1]*i[2]
print(ans)
Buggy code:
N=int(input())
m=0
a=0
r=0
c=0
h=0
for _ 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
ans=0
ans+=m*a*r
ans+=m*a*c
ans+=m*a*h
ans+=a*r*c
ans+=a*r*h
ans+=r*c*h
print(ans)

Fixed code:
N=int(input())
m=0
a=0
r=0
c=0
h=0
for _ 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
ans=0
ans+=m*a*r
ans+=m*a*c
ans+=m*a*h
ans+=m*r*c
ans+=m*r*h
ans+=m*c*h
ans+=a*r*c
ans+=a*r*h
ans+=a*c*h
ans+=r*c*h
print(ans)
Buggy code:
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)

Fixed code:
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)
Buggy code:
n=int(input())
s=[]
a,b,c,d,e=0,0,0,0,0
for i in range(n):
  S=input()
  if S[0]=='M':
    a+=1
  if S[0]=='A':
    b+=1
  if S[0]=='R':
    c+=1
  if S[0]=='C':
    d+=1
  if S[0]=='H':
    e+=1
print(a*b*c*+a*b*d+a*b*e+a*c*d+a*c*e+a*d*e+b*c*d+b*c*e+b*d*e+c*d*e)



Fixed code:
n=int(input())
s=[]
a,b,c,d,e=0,0,0,0,0
for i in range(n):
  S=input()
  if S[0]=='M':
    a+=1
  if S[0]=='A':
    b+=1
  if S[0]=='R':
    c+=1
  if S[0]=='C':
    d+=1
  if S[0]=='H':
    e+=1
print(a*b*c+a*b*d+a*b*e+a*c*d+a*c*e+a*d*e+b*c*d+b*c*e+b*d*e+c*d*e)
Buggy code:
from itertools import combinations

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

m = []
a = []
r = []
c = []
h = []
for i in range(N):
    if S[i][0] == 'M':
        m.append(S[i])
    elif S[i][0] == 'A':
        a.append(S[i])
    elif S[i][0] == 'R':
        r.append(S[i])
    elif S[i][0] == 'C':
        c.append(S[i])
    elif S[i][0] == 'H':
        h.append(S[i])

cnt = []
cnt.append(m.count)
cnt.append(a.count)
cnt.append(r.count)
cnt.append(c.count)
cnt.append(h.count)

com = list(combinations(range(5), 3))

ans = 0
for i in com:
    ans += cnt[i[0]]*cnt[i[1]]*cnt[i[2]]
print(ans)  

Fixed code:
from itertools import combinations

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

m = []
a = []
r = []
c = []
h = []
for i in range(N):
    if S[i][0] == 'M':
        m.append(S[i])
    elif S[i][0] == 'A':
        a.append(S[i])
    elif S[i][0] == 'R':
        r.append(S[i])
    elif S[i][0] == 'C':
        c.append(S[i])
    elif S[i][0] == 'H':
        h.append(S[i])

cnt = []
cnt.append(len(m))
cnt.append(len(a))
cnt.append(len(r))
cnt.append(len(c))
cnt.append(len(h))

com = list(combinations(range(5), 3))

ans = 0
for i in com:
    ans += cnt[i[0]]*cnt[i[1]]*cnt[i[2]]
print(ans)
Buggy code:
from collections import defaultdict
from itertools import combinations

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

c = defaultdict(int)

for i in range(N):
  if S[i][0] in {'M','A','R','C','H'}:
    c[S[i][0]] += 1

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

if len(c)==3:
  ans=0
  for k in c.keys():
    ans *= c[k]
  print(ans)
  exit()

else:
  ans = 0
  l = len(c)
  keys = list(c.keys())
  for C in combinations(range(l),3):
    tmp = c[keys[C[0]]]*c[keys[C[1]]]*c[keys[C[2]]]
    ans += tmp
  print(ans)

Fixed code:
from collections import defaultdict
from itertools import combinations

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

c = defaultdict(int)

for i in range(N):
  if S[i][0] in {'M','A','R','C','H'}:
    c[S[i][0]] += 1

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

if len(c)==3:
  ans=1
  for k in c.keys():
    ans *= c[k]
  print(ans)
  exit()

else:
  ans = 0
  l = len(c)
  keys = list(c.keys())
  for C in combinations(range(l),3):
    tmp = c[keys[C[0]]]*c[keys[C[1]]]*c[keys[C[2]]]
    ans += tmp
  print(ans)
Buggy code:
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(input())
ss = [input() for _ in range(n)]

march = ['M','A','R','C','H']
d = dict(zip(march, [0]*5))

nn = 0

for s in ss:
    if s[0] in march:
        d[s[0]] += 1
        nn += 1

ans = cmb(nn, 3)
for i in d.values():
    if i >= 2:
        if i > 3:
            ans -= cmb(i, 3)
        ans -= cmb(i,2)*(nn-i)

print(int(ans))



Fixed code:
from operator import mul
from functools import reduce

def cmb(n,r):
    if n < r: return 0
    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(input())
ss = [input() for _ in range(n)]
march = ['M','A','R','C','H']
d = dict(zip(march, [0]*5))

nn = 0

for s in ss:
    if s[0] in march:
        d[s[0]] += 1
        nn += 1
if nn < 3:
    print(0)
    exit()

ans = cmb(nn, 3)
for i in d.values():
    if i >= 2:
        if i > 3:
            ans -= cmb(i, 3)
        ans -= cmb(i,2)*(nn-i)

print(int(ans))
Buggy code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def main():
    N = int(input())
    s = []
    
    for i in range(N):
        tmp = input()
        s.append(tmp)
        
    m = 0
    a = 0
    r = 0
    c = 0
    h = 0
    for i in s:
        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
            
    ans = 0
    total = (a*b*c) + (a*b*d) + (a*b*e) + (a*c*d) + (a*c*e) + (a*d*e) + (b*c*d) + (b*c*e) + (b*d*e) + (c*d*e)
            
    print(total)
	
if __name__ == "__main__":
	main()


Fixed code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def main():
    N = int(input())
    s = []
    
    for i in range(N):
        tmp = input()
        s.append(tmp)
        
    m = 0
    a = 0
    r = 0
    c = 0
    h = 0
    for i in s:
        if i[0] == "M":
            m += 1
        elif i[0] == "A":
            a += 1
        elif i[0] == "R":
            r += 1
        elif i[0] == "C":
            c += 1
        elif i[0] == "H":
            h += 1
            
    #print("{} {} {} {} {}".format(m, a,r,c,h))
    total = (a*m*c) + (a*m*r) + (a*m*h) + (a*c*r) + (a*c*h) + (a*r*h) + (m*c*r) + (m*c*h) + (m*r*h) + (c*r*h)
            
    print(total)
	
if __name__ == "__main__":
	main()
Buggy code:
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)

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

N = int(input())
S = [0] * N
ans = 0
for i in range(N):
    s = input()
    if s[0] in ['M', 'A', 'R', 'C', 'H']:
        S[i] = s
S = list(set(S))
S.remove(0)
march = [0] * 5
for i in S:
    if i[0] == 'M':
        march[0] += 1
    elif i[0] == 'A':
        march[1] += 1
    elif i[0] == 'R':
        march[2] += 1
    elif i[0] == 'C':
        march[3] += 1
    else:
        march[4] += 1

for i, j, k in list(itertools.combinations([0, 1, 2, 3, 4], 3)):
    ans += march[i] * march[j] * march[k]
print(ans)

Fixed code:
import itertools

N = int(input())
S = [0] * N
ans = 0
for i in range(N):
    s = input()
    if s[0] in ['M', 'A', 'R', 'C', 'H']:
        S[i] = s
S = list(set(S))
if 0 in S:
    S.remove(0)
march = [0] * 5
for i in S:
    if i[0] == 'M':
        march[0] += 1
    elif i[0] == 'A':
        march[1] += 1
    elif i[0] == 'R':
        march[2] += 1
    elif i[0] == 'C':
        march[3] += 1
    else:
        march[4] += 1

for i, j, k in list(itertools.combinations([0, 1, 2, 3, 4], 3)):
    ans += march[i] * march[j] * march[k]
print(ans)
Buggy code:
import itertools
N = int(input())
MARCH = [0, 0, 0, 0, 0]
final_ans = 0
for i in range(N):
    a = input()
    if a[0] =='M':
        MARCH[0] += 1
    elif a[0] =='A':
        MARCH[1] += 1
    elif a[0] =='R':
        MARCH[2] += 1
    elif a[0] =='C':
        MARCH[3] += 1
    elif a[0] =='H':
        MARCH[4] += 1

MARCH = list(itertools.combinations(MARCH,3))

for i in ans:
    final_ans += i[0]*i[1]*i[2]
print(final_ans)

Fixed code:
import itertools
N = int(input())
M, A, R, C, H = 0, 0, 0, 0, 0
final_ans = 0
for i in range(N):
    a = input()
    if a[0] =='M':
        M += 1
    elif a[0] =='A':
        A += 1
    elif a[0] =='R':
        R += 1
    elif a[0] =='C':
        C += 1
    elif a[0] =='H':
        H += 1

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

final_ans = 0
for i in ans:
    final_ans += i[0]*i[1]*i[2]
print(final_ans)
Buggy code:
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 code:
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)
Buggy code:
n = int(input())

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

order = "MARCH"

initial_arary = [name[0] for name in s]
nums = [initial_array.count(order[i]) for i in range(len(order))]

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



Fixed code:
n = int(input())

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

order = "MARCH"

nums = [[name[0] for name in s].count(order[i]) for i in range(len(order))]

ans = 0
for i in range(0, 5):
    for j in range(i+1, 5):
        for k in range(j+1, 5):
            ans += nums[i] * nums[j] * nums[k]
            
print(ans)
Buggy code:
from collections import Counter
march = "MARCH"
n = int(input())
initial = Counter([input()[0] for _ in range(n)])
ans = []
for i, num in initial.items():
    if i in march:
        ans.append(num)

x = len(ans)
if x < 3:
    print(0)
elif x >= 3:
    y = 0
    for i in range(1, x-1):
        for j in range(i+1, x):
            for k in range(j+1, x+1):
                y += ans[i] * ans[j] * ans[k]
    print(y)




Fixed code:
from collections import Counter
march = "MARCH"
n = int(input())
initial = Counter([input()[0] for _ in range(n)])
ans = []
for i, num in initial.items():
    if i in march:
        ans.append(num)

x = len(ans)
if x < 3:
    print(0)
elif x >= 3:
    y = 0
    for i in range(0, x-2):
        for j in range(i+1, x-1):
            for k in range(j+1, x):
                y += ans[i] * ans[j] * ans[k]
    print(y)
Buggy code:
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)

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


Fixed code:
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)
Buggy code:
N = int(input())
S = [input() for _ in range(N)]
m = 0
a = 0
r = 0
c = 0
h = 0
for t in S:
    if t[0] == "M":
        m += 1
    elif t[0] == "A":
        a += 1
    elif t[0] == "R":
        r += 1
    elif t[0] == "C":
        c += 1
    elif t[0] == "H":
        h += 1
if m == 0:
  m = 1
if a == 0:
  a = 1
if r == 0:
  r = 1
if c == 0:
  c = 1
if h == 0:
  h = 1
print(m*a*r*c*h)

Fixed code:
N = int(input())
S = []

m = a = r = c = h = 0
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
ans = 0
ans += m * a * r
ans += m * a * c
ans += m * a * h
ans += m * r * c
ans += m * r * h
ans += m * c * h
ans += a * r * c
ans += a * r * h
ans += a * c * h
ans += r * c * h

print(ans)
Buggy code:
from collections import Counter
from itertools import combinations

n = int(input())
l = Counter(input()[0] for _ in range(n))
con = [l[c] for c in 'MARCH' if c in l]
print(sum(a * b * c) for a, b, c in combinations(con, 3))


Fixed code:
from collections import Counter
from itertools import combinations

n = int(input())
l = Counter(input()[0] for _ in range(n))
con = [l[c] for c in 'MARCH' if c in l]
print(sum(a * b * c for a, b, c in combinations(con, 3)))
Buggy code:
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)

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


Fixed code:
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)
Buggy code:
n=int(input())
l=[0]*5
m='MARCH'
for i in range(n):
  s=input()
  f=s[0]
  for i in range(5):
    if f==m[i]:
      l[i]+=1
      break
x=0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      x+=a[i]*a[j]*a[k]
print(x)

Fixed code:
n=int(input())
l=[0]*5
m='MARCH'
for i in range(n):
  s=input()
  f=s[0]
  for i in range(5):
    if f==m[i]:
      l[i]+=1
      break
x=0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      x+=l[i]*l[j]*l[k]
print(x)
Buggy code:
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))
  

Fixed code:
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))
Buggy code:
import itertools
from collections import Counter
n = int(input())
s = [input()[0] for _ in range(n)]
cnt = Counter(s)
print(cnt)

ans = 0
for x,y,z in itertools.combinations("MARCH",3):
 # print(x,y,z)
  ans += cnt[x]*cnt[y]*cnt[z]
  #print(cnt[x],cnt[y],cnt[z])
        
print(ans)

Fixed code:
import itertools
from collections import Counter
n = int(input())
s = [input()[0] for _ in range(n)]
cnt = Counter(s)
#print(cnt)

ans = 0
for x,y,z in itertools.combinations("MARCH",3):
 # print(x,y,z)
  ans += cnt[x]*cnt[y]*cnt[z]
  #print(cnt[x],cnt[y],cnt[z])
        
print(ans)
Buggy code:
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=s.values()
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)

Fixed code:
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)
Buggy code:
import sys
n=int(input())
s=[input()[0] for i in range(n)]
m,a,r,c,h=0,0,0,0,0
for i in range(n):
    if s[i]=="M": m+=1
    elif s[i]=="A": a+=1
    elif s[i]=="R": r+=1
    elif s[i]=="C": c+=1
    elif s[i]=="H": h+=1
t=sorted([m,a,r,c,h])
if t[2]==0:
    print(0)
    sys.exit()
if t[1]==0:
    print(t[2]*t[3]*t[4])
    sys.exit()
if t[0]==0:
    t[1],t[2],t[3],t[4]=a,b,c,d
    print(a*b*c+a*b*d+a*c*d+b*c*d)
    sys.exit()
else:
    t[0],t[1],t[2],t[3],t[4]=a,b,c,d,e
    x=a*b*c+a*b*d+a*b*e+a*c*d+a*c*e+a*d*e
    y=b*c*d+b*c*e+b*d*e+c*d*e
    print(x+y)

Fixed code:
import sys
n=int(input())
s=[input()[0] for i in range(n)]
m,a,r,c,h=0,0,0,0,0
for i in range(n):
    if s[i]=="M": m+=1
    elif s[i]=="A": a+=1
    elif s[i]=="R": r+=1
    elif s[i]=="C": c+=1
    elif s[i]=="H": h+=1
t=sorted([m,a,r,c,h])
q,w,e,r,u=0,0,0,0,0
if t[2]==0:
    print(0)
    sys.exit()
if t[1]==0:
    print(t[2]*t[3]*t[4])
    sys.exit()
if t[0]==0:
    q,w,e,r=t[1],t[2],t[3],t[4]
    print(q*w*e+q*w*r+q*e*r+w*e*r)
    sys.exit()
else:
    q,w,e,r,u=t[0],t[1],t[2],t[3],t[4]
    x=q*w*e+q*w*r+q*w*u+q*e*r+q*e*u+q*r*u
    y=w*e*r+w*e*u+w*r*u+e*r*u
    print(x+y)
Buggy code:
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)

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