qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n,m=map(int,input().split())

x=[0]*n
y=[0]*n
if m!=0:
  for i in range(m):
    P,s=input().split()
    p=int(P) 
    if x[p-1]==0:
      if s=="WA":
        y[p-1]+=1
      if s=="AC":
        x[p-1]+=1
    else:
      print(str(x[p-1]))
sx=0
sy=0
for i in range(n):
  sx+=x[i]
  sy+=y[i]
  
print(str(sx),str(sy))

Fixed code:
n,m=map(int,input().split())
x=[0]*n
y=[0]*n
for i in range(m):
  P,s=input().split()
  p=int(P) 
  if x[p-1]==0:
    if s=="WA":
      y[p-1]+=1
    if s=="AC":
      x[p-1]+=1

sx=0
sy=0
for i in range(n):
  sx+=x[i]
  if x[i]==1:
    sy+=y[i]
  
print(str(sx),str(sy))
Buggy code:
N,M=map(int,input().split())
PS=[list(input().split()) for _ in range(M)]

miss=[[0,False] for _ in range(N)]

for p,s in PS:
  p=int(p)
  if miss[p-1][1]==False and s=="WA":
    miss[p-1][0]+=1
  if s=="AC":
    miss[p-1][1]=True
pena=0
ac=0
for m,tf in miss:
  pena+=m
  ac+=tf

print(str(pena)+" "+str(ac))


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

miss=[[0,False] for _ in range(N)]

for p,s in PS:
  p=int(p)
  if miss[p-1][1]==False and s=="WA":
    miss[p-1][0]+=1
  if s=="AC":
    miss[p-1][1]=True
pena=0
ac=0
for m,tf in miss:
  pena+=m*tf
  ac+=tf

print(str(ac)+" "+str(pena))
Buggy code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M = map(int,readline().split())
PS = [line.split() for line in readlines()]

AC = [False] * (N+1)
WA_cnt = [0] * (N+1)

penal = 0
for p,s in PS:
    p = int(p)
    if AC[p]:
        continue
    if s == 'WA':
        WA_cnt[p] += 1
    else:
        AC[p] = True
        penal += WA_cnt[p]

ac = sum(AC)
print(ac, penal)

Fixed code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M = map(int,readline().split())
PS = [line.split() for line in readlines()]

AC = [False] * (N+1)
WA_cnt = [0] * (N+1)

penal = 0
for p,s in PS:
    p = int(p)
    if AC[p]:
        continue
    if s == b'WA':
        WA_cnt[p] += 1
    else:
        AC[p] = True
        penal += WA_cnt[p]

ac = sum(AC)
print(ac, penal)
Buggy code:
cin=input().split()
N=int(cin[0])
M=int(cin[1])


result={}
ac=0
was={}
for i in range(M):
    cin=input().split()
    p=int(cin[0])
    S=str(cin[1])

    log=result.get(p,None)
    if S == "AC" and log != "AC":
        ac+=1
        result[p]="AC"

    if S == "WA" and log != "AC":
        was[p]=was.get(p,0)+1

wa=0
for k,v in result.items():
    if v == "AC":
        wa+=was[k]
print(str(ac)+" "+str(wa))

Fixed code:
cin=input().split()
N=int(cin[0])
M=int(cin[1])


result={}
ac=0
was={}
for i in range(M):
    cin=input().split()
    p=int(cin[0])
    S=str(cin[1])

    log=result.get(p,None)
    if S == "AC" and log != "AC":
        ac+=1
        result[p]="AC"

    if S == "WA" and log != "AC":
        was[p]=was.get(p,0)+1

wa=0
for k,v in result.items():
    if v == "AC":
        wa+=was.get(k,0)
print(str(ac)+" "+str(wa))
Buggy code:
n,m=map(int,input().split())
ac=[0]*n
wa=ac
for i in range(m):
  p,s=map(str,input().split())
  p=int(p)-1
  if ac[p]==0:
    if s=='AC':
      ac[p]=1
    else:
      wa[p]+=1

w=0
for i in range (n):
  w+=ac[i]*wa[i]
print(sum(ac),w)

Fixed code:
n,m=map(int,input().split())
ac=[0]*n
wa=[0]*n
for i in range(m):
  p,s=map(str,input().split())
  p=int(p)-1
  if ac[p]==0:
    if s=='AC':
      ac[p]=1
    else:
      wa[p]+=1

w=0
for i in range (n):
  w+=ac[i]*wa[i]
print(sum(ac),w)
Buggy code:
n, m = map(int, input().split())
c = [input().split() for i in range(m)]
for i in range(m):
    c[i][0] = int(c[i][0])
AC, WA = 0, 0
aclist = [0 for i in range(n)]
for i in range(n):
    if aclist[c[i][0]] == 0:
        if c[i][1] == 'AC':
            aclist[c[i][0]] += 1
            AC += 1
        else:
            WA += 1
print(AC, WA)

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

print(AC, WA)
Buggy code:
N, M = map(int, input().split())

ac = 0
wa = 0

l = [0] * (N + 1)

for num in range(M):
    p, s =  input().split()
    p = int(p)
    if s == "AC":
        if l[p] <= 0:
            ac += 1
        
        wa += -l[p]
        l[p] = 1 
    else:
        if l[p] <= 0:
            l[p] -= 1
        
print(*[ac, wa])


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

ac = 0
wa = 0

l = [0] * (N + 1)

for num in range(M):
    p, s =  input().split()
    p = int(p)
    if s == "AC":
        if l[p] <= 0:
            ac += 1
            wa += -l[p]
            l[p] = 1
        
         
    else:
        if l[p] <= 0:
            l[p] -= 1
        
print(*[ac, wa])
Buggy code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
    
    
N,M=map(int,input().split())
a=0
b=0
AC=[0]*(M+1)
pen=0
l=[]
for i in range(M):
	j,r=input().split()
	if AC[int(j)]==0:
		if r=="WA":
			pen+=1
		else:
			AC[int(j)]+=1
print(sum(AC),pen)

Fixed code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
    
    
N,M=map(int,input().split())
a=0
b=0
AC=[0]*(N+1)
pen=[0]*(N+1)
p=0
l=[]
for i in range(M):
	j,r=input().split()
	if AC[int(j)]==0:
		if r=="WA":
			pen[int(j)]+=1
		else:
			AC[int(j)]+=1
for k in range(N+1):
	if AC[k]==1:
		p+=pen[k]

print(sum(AC),p)
Buggy code:
from collections import defaultdict

def main():
    N, M = map(int, input().split())
    a = [input().split() for _ in range(M)]
    ac_count = [0] * (N + 1)
    wa_count = defaultdict(lambda:0)
    ac, wa = 0, 0

    for q_no, ans in a:
        if ac_count[int(q_no)] == 0:
            if ans == "AC":
                ac_count[0] = 1
                ac += 1
                wa += wa_count.get(q_no, 0)
            else:
                wa_count[q_no] += 1
    
    print(ac, wa)

if __name__ == '__main__':
    main()

Fixed code:
from collections import defaultdict

def main():
    N, M = map(int, input().split())
    a = [input().split() for _ in range(M)]
    ac_count = [0] * (N + 1)
    wa_count = defaultdict(lambda:0)
    ac, wa = 0, 0

    for q_no, ans in a:
        q_no = int(q_no)
        if ac_count[q_no] == 0:
            if ans == "AC":
                ac_count[q_no] = 1
                ac += 1
                wa += wa_count.get(q_no, 0)
            else:
                wa_count[q_no] += 1
    
    print(ac, wa)

if __name__ == '__main__':
    main()
Buggy code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

acCount = 0
waCount = 0
check = [0] * n
waCheck = [0] * n

for i in range(m):
    p, s = map(str, input().split())
    # print(p,s)
    p = int(p)
    if (check[p - 1] == 0):
        if (s == 'WA'):
            waCheck[p - 1] += 1

        else:
            acCount += 1
            waCheck += waCheck[p - 1]

            check[p - 1] = 1
    else:
        continue

print(acCount, waCount)


Fixed code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

acCount = 0
waCount = 0
check = [0] * n
waCheck = [0] * n

for i in range(m):
    p, s = map(str, input().split())
    # print(p,s)
    p = int(p)
    if (check[p - 1] == 0):
        if (s == 'WA'):
            waCheck[p - 1] += 1

        else:
            acCount += 1
            waCount += waCheck[p - 1]

            check[p - 1] = 1
    else:
        continue

print(acCount, waCount)
Buggy code:
def main():
    n,m = map(int,input().split())
    flag = [False for i in range(n+1)]
    AC = 0
    WA = 0
    for i in range(m):
        input_line = input().split()
        p,s = int(input_line[0]), input_line[1]
        if flag[p] == False:
            if s == "AC":
                AC += 1
                flag[p] = def main():
    n,m = map(int,input().split())
    flag = [False for i in range(n+5)]
    AC = 0
    WA = [0 for i in range(n+5)]
    _WA = 0
    for i in range(m):
        input_line = input().split()
        p,s = int(input_line[0]), input_line[1]
        if flag[p] == False:
            if s == "AC":
                AC += 1
                _WA += WA[p]
                flag[p] = True
            else:
                WA[p] += 1
    print(AC,_WA)
    return


if __name__ == "__main__":
    main()
            else:
                WA += 1
    print(AC,WA)
    return 0


if __name__ == "__main__":
    main()

Fixed code:
def main():
    n,m = map(int,input().split())
    flag = [False for i in range(n+5)]
    AC = 0
    WA = [0 for i in range(n+5)]
    _WA = 0
    for i in range(m):
        input_line = input().split()
        p,s = int(input_line[0]), input_line[1]
        if flag[p] == False:
            if s == "AC":
                AC += 1
                _WA += WA[p]
                flag[p] = True
            else:
                WA[p] += 1
    print(AC,_WA)
    return


if __name__ == "__main__":
    main()
Buggy code:
N, M = map(int, input().split())

ans_list = [["WA", 0] for i in range(N)]


WA_count = 0
AC_count = 0
for i in range(M):
    p, S = map(str, input().split())
    p = int(p)
    if S == "WA":
        if ans_list[p-1][0] == 'WA':
            ans_list[p-1][1] += 1
            WA_count += 1
        else:
            pass
    else:
        if ans_list[p-1][0] == 'WA':
            ans_list[p-1][0] = 'AC'
            AC_count += 1
        else:
            pass
        
print(WA_count, AC_count)  

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

ans_list = [["WA", 0] for i in range(N)]

AC_count = 0
for i in range(M):
    p, S = map(str, input().split())
    p = int(p)
    if S == "WA":
        if ans_list[p-1][0] == 'WA':
            ans_list[p-1][1] += 1
        else:
            pass
    else:
        if ans_list[p-1][0] == 'WA':
            ans_list[p-1][0] = 'AC'
            AC_count += 1
        else:
            pass

WA_count = 0
for i in range(N):
    if ans_list[i][0] == 'AC':
        WA_count += ans_list[i][1]

print(AC_count, WA_count)
Buggy code:
N,M = map(int,input().split())
correct = [0]*N
penalty = [0]*N
ans_c,ans_p = 0,0
for i in range(M):
    p,s = input().split()
    p = int(p)
    if s=="AC":
        if correct[p-1]==0:
            correct[p-1]+=1
    if s=="WA":
        if correct[p-1]==0:
            penalty[p-1]+=1
            
ans_penalty = 0
for i in range(N):
    if correct[i]!=1:
        ans_penalty+=penalty[i]
print(sum(correct),ans_penalty)


Fixed code:
N,M = map(int,input().split())
correct = [0]*N
penalty = [0]*N
ans_c,ans_p = 0,0
for i in range(M):
    p,s = input().split()
    p = int(p)
    if s=="AC":
        if correct[p-1]==0:
            correct[p-1]+=1
    if s=="WA":
        if correct[p-1]==0:
            penalty[p-1]+=1

ans_penalty = 0
for i in range(N):
    if correct[i]>=1:
        ans_penalty+=penalty[i]
print(sum(correct),ans_penalty)
Buggy code:
import sys
import time
import math
import itertools as it
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N, M = inpl()
dp = [False] * (N+10)
ac = 0
wa = 0
for _ in range(M):
    p, S = input().split()
    p = int(p)
    if S == 'WA':
        if !dp[p]:
            wa += 1
    else:
        if !dp[p]:
            ac += 1
            dp[p] = True
print(ac, wa)


# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)


Fixed code:
import sys
import time
import math
import itertools as it
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N, M = inpl()
ac = [False] * (N+10)
wa = [0] * (N+10)

a = 0
w = 0
for _ in range(M):
    p, S = input().split()
    p = int(p)
    if S == 'WA':
        if not ac[p]:
            wa[p] += 1
    else:
        if not ac[p]:
            ac[p] = True
            a += 1
            w += wa[p]

print(a, w)

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)
Buggy code:
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import itertools
# import math

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 9

N, M = map(int, readline().split())
PS = [line.split() for line in read().decode('utf8')]
AC = [False] * (N + 1)
WA = [0] * (N + 1)

penal = 0
for p, s in PS:
    p = int(p)
    if AC[p]:
        continue
    if s == 'WA':
        WA[p] += 1
    else:
        AC[p] = True
        penal += WA[p]

ac = sum(AC)
print(ac, penal)

Fixed code:
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import itertools
# import math

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 9

N, M = map(int, readline().split())
PS = [line.split() for line in readlines()]
AC = [False] * (N + 1)
WA = [0] * (N + 1)

penal = 0
for p, s in PS:
    p = int(p)
    if AC[p]:
        continue
    if s == b'WA':
        WA[p] += 1
    else:
        AC[p] = True
        penal += WA[p]

ac = sum(AC)
print(ac, penal)
Buggy code:
n,m = map(int,input().split())
li = list()
for i in range(m):
  li.append(input().split())
print(li)
ac_cnt=0
wa_cnt=0

s_ac=set()
d_wa=dict()
for l in li:
  if l[1] == 'WA':
    d_wa[l[0]] = d_wa.get(l[0],0) + 1
  elif l[1] == 'AC':
    if l[0] not in s_ac:
      s_ac.add(l[0])
      ac_cnt +=1
      wa_cnt +=d_wa.get(l[0],0)
    else:
      pass

print(ac_cnt,wa_cnt)
  

Fixed code:
n, m = map(int, input().split())
li = list()
for i in range(m):
    li.append(tuple(input().split()))
 
ac_cnt = 0
wa_cnt = 0
 
s_ac = set()
d_wa = dict()
for l in li:
    if l[1] == 'AC':
        if l[0] not in s_ac:
            s_ac.add(l[0])
            ac_cnt += 1
            wa_cnt += d_wa.get(l[0], 0)
        else:
            pass
    elif l[1] == 'WA':
        d_wa[l[0]] = d_wa.get(l[0], 0) + 1
 
print(ac_cnt, wa_cnt)
Buggy code:
coding: utf-8

import bisect
import math

N, M = (int(v) for v in input().split())

seen = {}
WA = {}

acs = 0
was = 0

for i in range(M):
    q, tmp = input().split()
    if tmp == "AC":
        if q not in seen:
            acs += 1
            if q not in WA:
                WA[q] = 0
            was += WA[q]
            seen[q] = 1
    else:
        if q not in WA:
            WA[q] = 1
        else:
            WA[q] += 1

print (acs, was)



Fixed code:
#coding: utf-8

import bisect
import math

N, M = (int(v) for v in input().split())

seen = {}
WA = {}

acs = 0
was = 0

for i in range(M):
    q, tmp = input().split()
    if tmp == "AC":
        if q not in seen:
            acs += 1
            if q not in WA:
                WA[q] = 0
            was += WA[q]
            seen[q] = 1
    else:
        if q not in WA:
            WA[q] = 1
        else:
            WA[q] += 1

print (acs, was)
Buggy code:
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

def main():
    n,m = map(int, input().split())
    wa = 0
    ac = 0
    used = {}
    wa_tmp = {}
    for _ in range(m):
        p,s = map(str, input().split())
        if used.get(p):
            continue
        if s == 'WA':
            if not wa_tmp.get(p):
                wa_tmp[p] = 0
            wa_tmp[p] += 1
        if s == 'AC':
            ac += 1
            used[p] = True
            wa += wa_tmp[p]
    print(ac, wa)


if __name__ == '__main__':
    main()


Fixed code:
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

def main():
    n,m = map(int, input().split())
    wa = 0
    ac = 0
    used = {}
    wa_tmp = {}
    for _ in range(m):
        p,s = map(str, input().split())
        if used.get(p):
            continue
        if s == 'WA':
            if not wa_tmp.get(p):
                wa_tmp[p] = 0
            wa_tmp[p] += 1
        if s == 'AC':
            ac += 1
            used[p] = True
            if wa_tmp.get(p):
                wa += wa_tmp[p]
    print(ac, wa)


if __name__ == '__main__':
    main()
Buggy code:
n, m = map(int, input().split())
lis = [list(input().split()) for _ in range(m)]
d = {}
ac, wa = 0, 0
for i in range(m):
    if lis[i][0] not in d:
        if lis[i][1] == 'AC':
            ac += 1
        else:
            d[lis[i][0]] = 1
    else:
        if lis[i][1] == 'AC':
            ac += 1
            wa += d[lis[i][0]]
print(' '.join(map(str, [ac, wa])))

Fixed code:
n, m = map(int, input().split())
lis = [list(input().split()) for _ in range(m)]
d = {}
ac, wa = 0, 0
for i in lis:
    if i[0] not in d:
        if i[1] == 'AC':
            ac += 1
            d[i[0]] = 'AC'
        else:
            d[i[0]] = 1
    else:
        if i[1] == 'AC':
            if d[i[0]] != 'AC':
                ac += 1
                wa += d[i[0]]
                d[i[0]] = 'AC'
        else:
            if d[i[0]] != 'AC':
                d[i[0]] += 1
print(ac, wa)
Buggy code:
N, M = map(int, input().split())
wa, ac = [0]*(N+1), [0]*(N+1)
wa_ac = 0
for i in range(1, M+1):
  pi, Si = input().split()
  pi = int(pi)
  if Si == 'WA' and ac[pi] == 0: 
    wa[pi] += 1
  elif Si == 'AC' and ac[pi] == 0:
    ac[pi] += 1

for i in range(1, M+1):
  if ac[i] == 1:
    wa_ac += wa[i]

print('{} {}'.format(sum(ac), wa_ac))


Fixed code:
N, M = map(int, input().split())
wa, ac = [0]*(N+1), [0]*(N+1)
wa_ac = 0
for i in range(1, M+1):
  pi, Si = input().split()
  pi = int(pi)
  if Si == 'WA' and ac[pi] == 0: 
    wa[pi] += 1
  elif Si == 'AC' and ac[pi] == 0:
    ac[pi] += 1

for i in range(1, N+1):
  if ac[i] == 1:
    wa_ac += wa[i]

print('{} {}'.format(sum(ac), wa_ac))
Buggy code:
n,m = map(int,input().split())
L = [0]*n
AC = 0
WA = 0
tmp = [0]*n
for i in range(m):
	x,y = input().split()
	x = int(x)
	if L[x-1] == 0:
		if y == "WA":
			tmp[x-1] += 1
		else:
			AC += 1
			WA += tmp[x-1]
			L[x-1]=1
print(A,W)


Fixed code:
n,m = map(int,input().split())
L = [0]*n
AC = 0
WA = 0
tmp = [0]*n
for i in range(m):
	x,y = input().split()
	x = int(x)
	if L[x-1] == 0:
		if y == "WA":
			tmp[x-1] += 1
		else:
			AC += 1
			WA += tmp[x-1]
			L[x-1]=1
print(AC,WA)
Buggy code:
N,M = map(int,input().split())
box = [0]*N
cor = 0
fal = 0

for i in range(M):
  p,s = input().split()
  p = int(p)
  s = str(s)
  
  if s == "WA":
    if box[p-1] != -1:
      box[p-1] += 1
  else:
    if box[p-1] != -1:
      cor += 1
      fal = box[p-1]
      box[p-1] = -1

print(cor,fal)
     

  

Fixed code:
N,M = map(int,input().split())
box = [0]*N
cor = 0
fal = 0

for i in range(M):
  p,s = input().split()
  p = int(p)
  s = str(s)
  
  if s == "WA":
    if box[p-1] != -1:
      box[p-1] += 1
  else:
    if box[p-1] != -1:
      cor += 1
      fal += box[p-1]
      box[p-1] = -1

print(cor,fal)
Buggy code:

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

data = {}
ps = [0] * N
ACs = []

num_ac = 0
num_wa = 0


for i in range(M):
    p, S = input().split()
    p = int(p)

    if ps[p] == 0:
        ps[p] = 1
        data[p] = {'AC':0, 'WA':0}

    if S == 'AC' and data[p]['AC'] == 0:
        ACs.append(p)
        data[p]['AC'] += 1
        num_ac += 1
        num_wa += data[p]['WA']

    if S == 'WA' and data[p]['AC'] == 0:
        data[p][S] += 1

print(num_ac, num_wa)




Fixed code:

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

data = {}
ps = [0] * N
ACs = []

num_ac = 0
num_wa = 0


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

    if ps[p] == 0:
        ps[p] = 1
        data[p] = {'AC':0, 'WA':0}

    if S == 'AC' and data[p]['AC'] == 0:
        ACs.append(p)
        data[p]['AC'] += 1
        num_ac += 1
        num_wa += data[p]['WA']

    if S == 'WA' and data[p]['AC'] == 0:
        data[p][S] += 1

print(num_ac, num_wa)
Buggy code:
print("<input>") #
N,M=map(int,input().split())
A=[[] for i in range(N)]
for i in range(M):
    Pi,Si=map(str,input().split())
    Pi=int(Pi)
    A[Pi-1].append(Si)

print("<test>") #
print("A=",A) #

nAC=0
nWA=0
inWA=0
for i in range(N):
    if len(A[i])==0:
        pass
    else:
        j=0 
        while A[i][j]=="WA":
            inWA+=1
            nWA+=1
            if j==len(A[i])-1:
                nWA-=inWA
                break
            else:
                pass
            j+=1
        if A[i][j]=="AC":
            nAC+=1
        else:
            pass
        inWA=0
        
print("<ans>") #
print("{:1}{:2}".format(nAC,nWA))



Fixed code:
#print("<input>") #
N,M=map(int,input().split())
A=[[] for i in range(N)]
for i in range(M):
    Pi,Si=map(str,input().split())
    Pi=int(Pi)
    A[Pi-1].append(Si)

#print("<test>") #
#print("A=",A) #

nAC=0
nWA=0
inWA=0
j=0
for i in range(N):
    #print("i=",i) #
    if len(A[i])==0:
        pass
    else: 
        while A[i][j]=="WA":
            inWA+=1
            nWA+=1
            #print("j=",j) #
            #print("inWA=",inWA) #
            #print("nWA=",nWA) #
            if j==len(A[i])-1:
                nWA-=inWA
                break
            else:
                pass
            j+=1
        if A[i][j]=="AC":
            nAC+=1
        else:
            pass
        inWA=0
        j=0
        #print("inWA=",inWA) #
        #print("nWA=",nWA) #
        

#print("<ans>") #
print("{0} {1}".format(nAC,nWA))
Buggy code:
import copy

N,M=map(int,input().split())
L=[list(map(int,input().split())) for i in range(M)]

S=[]
component=[0,0]
for j in range(N):
    S.append(copy.deepcopy(component)

for k in range(1,M+1):
    if L[k-1][1]=='AC':
        if S[L[k-1][0]][0]==0:
            S[L[k-1][0]][0]=1
    else:
        if S[L[k-1][0]][0]==0:
            S[L[k-1][0]][1]+=1

ansAC=0
ansWA=0

for l in range(N):
    ansAC+=S[l][0]
    ansWA+=S[l][1]

print(ansAC,ansWA)




Fixed code:
import copy

N,M=map(int,input().split())
L=[list(map(str,input().split())) for i in range(M)]

for x in range(M):
    L[x][0]=int(L[x][0])

#print(N,M)
#print(L)

S=[]
component=[0,0]
for j in range(N):
    S.append(copy.deepcopy(component))

#print(S)

for k in range(1,M+1):
    if L[k-1][1]=='AC':
        if S[L[k-1][0]-1][0]==0:
            S[L[k-1][0]-1][0]=1
    else:
        if S[L[k-1][0]-1][0]==0:
            S[L[k-1][0]-1][1]+=1
    #print(S)

ansAC=0
ansWA=0

for l in range(N):
    ansAC+=S[l][0]
    if S[l][0]==1:
        ansWA+=S[l][1]

print(ansAC,ansWA)
Buggy code:
n,m = map(int,input().split())
a = [0]*n
ac,wa = 0,0
for i in range(m):
    p,s = map(str,input().split())
    p = int(p)
    if s =="AC" and a[p-1] != -1:
        ac +=1
        wa += a[p-1]
    elif s =="WA" and a[p-1] != -1:
        a[p-1] += 1
print(ac,wa)


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

PS = {}
for _ in range(m):
    p, s = input().split()
    try:
        PS[int(p)].append(s)
    except KeyError:
        PS[int(p)] = [s]
# print(PS)

a, b = 0, 0
for S in PS.values():
    for s in S:
        if "AC" not in s:
            break
        if s == "AC":
            a += 1
            break
        if s == "WA":
            b += 1

print(a, b)

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

PS = {}
for _ in range(m):
    p, s = input().split()
    try:
        PS[int(p)].append(s)
    except KeyError:
        PS[int(p)] = [s]

a, b = 0, 0
for S in PS.values():
    if "AC" in S:
        for s in S:        
            if s == "AC":
                a += 1
                break
            if s == "WA":
                b += 1

print(a, b)