qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N,M=map(int,input().split())
AC =[0]*(N+1)
WA =[0]*(N+1)

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

for m in range(N+1):
    if AC[m]==0:
        WA[m]=0
print(sum(WA),sum(AC))

Fixed code:
N,M=map(int,input().split())
AC =[0]*(N+1)
WA =[0]*(N+1)

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

for m in range(N+1):
    if AC[m]==0:
        WA[m]=0
print(sum(AC),sum(WA))
Buggy code:
n, m=map(int, input().split())
a=set()
d={}
pena=0
for i in range(m):
    p, s=input().split()
    if s=="AC":
        a.add(int(p))
        pena+=d.pop(p)
    else:
        if p in d:
            d[p]+=1
        else:
            d[p]=1
print(len(a), pena)


Fixed code:
n, m=map(int, input().split())
a=set()
d={}
pena=0
for i in range(m):
    p, s=input().split()
    if s=="AC" and int(p) not in a:
        a.add(int(p))
        if p in d:
            pena+=d.pop(p)
    else:
        if p in d:
            d[p]+=1
        else:
            d[p]=1
print(len(a), pena)
Buggy code:

if __name__ == "__main__":
    H, W = [int(s) for s in input().split()]



    accepted = [False] * N
    penalties = [0] * N
    for _ in range(M):
        p, S = input().split()
        p = int(p)
        # S = 'AC' or 'WA'
        if S == "AC":
            accepted[p - 1] = True
        if S == "WA" and not accepted[p - 1]:
            penalties[p - 1] += 1

    N_accepted = len([a for a in accepted if a])
    sum_penalties = sum([p for p, a in zip(penalties, accepted) if a])
    print(N_accepted, sum_penalties)

Fixed code:
if __name__ == "__main__":
    N, M = [int(s) for s in input().split()]
    accepted = [False] * N
    penalties = [0] * N
    for _ in range(M):
        p, S = input().split()
        p = int(p)
        # S = 'AC' or 'WA'
        if S == "AC":
            accepted[p - 1] = True
        if S == "WA" and not accepted[p - 1]:
            penalties[p - 1] += 1

    N_accepted = len([a for a in accepted if a])
    sum_penalties = sum([p for p, a in zip(penalties, accepted) if a])
    print(N_accepted, sum_penalties)
Buggy code:
n, m = map(int, input().split())
p = []
s = []
for i in range(m):
    p_i, s_i = input().split()
    p.append(int(p_i))
    s.append(b)


res = [0]*n
correct = 0
penalty = 0
for i in range(m):
    no = p[i] - 1
    if res[no] == 1:
        continue
    elif s[i] == 'WA':
        penalty += 1
    elif s[i] == 'AC':
        correct += 1
        res[no] = 1

print(correct, penalty)

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

correct = [0]*n
penalty = [0]*n

for i in range(m):
    no = p[i]
    if correct[no-1] == 1:
        continue
    elif s[i] == 'WA':
        penalty[no-1] += 1
    elif s[i] == 'AC':
        correct[no-1] = 1

pen = 0
for i in range(n):
    if correct[i] == 1:
        pen += penalty[i]
print(sum(correct), pen)
Buggy code:
N, M=map(int,input().split())
 
ans=[0]*N
pena=[0]*N
AC=[0]*N
 
for i in range(M):
    p,s=input().split()
    p=int(p)
    if s=="WA":
        pena[p-1]+=1
        print(pena)
    else:
        if AC[p-1]==0:
            ans[p-1]+=pena[p-1]
        AC[p-1]=1
        print(AC)
 
print(AC.count(1),sum(ans))

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

ans=[0]*N
pen=[0]*N
AC=[0]*N

for i in range(M):
    p,s=input().split()
    p=int(p)
    if s=="WA":
        pen[p-1]+=1
    else:
        if AC[p-1]==0:
            ans[p-1]+=pen[p-1]
        AC[p-1]=1

print(AC.count(1),sum(ans))
Buggy code:
N, M = map(int, input().split())

if M == 0 or N == 0:
    print("{} {}".format(0, 0))
else:

    p = [0]*M
    S = [0]*M

    for i in range(M):
        tmp = input().split()
        p[i] = int(tmp[0])
        S[i] = tmp[1]

    penalty = 0


    correct_set = set()
    for i in range(M):
        if S[i] == 'AC':
            correct_set.add(p[i])

    correct = len(correct_set)

    for i in range(M):
        if S[i] == 'AC':
            correct_set.remove(p[i])
        elif S[i] == 'WA' and p[i] in correct_set:
            penalty += 1


            

    print("{} {}".format(correct, penalty))

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

if M == 0 or N == 0:
    print("{} {}".format(0, 0))
else:

    p = [0]*M
    S = [0]*M

    for i in range(M):
        tmp = input().split()
        p[i] = int(tmp[0])
        S[i] = tmp[1]

    penalty = 0


    correct_set = set()
    for i in range(M):
        if S[i] == 'AC':
            correct_set.add(p[i])

    correct = len(correct_set)

    for i in range(M):
        if S[i] == 'AC' and p[i] in correct_set:
            correct_set.remove(p[i])
        elif S[i] == 'WA' and p[i] in correct_set:
            penalty += 1


            

    print("{} {}".format(correct, penalty))
Buggy code:
n,m=map(int,input().split())
AC = [0] * n
WA = [0] * n

for i in range(m):
    x = input().split()
    num = int(x[0]) - 1
    if x[1]=='AC':
        AC[num]+=1
    elif x[1]=='WA' and AC[num]==0:
        WA[num]+=1
print(sum(AC), sum([w for i, w in enumerate(WA) if AC[i]]))

Fixed code:
n,m=map(int,input().split())
AC = [0] * n
WA = [0] * n

for i in range(m):
    x = input().split()
    num = int(x[0]) - 1
    if x[1]=='AC':
        AC[num]=1
    elif x[1]=='WA' and AC[num]==0:
        WA[num]+=1
        
print(sum(AC), sum([w for i, w in enumerate(WA) if AC[i]]))
Buggy code:
n, m = map(int, input().split())
ac = [0]*n
wa = [0]*n
a = 0
w = 0
for i in range(m):
  p, s = input().split()
  p = int(p)-1
  if ac[p] == 0, s == "AC":
    acs[p] += 1
    a += 1
    w += was[p] 
  elif ac[p] == 0, s == "WA":
    was[p] += 1
print(a,w)

Fixed code:
n, m = map(int, input().split())
ac = [0]*n
wa = [0]*n
a = 0
w = 0
for i in range(m):
  p, s = input().split()
  p = int(p)-1
  if ac[p] == 0 and s == "AC":
    ac[p] += 1
    a += 1
    w += wa[p] 
  elif ac[p] == 0 and s == "WA":
    wa[p] += 1
print(a,w)
Buggy code:
from collections import defaultdict

params = input().split()
n = int(params[0])
m = int(params[1])

penaltyCount = dict()
penaltyCount = defaultdict(lambda: 0, penaltyCount)

correct = 0
penalty = 0

for i in range(m):
    submission = input.split()
    p = int(submission[0]) - 1
    status = submission[1]

    if penaltyCount[p] == -1:
        continue
    if status == "WA":
        penaltyCount[p] += 1
    else:
        penalty += penaltyCount[p]
        penaltyCount[p] = -1
        correct += 1

print(str(correct) + " " + str(penalty))



Fixed code:
from collections import defaultdict

params = input().split()
n = int(params[0])
m = int(params[1])

penaltyCount = dict()
penaltyCount = defaultdict(lambda: 0, penaltyCount)

correct = 0
penalty = 0

for i in range(m):
    submission = input().split()
    p = int(submission[0]) - 1
    status = submission[1]

    if penaltyCount[p] == -1:
        continue
    if status == "WA":
        penaltyCount[p] += 1
    else:
        penalty += penaltyCount[p]
        penaltyCount[p] = -1
        correct += 1

print(str(correct) + " " + str(penalty))
Buggy code:
NM = input().split()
N = int(NM[0])
M = int(NM[1])
prob = []
probStatus = []
for i in range(M):
    pS = input().split()
    prob.append(int(pS[0]))
    probStatus.append(pS[1])
correct = 0
penalty = 0
submissions = [''] * N
for i in range(M):
    if probStatus[i] == 'AC' and submissions[prob[i] - 1] == '':
        correct += 1
        submissions[prob[i] - 1] = 'AC'
    elif probStatus[i] == 'AC' and submissions[prob[i] - 1] == 'AC':
        correct += 1
    elif probStatus[i] == 'WA' and submissions[prob[i] - 1] == '':
        penalty += 1
print(correct, penalty)


Fixed code:
NM = input().split()
N = int(NM[0])
M = int(NM[1])
prob = []
probStatus = []
for i in range(M):
    pS = input().split()
    prob.append(int(pS[0]))
    probStatus.append(pS[1])
correctAr = [0] * N
penaltyAr = [0] * N
submissions = [''] * N
for i in range(M):
    if probStatus[i] == 'AC' and submissions[prob[i] - 1] == '':
        correctAr[prob[i] - 1] += 1
        submissions[prob[i] - 1] = 'AC'
    elif probStatus[i] == 'WA' and submissions[prob[i] - 1] == '':
        penaltyAr[prob[i] - 1] += 1
correct = 0
penalty = 0
for i in range(N):
    if submissions[i] == 'AC':
        correct += correctAr[i]
        penalty += penaltyAr[i]

print(correct, penalty)
Buggy code:
n, m = map(int, input().split())
ans_ac = 0
ans_wa = 0
lst = [[False, 0]] * n
for i in range(m):
  p, s = input().split()
  p = int(p)
  if lst[p-1][0]:
    continue
  if s == 'WA':
    lst[p-1][1] += 1
  else:
    ans_ac += 1
    ans_wa += lst[p-1][1]
    lst[p-1][0] = True
print(ans_ac, ans_wa)


Fixed code:
n, m = map(int, input().split())
ans_ac = 0
ans_wa = 0
lst = []
for i in range(n):
  lst.append([False, 0])
for i in range(m):
  p, s = input().split()
  p = int(p) - 1
  if lst[p][0]:
    continue
  if s == 'WA':
    lst[p][1] += 1
  else:
    ans_ac += 1
    ans_wa += lst[p][1]
    lst[p][0] = True
print(ans_ac, ans_wa)
Buggy code:
n,m = map(int, input().split())
la = []
lw = []
lwa = []
for i in range(n):
  la.append(0)
  lw.append(0)
  lwa.append(0)
for _ in range(m):
  q,a = input().split()
  if a == "WC" and la[int(q)-1] != 1:
    lw[int(q)-1] += 1
  elif a == "AC" and la[int(q)-1] != 1:
    la[int(q)-1] = 1
    lwa[int(q)-1] = lw[int(q)-1]
    
print(sum(la), sum(lwa))

Fixed code:
n,m = map(int, input().split())
la = []
lw = []
lwa = []
for i in range(n):
  la.append(0)
  lw.append(0)
  lwa.append(0)
for _ in range(m):
  q,a = input().split()
  if a == "WA" and la[int(q)-1] != 1:
    lw[int(q)-1] += 1
  elif a == "AC" and la[int(q)-1] != 1:
    la[int(q)-1] = 1
    lwa[int(q)-1] = lw[int(q)-1]
    
print(sum(la), sum(lwa))
Buggy code:
n,m = map(int,input().split())
L = [0]*n
ans = 0
penalty = 0
for i in range(m):
  p,q = input().split()
  if q == 'AC':
    if L[int(p)-1] == 0:
      L[int(p)-1] = 1
    ans += 1
  else:
    if L[int(p)-1] == 0:
      penalty += 1
print(ans,penalty)

Fixed code:
n,m = map(int,input().split())
L = [0]*n
penalty = [0]*n
ans = 0
out = 0
for i in range(m):
  p,q = input().split()
  if q == 'AC':
    if L[int(p)-1] == 0:
      L[int(p)-1] = 1
      ans += 1
  else:
    if L[int(p)-1] == 0:
      penalty[int(p)-1] += 1
for i in range(n):
  if L[i] == 1:
    out += penalty[i]
print(ans,out)
Buggy code:
n, m = input().split(" ")
score_dict = {}
 
for i in range(m):
    p, s = input().split(" ")
    if p not in score_dict:
        score_dict[p] = []
    
    score_dict[p].append(s)
 
ac_count = 0
wa_count = 0
 
for i in score_dict.values():
    if "AC" in i:
        ac_count += 1
    
    wa_count += len(i[:i.index("AC")])
 
print("{0} {1}".format(ac_count, wa_count))

Fixed code:
n, m = [int(i) for i in input().split(" ")]
score_dict = {}
 
for i in range(m):
    p, s = input().split(" ")
    if p not in score_dict:
        score_dict[p] = []
    
    score_dict[p].append(s)
 
ac_count = 0
wa_count = 0
 
for i in score_dict.values():

    if "AC" in i:
        ac_count += 1
        wa_count += i.index("AC")
 
print("{0} {1}".format(ac_count, wa_count))
Buggy code:
ps = [list(input().split()) for _ in range(m)]
aw = ["WA"] * n
ac = 0
wa = 0
for i in ps:
    if i[1] == "WA":
        if aw[int(i[0])-1] == "WA":
            wa += 1
        else:
            pass
    else:
        if aw[int(i[0])-1] =="WA":
            ac += 1
            aw[int(i[0])-1] = "AC"
        else:
            pass
print(ac,wa)

Fixed code:
n,m = map(int,input().split())
ps = [list(input().split()) for _ in range(m)]
aw = ["WA"] * n
wacnt = [0] * n
ac = 0
wa = 0
for i in ps:
    if aw[int(i[0])-1] == "WA":
        if i[1] == "AC":
            ac += 1
            wa += wacnt[int(i[0])-1]
            aw[int(i[0])-1] = "AC"
        else:
            wacnt[int(i[0])-1] += 1
    else:
        pass
print(ac,wa)
Buggy code:
n, m = map(int, input().split())
ac = [0 for _ in range(n)]
pen = [0 for _ in range(n)]

for _ in range(m):
  p, s = input().split()
  p = int(p) - 1
  if s == 'WA':
    if ac[p] == 0:
      pen[p] += 1
  else:
    ac[p] = 1

for p in range(m):
  if ac[p] == 0:
    pen[p] = 0
print(str(sum(ac)) + ' ' + str(sum(pen)))

Fixed code:
n, m = map(int, input().split())
ac = [0 for _ in range(n)]
pen = [0 for _ in range(n)]

for _ in range(m):
  p, s = input().split()
  p = int(p) - 1
  if s == 'WA':
    if ac[p] == 0:
      pen[p] += 1
  else:
    ac[p] = 1

for p in range(n):
  if ac[p] == 0:
    pen[p] = 0
print(str(sum(ac)) + ' ' + str(sum(pen)))
Buggy code:
n,m = map(int,input().split())
da = [map(str,input().split()) for i in range(m)]
penalty = [0 for i in range(n)]
accepted = [False for i in range(n)]
for i in range(m):
  now = int(da[i][0])
  if da[i][1] == 'AC':
    accepted[now] = True
  elif not accepted[now]:
    penalty[now] += 1
AC,WA = 0,0
for i in range(n):
  if accepted[i]:
    AC += 1
    WA += penalty[i]
print(AC,WA)
    

Fixed code:
n,m = map(int,input().split())
da = [list(map(str,input().split())) for i in range(m)]
penalty = [0 for i in range(n)]
accepted = [False for i in range(n)]
for i in range(m):
  now = int(da[i][0]) - 1
  if da[i][1] == 'AC':
    accepted[now] = True
  elif not accepted[now]:
    penalty[now] += 1
AC,WA = 0,0
for i in range(n):
  if accepted[i]:
    AC += 1
    WA += penalty[i]
print(AC,WA)
Buggy code:
N, M = map(int, input().split())
AC = [0]*(N+1)
WA = [0]*(N+1)

for i in range (0, M):
    A, B = map(str, input().split())
    A = int(A)
    if B == 'WA':
        if AC[A] == 0:
            WA[A]+=1
    else:
        if AC[A] == 0:
            AC[A] = 1

Wronganswer = 0
for i in range (0, N):
    Wronganswer+=(AC[i]*WA[i])
print(sum(AC), Wronganswer)

Fixed code:
N, M = map(int, input().split())
AC = [0]*(N+1)
WA = [0]*(N+1)

for i in range (0, M):
    A, B = map(str, input().split())
    A = int(A)
    if B == 'WA':
        if AC[A] == 0:
            WA[A]+=1
    else:
        if AC[A] == 0:
            AC[A] = 1

Wronganswer = 0
for i in range (0, N+1):
    Wronganswer+=(AC[i]*WA[i])
print(sum(AC), Wronganswer)
Buggy code:
n, m = map(int,input().split())
q = [0 for i in range(n)]
alist = []
ac = 0
pe = 0
be = be
for i in range(m):
    a,b=input().split()
    alist.append((int(a), b))
for i in range(m):
    if q[alist[i][0]-1] == 0:
        if alist[i][1] == 'AC':
            ac += 1
            be = be + pe
            q[alist[i][0]-1] = 1
        else:
            pe += 1
    else:
        continue
print(ac,be)

Fixed code:
n, m = map(int,input().split())
q = [0 for i in range(n)]
alist = []
ac = 0
pe = [0 for i in range(n)]
be = 0
for i in range(m):
    a,b=input().split()
    alist.append((int(a), b))
for i in range(m):
    if q[alist[i][0]-1] == 0:
        if alist[i][1] == 'AC':
            ac += 1
            be = be + pe[alist[i][0]-1]
            q[alist[i][0]-1] = 1
        else:
            pe[alist[i][0]-1] +=  1
    else:
        continue
print(ac,be)
Buggy code:
N, M = map(int, input().split())
A = [input().split() for _ in range(M)]

c = [0]*N
w = [0]*M

ac = 0
wa = 0

for i, v in A:
    if c[int(i)-1] == 0:
        if v == 'WA':
            w[int(i)-1] += 1
        elif v == 'AC':
            ac += 1
            wa += w[int(i)-1]
            c[int(i)-1] = 1

print(ac, wa)

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

c = [0]*N
w = [0]*N

ac = 0
wa = 0

for i, v in A:
    if c[int(i)-1] == 0:
        if v == 'WA':
            w[int(i)-1] += 1
        elif v == 'AC':
            ac += 1
            wa += w[int(i)-1]
            c[int(i)-1] = 1

print(ac, wa)
Buggy code:
n, m = map(int, input().split(' '))

pena = [0 for i in range(n)]
acc = [0 for i in range(n)]

for i in range(m):
    pp, ss = input().split(' ')
    p = int(pp) - 1

    if acc[p] == 0:
        if ss == 'WA':
            pena[p] += 1
        else:
            acc[p] = 1

for i in range(m):
    pena[i] = pena[i] * acc[i]

print(sum(acc), sum(pena))

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

pena = [0 for i in range(n)]
acc = [0 for i in range(n)]

for i in range(m):
    pp, ss = input().split(' ')
    p = int(pp) - 1

    if acc[p] == 0:
        if ss == 'WA':
            pena[p] += 1
        else:
            acc[p] = 1

for i in range(n):
    pena[i] = pena[i] * acc[i]

print(sum(acc), sum(pena))
Buggy code:
N, M = map(int, input().split())
l = [[] for i in range(N)]
old_p = 0
for i in range(M):
    tmp = list(input().split())
    # if tmp[0] != str(old_p + 1):
    #     old_p += 1
    # l[old_p].append(tmp[1])
    l[int(tmp[0]) - 1].append(tmp[1])
ac = 0
wa = 0
print(l)
for i in range(N):
    wa_tmp = 0
    for j in range(len(l[i])):
        if l[i][j] == 'WA':
            wa_tmp += 1
        else:
            ac += 1
            wa += wa_tmp
            break
print('{} {}'.format(ac, wa))

Fixed code:
N, M = map(int, input().split())
l = [[] for i in range(N)]
old_p = 0
for i in range(M):
    tmp = list(input().split())
    # if tmp[0] != str(old_p + 1):
    #     old_p += 1
    # l[old_p].append(tmp[1])
    l[int(tmp[0]) - 1].append(tmp[1])
ac = 0
wa = 0
#print(l)
for i in range(N):
    wa_tmp = 0
    for j in range(len(l[i])):
        if l[i][j] == 'WA':
            wa_tmp += 1
        else:
            ac += 1
            wa += wa_tmp
            break
print('{} {}'.format(ac, wa))
Buggy code:
from collections import defaultdict as dic
n, m = map(int, input().split())
ac = 0
pena = 0
d = dic(list)
for i in range(m):
    pi, si = input().split()
    d[pi].append(si)


print(d)
for (k, v) in d.items():
    pe = 0
    flag = False
    for aw in v:
        if aw == 'WA':
            pe += 1
        else:
            ac += 1
            flag = True
            break

    if flag:
        pena += pe

print(ac, pena)


Fixed code:
from collections import defaultdict as dic
n, m = map(int, input().split())
ac = 0
pena = 0
d = dic(list)
for i in range(m):
    pi, si = input().split()
    d[pi].append(si)

for (k, v) in d.items():
    pe = 0
    flag = False
    for aw in v:
        if aw == 'WA':
            pe += 1
        else:
            ac += 1
            flag = True
            break

    if flag:
        pena += pe

print(ac, pena)
Buggy code:
N, M = [int(s) for s in input().split(' ')]
ac = 0
wa = 0
result = dict()
fail = dict()
for m in range(M):
    p, s = input().split(' ')
    if p in result and result[p] == 'AC':
        continue
    if s == 'WA':
        fail[p] = fail.get(p, 0) + 1
        result[p] = s
    elif s == 'AC': # AC
        ac += 1
        wa += fail[p]
        result[p] = s
    
print(str(ac) + ' ' + str(wa))


Fixed code:
N, M = [int(s) for s in input().split(' ')]
ac = 0
wa = 0
result = dict()
fail = dict()
for m in range(M):
    p, s = input().split(' ')
    if p in result and result[p] == 'AC':
        continue
    if s == 'WA':
        fail[p] = fail.get(p, 0) + 1
        result[p] = s
    elif s == 'AC': # AC
        ac += 1
        wa += fail.get(p, 0) 
        result[p] = s
    
print(str(ac) + ' ' + str(wa))
Buggy code:
N,M=map(int,input().split())
if M==0:
  print('0 0')
AC=[0]*(N+1)
WA=[0]*(N+1)
for i in range(M):
  p,s=map(str,input().split())
  if s=='AC':
    key=int(p)
    AC[key]+=1
  elif s=='WA' and AC[int(p)]==0:
    WA[int(p)]+=1
for i in range(N+1):
  if AC[i]==0:
    WA[i]=0
ansc=AC.count(0)
ANSC=len(AC)-ansc
ANSW=sum(WA)
print(ANSC,ANSW)

Fixed code:
N,M=map(int,input().split())
if M==0:
  print('0 0')
  exit()
AC=[0]*(N+1)
WA=[0]*(N+1)
for i in range(M):
  p,s=map(str,input().split())
  if s=='AC':
    key=int(p)
    AC[key]+=1
  elif s=='WA' and AC[int(p)]==0:
    WA[int(p)]+=1
for i in range(N+1):
  if AC[i]==0:
    WA[i]=0
ansc=AC.count(0)
ANSC=len(AC)-ansc
ANSW=sum(WA)
print(ANSC,ANSW)
Buggy code:
N,M = input().split()
l = [0]*int(N) #flg
m = [0]*int(N) #counter
c =0

for i in range(int(M)+1):
    p,s = input().split()
    if s =="AC":
        if l[int(p)-1]==1:
            pass
        else:
            l[int(p)-1] = 1
            c += m[int(p)-1]
    elif s == "WA":
        m[int(p)-1] += 1



print(l.count(1),c)





Fixed code:
N,M = input().split()
l = [0]*int(N) #flg
m = [0]*int(N) #counter
c =0

for i in range(int(M)):
    p,s = input().split()
    if s =="AC":
        if l[int(p)-1]==1:
            pass
        else:
            l[int(p)-1] = 1
            c += m[int(p)-1]
    elif s == "WA":
        m[int(p)-1] += 1



print(l.count(1),c)
Buggy code:
n, m = map(int, input().split())
l = list("")
ac, wa = 0, 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if l[p - 1] != -1 and s == "AC":
        ac += 1
        wa += l[p - 1]
        l[p - 1] = -1
    if l[p - 1] != -1 and s == "WA":
        l[p - 1] += 1
print(ac, wa)

Fixed code:
n, m = map(int, input().split())
l = [0] * n
ac, wa = 0, 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if l[p - 1] != -1 and s == "AC":
        ac += 1
        wa += l[p - 1]
        l[p - 1] = -1
    if l[p - 1] != -1 and s == "WA":
        l[p - 1] += 1
print(ac, wa)
Buggy code:
n,m=map(int,input().split())
d=[ input().split() for i in range(m)]
ans=[[0,0] for i in range(m+n+1)]
count=0
ac=0
wa=0

for i in range(m):
  if count!=d[i][0]:
    if ans[count][0]==0 and ans[count][1]>=1:
      ans[count][1]=0
    count=int(d[i][0])
  if d[i][1]=="WA" and ans[count][0]==0:
    ans[count][1]+=1
  elif d[i][1]=="AC" and ans[count][0]==0:
    ans[count][0]+=1
if ans[count][0]==0 and ans[count][1]>=1:
      ans[count][1]=0
for i in range(n+m+1):
  ac+=int(ans[i][0])
  wa+=int(ans[i][1])
print(ac,wa)

Fixed code:
n,m=map(int,input().split())
d=[ input().split() for i in range(m)]
ans=[[0,0] for i in range(m+n+1)]
count=0
ac=0
wa=0

for i in range(m):
  if count!=d[i][0]:
    count=int(d[i][0])
  if d[i][1]=="WA" and ans[count][0]==0:
    ans[count][1]+=1
  elif d[i][1]=="AC" and ans[count][0]==0:
    ans[count][0]+=1
for i in range(n+m+1):
  ac+=int(ans[i][0])
  if int(ans[i][0])>=1:
    wa+=int(ans[i][1])
print(ac,wa)
Buggy code:
n,m=map(int,input().split())
a=[-1]*(10**5)
for i in range(m):
	p,s=input().split()
	p=int(p)
	if s=="AC" and a[p]<0:
		a[p] = a[p]*(-1)
	if s=="WA" and a[p]<0:
		a[p] -= 1
ac=0
wa=0
for i in range(m):
	if a[i] > 0:
		ac += 1
		wa += a[i] - 1

print(ac,wa)		

Fixed code:
n,m=map(int,input().split())
a=[-1]*n
for i in range(m):
	p,s=input().split()
	p=int(p)-1
	if s=="AC" and a[p]<0:
		a[p] = a[p]*(-1)
	if s=="WA" and a[p]<0:
		a[p] -= 1
ac=0
wa=0
for i in range(n):
	if a[i] > 0:
		ac += 1
		wa += a[i] - 1

print(ac,wa)
Buggy code:
N,M = map(int,input().split())
PS = [list(map(str,input().split())) for i in range(M)]
A_num = [0]*N
w=0
print(PS)
for j in range(M):
    print(A_num)
    if PS[j][1] == 'WA'and A_num[int(PS[j][0])-1]==0:
        w+=1
    if PS[j][1]== 'AC' and A_num[int(PS[j][0])-1]==0:
        A_num[int(PS[j][0])-1] =1
s = sum(A_num)
print(s,w)

Fixed code:
N,M = map(int,input().split())
PS = [list(map(str,input().split())) for i in range(M)]
A_num = [0]*N
W_num = [0]*N
w=0
#print(PS)
for j in range(M):
    #print(A_num)
    if PS[j][1] == 'WA'and A_num[int(PS[j][0])-1]==0:
        W_num[int(PS[j][0])-1]+=1 
    if PS[j][1]== 'AC' and A_num[int(PS[j][0])-1]==0:
        A_num[int(PS[j][0])-1]=1
s = sum(A_num)
for k in range(N):
    if A_num[k] == 0:
        W_num[k]=0
w = sum(W_num)
print(s,w)
Buggy code:
N,M=map(int,input().split())
AC={}
WA={}
for i in range(M):
    a,b=input().split()
    if not(a in AC.keys()):
        if b=="AC":
            AC[a]=1
        else:
            if a in WA.keys():
                WA[a]+=1
            else:
                WA[a]=1
y=0
for i in AC.keys():
    y+=WA[i]
print(sum(AC.values()),y)

Fixed code:
N,M=map(int,input().split())
AC={}
WA={}
for i in range(M):
    a,b=input().split()
    if not(a in AC.keys()):
        if b=="AC":
            AC[a]=1
        else:
            if a in WA.keys():
                WA[a]+=1
            else:
                WA[a]=1
y=0
for i in AC.keys():
    if i in WA.keys():
        y+=WA[i]
print(sum(AC.values()),y)