Problem:
 Score : 300 points    Problem Statement Takahashi participated in a contest on AtCoder.  The contest had N problems.  Takahashi made M submissions during the contest.  The i -th submission was made for the p_i -th problem and received the verdict S_i ( AC or WA ).  The number of Takahashi's correct answers is the number of problems on which he received an AC once or more.  The number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WA s received before receiving an AC for the first time on that problem.  Find the numbers of Takahashi's correct answers and penalties.      Constraints  N , M , and p_i are integers.  1 \leq N \leq 10^5  0 \leq M \leq 10^5  1 \leq p_i \leq N  S_i is AC or WA .         Input Input is given from Standard Input in the following format:  N  M  p_1  S_1  :  p_M  S_M       Output Print the number of Takahashi's correct answers and the number of Takahashi's penalties.        Sample Input 1 2 5
1 WA
1 AC
2 WA
2 AC
2 WA      Sample Output 1 2 2  In his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.  In his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.  Thus, he has two correct answers and two penalties.       Sample Input 2 100000 3
7777 AC
7777 AC
7777 AC      Sample Output 2 1 0  Note that it is pointless to get an AC more than once on the same problem.       Sample Input 3 6 0      Sample Output 3 0 0

Solution (Python):
N,M=map(int,input().split())
ac=[0]*N
wa=[0]*N
for i in range(M):
  p,s=input().split()
  p=int(p)-1
  if not ac[p]:
    if s>"AC":
      wa[p]+=1
    else:
      ac[p]=1
a=0
w=0
for i in range(N):
  if ac[i]:
    a+=1
    w+=wa[i]
print(a,w)

Solution (Python):
from collections import defaultdict
N, M = map(int, input().split())
X = [False] * N
D = defaultdict(int)
ans = 0
for i in range(M):
    p, s = input().split()
    p = int(p) - 1

    if X[p] is False:
        if s == 'WA':
            D[p] += 1
            ans += 1
        else:
            X[p] = True


for i in range(N):
    if X[i] is False:
        ans -= D[i]

print(sum(X), ans)

Solution (Python):
n, m = map(int, input().split())

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

for i in range(m):
    no, re = input().split()
    no = int(no) - 1
    if re == "AC":
        ac[no] = True
    else:
        if not ac[no]:
            wa[no] += 1

a = sum(ac)
b = 0
for i in range(n):
    if ac[i]:
        b += wa[i]

print("{} {}".format(a, b))

Solution (Python):
n,m = map(int,input().split(' '))
score = 0
penalty = 0
penalties = {}
acs = set()
for _ in range(m):
    num,result = input().split(' ')
    if num in acs:
        continue
    
    if result == "WA":
        if num in penalties:
            penalties[num] +=1
        else:
            penalties[num] =1
    else:
        score +=1
        if num in penalties:
            penalty += penalties[num]
        acs.add(num)

print(score,penalty)

Solution (Python):
N, M = [int(i) for i in input().split()]

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

Solution (Python):

import sys
n,m=map(int,input().split())
ps=[]
num={}

ac=0
pena=0
if m==0:
    print('0 0')
    sys.exit()
for i in range(m):
    result=input().split()
    ps.append(result)
    if result[1]=="AC":
        num[result[0]]=0

for x in ps:
    if not x[0] in num:
        continue
    if x[1]=="WA" and num[x[0]]==0:
        pena+=1
    if x[1]=="AC" and num[x[0]]==0:
        ac+=1
        num[x[0]]=1

print(ac,pena)

Solution (Python):
N, M = map(int, input().split())

ac = 0
wa = 0

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

print(ac, wa)

Solution (Python):
n, m = map(int, input().split())
ans = []
for i in range(n):
    ans.append([0, 'WA'])
for i in range(m):
    p, s = map(str, input().split())
    p = int(p)-1
    if(s=='WA' and ans[p][1] == "WA"):ans[p][0]+=1
    else:ans[p][1] = 'AC'
ac = 0
wa = 0
for i in ans:
    if(i[1] == 'AC'):
        ac+=1
        wa+=i[0]
print(ac, wa)

Solution (Python):


import math


def inputIntList():
  return [int(s) for s in input().split()]


def inputInt():
  return int(input())


def main():
  N, M = inputIntList()

  ac = 0
  wa = 0
  problem = [['', 0] for _ in range(N)]
  for _ in range(M):
    i, s = input().split()
    i = int(i)-1
    if problem[i][0] == 'AC':
      continue
    else:
      problem[i][0] = s

    if problem[i][0] == 'WA':
      problem[i][1] += 1
    else:
      ac += 1
  for result, wa_cnt in problem:
    if result == 'AC':
      wa += wa_cnt
  return '{} {}'.format(ac, wa)


if __name__ == "__main__":
  print(main())

Solution (Python):
n, m = map(int, input().split())
ac = set()
pena = 0

wa = [0] * (n+1)
for i in range(m):
    
    p, s = input().split()
    p = int(p)
    if p in ac:
        continue
    if s == 'AC':
        
        pena += wa[p]
        
        ac.add(p)
    else:
        
        wa[p] += 1
print(len(ac), pena)

Solution (Python):
N, M = map(int, input().split())
PS = []
for i in range(M):
    p, s = input().split()
    PS.append([int(p), s])

ac = [False] * N
pena = [0] * N

for p, s in PS:
    p -= 1
    if ac[p]:
        continue

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

a_cnt = 0
w_cnt = 0
for i in range(N):
    if ac[i]:
        a_cnt += 1
        w_cnt += pena[i]

print(a_cnt, w_cnt)

Solution (Python):
def main():
    N, M = [int(x) for x in input().split()]

    accepted = set()
    ans = 0
    from collections import defaultdict
    wa_count = defaultdict(int)
    for i in range(M):
        p, s = input().split()
        if p in accepted:
            continue
        if s == "WA":
            wa_count[p] += 1
        else:
            accepted.add(p)
            ans += wa_count[p]
    print(len(accepted), ans)


if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())
X = [[] for _ in range(N)]
for _ in range(M):
    p, s = input().split()
    p = int(p) - 1
    X[p].append(s)

def wacnt(y):
    if y.count("AC") == 0: return 0
    re = 0
    for a in y:
        if a == "AC": return re
        re += 1
ac = sum([min(x.count("AC"), 1) for x in X])
wa = sum([wacnt(x) for x in X])
print(ac, wa)

Solution (Python):

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)


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 = " ")

Solution (Python):

from collections import defaultdict
dd = defaultdict(int)
N,M = map(int, input().split())
ans = 0
ac = 0
for m in range(M):
    p, s = input().split()
    p = int(p)
    if dd[p] != -1:
        if (s=="WA"):
                dd[p]+=1
        else:
            ans += dd[p]
            ac += 1
            dd[p] = -1
print (ac,ans)

Solution (Python):
n, m = input().split()
n = int(n)
m = int(m)



correct = 0
pn = 0
done_list = [0] * n
pn_list = [0] * n

for i in range(m):
    a,b=input().split()
    
    if done_list[int(a)-1] == 0 and b == "AC":
        done_list[int(a)-1] += 1
        correct += 1
        pn += pn_list[int(a) - 1]
    elif b == "WA":
        pn_list[int(a) - 1] += 1

print(correct, pn)

Solution (Python):
s = input().split()
n=int(s[0])
m=int(s[1])
acc=0
penalty={}
ans={}
pen=0
for i in range(n+1):
    penalty[str(i)]=0
    ans[str(i)]=0
for i in range(m):
    s = input().split()
    if s[1]=='AC':
        ans[s[0]]=1
    if ans[s[0]]==0 and s[1]=='WA':
        penalty[s[0]]+=1
for p in penalty:
    if ans[p]==1:
        pen+=penalty[p]
print(list(ans.values()).count(1),pen)

Solution (Python):
N, M = map(int, input().split())
PS = []
for i in range(M):
    p, s = input().split()
    PS.append([int(p), s])

a_w = []
for i in range(N+1):
    a_w.append([False, 0])

a_cnt = 0
w_cnt = 0
for p, s in PS:
    
    if a_w[p][0]:
        continue

    
    if s == 'AC':
        a_w[p][0] = True
        a_cnt += 1
        w_cnt += a_w[p][1]
    else:
        a_w[p][1] += 1


print(a_cnt, w_cnt)

Solution (Python):
from collections import defaultdict
N, M = map(int, input().split())
L = []
for i in range(M):
  L += [input().split()]

WA = defaultdict(lambda: 0)
cnt_AC = 0
alr = set()
for j, k in L:
  j = int(j)
  if j in alr:
    continue
  if k == 'AC':
    cnt_AC += 1
    alr.add(int(j))
  else:
    WA[j] += 1

print(cnt_AC, sum(WA[l] for l in alr))

Solution (Python):
N, M = map(int, input().split())
PS = []
for i in range(M):
    p, s = input().split()
    PS.append([int(p), s])

a_w = []
for i in range(N+1):
    a_w.append([False, 0])

for p, s in PS:
    if s == 'AC':
        a_w[p][0] = True
    else:
        if not a_w[p][0]:
            a_w[p][1] += 1

a_cnt = 0
w_cnt = 0
for a, w in a_w:
    if a:
        a_cnt += 1
        w_cnt += w
print(a_cnt, w_cnt)

Solution (Python):
n, m = map(int, input().split())
flag=[0]*n
wa=0
ac=0

for i in range(m):
  p,s = input().split()
  p=int(p)-1
  
  if flag[p]!='AC':
    if s=='WA':
      
      flag[p]+=1
    else:
      ac+=1
      wa+=flag[p] 
      flag[p]='AC'
print(ac, wa)

Solution (Python):
N, M = map(int, input().split())

ac = [0] * N
wa = [0] * N

for i in range(M):
    p,s = input().split()
    p = int(p)
    p -= 1
    if ac[p]:
        continue
    if s == 'AC': 
        ac[p] = 1
    else:
        wa[p] += 1
AC = sum(ac)
WA = 0
for i in range(N):
    if ac[i]:
        WA += wa[i]
print(AC, WA)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline

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

WA = [0] * (N + 1)
wa = 0
AC = [False] * (N + 1)
for _ in range(M):
    p, S = readline().split()
    p = int(p)
    if AC[p]:
        continue

    if S == 'AC':
        AC[p] = True
        wa += WA[p]
    else:
        WA[p] += 1

print(sum(AC), wa)

Solution (Python):
N,M=map(int,input().split())
    
if M==0 :
    print(0,0)
    exit()

ACCNT=[False]*N
Asum=0
WACNT=[0]*N

for i in range(M):
    PI,SI=input().split()
    iii=int(PI)-1
    if ACCNT[iii]==False:
        if SI=="WA" :
            WACNT[iii]=WACNT[iii]+1
        elif SI=="AC" :
            ACCNT[iii]=True
            Asum=Asum+1

Wsum=0
for i in range(N):
    if ACCNT[i]==True:
        Wsum=Wsum+WACNT[i]

print(Asum,Wsum)

Solution (Python):
N,M = list(map(int, input().split()))
ps = []
for i in range(M):
    p, s = input().split()
    ps.append([int(p), s])

ac = {}
wa = {}
for i in range(M):
    if ps[i][1] == 'AC':
        if not ac.get(ps[i][0]):
            ac[ps[i][0]] = 1
    else:
        if not ac.get(ps[i][0]):
            wa[ps[i][0]] = wa.get(ps[i][0], 0)
            wa[ps[i][0]] += 1

ansac = len(ac.keys())
answa = 0
for k in wa.keys():
    if ac.get(k):
        answa += wa[k]

print(ansac, answa)

Solution (Python):
n,m = map(int, input().split())
ac = [0] * (n+1)
wa = [0] * (n+1)
ans = [0, 0]

for i in range(m):
    p,s = map(str, input().split())
    p = int(p)-1
    
    if ac[p] == 1:
        continue
    elif s == "WA":
        wa[p] +=1
    else:
        ans[0] += 1
        ans[1] += wa[p]
        ac[p] += 1
print(*ans)

Solution (Python):
import sys


def solve(inp):
    (N, M) = map(int, inp.readline().strip().split(' '))
    PS = [inp.readline().strip().split(' ') for i in range(M)]

    total_penalty = 0
    total_ac = 0
    pena = {}
    ac = {}
    for (P, S) in PS:
        P = int(P) - 1
        if S == "WA":
            if P not in pena:
                pena[P] = 0
            pena[P] += 1
        elif S == "AC":
            if P not in ac:
                total_ac += 1
                ac[P] = 1
                if P in pena:
                    total_penalty += pena[P]
    return "{} {}".format(total_ac, total_penalty)


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()

Solution (Python):
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)

Solution (Python):
n,m=map(int,input().split())
j=[0]*n
c=[0]*n
wa=0
ac=0
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if s[0]=="A" and j[p]==0:
        j[p]=1
        ac+=1
        wa+=c[p]
    elif s[0]=="W":c[p]+=1
print(ac,wa)

Solution (Python):
N, M = map(int, input().split())
P = [0 for _ in range(N+1)]
S = [0 for _ in range(N+1)]

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

for i in range(N+1):
    if S[i] == 0 and P[i] > 0:
      P[i] = 0
        
print(sum(S), sum(P))

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    PS=[None]*m
    for i in range(m):
        p,s=input().split()
        PS[i]=int(p)-1,s

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

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

    print(ac,wa)
resolve()

Solution (Python):
N,M = map(int,input().split())
AC = {} 
WA = {}
acNum = 0

for i in range(M):
    p,S = input().split()
    p = int(p)
    if S == 'AC':
        if p in AC:
            pass
        else:
            AC[p] = 1
            acNum += 1
    else:
        
        if not p in AC:
            if not p in WA:
                WA[p] = 0
            WA[p]+=1


peNum = 0
for k,v in WA.items():
    if k in AC:
        peNum += v

print(acNum,peNum)

Solution (Python):
import sys

n, m = map(int, sys.stdin.readline().split())
pv = []
for _ in range(m):
    p, v = sys.stdin.readline().split()
    p = int(p)
    v = 1 if v == 'AC' else 0
    pv.append((p, v))

def main():
    ac = [0] * (n + 1)
    wa = [0] * (n + 1)
    for p, v in pv:
        wa[p] += (ac[p] | v) ^ 1
        ac[p] |= v
    
    for p in range(1, n+1):
        wa[p] *= ac[p]

    return sum(ac), sum(wa)

if __name__ == '__main__':
    ans = main()
    print(*ans, sep=' ')

Solution (Python):
n, m = [int(s) for s in input().split()]
a = [0 for _ in range(n)]
for i in range(m):
  p, res = input().split()
  p = int(p) - 1
  if a[p]%2==0:
  	a[p] += 2 if res=='WA' else 1
  
print(sum([tmp%2 for tmp in a]), sum([tmp//2 if tmp%2==1 else 0 for tmp in a]))

Solution (Python):
N,M = map(int, input().split())
ac = 0
count = [0 for i in range(N)]
done = [False for i in range(N)]
ans = 0
for i in range(M):
    p,s = input().split()
    p = int(p) - 1
    if done[p]:
        continue
    elif s == 'AC':
        done[p] = True
        ac += 1
        ans += count[p]
    else:
        count[p] += 1

print( ac, ans)

Solution (Python):
import sys
N,M = map(int,input().split())
if M == 0:
    print('%d %d' % (0,0))
    sys.exit(0)
Liste = dict()
Question = [0] * M
ACorWE = [0] * M
correct = 0
penalty = 0
for i in range(M):
    Question[i], ACorWE[i]= map(str, input().split())
Question = [int(element) for element in Question]
for _ in Question:
    Liste[_] = [0] 
for i in range(M):
    Liste[Question[i]].append(ACorWE[i])
for liste in Liste:
    while 0 in Liste[liste]:
        Liste[liste].remove(0)
AC = []
for key in Liste:
    if 'AC' in Liste[key]:
        correct += 1
        AC.append(key)
j = 0
for key in AC:
    while Liste[key][j] != 'AC' and j<len(Liste[key]):
        penalty += 1
        j += 1 
    j = 0         
print('%d %d' % (correct,penalty))

Solution (Python):
n,m=map(int,input().split())
cnt=[0 for i in range(n)]
done=[False for i in range(n)]
ac, pen = 0, 0
for i in range(m):
  p,s=input().split()
  p=int(p)
  p-=1
  if done[p]:
    continue
  elif s=='AC':
    done[p]=True
    ac += 1
    pen += cnt[p]
  else:
    cnt[p] += 1
print('{} {}'.format(ac,pen))

Solution (Python):
from operator import mul
N, M = map(int, input().split())
p = [0]*M
S = [None]*M

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

p = list(map(int, p))
clear_flag = [0]*(N+1)
correct_N = 0
wrong_N = [0]*(N+1)

for i in range(M):

    if clear_flag[p[i]] == 0:
        if S[i] == 'AC':
            correct_N += 1
            clear_flag[p[i]] = 1
        else:
            wrong_N[p[i]] += 1

wa =  sum(map(mul, clear_flag, wrong_N))
print(correct_N, wa)

Solution (Python):
N, M = map(int, input().split())
ans_list = [False] * N
WA = [0] * N

now = 0
false_count = 0
ans_false = 0
ans = 0



for i in range(M):
    p, s = input().split()
    if ans_list[int(p) - 1]:
        continue
    if s == "AC":
        ans += 1
        ans_false +=  WA[int(p) - 1]
        ans_list[int(p) - 1] = True
    else:
        WA[int(p) - 1] += 1
 
print(ans, ans_false)

Solution (Python):
n, m = map(int, input().split())  
lst = [input().split() for i in range(m)]

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

for i in range(m):
    p_i = int(lst[i][0])
    s_i = lst[i][1]
    if s_i == 'AC':
        ac[p_i-1] = True
    else:
        if ac[p_i-1] is False:
            wa[p_i-1] += 1

num_ac = 0
pnlt = 0
for i in range(n):
    if ac[i]:
        num_ac += 1
        pnlt += wa[i]
print(num_ac, pnlt)

Solution (Python):
n, m = map(int, input().split())  
lst = [input().split() for i in range(m)]

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

for i in range(m):
    p_i = int(lst[i][0])
    s_i = lst[i][1]
    if s_i == 'AC':
        ac[p_i-1] = True
    else:
        if ac[p_i-1] is False:
            wa[p_i-1] += 1




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

Solution (Python):
N, M = map(int, input().split())

AC, WA, C = 0, 0, [0] * N
for _ in range(M):
    p, S = input().split()
    p = int(p) - 1
    if C[p] >= 0:
        if S == 'AC':
            AC, WA, C[p] = AC + 1, WA + C[p], -1
        else:
            C[p] += 1

print(AC, WA)

Solution (Python):
n, m = map(int, input().split())

hasAC, pena = [0] * n, [0] * n

for i in range(m):
    li = input().split()
    p = int(li[0]) - 1
    s = li[1]
    if hasAC[p]: continue
    if s == 'AC': hasAC[p] = 1
    else: pena[p] += 1
AC, pena_sum = 0, 0
for i in range(n):
    AC += hasAC[i]
    if hasAC[i]: pena_sum += pena[i]
print(AC, pena_sum)

Solution (Python):
from sys import stdin
import sys
import numpy as np
import collections
from functools import cmp_to_key
import heapq


def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()

def main():
    N, M = rip()
    P = [0] * M
    S = [""] * M
    for i in range(M):
        ss = rsa()
        P[i] = int(ss[0]) - 1
        S[i] = ss[1]
    
    accept = [False] * N
    penalty = [0] * N
    for i in range(M):
        if S[i] == 'AC':
            accept[P[i]] = True
            continue
        if not accept[P[i]]:
            penalty[P[i]] += 1
    
    ac_count = 0
    penalty_count = 0
    for i in range(N):
        if accept[i]:
            ac_count += 1
            penalty_count += penalty[i]
    
    print("{0} {1}".format(ac_count, penalty_count))



if __name__ == "__main__":
    main()

Solution (Python):
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)

Solution (Python):
n, m = map(int, input().split())

hasAC, pena, tmpP= [0] * n, [0] * n, [0] * n

for i in range(m):
    li = input().split()
    p = int(li[0]) - 1
    s = li[1]
    if hasAC[p]:
        continue
    if s == 'AC':
        hasAC[p] = 1
        pena[p] += tmpP[p]
    else:
        tmpP[p] += 1

print(sum(hasAC), sum(pena))

Solution (Python):
n,m = map(int,input().split())
ac = [0]*n
wa = [0]*n
pena = 0

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

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

Solution (Python):
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y


N,M=LI()
RES=[[0,0] for _ in range(N+1)]
WA=0
AC=0
for i in range(M):
    ps, re = input().split()
    n = int(ps)
    if not RES[n][0]:
        if re == "AC": RES[n][0] = 1
        else: RES[n][1] += 1


for i,j in RES:
    AC += i
    if i: WA += j

print("{} {}".format(AC, WA))

Solution (Python):
N, M = map(int, input().split())
ac = [0] * (N+1)  
wa = [0] * (N+1)
ans= [0, 0]

for i in range(M):
    p, s = input().split()
    p = int(p)-1
    if ac[p] == 1:
        continue
    elif s == "WA":
        wa[p] += 1
    else:
        ans[0] += 1
        ans[1] += wa[p]
        ac[p] = 1
print(*ans)

Solution (Python):
n,m = map(int,input().split())
x = [0]*(n+1)
t = [0]*(n+1)
p=q=0
for i in range(m):
  k,l = input().split()
  y=int(k)-1
  if x[y]==0:
    if l=='WA':
      t[y]+=1
    else:
      q+=t[y]
      p+=1
      x[y]=1
print(p,q)

Solution (Python):
n, m = map(int, input().split())
ac = {}
wa = {}
for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC':
        ac[p] = 1
    else:
        if not ac.get(p, 0):
            wa[p] = wa.get(p, 0) + 1
pen = 0
for p in ac:
    pen += wa.get(p, 0)
print(len(ac), pen)

Solution (Python):
N, M = map(int, input().split())
P = [0] * N  
wa = [0] * N  
ac, penalty = 0, 0

for _ in range(M):
    
    p, S = input().split()
    p = int(p)
    if P[p-1] == 1:
        
        continue
    elif S == "WA":
        
        wa[p-1] += 1
    else:
        
        ac += 1
        penalty += wa[p-1]
        P[p-1] = 1
print(ac, penalty)

Solution (Python):
n, m = map(int, input().split())
resultList = [[0] * 2 for i in range(n)]

ansAC = 0
ansWA = 0
for i in range(m) :
    result = input().split()
    prob = int(result[0]) - 1
    if result[1] == 'AC' and resultList[prob][0] == 0 :
        resultList[prob][0]= 1
        ansAC += 1
        ansWA += resultList[prob][1]
    if result[1] == 'WA' and resultList[prob][0] == 0 :
        resultList[prob][1] += 1

print(ansAC, ansWA)

Solution (Python):
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 ac[p-1] == 1:
        continue
    
    if s=='AC':
        ac[p-1] = 1
    else:
        wa[p-1] += 1
        

AC=0
WA=0
for i in range(n):
    AC += ac[i]
    if ac[i] == 1:
      WA += wa[i]
print("{} {}".format(AC,WA))

Solution (Python):
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 ac[p-1] == 1:
        continue
    if s=='AC':
        ac[p-1] = 1
    else:
        wa[p-1] += 1
AC=0
WA=0
for i in range(n):
    AC += ac[i]
    if ac[i] == 1:
        WA += wa[i]
print("{} {}".format(AC,WA))

Solution (Python):
N, M = map(int, input().split())
pS = [tuple(map(str, input().split())) for _ in range(M)]

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

pena = 0
for p, s in pS:
    p = int(p)
    if AC[p]:
        continue
    if s == 'WA':
        WA[p] += 1
    else:
        AC[p] = True
        pena += WA[p]
ac = sum(AC)
print(ac, pena)

Solution (Python):
N, M = map(int, input().split())

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

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

Solution (Python):
n,m=map(int,input().split())
j=[0]*n 
c=[0]*n 
pe=0
ac=0
for i in range(m):
  p,s=input().split()
  p=int(p)-1
  if s[0]=="A" and j[p]==0:
    
    j[p]=1
    ac+=1
    pe+=c[p]
  elif s[0]=="W":c[p]+=1
print(ac,pe)

Solution (Python):
from collections import defaultdict
correct = defaultdict(bool)
local_wa = defaultdict(int)

N, M = map(int, input().split())
p = []
s = []
for i in range(M):
    a, b = input().split()
    p.append(int(a))
    s.append(b)
    
ac = 0
wa = 0


for pp in p:
    correct[pp] = False

for pp, ss in zip(p,s):
    if correct[pp]:
        pass
    else:
        if ss == 'AC':
            correct[pp] = True
            ac += 1
            wa += local_wa[pp]
            local_wa[pp] = 0

        elif ss == 'WA':
            local_wa[pp] += 1
print(ac, wa)

Solution (Python):
n, m = map(int, input().split())
ac = {}
wa = {}
for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC':
        ac[p] = 1
    else:
        if not ac.get(p, 0):
            wa[p] = wa.get(p, 0) + 1
pen = 0
for p in ac:
    pen += wa.get(p, 0)
print(len(ac), pen)

Solution (Python):


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

AC = [0] * N
WA = [0] * N
WA_count = 0

for i in range(M):
    p, S = input().split()
    p = int(p) - 1
    
    if S == "WA" and AC[p] == 0:
        WA[p] += 1
    elif S == "AC" and AC[p] == 0:
        AC[p] += 1
        WA_count += WA[p]
    else:
        continue

print(sum(AC), WA_count)

Solution (Python):
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))

Solution (Python):


import sys
input = sys.stdin.readline

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

ac_set = set()
penalty = 0
wa_count = [0] * (n+1)

for i in range(m):
    p, s = input().split()
    p = int(p)

    if s == "AC":
        if not p in ac_set:
            penalty += wa_count[p]
            ac_set.add(p)
    elif s == "WA":
        wa_count[p] += 1


print(len(ac_set), penalty)

Solution (Python):
from collections import defaultdict



n, m = map(int, input().split())
ac = 0
wa = defaultdict(lambda: 0) 
already = set()
sum_wa = 0
for line in range(m):
    p, s = input().split() 
    p = int(p)
    if p in already: 
        continue
    if s == 'AC':
        ac += 1
        already.add(p) 
        
    else:
        wa[p] += 1 



print(ac, sum(wa[i] for i in already))

Solution (Python):
from collections import defaultdict
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ac = 0
wa = defaultdict(lambda: 0) 
already = set()
sum_wa = 0
for line in range(m):
    p, s = input().split() 
    p = int(p)
    if p in already: 
        continue
    if s == 'AC':
        ac += 1
        already.add(p) 
        
    else:
        wa[p] += 1 



print(ac, sum(wa[i] for i in already))

Solution (Python):
from collections import defaultdict
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ac = 0
wa = defaultdict(lambda: 0) 
already = set()
sum_wa = 0
for line in range(m):
    p, s = input().split() 
    p = int(p)
    if p in already: 
        continue
    if s == 'AC':
        ac += 1
        already.add(p) 
        sum_wa += wa[p]
    else:
        wa[p] += 1 


print(ac, sum_wa)

Solution (Python):
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 ac[p-1]:
        continue
    if s == 'AC':
        ac[p-1] = 1
    else:
        wa[p-1] += 1
count_ac = 0
count_wa = 0
for i in range(n):
    count_ac += ac[i]
    if ac[i]:
        count_wa += wa[i]
print(str(count_ac) + " " + str(count_wa))

Solution (Python):
'''input
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
'''

from sys import stdin, stdout
import gc
gc.disable()
input = stdin.readline




n, m = list(map(int, input().split()))
ac = dict()
wa = dict()
w = 0
for _ in range(m):
	a, t = list(input().split())
	a = int(a)
	if t == 'AC':
		if a in ac:
			pass
		else:
			if a in wa:
				w += wa[a]
			ac[a] = 1

	else:
		if a in ac:
			pass
		else:
			if a in wa:
				wa[a] += 1
			else:
				wa[a] = 1
print(len(ac), w)

Solution (Python):
from collections import defaultdict
 
n, m = map(int, input().split())
ac = 0
wa = defaultdict(lambda: 0) 
already = set()
for line in range(m):
    p, s = input().split() 
    p = int(p)
    if p in already: 
        continue
    if s == 'AC':
        ac += 1
        already.add(p) 
    else:
        wa[p] += 1 

print(ac, sum(wa[i] for i in already))

Solution (Python):
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)
  if AC[p-1] == 1: 
    continue
  if s == 'AC':
    AC[p-1] = 1
  if s == 'WA':
    WA[p-1] += 1


result = [x * y for (x, y) in zip(AC, WA)]
AC_sum = sum(AC)
WA_sum = sum(result)

print(AC_sum, WA_sum)

Solution (Python):

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

isAC = [0] * (N+1)
isWA = [0] * (N+1)

ACnum = 0
WAnum = 0

for _ in range(M):
    p, s = input().split()
    p = int(p)

    if isAC[p] == 1: continue
    if s == 'AC':
        isAC[p] = 1
        ACnum += 1
        WAnum += isWA[p]
    elif s == 'WA':
        isWA[p] += 1

print("%d %d"%(ACnum, WAnum))

Solution (Python):
n, m = map(int, input().split())
lp, ls = [0] * m, [0] * m
for i in range(m):
    lp[i], ls[i] = input().split()

lac = [0] * n
lwa = [0] * n

for j in range(m):
    p = int(lp[j]) - 1
    if lac[p] == 0:
        if ls[j] == 'AC':
            lac[p] = 1
        else:
            lwa[p] += 1

print(sum(lac), sum(x * y for x, y in zip(lac, lwa)))

Solution (Python):
import sys
readline = sys.stdin.buffer.readline

n, m = map(int, readline().split())
ac_lst = [False] * (n + 1)
wa_lst = [0] * (n + 1)
ac = w = 0
for _ in range(m):
    a, b = readline().split()
    a = int(a)
    if ac_lst[a]:
        continue
    if b == b'WA':
        wa_lst[a] += 1
    else:
        ac += 1
        w += wa_lst[a]
        ac_lst[a] = True
print(ac, w)