qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N, M = tuple(map(int, input().split()))
P, S = [], []
for _ in range(M):
    p, s = input().split()
    P.append(int(p))
    S.append(s)

accepted = [False for _ in range(N)]
AC = 0
WA = 0
for p, s in zip(P, S):
    if s == "WA":
        if not accepted[p-1]:
            WA += 1
    elif s == "AC":
        accepted[p-1] = True
        AC += 1
print(AC, WA)


Fixed code:
N, M = tuple(map(int, input().split()))
P, S = [], []
for _ in range(M):
    p, s = input().split()
    P.append(int(p))
    S.append(s)

accepted = [False] * N
wrong = [0] * N
AC, WA = 0, 0
for p, s in zip(P, S):
    if s == "WA":
        if not accepted[p-1]:
            wrong[p-1] += 1
    elif s == "AC" and accepted[p-1] is False:
        accepted[p-1] = True
        AC += 1
        WA += wrong[p-1]
print(AC, WA)
Buggy code:
import math
import fractions

n, m = map(int, input().split())
ac_list = [0 for _ in range(n)]
wa_list = [0 for _ in range(n)]
wa_cnt = 0
cnt = 1
while cnt <= m:
    p, s = input().split()
    p = int(p)
    if s == "AC":
        ac_list[p - 1] = 1
    else:
        wa_list[p - 1] += 1
    cnt += 1
for i in range(n):
    if wa_list[i] == 1 and ac_list[i] == 1:
        wa_cnt += wa_list[i]
print(sum(ac_list), wa_cnt)



Fixed code:
import math
import fractions

n, m = map(int, input().split())
ac_list = [0 for _ in range(n)]
wa_list = [0 for _ in range(n)]
wa_cnt = 0
cnt = 1
while cnt <= m:
    p, s = input().split()
    p = int(p)
    if s == "AC":
        ac_list[p - 1] = 1
    else:
        if ac_list[p - 1] == 0:
            wa_list[p - 1] += 1
    cnt += 1
for i in range(n):
    if wa_list[i] >= 1 and ac_list[i] == 1:
        wa_cnt += wa_list[i]
print(sum(ac_list), wa_cnt)
Buggy code:
n, m = map(int, input().split())

scores = [[0, False] for _ in range(n)]

for _ in range(m):
    p, S = input().split()
    p = int(p)

    if scores[p][1]:
        continue

    if S == "AC":
        scores[p][1] = True
        continue

    if S == "WA":
        scores[p][0] += 1

score = pena = 0
for count, ac in scores:
    if ac:
        score += 1
        pena += count

print(score, pena)


Fixed code:
n, m = map(int, input().split())

scores = [[0, False] for _ in range(n+1)]

for _ in range(m):
    p, S = input().split()
    p = int(p)

    if scores[p][1]:
        continue

    if S == "AC":
        scores[p][1] = True
        continue

    if S == "WA":
        scores[p][0] += 1

score = pena = 0
for count, ac in scores:
    if ac:
        score += 1
        pena += count

print(score, pena)
Buggy code:
n,m = map(int, input().split())

ac = [False]*n
c_ac = 0
c_wa = 0

for _ in range(m):
    pi,si = input().split()
    pi = int(pi)
    
    if ac[pi] == False:
        if si == 'WA':
            c_wa += 1
        elif si == 'AC':
            c_ac += 1
            ac[pi] = True

print(c_ac, c_wa)

Fixed code:
n,m = map(int, input().split())

ac = [False]*n
c_ac = 0
c_wa = 0
wa = [0]*n
for _ in range(m):
    pi,si = input().split()
    pi = int(pi) - 1
    
    if ac[pi] == False:
        if si == 'WA':
            wa[pi] += 1
        elif si == 'AC':
            c_ac += 1
            c_wa += wa[pi]
            ac[pi] = True

print(c_ac, c_wa)
Buggy code:
N, M = map(int, input().split())
results = [input().split() for _ in range(M)]
solved = set()
missed = dict()
penalty = 0

for p, S in results:
    if p in solved:
        continue

    if S == 'AC':
        solved.add(p)
        penalty += missed[p]
    elif p not in missed:
        missed[p] = 1
    else:
        missed[p] += 1

print(len(solved), penalty)

Fixed code:
N, M = map(int, input().split())
results = [input().split() for _ in range(M)]
solved = set()
missed = dict()
penalty = 0

for p, S in results:
    if p in solved:
        continue

    if S == 'AC':
        solved.add(p)
        penalty += missed[p] if p in missed else 0
    else:
        missed[p] = missed[p] + 1 if p in missed else 1

print(len(solved), penalty)
Buggy code:
n, m = map(int, input().split())
ac = "AC"
ac_dic= {}
wa_dic = {}
wa_num = 0
for _ in range(m):
  p, s = input().split()
  if s == ac:
    ac_dic[p] = 1
  else:
    if p in wa_dic:
      wa_dic[p]+=1
    else:
      wa_dic[p] = 1
for key, value in wa_dic.items():
  if key in ac_dic:
    wa_num += value
ans = len(ac_dic)
print(ans, wa_num)

Fixed code:
n, m = map(int, input().split())
ac = "AC"
ac_dic= {}
wa_dic = {}
wa_num = 0
for _ in range(m):
  p, s = input().split()
  if s == ac:
    ac_dic[p] = 1
  elif not (p in ac_dic):
    if p in wa_dic:
      wa_dic[p]+=1
    else:
      wa_dic[p] = 1
for key, value in wa_dic.items():
  if key in ac_dic:
    wa_num += value
ans = len(ac_dic)
print(ans, wa_num)
Buggy code:
# import itertools
# import math

# N = int(input())
# S = input()
N, M = map(int, input().split())
# A = list(map(int, input().split()))

ans_p = [0] * N
ans_s = [0] * N

for i in range(M):
    input_sp = input().split()
    P = int(input_sp[0]) - 1
    S = input_sp[1]

    if S == 'AC':
        ans_s[P] = 1
    elif S == 'WA' and ans_p[P] == 0:
        ans_p[P] += 1

for i in range(ans_p):
    if ans_s[i] == 0 and ans_p[i] != 0:
        ans_p[i] = 0


print(str(sum(ans_s)) + " " + str(sum(ans_p)))


Fixed code:
# import itertools
# import math

# N = int(input())
# S = input()
N, M = map(int, input().split())
# A = list(map(int, input().split()))

ans_p = [0] * N
ans_s = [0] * N

for i in range(M):
    input_sp = input().split()
    P = int(input_sp[0]) - 1
    S = input_sp[1]

    if S == 'AC':
        ans_s[P] = 1
    elif S == 'WA' and ans_s[P] == 0:
        ans_p[P] += 1

for i in range(len(ans_p)):
    if ans_s[i] == 0 and ans_p[i] != 0:
        ans_p[i] = 0

print(str(sum(ans_s)) + " " + str(sum(ans_p)))
Buggy code:
N, M = map(int, input().split())
ac = [0]*N
wa = 0

for i in range(M):
    P, S = map(str, input().split())
    P = int(P)-1
    if ac[P] != 1 and S == "AC":
        wa += abs(ac[P])
        ac[P] = 1
    elif ac[P] != 1 and S == "WA":
        ac[P] -= 1
    print(ac.count(1), wa)
    print(ac)
    print(wa)


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

for i in range(M):
    P, S = map(str, input().split())
    P = int(P)-1
    if ac[P] != 1 and S == "AC":
        wa += abs(ac[P])
        ac[P] = 1
    elif ac[P] != 1 and S == "WA":
        ac[P] -= 1

print(ac.count(1), wa)
Buggy code:

n,m=map(int,input().split())

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

for i in range(m):
    problem,status=input().split()
    problem=int(problem)

    if status=='WA' and AC[problem-1]==0:
        WA[problem-1]+=1
    elif status=='AC':
        AC[problem-1]+=1
print(sum(WA),sum(AC))


Fixed code:
n,m=map(int,input().split())
 
WA=[0]*n
AC=[0]*n
 
for i in range(m):
    problem,status=input().split()
    problem=int(problem)
 
    if status=='WA':
        if AC[problem-1]==1:
            continue
        else:
            WA[problem-1]+=1
    elif status=='AC':
        AC[problem-1]=1

for i in range(n):
    if AC[i]==0:
        WA[i]=0
print(sum(AC),sum(WA))
Buggy code:
a = list(map(int,input().split()))
N = a[0]
M = a[1]

list = []
for i in range(M):
  a,b=input().split()
  list.append((int(a), b))

bool_ac = []
ac_sum = 0
wa = []
wa_sum = 0
for i in range(N):
  bool_ac.append(0)
  wa.append(0)


for i in range(M):
  j = list[i][0] - 1
  if list[i][1] == "AC":
    bool_ac[j] = 1
    ac_sum += 1
    wa_sum += wa[j]
  elif list[i][1] == "WA":
    if bool_ac[j] == 0:
      wa[j] += 1

print(ac_sum, end=" "), print(wa_sum)

Fixed code:
a = list(map(int,input().split()))
N = a[0]
M = a[1]

list = []
for i in range(M):
  a,b=input().split()
  list.append((int(a), b))

bool_ac = []
ac_sum = 0
wa = []
wa_sum = 0
for i in range(N):
  bool_ac.append(0)
  wa.append(0)


for i in range(M):
  j = list[i][0] - 1
  if list[i][1] == "AC" and bool_ac[j] != 1:
    bool_ac[j] = 1
    ac_sum += 1
    wa_sum += wa[j]
  elif list[i][1] == "WA":
    if bool_ac[j] == 0:
      wa[j] += 1

print(ac_sum, end=" "), print(wa_sum)
Buggy code:
n,m = map(int,input().split())
cor = set()
pens = {}
for i in range(m):
  p,s = input().split()
  if s=="AC":
    cor.add(p)
  else:
    if not p in cor:
      if p in pens:
        pens[p] += 1
      else:
        pens[p] = 1
pen = 0
for x in cor:
  if x in pens:  
    pen += pens(x)
print(str(len(cor))+" "+str(pen))

Fixed code:
n,m = map(int,input().split())
cor = set()
pens = {}
for i in range(m):
  p,s = input().split()
  if s=="AC":
    cor.add(p)
  else:
    if not p in cor:
      if p in pens:
        pens[p] += 1
      else:
        pens[p] = 1
pen = 0
for x in cor:
  if x in pens:  
    pen += pens[x]
print(str(len(cor))+" "+str(pen))
Buggy code:
N, M = map(int, input().split())
AC = [0]*N
WA = [0]*N
L = []
for m in range(M):
    p, S = map(str, input().split())
    p = int(p)
    L.append([p, S])
for m in range(M):
    if not AC[L[m][0]-1] == 0:
        continue    
    if L[m][1] == 'AC':
        AC[L[m][0]-1] = 1
    elif L[m][1] == 'WA':
        WA[L[m][0]-1] += 1
A = sum(AC)
W = 0
for n in range(N):
    if AC[n] == 1:
        W += AC[n]
print(A, W)

Fixed code:
N, M = map(int, input().split())
AC = [0]*N
WA = [0]*N
L = []
for m in range(M):
    p, S = map(str, input().split())
    p = int(p)
    L.append([p, S])
for m in range(M):
    if not AC[L[m][0]-1] == 0:
        continue    
    if L[m][1] == 'AC':
        AC[L[m][0]-1] = 1
    elif L[m][1] == 'WA':
        WA[L[m][0]-1] += 1
A = sum(AC)
W = 0
for n in range(N):
    if AC[n] == 1:
        W += WA[n]
print(A, W)
Buggy code:
n,m = map(int, input().split())

ac = [0]*(n)
wa = [0]*(n)


for i in range(m):
	p, s = input().split()
    p = int(p)
    
    if s== "AC":
		ac[p] = 1
    else:
        wa[p]+=1

for i in range(m):
	if ac[i]=0:
		wa[p]=0
        
print(sum(ac),sum(wa))

Fixed code:
n,m = map(int, input().split())

ac = [0]*(n+1)
wa = [0]*(n+1)


for i in range(m):
	p, s = input().split()
	p = int(p)
    
	if s== "AC":
		ac[p] = 1
	else:
		if ac[p]==0:
			wa[p]+=1

for i in range(n+1):
	if ac[i]==0:
		wa[i]=0
        
print(sum(ac),sum(wa))
Buggy code:
n,m=map(int,input().split())
num = [1]*(n + 1)
AC_cnt = 0
WA_cnt = 0
for i in range(m):
    p,s=input().split()
    if s == 'AC'
        if num[int(p)]:
            num[int(p)] = 0
            AC_cnt += 1
else:
    WA_cnt += 1
print(AC_cnt,WA_cnt)


Fixed code:
n,m=map(int,input().split())
num = [1]*(n + 1)
pena = [0]*(n + 1)
AC_cnt = 0
WA_cnt = 0
for i in range(m):
    p,s=input().split()
    if s == 'AC':
        if num[int(p)]:
            num[int(p)] = 0
            AC_cnt += 1
            WA_cnt += pena[int(p)]
    else:
        pena[int(p)] += 1
print(AC_cnt,WA_cnt)
Buggy code:
N, M=map(int,input().split())
if M==0:
	print("0 0")
else:
	ac=0
	pe=0
	ch=[0]*N
    Ch=[0]*N
	for i in range(M):
		a, b=input().split()
		a=int(a)-1
		if ch[a]==1:
			continue
		elif b=="WA":
			Ch[a]+=1
		else:
			ch[a]=1
			ac+=1
			pe+=Ch[a]
	print(ac,pe)

Fixed code:
N, M=map(int,input().split())
if M==0:
	print("0 0")
else:
	ac=0
	pe=0
	ch=[0]*N
	Ch=[0]*N
	for i in range(M):
		a, b=input().split()
		a=int(a)-1
		if ch[a]==1:
			continue
		elif b=="WA":
			Ch[a]+=1
		else:
			ch[a]=1
			ac+=1
			pe+=Ch[a]
	print(ac,pe)
Buggy code:
# coding: utf-8
import re
import math
#import numpy as np


#main
n,m=map(int,input().split())
MAP={}
PS=[]
for a in range(m):
    s,t=input().split()
    if(not s in MAP):MAP[s]=[]
    MAP[s].append(t)
ac=0
wa=0
for a,b in MAP.items():
    if(not "AC" in MAP[a]):continue
    for c in b:
        if(c=="WA"):
            ac+=1
        else:
            wa+=1
            break
print(ac,wa)

Fixed code:
# coding: utf-8
import re
import math
#import numpy as np


#main
n,m=map(int,input().split())
MAP={}
PS=[]
for a in range(m):
    s,t=input().split()
    if(not s in MAP):MAP[s]=[]
    MAP[s].append(t)
ac=0
wa=0
for a,b in MAP.items():
    if(not "AC" in MAP[a]):continue
    for c in b:
        if(c=="WA"):
            wa+=1
        else:
            ac+=1
            break
print(ac,wa)
Buggy code:
n,m=map(int,input().split())
dp=[0]*(n+1)
cnt=0
for i in range(m):
  q=input()
  if dp[int(q[i])]!="A" and q[-2]=="W":
    dp[int(q[:-3])]="W"
    cnt+=1
  elif dp[int(q[i])]!="A" and q[-2]=="A":
    dp[int(q[:-3])]="A"
print(dp.count("A"),cnt)

Fixed code:
n,m=map(int,input().split())
dp=[0]*(n+1)
charge=[0]*(n+1)
cnt=0
ans=0
for i in range(m):
  q=input()
  if dp[int(q[:-3])]!="A" and q[-2]=="W":
    dp[int(q[:-3])]="W"
    charge[int(q[:-3])]+=1
  elif dp[int(q[:-3])]!="A" and q[-2]=="A":
    dp[int(q[:-3])]="A"
    ans+=1
    cnt+=charge[int(q[:-3])]
    charge[int(q[:-3])]=0
print(ans,cnt)
Buggy code:
n,m = map(int,input().split())
t = dict()
account,pena = 0,0
for i in range(m):
	s = input().split()
	if not s[0] in t.keys():
		t[s[0]] = s[1]
	else:
		if t[s[0]][-2::] == 'WA':
			t[s[0]] += s[1]
for j in t.values():
	print(j)
	if j[-2::] == 'AC':
		account += 1
		pena += j.count('WA')
print(account,pena)


Fixed code:
n,m = map(int,input().split())
t = dict()
account,pena = 0,0
for i in range(m):
	s = input().split()
	if not s[0] in t.keys():
		t[s[0]] = s[1]
	else:
		if t[s[0]][-2::] == 'WA':
			t[s[0]] += s[1]
for j in t.values():
	if j[-2::] == 'AC':
		account += 1
		pena += j.count('WA')
print(account,pena)
Buggy code:

n,m = map(int,input().split())
ac = [0]*(n+1)
wa = [0]*(n+1)
for i in range(m):
    p,s = input().split()
    p = int(p)
    if s=="AC":
        ac[p]=1
    else:
        if ac[p] ==0:
            wa[p]+=1
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())
ac = [0]*(n+1)
wa = [0]*(n+1)
for i in range(m):
    p,s = input().split()
    p = int(p)
    if s=="AC":
        ac[p]=1
    else:
        if ac[p] ==0:
            wa[p]+=1
w = 0
for i in range(n+1):
    if ac[i] ==1:
        w+=wa[i]
print(sum(ac),w)
Buggy code:
n,m=map(int,input().split())
l=[0]*(n+1)
p=0
for _ in range(m):
  a,b=list(input().split())
  if str(b)=="AC" and l[int(a)]==0:
    l[int(a)]==1
  elif str(b)=="WA" and l[int(a)]==0:
    p+=1
print(l.count(1),p)

Fixed code:
n,m=map(int,input().split())
l=[0]*(n+1)
p=0
for _ in range(m):
  a,b=list(input().split())
  if str(b)=="AC" and l[int(a)]!=-1:
    p+=l[int(a)]
    l[int(a)]=-1
  elif str(b)=="WA" and l[int(a)]!=-1:
    l[int(a)]+=1
print(l.count(-1),p)
Buggy code:
R = lambda : input().split()

n, m = map(int, R())
a = [False] * n
b = [0] * n
for _ in range(m):
  p, s = R()
  p = int(p) - 1
  if s == 'AC':
    a[p] = True
  elif not a[p]:
    b[p] += 1
b =  [y for x, y in zip(a, b) if a]
print(len(b), sum(b))


Fixed code:
R = lambda : input().split()

n, m = map(int, R())
a = [False] * n
b = [0] * n
for _ in range(m):
  p, s = R()
  p = int(p) - 1
  if s == 'AC':
    a[p] = True
  elif not a[p]:
    b[p] += 1
b =  [y for x, y in zip(a, b) if x]
print(len(b), sum(b))
Buggy code:
N,M=map(int,input().split())
if M==0:
  print(0,0)
ac = [0]*N
score=0
mis=0
for i in range(M):
  p,s = input().split()
  p=int(p)
  if s =="AC":
    if ac[p-1]==0:
      ac[p-1] = 1
      score += 1
  else:
    
    if ac[p-1] == 0:
      mis += 1
print(score,mis)

    
  




Fixed code:
N,M=map(int,input().split())
if M==0:
  print(0,0)
else:
  ac = [0]*N
  wa = [0]*N
  score=0
  mis=0
  for i in range(M):
    p,s = input().split()
    p=int(p)
    if s =="AC":
      if ac[p-1]==0:
        ac[p-1] = 1
        score += 1
    else:
    
      if ac[p-1] == 0:
        wa[p-1] += 1
  
  
  for i in range(N):
    if ac[i-1] == 1:
      mis += wa[i-1]
  print(score,mis)
Buggy code:
n, m = map(int,input().split())

aclist = []
ac = 0
wac = 0
count = [0 for x in range(n+1)]

for i in range(m):
  a , b = input().split()
  int(a)
  if n >= 0:
    if n == "AC":
      ac += 1
      wac += count[a]
      count[a] = -1
    else:
      count[a] += 1

print(ac, wac)

Fixed code:
n, m = map(int,input().split())

ac = 0
wac = 0
count = [0 for x in range(n+1)]

for i in range(m):
  a , b = input().split()
  c = int(a)
  if count[c] >= 0:
    if b == "AC":
      ac += 1
      wac += count[c]
      count[c] = -1
    else:
      count[c] += 1

print(ac, wac)
Buggy code:
N,M = list(map(int,input().split()))
p = []
for i in range(M):
    x,y = list(map(str, input().split()))
    p.append([int(x),y])
count = [[0,0]for i in range(M)]
ansac = 0
answa = 0
for i in range(M):
    if count[p[i][0]-1][1] != 0:
        pass
    else:
        if p[i][1] == 'AC':
            count[p[i][0]-1][1] += 1
        else:
            count[p[i][0]-1][0] += 1
for i in range(N):
    answa += count[i][0]
    ansac += count[i][1]
print(str(ansac) + ' ' + str(answa))

Fixed code:
N,M = list(map(int,input().split()))
p = []
for i in range(M):
    x,y = list(map(str, input().split()))
    p.append([int(x),y])
count = [[0,0]for i in range(N)]
ansac = 0
answa = 0
for i in range(M):
    if count[p[i][0]-1][1] != 0:
        pass
    else:
        if p[i][1] == 'AC':
            count[p[i][0]-1][1] += 1
        else:
            count[p[i][0]-1][0] += 1
for i in range(N):
    if count[i][1] > 0:
        answa += count[i][0]
    ansac += count[i][1]
print(str(ansac) + ' ' + str(answa))
Buggy code:
n,m=map(int,input().split())
wa=0
hoge=[0 for i in range(n)]
huga=[0 for i in range(n)]
for i in range(m):
  a,b=map(str,input().split())
  if(hoge[int(a)-1]==0 and b=="AC"):
    hoge[int(a)-1]=1
  if(hoge[int(a)-1]==0 and b=="WA"):
    huga[int(a)-1]=1
    
for i in range(n):
  if(hoge[i]==0):
    huga=0
    
print(sum(hoge),sum(huga))

Fixed code:
n,m=map(int,input().split())
hoge=[0 for i in range(n)]
huga=[0 for i in range(n)]
for i in range(m):
  a,b=map(str,input().split())
  if(hoge[int(a)-1]==0 and b=="AC"):
    hoge[int(a)-1]=1
  if(hoge[int(a)-1]==0 and b=="WA"):
    huga[int(a)-1]+=1
    
for i in range(n):
  if(hoge[i]==0):
    huga[i]=0
    
print(sum(hoge),sum(huga))
Buggy code:
N,M= map(int,input().split())

tempP = ""
ac = []
wa = []

for count in range(N):
    ac.append(0)
    wa.append(0)

for count in range(M):
    P,S = input().split()
    P = int(P)
    P -= 1
    
    if ac[P] == 0:
        if S == "AC":
            ac[P] = 1
        else:
            wa[P] +=1



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

    

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

tempP = ""
ac = []
wa = []

for count in range(N):
    ac.append(0)
    wa.append(0)

for count in range(M):
    P,S = input().split()
    P = int(P)
    P -= 1
    
    if ac[P] == 0:
        if S == "AC":
            ac[P] = 1
        else:
            wa[P] +=1



a = 0
b = 0
 
for i in range(N):
    if ac[i] == 1:
        a += 1
        b += wa[i]
 
print(*[a, b])
Buggy code:
import numpy as np

def main():
    # N, M = map(int, input().split())
    # PS = {}
    # for i in range(M):
    #     row = input().split()
    #     row[0] = int(row[0])
    #     if row[0] not in PS:
    #         PS[row[0]] = [row[1]]
    #     else:
    #         PS[row[0]].append(row[1])

    # n_correct = 0
    # n_penalty = 0
    # for p in PS:
    #     if 'AC' in PS[p]:
    #         n_correct += 1
    #         for result in PS[p]:
    #             if result == 'AC':
    #                 break
    #             if result == 'WA':
    #                 n_penalty += 1
    
    # print('{} {}'.format(n_correct, n_penalty))

    N, M = map(int, input().split())
    accepted = [False] * N
    penalties = [0] * N
    for _ in range(M):
        q, res = input().split()
        q = int(q) - 1
        if res[0] == 'A':
            accepted[q] = True
        else:
            penalties[q] += 1

    s_acc = 0
    s_pen = 0
    for i in range(N):
        if accepted[i]:
            s_acc += 1
            s_pen += penalties[i]

    print('{} {}'.format(s_acc, s_pen))
    

if __name__ == '__main__':
    main()

Fixed code:
import numpy as np

def main():
    # N, M = map(int, input().split())
    # PS = {}
    # for i in range(M):
    #     row = input().split()
    #     row[0] = int(row[0])
    #     if row[0] not in PS:
    #         PS[row[0]] = [row[1]]
    #     else:
    #         PS[row[0]].append(row[1])

    # n_correct = 0
    # n_penalty = 0
    # for p in PS:
    #     if 'AC' in PS[p]:
    #         n_correct += 1
    #         for result in PS[p]:
    #             if result == 'AC':
    #                 break
    #             if result == 'WA':
    #                 n_penalty += 1
    
    # print('{} {}'.format(n_correct, n_penalty))

    N, M = map(int, input().split())
    accepted = [False] * N
    penalties = [0] * N
    for _ in range(M):
        q, res = input().split()
        q = int(q) - 1
        if res[0] == 'A':
            accepted[q] = True
        elif res[0] == 'W' and not accepted[q]:
            penalties[q] += 1

    s_acc = 0
    s_pen = 0
    for i in range(N):
        if accepted[i]:
            s_acc += 1
            s_pen += penalties[i]

    print('{} {}'.format(s_acc, s_pen))
    

if __name__ == '__main__':
    main()
Buggy code:
n, m = [int(x) for x in input().split()]
nac = 0
nwa = 0
past_ac = {}
for i in range(m):
    p, s = [x for x in input().split()]
    d = p + s
    if (p + 'AC') in past_ac:
        next
    else:
        if s == 'WA':
            past_ac[d] = 1 if d not in past_ac else past_ac[d] + 1
        else:
            past_ac[d] = 1
            nac += 1
            nwa += past_ac[p + 'WA']
print(nac, nwa)

Fixed code:
n, m = [int(x) for x in input().split()]
nac = 0
nwa = 0
past = {}
for i in range(m):
    p, s = [x for x in input().split()]
    d = p + s
    if (p + 'AC') in past:
        next
    else:
        if s == 'WA':
            past[d] = 1 if d not in past else past[d] + 1
        else:
            past[d] = 1
            nac += 1
            nwa += 0 if (p + 'WA') not in past else past[p + 'WA']
print(nac, nwa)
Buggy code:
N, M = map(int, input().split())
ac = 0
wa = 0
arr = [0] * N
if M == 0:
  print(0)
  exit()
  
for i in range(M):
  p, s = list(input().split())
  p = int(p)
  if arr[p-1] != "AC":
    if s == "AC":
      arr[p-1] = "AC"
      ac += 1
    else:
      wa += 1
print(ac, wa)
    

Fixed code:
N, M = map(int, input().split())
ac = 0
wa = 0
arr = [0] * N
if M == 0:
  print("0 0")
  exit()
  
for i in range(M):
  p, s = list(input().split())
  p = int(p)
  if arr[p-1] != "AC":
    if s == "AC":
      wa += arr[p-1]
      arr[p-1] = "AC"
      ac += 1
    else:
      arr[p-1] += 1
print(ac, wa)
Buggy code:
N,M = map(int,input().split())

judge = [False]*N
WAcnt = [0] * N
ACcnt = 0
for i in range(M):
    p,S = (x for x in input().split())
    p = int(p)
    if judge[p-1] == False:
        if S == "AC":
            judge[p-1] = True
            ACcnt += 1
        else:
            WAcnt[p-1] += 1

WAans = 0
for i in range(N):
    if judge[p-1] == True:
        WAans += WAans[p-1]

print(ACcnt,WAans)

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

judge = [False]*N
WAcnt = [0] * N
ACcnt = 0
for i in range(M):
    p,S = (x for x in input().split())
    p = int(p)
    if judge[p-1] == False:
        if S == "AC":
            judge[p-1] = True
            ACcnt += 1
        else:
            WAcnt[p-1] += 1

WAans = 0
for i in range(N):
    if judge[i] == True:
        WAans += WAcnt[i]

print(ACcnt,WAans)
Buggy code:
n,m = map(int,input().split())
pS = [list(input().split()) for i in range(m)]

for _ in range(m) :
    pS[_][0] = int(pS[_][0])

ac = [0]*n
wa = [0]*n

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

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


Fixed code:
n,m = map(int,input().split())
pS = [list(input().split()) for i in range(m)]

for _ in range(m) :
    pS[_][0] = int(pS[_][0])

ac = [0]*n
wa = [0]*n

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

awa=0
for i in range(n) :
    if ac[i] == 1 :
        awa += wa[i]

print(sum(ac),awa)