qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n, m = map(int, input().split())
score = [(False, 0) for i in range(n)]
for i in range(m):
	problem, s = input().split()
	p = int(problem)-1
	if not score[p][0]:
		if s=="AC":
			score[p][0] = True
		else:
			score[p][1] += 1
	

print(sum(i[0] for i in score), sum(j if i else 0 for i, j in score))

Fixed code:
n, m = map(int, input().split())
score = [(False, 0) for i in range(n)]
for i in range(m):
	problem, s = input().split()
	p = int(problem)-1
	if not score[p][0]:
		score[p] = (True, score[p][1]) if s=="AC" else (False, score[p][1]+1)
	

print(sum(i[0] for i in score), sum(j if i else 0 for i, j in score))
Buggy code:
N, M = map(int, input().split())

ac = [False] * N
wa = [0] * N
for _ in range(M):
   p, S = input().split()
   p = int(p) - 1
   if (S == 'AC'):
      ac[p] = True
   else:
   if not ac[p]:
      wa[p] += 1

a = 0
b = 0
for i in range(N):
   if ac[i]:
      a += 1
      b += wa[i]
      print(*[a, b])


Fixed code:
N, M = map(int, input().split())

ac = [False] * N
wa = [0] * N
for _ in range(M):
   p, S = input().split()
   p = int(p) - 1
   if (S == 'AC'):
      ac[p] = True
   else:
      if not ac[p]:
         wa[p] += 1

a = 0
b = 0
for i in range(N):
   if ac[i]:
      a += 1
      b += wa[i]
print(*[a, b])
Buggy code:
n, m = map(int, input().split())
ans = []
ans_0 = []
for i in range(m):
    ans_0 = list(map(str, input().split()))
    ans.append(ans_0)
list0 = []
for j in range(n):
    list0.append(0)
sei = 0
pen = 0
for lis in ans:
    if list0[int(lis[0])] == 0:
        if lis[1] == "AC":
            sei += 1
            list0[int(lis[0])] = 1
        else:
            pen += 1
    else:
        if lis[1] == "AC":
            pass
        else:
            pen += 1
print(str(sei)+" "+str(pen))



Fixed code:
n, m = map(int, input().split())
ans = []
ans_0 = []
for i in range(m):
    ans_0 = list(map(str, input().split()))
    ans.append(ans_0)
list0 = []
listpen = []
for j in range(n):
    list0.append(0)
for k in range(n):
    listpen.append(0)
sei = 0
pen = 0
for lis in ans:
    if list0[int(lis[0])-1] == 0:
        if lis[1] == "AC":
            sei += 1
            list0[int(lis[0])-1] = 1
        else:
            listpen[int(lis[0])-1] += 1
    else:
        pass
for l in range(n):
    if list0[l] == 1:
        pen += listpen[l]
print(str(sei)+" "+str(pen))
Buggy code:
N,M = map(int,input().split())

AC = {}
WA = {}

if M == 0:
    print("0 0")
    exit()
for i in range(M):
    prob,sub = input().split()
    if sub == "WA":
        if (prob in AC) == False:
            if (prob in WA) == False:
                WA[prob] = 1
            else:
                WA[prob] += 1
    
    if sub == "AC":
         if (prob in AC) == False:
            AC[prob] = 1
         else:
            AC[prob] += 1
            
ans_WA = 0
for prob,sub in WA.items:
    if (prob in AC) = True:
        ans_WA += sub
            
print(len(AC.values()),ans_WA)

Fixed code:
N,M = map(int,input().split())

AC = {}
WA = {}

if M == 0:
    print("0 0")
    exit()
for i in range(M):
    prob,sub = input().split()
    if sub == "WA":
        if (prob in AC) == False:
            if (prob in WA) == False:
                WA[prob] = 1
            else:
                WA[prob] += 1
    
    if sub == "AC":
         if (prob in AC) == False:
            AC[prob] = 1
         else:
            AC[prob] += 1
            
ans_WA = 0
for prob,sub in WA.items():
    if (prob in AC) == True:
        ans_WA += int(sub)
            
print(len(AC.values()),ans_WA)
Buggy code:
def main():
    n,m=map(int,input().split())
    r=set()
    x={}
    for _ in range(m):
        p,s=input().split()
        print(p,s)
        if p not in r:
            if s=='WA':
                x[p]=x.setdefault(p,0)+1
            else:
                x[p]=x.setdefault(p,0)
                r.add(p)
    print(len(r),sum(x[p] for p in r)) 

main()

Fixed code:
def main():
    n,m=map(int,input().split())
    r=set()
    x={}
    for _ in range(m):
        p,s=input().split()
        if p not in r:
            if s=='WA':
                x[p]=x.setdefault(p,0)+1
            else:
                x[p]=x.setdefault(p,0)
                r.add(p)
    print(len(r),sum(x[p] for p in r)) 

main()
Buggy code:
n,m = map(int, input().split())
ac = [False for i in range(n)]
pen = [0 for i in range(n)]
s = list()
p = list()
for i in range(m):
    a,b = input().split()
    a = int(a)
    s.append(a)
    p.append(b)
for i in range(m):
    if ac[s[i]-1] == True:
        pass
    else:
        if p[i] == "AC":
            ac[s[i]-1] = True
        else:
            pen[s[i]-1] += 1
wa = 0
for i in range(n):
    if ac[i] == "AC":
        wa += pen[i]
print(sum(ac), wa)


Fixed code:
n,m = map(int, input().split())
ac = [False for i in range(n)]
pen = [0 for i in range(n)]
s = list()
p = list()
for i in range(m):
    a,b = input().split()
    a = int(a)
    s.append(a)
    p.append(b)
for i in range(m):
    if ac[s[i]-1] == True:
        pass
    else:
        if p[i] == "AC":
            ac[s[i]-1] = True
        else:
            pen[s[i]-1] += 1
wa = 0
for i in range(n):
    if ac[i] == True:
        wa += pen[i]
print(sum(ac), wa)
Buggy code:
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
pS = [input().split()[:2] for _ in range(m)]

AC = [0]*n
WA = [0]*n

for p, S in pS:
    p = int(p)
    print(p)
    if AC[p-1] == 0:
        if S == 'AC':
            AC[p-1] = 1
        else:
            WA[p-1] += 1

for i in range(n):
    if WA[i] > 0 and AC[i] == 0:
        WA[i] = 0
print(sum(AC), sum(WA))

Fixed code:
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
pS = [input().split()[:2] for _ in range(m)]

AC = [0]*n
WA = [0]*n

for p, S in pS:
    p = int(p)
    if AC[p-1] == 0:
        if S == 'AC':
            AC[p-1] = 1
        else:
            WA[p-1] += 1

for i in range(n):
    if WA[i] > 0 and AC[i] == 0:
        WA[i] = 0
print(sum(AC), sum(WA))
Buggy code:
N, M = map(int, input().split())
t_ans = []
for _ in range(M):
  t_ans.append(list(map(str,input().split())))

ans_num = [0]*(N+1)
ans_pe = [0]*(N+1)

for i in range(M):
  result = t_ans[i][1]
  question = int(t_ans[i][0])
  print(question)
  if result == 'AC' and ans_num[question] == 0:
    ans_num[question] = 1
  elif result == 'WA' and ans_num[question] == 0:
    ans_pe[question] += 1
  
for i in range(N):
  if ans_num[i] != 1:
    ans_pe[i] = 0

print(f'{sum(ans_num)} {sum(ans_pe)}')

Fixed code:
N, M = map(int, input().split())
t_ans = []
for _ in range(M):
  t_ans.append(list(map(str,input().split())))

ans_num = [0]*(N+1)
ans_pe = [0]*(N+1)

for i in range(M):
  result = t_ans[i][1]
  question = int(t_ans[i][0])
  if result == 'AC' and ans_num[question] == 0:
    ans_num[question] = 1
  elif result == 'WA' and ans_num[question] == 0:
    ans_pe[question] += 1

for i in range(N+1):
  if ans_num[i] != 1:
    ans_pe[i] = 0

print(f'{sum(ans_num)} {sum(ans_pe)}')
Buggy code:
n,m=map(int,input().split())
lst=[list(input().split()) for _ in range(m)]
print(lst)
pena_lst=[0]*n
acn_lst=[0]*n

for p,s in lst:
    p=int(p)-1
    if acn_lst[p]==1:
        continue
    if s =="AC":
        acn_lst[p]=1
    else: pena_lst[p]+=1
pena=0
acn=0
for i in range(n):
    acn+=acn_lst[i]
    if acn_lst[i]==1:
        pena+=pena_lst[i]
print(pena,acn)

Fixed code:
n,m=map(int,input().split())
lst=[list(input().split()) for _ in range(m)]
pena_lst=[0]*n
acn_lst=[0]*n

for p,s in lst:
    p=int(p)-1
    if acn_lst[p]==1:
        continue
    if s =="AC":
        acn_lst[p]=1
    else: pena_lst[p]+=1
pena=0
acn=0
for i in range(n):
    acn+=acn_lst[i]
    if acn_lst[i]==1:
        pena+=pena_lst[i]
print(acn,pena)
Buggy code:
N, M = map(int, input().split())
ans = 0
Q = [0] * N
wrong = [0] * N
for i in range(M):
  p, S = map(str, input().split())
  p = int(p) - 1
  if Q[p] == 0 and S == "AC":
    ans += wrong[p]
    Q[p] = 1
  elif S == "WA":
    wrong[p] += 1
print(ans)

Fixed code:
N, M = map(int, input().split())
ans1 = 0
ans2 = 0
Q = [0] * N
wrong = [0] * N
for i in range(M):
  p, S = map(str, input().split())
  p = int(p) - 1
  if Q[p] == 0 and S == "AC":
    ans1 += 1
    ans2 += wrong[p]
    Q[p] = 1
  elif S == "WA":
    wrong[p] += 1
print(ans1,ans2)
Buggy code:
# input
N, M = map(int, input().split())

# check
AC_questions = {}
for i in range(M):
    P, S = map(str, input().split())

    if P not in AC_questions:
        AC_questions[P] = {
            "wa_cnt": 0,
            "ac": False
        }

    if AC_questions[P]["wa_cnt"] is True:
        continue
    elif S == "AC":
        AC_questions[P]["ac"] = True
    # S == "WA"
    else:
        AC_questions[P]["wa_cnt"] += 1
        
AC_cnt = sum([1 for a in AC_questions if a['ac'] is True])
WA_cnt = sum([a["wa_cnt"] for a in AC_questions if a["ac"] is True])

print(AC_cnt, WA_cnt)

Fixed code:
# input
N, M = map(int, input().split())

# check
AC_questions = {}
for i in range(M):
    P, S = map(str, input().split())

    if P not in AC_questions:
        AC_questions[P] = {
            "wa_cnt": 0,
            "ac": False
        }

    if AC_questions[P]["ac"] is True:
        continue
    elif S == "AC":
        AC_questions[P]["ac"] = True
    # S == "WA"
    else:
        AC_questions[P]["wa_cnt"] += 1

AC_cnt = sum([1 for key in AC_questions.keys() if AC_questions[key]['ac'] is True])
WA_cnt = sum([AC_questions[key]["wa_cnt"] for key in AC_questions.keys() if AC_questions[key]["ac"] is True])

print(AC_cnt, WA_cnt)
Buggy code:
N,M = map(int,input().split())
dic = {}

for _ in range (M):
  p, s = input().split()
  if p not in dic and s == 'AC':
    dic[p] = [1,0]
  elif p not in dic and s == 'WA':
    dic[p] = [0,1]
  elif s == 'AC' and dic[p][0] == 0:
    dic[p][0] += 1
  elif s == 'WA'and dic[p][0]:
    dic[p][1] += 1

right = 0
wrong = 0

for item in dic.values():
  right += item[0]
  if item[0]== 1:
    wrong += item[1]

print(right, wrong)



Fixed code:
N,M = map(int,input().split())
dic = {}
 
for _ in range (M):
  p, s = input().split()
  if p not in dic and s == 'AC':
    dic[p] = [1,0]
  elif p not in dic and s == 'WA':
    dic[p] = [0,1]
  elif s == 'AC' and dic[p][0] == 0:
    dic[p][0] += 1
  elif s == 'WA' and dic[p][0] == 0:
    dic[p][1] += 1

right = 0
wrong = 0
 
for item in dic.values():
  right += item[0]
  if item[0]==1:
    wrong += item[1]

print(right, wrong)
Buggy code:
n, m = map(int, input().split())
p, s = [], []
for i in range(n):
    pi, si = input().split()
    p.append(int(pi))
    s.append(si)

lst_ac = [0 for i in range(n+1)]
for i in range(n):
    if s[i] == 'AC':
        lst_ac[p[i]] = 1
ans_ac = sum(lst_ac)

out = 0
for i in range(n):
    if s[i] == 'WA' and lst_ac[p[i]] == 1:
        out += 1

print(ans_ac, out)

Fixed code:
n, m = map(int, input().split())
p, s = [], []
for i in range(m):
    pi, si = input().split()
    p.append(int(pi))
    s.append(si)

lst_ac = [0 for i in range(n+1)]
for i in range(m):
    if s[i] == 'AC':
        lst_ac[p[i]] = 1
ans_ac = sum(lst_ac)

out = 0
for i in range(m):
    if s[i] == 'WA' and lst_ac[p[i]] == 1:
        out += 1
    if s[i] == 'AC' and lst_ac[p[i]] == 1:
        lst_ac[p[i]] = 2

print(ans_ac, out)
Buggy code:
hist = []
nm = list(map(int, input().split()))
for i in range(nm[1]):
    a,b=input().split()
    hist.append((int(a), b))

ac = [0] * nm[0]
wa = [0] * nm[0]

for i in range(nm[1]):
    if hist[i][1] == "AC":
        if ac[hist[i][0]-1] != 1:
            ac[hist[i][0]-1] = 1
    elif hist[i][1] == "WA":
        if ac[hist[i][0]-1] != 1:
            wa[hist[i][0]-1] = wa[hist[i][0]-1] + 1

for i in range(nm[0]):
    wa[i] = wa[i] * (1-ac[i])

print(sum(ac), sum(wa))

Fixed code:
hist = []
nm = list(map(int, input().split()))
for i in range(nm[1]):
    a,b=input().split()
    hist.append((int(a), b))

ac = [0] * nm[0]
wa = [0] * nm[0]

for i in range(nm[1]):
    if hist[i][1] == "AC":
        if ac[hist[i][0]-1] != 1:
            ac[hist[i][0]-1] = 1
    elif hist[i][1] == "WA":
        if ac[hist[i][0]-1] != 1:
            wa[hist[i][0]-1] = wa[hist[i][0]-1] + 1


for i in range(nm[0]):
    wa[i] = wa[i] * ac[i]

print(sum(ac), sum(wa))
Buggy code:
import sys
sys.setrecursionlimit(10**6)
# input = sys.stdin.readline
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    n,m=mis()
    lis=[0]*(n+1)
    wa=0
    for _ in range(m):
        P,s=input().split()
        p=int(P)
        if lis[p]==0:
            if s=='WA': wa+=1
            else: lis[p]+=1
    print(sum(lis))
    print(wa)


if __name__ == "__main__":
    main()

Fixed code:
import sys
sys.setrecursionlimit(10**6)
# input = sys.stdin.readline
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    n,m=mis()
    lis=[0]*(n+1)
    ww=[0]*(n+1)
    wa=0
    for _ in range(m):
        P,s=input().split()
        p=int(P)
        if lis[p]==0:
            if s=='WA': ww[p]+=1
            else:
                lis[p]+=1
                wa+=ww[p]
    print(sum(lis),wa)


if __name__ == "__main__":
    main()
Buggy code:
n,m=map(int,input().split())
s=[0]*n
t=[0]*n
for i in range(m):
    a,b=map(str,input().split())
    a,
    a=int(a)-1
    if not s[a]:
        if b=="WA":
            t[a]+=1
        else:
            s[a]=1
print(sum(s),sum(t[i] for i in range(n)if s[a]))

Fixed code:
n,m=map(int,input().split())
s=[0]*n
t=[0]*n
for i in range(m):
    a,b=map(str,input().split())
    a,
    a=int(a)-1
    if not s[a]:
        if b=="WA":
            t[a]+=1
        else:
            s[a]=1
print(sum(s),sum(t[i] for i in range(n)if s[i]))
Buggy code:


a,b=map(int,input().split())

c=[]
for i in range(b):
    d,e=map(str,input().split())
    c.append([int(d),e])

acans=0
waans=0
ac=[0]*(a+1)
wa=[0]*(a+1)
for i in range(b):
    if c[i][1]=="AC":
        if ac[c[i][0]-1]==0:
            acans+=1
            ac[c[i][0]-1]==1
            waans+=wa[c[i][0]-1]
    else:
        wa[c[i][0]-1]+=1
#print(wa)
print(acans,waans)

Fixed code:

a,b=map(int,input().split())

c=[]
for i in range(b):
    d,e=map(str,input().split())
    c.append([int(d),e])

acans=0
waans=0
ac=[0]*(a+1)
wa=[0]*(a+1)
for i in range(b):
    if c[i][1]=="AC":
        if ac[c[i][0]-1]==0:
            acans+=1
            ac[c[i][0]-1]+=1
            waans+=wa[c[i][0]-1]
    else:
        wa[c[i][0]-1]+=1
#print(ac)
#print(wa)
print(acans,waans)
Buggy code:
n,m=map(int,input().split())
if m == 0:
  print(0,0)
  exit()
A=[[0,0] for _ in range(n)]
for i in range(m):
  p,s=input().split()
  p=int(p)-1
  if A[p][0]==1:
    continue
  elif s=='AC':
    A[p][0]=1
  else:
  	A[p][1]+=1
ac=0
wa=0
for a in A:
  ac+=a[0]
  wa+=a[1] if a[0]==1 else 0
print(A)
print(ac,wa)

Fixed code:
n,m=map(int,input().split())
if m == 0:
  print(0,0)
  exit()
A=[[0,0] for _ in range(n)]
for i in range(m):
  p,s=input().split()
  p=int(p)-1
  if A[p][0]==1:
    continue
  elif s=='AC':
    A[p][0]=1
  else:
  	A[p][1]+=1
ac=0
wa=0
for a in A:
  ac+=a[0]
  if a[0] == 1:wa+=a[1]
print(ac,wa)
Buggy code:
N, M = map(int, input().split())

ac_list = [0] * (N + 1)
a = 0
w = 0
wa = 0
for i in range(M):
    l = input().split()
    if ac_list[int(l[0])]!='AC':
        if l[1] == 'AC':
            ac_list[int(l[0])-1] = 'AC'
            a += 1
            w = wa
        else:
            wa += 1

print('{} {}'.format(a, w))

Fixed code:
N, M = map(int, input().split())

ac_list = [0] * (N + 1)
wa_list = [0] * (N + 1)
a = 0
w = 0
for i in range(M):
    l = input().split()
    if ac_list[int(l[0])]!='AC':
        if l[1] == 'AC':
            ac_list[int(l[0])] = 'AC'
            a += 1
            w += wa_list[int(l[0])]
        else:
            wa_list[int(l[0])] += 1

print('{} {}'.format(a, w))
Buggy code:
N, M = map(int, input().split())
Q_n = [0] * N
C = [0] * N

Ans = 0
Pen = 0
for i in range(M):
    p, S = input().split
    p = int(p)-1
    if (S == 'AC') and (Q_n[p] == 0):
        Q_n[p] = 1
        Ans += 1
        Pen += C[p]
    elif (S == 'WA'):
        C[p] += 1
        
print(Ans, Pen)
  


Fixed code:
N, M = map(int, input().split())
Q_n = [0] * N
C = [0] * N

Ans = 0
Pen = 0
for i in range(M):
    p, S = input().split()
    p = int(p)-1
    if (S == 'AC') and (Q_n[p] == 0):
        Q_n[p] = 1
        Ans += 1
        Pen += C[p]
    elif (S == 'WA'):
        C[p] += 1
        
print(Ans, Pen)
Buggy code:
N,M = map(int,input().split())
PS = [list(input().split()) for i in range(M)]
PS = [[int(PS[i][0])-1,PS[i][1]] for i in range(M)]
AC = [0]*N
WA = [0]*N

for i in range(M):
    print(PS[i][0])
    if AC[PS[i][0]] == 0:
        if PS[i][1] == "AC":
            AC[PS[i][0]] = 1
        else:
            WA[PS[i][0]] += 1
        # print(AC,WA)
w = 0
for i in range(N):
    if AC[i] == 1:
        w += WA[i]
print(sum(AC),w)


Fixed code:
N,M = map(int,input().split())
PS = [list(input().split()) for i in range(M)]
PS = [[int(PS[i][0])-1,PS[i][1]] for i in range(M)]
AC = [0]*N
WA = [0]*N

for i in range(M):
    # print(PS[i][0])
    if AC[PS[i][0]] == 0:
        if PS[i][1] == "AC":
            AC[PS[i][0]] = 1
        else:
            WA[PS[i][0]] += 1
        # print(AC,WA)
w = 0
for i in range(N):
    if AC[i] == 1:
        w += WA[i]
print(sum(AC),w)
Buggy code:
N, M = map(int, input().split())
P = []
S = []
flag = [False for i in range(0, N)]
for i in range(0, M):
    x, y = map(str, input().split())
    P.append(int(x-1))
    S.append(y)
ans = [0, 0]
for i in range(0, M):
    if flag[P[i]]:
        continue
    else:
        if S[i] == 'AC':
            flag[P[i]] = True
            ans[0] += 1
        else:
            ans[1] += 1
print(*ans)


Fixed code:
N, M = map(int, input().split())
P = []
S = []
flag = [False for i in range(0, N)]
for i in range(0, M):
    x, y = map(str, input().split())
    P.append(int(x)-1)
    S.append(y)
ans = [0, 0]
wa = [0 for i in range(0, N)]
for i in range(0, M):
    if not flag[P[i]]:
        if S[i] == 'AC':
            flag[P[i]] = True
            ans[0] += 1
            ans[1] += wa[P[i]]
        else:
            wa[P[i]] += 1
print(*ans)
Buggy code:
import math
n,m = map(int,input().split())
ps_ls = [list(input().split()) for i in range(m)]
ans_wa = 0
ans_ac = 0
strk_wa = 0
frag = 1
for i in range(m):
    ps_ls[i][0] = int(ps_ls[i][0])
ps_ls.sort(key=lambda x: x[0])

for i in range(m-1):
    if ps_ls[i][1] == "WA" and frag == 1:
        strk_wa += 1

    if ps_ls[i][1] == "AC":
        if frag == 1:
            ans_ac += 1
        frag = 0
        ans_wa += strk_wa
    if ps_ls[i][0] != ps_ls[i+1][0]:
        strk_wa = 0
        frag = 1
if ps_ls[-1][1] == "AC":
    if frag == 1:
            ans_ac += 1
    ans_wa += strk_wa

print(ans_ac,ans_wa)

Fixed code:
import math
n,m = map(int,input().split())
ps_ls = [list(input().split()) for i in range(m)]
ans_wa = 0
ans_ac = 0
strk_wa = 0
frag = 1
for i in range(m):
    ps_ls[i][0] = int(ps_ls[i][0])
ps_ls.sort(key=lambda x: x[0])

for i in range(m-1):
    if ps_ls[i][1] == "WA" and frag == 1:
        strk_wa += 1

    if ps_ls[i][1] == "AC":
        if frag == 1:
            ans_ac += 1
        frag = 0
        ans_wa += strk_wa
        strk_wa = 0
    if ps_ls[i][0] != ps_ls[i+1][0]:
        strk_wa = 0
        frag = 1
if ps_ls != []:
    if ps_ls[-1][1] == "AC":
        if frag == 1:
                ans_ac += 1
        ans_wa += strk_wa

print(ans_ac,ans_wa)
Buggy code:
N, M = map(int, input().split())
l = [0] * (N + 1)
ac = 0
wa = 0
for _ in range(M):
    p, S = input().split()
    if S == 'WA':
        if l[int(p)] >= 0:
            l[int(p)] += 1
    else:
        if l[int(p)] >= 0:
            wa += l[int(p)]
            ac += 1

print(ac, wa)


Fixed code:
N, M = map(int, input().split())
l = [0] * (N + 1)
ac = 0
wa = 0
for _ in range(M):
    p, S = input().split()
    if S == 'WA':
        if l[int(p)] >= 0:
            l[int(p)] += 1
    else:
        if l[int(p)] >= 0:
            wa += l[int(p)]
            ac += 1
            l[int(p)] = -1

print(ac, wa)
Buggy code:
n,m=map(int,input().split())
l=[input().split() for _ in range(m)]
arr=[False for _ in range(n)]
ac,wa=0,0

for r in l:
  p,s=int(r[0])-1,r[1]
  if s=='AC' and arr[p]==False:
    ac+=1
    arr[p]=True
    continue
  elif s=='WA' and arr[p]==False and [p,'AC'] in l:
    wa+=1
    continue
print(ac,wa)

Fixed code:
n,m=map(int,input().split())
l=[input().split() for _ in range(m)]
arr=[]
ac,wa=0,0
acl=[False for _ in range(n)]
for r in l:
  p,s=int(r[0])-1,r[1]
  if s=='AC' and acl[p]==False:
    arr.append([p,s])
    acl[p]=True
  elif s=='WA' and acl[p]==False:
    arr.append([p,s])
    
for r in arr:
  p,s=r
  if s=='WA' and acl[p]:
    wa+=1
  elif s=='AC':
    ac+=1
    
print(ac,wa)
Buggy code:
import numpy as np

N,M=map(int,input().split())
ac=np.array([0]*N)
wa=np.array([0]*N)

for i in range(M):
    a,b=input().split()
    A=int(a)
    if ac[A-1]==0 and b=="WA":
        wa[A-1]+=1
    else :
        ac[A-1]=1

cal=sum(ac)
ans=sum(ac*wa)

Fixed code:
import numpy as np

N,M=map(int,input().split())
ac=np.array([0]*N)
wa=np.array([0]*N)

for i in range(M):
    a,b=input().split()
    A=int(a)
    if ac[A-1]==0 and b=="WA":
        wa[A-1]+=1
    else :
        ac[A-1]=1

cal=sum(ac)
ans=sum(ac*wa)
print(cal, ans)
Buggy code:
N,M = list(map(int,input().split()))
A = ['a']*N
B = [0]*N
ans1 = 0
ans2 = 0
for i in range(M):
  C,D = input().split()
  C = int(C)-1
  if A[C] == D == 'WA':
    ans1 += 1
    B[C] += 1
  if A[C] == 'a' and D == 'WA':
    ans1 += 1
    B[C] += 1
  if A[C] == 'WA' and D == 'AC':
    ans2 += 1
    A[C] = 'AC'
  if A[C] == 'a' and D == 'AC':
    ans2 += 1
    A[C] = 'AC'
for i in range(N):
  if A[i] == 'a':
    ans1 -= B[i]
print('{0} {1}'.format(ans1,ans2))

Fixed code:
N,M = list(map(int,input().split()))
A = ['a']*N
B = [0]*N
ans1 = 0
ans2 = 0
for i in range(M):
  C,D = input().split()
  C = int(C)-1
  if A[C] == D == 'WA':
    ans1 += 1
    B[C] += 1
  if A[C] == 'a' and D == 'WA':
    ans1 += 1
    B[C] += 1
  if A[C] == 'WA' and D == 'AC':
    ans2 += 1
    A[C] = 'AC'
  if A[C] == 'a' and D == 'AC':
    ans2 += 1
    A[C] = 'AC'
for i in range(N):
  if A[i] == 'a':
    ans1 -= B[i]
print('{0} {1}'.format(ans2,ans1))
Buggy code:
from collections import defaultdict

N, M = map(int, input().split())

d = defaultdict(int)

for i in range(M):
    p, S = input().split()
    p = int(p)
    if d[(p, 'AC')] > 0:
        pass
    elif S == 'AC':
        d[(p, 'AC')] += 1
        # print(p, 'AC')
    else:
        d[(p, 'WA')] += 1

ans = 0
penalty = 0

for i in range(N):
    ans += d[(i, 'AC')]
    penalty += d[(i, 'WA')]

print('{} {}'.format(ans, penalty))




Fixed code:
from collections import defaultdict

N, M = map(int, input().split())

d = defaultdict(int)

if M > 0:
    for i in range(M):
        p, S = input().split()
        p = int(p)
        if d[(p, 'AC')] > 0 and S == 'AC':
            pass
        elif d[(p, 'AC')] == 0 and S == 'AC':
            d[(p, 'AC')] = 1
        elif d[(p, 'AC')] == 0 and S == 'WA':
            d[(p, 'WA')] += 1

ans = 0
penalty = 0

for i in range(1, N + 1):
    if d[(i, 'AC')]:
        ans += d[(i, 'AC')]
        penalty += d[(i, 'WA')]
        # print(i, ans, penalty)

print('{} {}'.format(ans, penalty))