qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N, M=map(int, input().split())
solved=[False]*N
ac=0
wa=0
for _ in range(M):
  p, s=input().split()
  p=int(p)-1
  if solved[p]:
    continue
  if s=="AC":
    solved[p]=True
    ac+=1
  else:
    wa+=1
print(as, wa)  

Fixed code:
N, M=map(int, input().split())
solved=[False]*N
wal=[0]*N
ac=0
wa=0
for _ in range(M):
  p, s=input().split()
  p=int(p)-1
  if solved[p]:
    continue
  if s=="AC":
    solved[p]=True
    ac+=1
    wa+=wal[p]
  else:
    wal[p]+=1
print(ac, wa)
Buggy code:
n,m = map(int, input().split())
ac_list = [False]*(n+1)
pena_count = [0]*(n+1)
for i in range(m):
  p, s = map(int, input().split())
  if not ac_list[p]:
    if s == "AC":
      ac_list[p] = True
    else:
      pena_count[p] += 1
ac_count = 0
pena_c = 0
for i in range(1, n+1):
  if ac_list[i]:
    ac_count += 1
    pena_c += pena_count[i]
print(ac_count, pena_c)
      

Fixed code:
n,m = map(int, input().split())
ac_list = [False]*(n+1)
pena_count = [0]*(n+1)
for i in range(m):
  p, s = input().split()
  p = int(p)
  if not ac_list[p]:
    if s == "AC":
      ac_list[p] = True
    else:
      pena_count[p] += 1
ac_count = 0
pena_c = 0
for i in range(1, n+1):
  if ac_list[i]:
    ac_count += 1
    pena_c += pena_count[i]
print(ac_count, pena_c)
Buggy code:
# coding: utf-8


def main():
    N, M = map(int, input().split())
    ans = [0, 0]
    A = [[0, 0] for _ in range(N)]

    for i in range(M):
        p, s = input().split()
        p = int(p)
        if s == 'AC':
            A[p - 1][1] = 1
        elif A[p - 1][1] == 0:
            A[p - 1][0] += 1
    
    for i, j in A:
        if i == 1:
            ans[0] += 1
            ans[1] += j

    print(ans[0], ans[1])

if __name__ == "__main__":
    main()


Fixed code:
# coding: utf-8


def main():
    N, M = map(int, input().split())
    ans = [0, 0]
    A = [[0, 0] for _ in range(N)]

    for i in range(M):
        p, s = input().split()
        p = int(p)
        if s == 'AC':
            A[p - 1][1] = 1
        elif A[p - 1][1] == 0:
            A[p - 1][0] += 1
    
    for i, j in A:
        if j == 1:
            ans[0] += 1
            ans[1] += i

    print(ans[0], ans[1])

if __name__ == "__main__":
    main()
Buggy code:
N, M = map(int, input().split())
arr = [input().split() for i in range(M)]
s = [[0,0] for i in range(N)]
p = 0
a = 0
for i, j in arr:
    if j == 'AC':
        s[int(i)-1][0] = 1
    elif j == 'WA':
        if s[int(i)-1][0] == 1: # if done
            pass
        else:
            s[int(i)-1][1] += 1
print(s)
for i, j in s:
    if i == 1:
        p += j
        a += 1
print(a, p)


Fixed code:
N, M = map(int, input().split())
arr = [input().split() for i in range(M)]
s = [[0,0] for i in range(N)]
p = 0
a = 0
for i, j in arr:
    if j == 'AC':
        s[int(i)-1][0] = 1
    elif j == 'WA':
        if s[int(i)-1][0] == 1: # if done
            pass
        else:
            s[int(i)-1][1] += 1
for i, j in s:
    if i == 1:
        p += j
        a += 1
print(a, p)
Buggy code:
N, M = map(int, input().split())
A = [input().split() for i in range(M)]
problems = {}
reject_count = 0
for P, S in A:
    if not problems.get(P) and P <= N:
        if S != 'AC':
            reject_count += 1
        else:
            problems[P] = S
print(len(problems), reject_count)

Fixed code:
N, M = map(int, input().split())
A = [input().split() for i in range(M)]
problems = {}
rejected = [0]*(N+1)
reject_count = 0
for P, S in A:
    P = int(P)
    if not problems.get(P):
        if S != 'AC':
            rejected[P] += 1
        else:
            problems[P] = S
for i in range(N+1):
    if problems.get(i):
        reject_count += rejected[i]
print(len(problems), reject_count)
Buggy code:
n, m = [int(i) for i in input().split()]
ans = [input().split() for _ in range(m)]

is_ac = [0 for i in range(n)]
cnt_wa = [0 for i in range(n)]
for p, s in ans:
  p = int(p) - 1
  if is_ac[p]:
    continue
  if s == 'AC':
    is_ac[p] = 1
  else:
    cnt_wa[p] += 1

cor = sum(is_ac)
pena = 0
for c in is_ac:
  if c:
    pena += 1

print(cor, pena)

Fixed code:
n, m = [int(i) for i in input().split()]
ans = [input().split() for _ in range(m)]

is_ac = [0 for i in range(n)]
cnt_wa = [0 for i in range(n)]
for p, s in ans:
  p = int(p) - 1
  if is_ac[p]:
    continue
  if s == 'AC':
    is_ac[p] = 1
  else:
    cnt_wa[p] += 1

cor = sum(is_ac)
pena = 0
for p, c in enumerate(is_ac):
  if c:
    pena += cnt_wa[p]

print(cor, pena)
Buggy code:
#!/usr/bin/env python3

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

flag = [0 for _ in range(n)]
wa_num_list = [0 for _ in range(n)]

for i in range(m):
    p, s = list(map(str, input().split()))
    p = int(p)
    if flag[p-1] == 0:
        if s == "WA":
            wa_num_list[p-1] += 1
        else:
            flag[p-1] = 1

pen = 0
for i in range(m):
    if flag[i] == 1:
        pen += wa_num_list[i]

print(sum(flag), pen)


Fixed code:
#!/usr/bin/env python3

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

flag = [0 for _ in range(n)]
wa_num_list = [0 for _ in range(n)]

for i in range(m):
    p, s = list(map(str, input().split()))
    p = int(p)
    if flag[p-1] == 0:
        if s == "WA":
            wa_num_list[p-1] += 1
        else:
            flag[p-1] = 1

pen = 0
for i in range(n):
    if flag[i] == 1:
        pen += wa_num_list[i]

print(sum(flag), pen)
Buggy code:
n,m =map(int, input().split())
a =[list(input().split()) for i in range(m)]
ends = [0]*n
was = [0]*n
for num, kekka in a:
    num=int(num)-1
    if kekka=='AC':
        ends[num]=1
    else:
        if ends[num]!=1:
            was[num]+=1
for i in range(n):
    if end[i]==0:
        was[i]=0
print(sum(ends), sum(was))

Fixed code:
n,m =map(int, input().split())
a =[list(input().split()) for i in range(m)]
ends = [0]*n
was = [0]*n
for num, kekka in a:
    num=int(num)-1
    if kekka=='AC':
        ends[num]=1
    else:
        if ends[num]!=1:
            was[num]+=1
for i in range(n):
    if ends[i]==0:
        was[i]=0
print(sum(ends), sum(was))
Buggy code:
#input
N, M = map(int, input().split())
L = [[] for _ in range(N)]
for i in range(M):
    x, y = input().split()
    x = int(x)
    L[x-1].append(y)

#output
point = 0
penalty = 0
for i in range(N):
    if not "AC" in L[i]:
        break
    for j in range(len(L[i])):
        if L[i][j] == "WA":
            penalty += 1
        else:
            point += 1
            break

print(point, penalty, sep = " ")

Fixed code:
#input
N, M = map(int, input().split())
L = [[] for _ in range(N)]
for i in range(M):
    x, y = input().split()
    x = int(x)
    L[x-1].append(y)

#output
point = 0
penalty = 0
for i in range(N):
    if not "AC" in L[i]:
        continue
    else:
        for j in range(len(L[i])):
            if L[i][j] == "WA":
                penalty += 1
            else:
                point += 1
                break

print(point, penalty, sep = " ")
Buggy code:
N, M = map(int, input().split())
p = [list(map(str, input().split())) for _ in range(M)]
aclst = [0] * (N + 1)
cntw = 0
cnta = 0

for i in range(M):
    if aclst[int(p[i][0])] == 0:
        if p[i][1] == 'AC':
            cnta += 1
            aclst[int(p[i][0])] = 1
            print(aclst)
        else:
            cntw += 1

print(cnta, cntw)

Fixed code:
N, M = map(int, input().split())
p = [list(map(str, input().split())) for _ in range(M)]
aclst = [0] * (N + 1)
walst = [0] * (N + 1)
cntw = 0
cnta = 0
for i in range(M):
    if aclst[int(p[i][0])] == 0:
        if p[i][1] == 'WA':
            walst[int(p[i][0])] += 1
        else:
            cnta += 1
            cntw += walst[int(p[i][0])]
            aclst[int(p[i][0])] = 1


print(cnta, cntw)
Buggy code:
n, m = list(map(int,input().split()))

penalty = 0

corrected = {}
wa = {}

for i in range(m):
  pi, si = input().split()
  if (si == 'AC' and not corrected.get(pi)):
    corrected[pi] = True
  elif (si == 'WA' and not corrected.get(pi)):
    wa[pi] += wa[pi]

correct = len(corrected.keys())
for i in corrected.keys()
	penalty += wa[i]

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


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

penalty = 0

corrected = {}
wa = {}

for i in range(m):
  pi, si = input().split()
  if (si == 'AC' and not corrected.get(pi)):
    corrected[pi] = True
  elif (si == 'WA' and not corrected.get(pi)):
    wa[pi] = wa[pi] + 1 if wa.get(pi) else 1

correct = len(corrected.keys())
for i in corrected.keys():
	penalty += wa[i] if  wa.get(i) else 0

print("{} {}".format(correct, penalty))
Buggy code:
def II(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
ans,pena=0,0
N,M=MI()
P=[0]*N
PENA=[0]*N
for i in range(M):
  p,s=input().split()
  p=int(p)
  p-=1
  if s=='AC':
    if P[p]==0:
      ans+=1
      P[p]=1
  if s=='WA':
    if P[p]==0:
      PENA[p]+=1
for i in range(N):
  if P[p]!=1:
    PENA[p]=0
pena=sum(PENA)  
print(ans,pena)

Fixed code:
def II(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
ans,pena=0,0
N,M=MI()
P=[0]*N
PENA=[0]*N
for i in range(M):
  p,s=input().split()
  p=int(p)
  p-=1
  if s=='AC':
    if P[p]==0:
      ans+=1
      P[p]=1
      if PENA[p]!=0:
        pena+=PENA[p]
  if s=='WA':
    if P[p]==0:
      PENA[p]+=1
print(ans,pena)
Buggy code:
n, m = map(int, input().split())
ac = 0
pena = 0
isac = [0] * n
wa = [0] * n

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

print(ac, pena)

Fixed code:
n, m = map(int, input().split())
ac = 0
pena = 0
isac = [0] * n
wa = [0] * n

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

print(ac, pena)
Buggy code:
N, M = map(int, input().split())
WA = [0] * N
AC = [0] * N
for i in range(M):
    p,s = input().split()
    p = int(p)
    if AC[p-1] == 0:
        if s == "AC":
            AC[p-1] = 1
        else:
            WA[p-1] += 1
wa = 0
for j in range(M):
    if AC[j] == 1:
        wa += WA[j]
print(sum(AC),wa)

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

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC':
        lst[p-1][0] = 1
    elif lst[p-1][0] == 0:
        lst[p-1][1] += 1

correct = 0
wrong = 0
for i in range(n):
    correct += lst[i][0]
    if lst[i][0] == 1:
        wrong += lst[i][1]
print(correct, wrong)
print(lst)

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

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC':
        lst[p-1][0] = 1
    elif lst[p-1][0] == 0:
        lst[p-1][1] += 1

correct = 0
wrong = 0
for i in range(n):
    correct += lst[i][0]
    if lst[i][0] == 1:
        wrong += lst[i][1]
print(correct, wrong)
Buggy code:
n,m=list(map(int,input().split()))
ac,wa=0,0
aclis=[0]*n
walis=[0]*n

for i in range(m):
  p,s=input().split()
  p = int(p)  
  if s == "AC" and aclis[p-1] == 0:
    aclis[p-1] = 1
    ac += 1
    wa += wa[p-1]
  elif s == "WA" and aclis[p-1] == 0:
    wa[p-1] += 1
print(ac,wa)

Fixed code:
n,m=list(map(int,input().split()))
ac,wa=0,0
aclis=[0]*n
walis=[0]*n

for i in range(m):
  p,s=input().split()
  p = int(p)  
  if s == "AC" and aclis[p-1] == 0:
    aclis[p-1] = 1
    ac += 1
    wa += walis[p-1]
  elif s == "WA" and aclis[p-1] == 0:
    walis[p-1] += 1
print(ac,wa)
Buggy code:
N,M=map(int,input().split())
ACL=[0]*N
PL=[0]*N
AC=0
P=0
for i in range(M):
  p,S=input().split()
  p=int(p)
  if S =='AC':
    if ACL[p]==0:
      AC+=1
      P+=PL[p]
      ACL[p]=1
    else:
      PL[p]+=1
print(AC,P)
      
  

Fixed code:
N,M=map(int,input().split())
ACL=[0]*N
PL=[0]*N
AC=0
P=0
for i in range(M):
  p,S=input().split()
  p=int(p)
  p-=1
  if S =='AC':
    if ACL[p]==0:
      AC+=1
      P+=PL[p]
      ACL[p]=1
  else:
    PL[p]+=1
print(AC,P)
Buggy code:
n,m=map(int,input().split())
p=[0]*m
s=[0]*m
for i in range(m):
    pi,si=input().split()
    p[i]=int(pi)
    s[i]=si
judge=[0]*(n+1)
ac=0
wa=0
for i in range(m):
    if judge[p[i]]==-1:
        continue
    if judge[p[i]]==0:
        if s[i]=='WA':
            judge[p[i]]+=1
        else:
            wa+=judge[p[i]]
            judge[p[i]]=-1
            ac+=1
print(ac,wa)

Fixed code:
n,m=map(int,input().split())
p=[0]*m
s=[0]*m
for i in range(m):
    pi,si=input().split()
    p[i]=int(pi)
    s[i]=si
judge=[0]*(n+1)
ac=0
wa=0
for i in range(m):
    if judge[p[i]]==-1:
        continue
    if judge[p[i]]!=-1:
        if s[i]=='WA':
            judge[p[i]]+=1
        else:
            wa+=judge[p[i]]
            judge[p[i]]=-1
            ac+=1
print(ac,wa)
Buggy code:
from collections import deque

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

for a in range(M):
    p,s = input().split()
    
    p = int(p) - 1

    if ac[p]:
        continue
    if s == 'AC':
        ac[p] = 1
    else:
        pena[p] += 1

AC = 0
PENA = 0

for a in ac:
    AC += a
    if a:
        PENA += pena[ac.index(a)]

print(AC,PENA)

Fixed code:
from collections import deque

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

for a in range(M):
    p,s = input().split()
    
    p = int(p) - 1

    if ac[p]:
        continue
    if s == 'AC':
        ac[p] = 1
    else:
        pena[p] += 1

AC = 0
PENA = 0

for a in range(N):
    AC += ac[a]
    if ac[a]:
        PENA += pena[a]

print(AC,PENA)
Buggy code:
n,m = map(int,input().split())

l=list(input().split() for _ in range(m))

w=[0]*n
a=[0]*n
seitou=0
pena=0

for i in l:
    k=int(i[0])-1
    if a[k]==0:
        if i[1]=="AC":
            a[k]+=1
        else:
            w[k]+=1

seitou=sum(a)
for j in range(n):
    if a[i]==1:
        pena+=w[i]
        
print(seitou,pena)

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

l=list(input().split() for _ in range(m))

w=[0]*n
a=[0]*n
seitou=0
pena=0

for i in l:
    k=int(i[0])-1
    if a[k]==0:
        if i[1]=="AC":
            a[k]+=1
        else:
            w[k]+=1

seitou=sum(a)
for j in range(n):
    if int(a[j])==1:
        pena+=w[j]
        
print(seitou,pena)
Buggy code:
N,M = map(int,input().split())
penalty =0
check = [0]*N
ac = 0
wa = 0
for i in range(M):
  pi, si = input().split()
  pi = int(pi)
  if check[pi] == -1:
    continue
  if si = 'WA':
    check[pi] += 1
  else:
    ac += 1
    wa += check[pi]
    check[pi] = -1
print(ac,wa)


Fixed code:
N,M = map(int,input().split())
check = [0]*N
ac = 0
penalty = 0
for i in range(M):
  pi, si = input().split()
  pi = int(pi)
  if check[pi-1] == -1:
    continue
  if si == 'WA':
    check[pi-1] += 1
  else:
    ac += 1
    penalty += check[pi-1]
    check[pi-1] = -1
print(ac,penalty)
Buggy code:
def resolve():
    n,m = map(int,input().split())
    ac_list = [1]*n
    ac = 0
    wa = 0
    for _ in range(m):
        p,s = input().split()
        if s == 'WA' and ac_list[int(p)-1]==1:
            wa += 1
        elif s == 'AC' and ac_list[int(p)-1]==1:
            ac += 1
            ac_list[int(p)-1] = 0
    print(f'{ac} {wa}')
resolve():

Fixed code:
def resolve():
    n,m = map(int,input().split())
    ac_list = [0]*n
    wa_count = [0]*n
    ac = 0
    wa = 0
    for _ in range(m):
        p,s = input().split()
        if s == 'WA' and (ac_list[int(p)-1]==0):
            wa_count[int(p)-1] += 1
        elif s == 'AC' and (ac_list[int(p)-1]==0):
            ac += 1
            ac_list[int(p)-1] = 1
    for (i,j) in zip(wa_count,ac_list):
        if j: wa+=i
    print(f'{ac} {wa}')
resolve()
Buggy code:
N, M, *PS = open(0).read().split()
N, M = [int(_) for _ in [N, M]]
cor = [0] * (N + 1)
pen = [0] * (N + 1)
for p, s in PS:
    p = int(p)
    if cor[p] == 1:
        continue
    if s == 'AC':
        cor[p] = 1
    else:
        pen[p] += 1
ans = [0, 0]
for i in range(1, N + 1):
    if cor[p] == 0:
        continue
    ans[0] += 1
    ans[1] += pen[ @ ]
print(*ans)


Fixed code:
N, M, *PS = open(0).read().split()
N, M = [int(_) for _ in [N, M]]
cor = [0] * (N + 1)
pen = [0] * (N + 1)
for p, s in zip(PS[::2], PS[1::2]):
    p = int(p)
    if cor[p] == 1:
        continue
    if s == 'AC':
        cor[p] = 1
    else:
        pen[p] += 1
ans = [0, 0]
for i in range(1, N + 1):
    if cor[i] == 0:
        continue
    ans[0] += 1
    ans[1] += pen[i]
print(*ans)
Buggy code:
n,m= list(map(int, input().split()))
ans_box=[0]*n
wa=[0]*m
ac=0
wa_cnt=0
for j in range(m):
    k,l=input().split()
    h=int(k)-1
    if ans_box[h]==0:
        if l=="AC":
            ac+=1
            ans_box[h]+=1
            wa_cnt+=wa[h]
        else:
            wa[h]+=1
print(ac,wa_cnt)           
            
    


Fixed code:
n,m= list(map(int, input().split()))
ans_box=[0]*n
wa=[0]*n
ac=0
wa_cnt=0
for j in range(m):
    k,l=input().split()
    h=int(k)-1
    if ans_box[h]==0:
        if l=="AC":
            ac+=1
            ans_box[h]+=1
            wa_cnt+=wa[h]
        else:
            wa[h]+=1
print(ac,wa_cnt)
Buggy code:
def main(n, m, p_s):
    st = [False for _ in range(n)]
    ac, wa = 0, 0

    for p, s in p_s:
        if st[p - 1]:
            continue

        if s == "AC":
            ac += 1
            st[p - 1] = True
        if s == "WA":
            wa += 1

    print(ac, wa)


if __name__ == "__main__":
    n, m = map(int, input().split())
    p_s = [list(map(int, input().split())) for _ in range(m)]

    main(n, m, p_s)


Fixed code:
def main(n: int, m: int, p_s: list):
    bool_ac = [False for _ in range(n)]
    count_wa = [0 for _ in range(n)]
    ac, wa = 0, 0

    for p, s in p_s:
        p = int(p)

        if bool_ac[p - 1]:
            continue

        if s == "AC":
            bool_ac[p - 1] = True
            wa += count_wa[p - 1]
            ac += 1
        elif s == "WA":
            count_wa[p - 1] += 1

    print(ac, wa)


if __name__ == "__main__":
    n, m = map(int, input().split())
    p_s = [input().split() for _ in range(m)]

    main(n, m, p_s)
Buggy code:
def resolve_c():
    n, m = map(int, input().split())
    ac_list = [0] * m
    wa_list = [0] * m
    wa_tmp_list = [0] * m
    for i in range(m):
        p, s = input().split()
        if ac_list[int(p)] == 0:
            if s == "AC":
                ac_list[int(p)] = 1
                wa_list[int(p)] = wa_tmp_list[int(p)]
            elif s == "WA":
                wa_tmp_list[int(p)] += 1
    print(str(sum(ac_list)) + " " + str(sum(wa_list)))
resolve_c()

Fixed code:
def resolve_c():
    n, m = map(int, input().split())
    ac_list = [0] * n
    wa_list = [0] * n
    wa_tmp_list = [0] * n
    for i in range(m):
        p, s = input().split()
        if ac_list[int(p)-1] == 0:
            if s == "AC":
                ac_list[int(p)-1] = 1
                wa_list[int(p)-1] = wa_tmp_list[int(p)-1]
            elif s == "WA":
                wa_tmp_list[int(p)-1] += 1
    print(str(sum(ac_list)) + " " + str(sum(wa_list)))
resolve_c()
Buggy code:
s=[]
lis=[]
N,M=map(int, input().split())
wacount=0
account=0
zero=0
flag=0
cur=0
changeflag=1
#s=[list(input()) for i in range(2)] 
#for range(M):
#print(N,M)

for i in range(M):
     lis=input().split()
     #print(lis)
     lis[0]=int(lis[0])
     lis.append(i)
     #print(lis)
     s.append(lis)
if M==0:
    print(zero,zero)
else:
    s2=sorted(s,key=lambda x:x[0])
    sorted(s2,key=lambda x:x[2])
    j=1
    cur=j
    for i in range(len(s2)):
        if s2[i][0]>cur:
            j=s2[i][0]
        if s2[i][0]==j:
            if s2[i][1]=="WA":
                wacount=wacount+1
            elif s2[i][1]=="AC":
                account=account+1
                j=j+1
                cur=j
                
                   
    print(wacount,account)

Fixed code:
s=[]
lis=[]
N,M=map(int, input().split())
wacount=0
account=0
count=0
zero=0
flag=1
cur=0
changeflag=1
#s=[list(input()) for i in range(2)] 
#for range(M):
#print(N,M)
 
for i in range(M):
     lis=input().split()
     #print(lis)
     lis[0]=int(lis[0])
     lis.append(i)
     #print(lis)
     s.append(lis)
 
s2=sorted(s,key=lambda x:x[0])
sorted(s2,key=lambda x:x[2])
j=1
for i in range(len(s2)):
    if s2[i][0]>j:
        j=s2[i][0]
        flag=1
        count=0
    if (s2[i][0]==j)and(flag==1):
        if s2[i][1]=="WA":
            count=count+1
        elif s2[i][1]=="AC":
            account=account+1
            wacount=wacount+count
            flag=0
            count=0
                
print(account,wacount)
Buggy code:
n,m = map(int,input().split())
a=[0]*n
w=[0]*n
ac=0
wa=0
for _ in range(m):
    p,s=input().split()
    p=int(p)-1
    if a[p]==0:
        if s=="AC":
            a[p]=1
            ac+=1
            wc+=w[p]
        else:
            w[p]+=1
print(ac,wc)

Fixed code:
n,m = map(int,input().split())
a=[0]*n
w=[0]*n
ac=0
wc=0
for _ in range(m):
    p,s=input().split()
    p=int(p)-1
    if a[p]==0:
        if s=="AC":
            a[p]=1
            ac+=1
            wc+=w[p]
        else:
            w[p]+=1
print(ac,wc)
Buggy code:
N,M=[int(_) for _ in input().split()]
PS=[input().split() for _ in range(M)]
count=[0]*(N+1)
isac=[0]*(N+1)
for p,s in PS:
 p=int(p)
 if s=='AC':
  isac[p]=1
 else:
  count[p]+=1
wa=0
ac=0
for i in range(N+1):
 if isac[i]==1:
  ac+=1
  wa+=count[i]
print(ac,wa)


Fixed code:
N,M=[int(_) for _ in input().split()]
PS=[input().split() for _ in range(M)]
count=[0]*(N+1)
isac=[0]*(N+1)
for p,s in PS:
 p=int(p)
 if isac[p]==1:
    continue
 if s=='AC':
  isac[p]=1
 else:
  count[p]+=1
wa=0
ac=0
for i in range(N+1):
 if isac[i]==1:
  ac+=1
  wa+=count[i]
print(ac,wa)
Buggy code:
# -*- coding: utf-8 -*-
# abc151/abc151_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, M = i2nn()
    wa_list = [0] * N
    penalty = 0
    ac = 0
    for _ in range(M):
        p, S = i2s().split(' ')
        p = int(p)
        if wa_list[p] >= 0:
            if S == 'WA':
                wa_list[p] += 1
            else:
                penalty += wa_list[p]
                wa_list[p] = -1
                ac += 1
    print(ac, penalty)
    return

main()


Fixed code:
# -*- coding: utf-8 -*-
# abc151/abc151_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, M = i2nn()
    wa_list = [0] * N
    penalty = 0
    ac = 0
    for _ in range(M):
        p, S = i2s().split(' ')
        p = int(p) - 1
        if wa_list[p] >= 0:
            if S == 'WA':
                wa_list[p] += 1
            else:
                penalty += wa_list[p]
                wa_list[p] = -1
                ac += 1
    print(ac, penalty)
    return

main()