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())
hasAC = [False] * n 
wa = [0] * n 
a = 0
b = 0

for _ in range(m):
    p, s = map(str, input().split())

    p = int(p) - 1
    if s == 'AC':    
        hasAC[p] = True
    else:
        if not hasAC[p]:
            wa[p] += 1

for i in range(n):
    if hasAC[i]:
        a += 1
        b += wa[i]

print(a, b)

Solution (Python):
import collections
N, M = map(int, input().split())
result = []
for i in range(M):
    p, S = input().split()
    result.append((int(p), S))

AC = collections.defaultdict(bool)
WA = collections.defaultdict(int)

const = 0
score = 0
for p, s in result:
    if s == "AC" and not AC[p]:
        score += 1
        const += WA[p]
        AC[p] = True
    if s == "WA" and not AC[p]:
        WA[p] += 1
print(score, const)

Solution (Python):
from collections import defaultdict

n, m = map(int, input().split())
ps = []
for _ in range(m):
    ps.append(input().split())

sub_st = defaultdict(list)
for p, s in ps:
    sub_st[p].append(s)

solved = 0
error = 0
for k, v in sub_st.items():
    temp_error = 0
    for history in v:
        if 'AC' in history:
            error += temp_error
            solved += 1
            break
        temp_error += 1

print(solved, error)

Solution (Python):

n,w=map(int,input().split())
ac=0
wa=[0]*n
wa_cnt=[0]*n
ac_flg=[0]*n
for i in range(w):
	p,s=input().split()
	p=int(p)-1
	if ac_flg[p]==1:
		continue
	else:
		if s=='AC':
			ac_flg[p]=1
			ac+=1
			wa[p] =wa_cnt[p]
			
		else:
			wa_cnt[p]+=1

wa_ans=0
for i in range(n):
	wa_ans+=wa[i]

print(ac,wa_ans)

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

n_flg = [False for _ in range(n)]
pena_tmp = [0 for _ in range(n)]

pena = 0

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

    p = int(p) - 1


    if n_flg[p]:
        pass
    elif s == 'WA':
        pena_tmp[p] += 1
    elif s == 'AC':
        pena += pena_tmp[p]
        n_flg[p] = True

print(n_flg.count(True), pena)

Solution (Python):

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

Solution (Python):

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

Solution (Python):
d=dict()
wa=ans=0
N,M=map(int,input().split())
for i in range(M):
  p,s=input().split()
  if p not in d:
    d[p]=0
  if d[p]>=0 and s=="AC":
    ans+=1
    wa+=d[p]
    d[p]=-float("inf")
  else:
    d[p]+=1
print(ans,wa)

Solution (Python):
d=dict()
wa=ans=0
N,M=map(int,input().split())
for i in range(M):
  p,s=input().split()
  if p not in d:
    d[p]=0
  if d[p]>=0 and s=="AC":
    ans+=1
    wa+=d[p]
    d[p]=-1
  elif d[p]>=0:
    d[p]+=1
print(ans,wa)

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

Solution (Python):
from collections import defaultdict

N, M = map(int, input().split())
WA = {i : 0 for i in range(1,N+1)}
AC = defaultdict(int)
boollist = [False]*N

for _ in range(M):
    p,s = input().split()
    p = int(p)
    if s == 'WA' and not boollist[p-1]:
        WA[p] += 1
    elif s == 'AC':
        boollist[p-1] = True
        AC[p] = 1
print(sum(AC.values()), sum([a for a,b in zip(WA.values(), boollist) if b==True]))

Solution (Python):
from collections import defaultdict

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

ac_set = set()
wa_count = defaultdict(int)
for p, s in PS:
    if s == 'AC':
        ac_set.add(p)
    else:
        if p not in ac_set:
            wa_count[p] += 1
print(len(ac_set), sum(wa_count[p] for p in ac_set))

Solution (Python):
def solve():
    N,M = map(int, input().split())
    accepted = [False]*(N+1)
    AC_num = [0]*(N+1)
    WA_num = [0]*(N+1)
    res = [0,0]
    for _ in range(M):
        p, submit_res = input().split()
        p = int(p)
        if not accepted[p]:
            if submit_res == 'WA':
                WA_num[p] += 1
                
            else:
                
                AC_num[p] += 1
                accepted[p] = True
                
    res = [sum(accepted[i]*n for i,n in enumerate(AC_num)), sum(accepted[i]*n for i,n in enumerate(WA_num))]
    print(' '.join(map(str, res)))
    
solve()

Solution (Python):
N, M = [int(i) for i in input().split()]
pS = {}
 
for _ in range(M):
    a, s = [i for i in input().split()]
    if a not in pS:
        pS[a] = {}
        if s == 'AC':
            pS[a]['AC'] = True
        else:
            pS[a]['count'] = 1
    else:
        if s == 'AC':
            pS[a]['AC'] = True
        elif 'AC' not in pS[a]:
            pS[a]['count'] += 1
 
s = 0
a = 0
for v in pS.values():
    if 'AC' in v and 'count' in v:
        s += v['count']
    if 'AC' in v:
        a += 1
    
print(a, s)

Solution (Python):
from collections import defaultdict

n, m = map(int, input().split())
PS = [input().split() for _ in range(m)]
ac = defaultdict(bool)
wa = defaultdict(int)
cost = 0
score = 0
for p, s in PS:
  if s == 'AC' and not ac[p]:
    score += 1
    cost += wa[p]
    ac[p] = True
  if s == 'WA' and not ac[p]:
    wa[p] += 1
print(score, cost)

Solution (Python):

import sys


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    A = [False] * (N+1)
    W = [0] * (N+1)
    wans = 0
    for _p, _s in zip(p, S):
        if A[_p]:
            continue
        if _s == 'WA':
            W[_p] += 1
        else:
            A[_p] = True
            wans += W[_p]
    ans = sum(A)
    print(ans, wans)



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    p = [int()] * (M)  
    S = [str()] * (M)  
    for i in range(M):
        p[i] = int(next(tokens))
        S[i] = next(tokens)
    solve(N, M, p, S)

if __name__ == '__main__':
    main()

Solution (Python):
n,m=map(int,input().split())
ps=[list(map(int,input().replace('WA','0').replace('AC','1').split())) for i in range(m)]
ps.sort(key=lambda x:x[0])

tmp_p=0
ac_cnt=0
wa_cnt=0
wa=0
flg=0
for i in range(m):
  p=ps[i][0]
  s=ps[i][1]
  if tmp_p!=p:
    wa=0
    flg=0
  if s==1 and flg==0:
    flg=1
    ac_cnt+=1
    wa_cnt+=wa
  elif s==0 and flg==0:
    wa+=1
  tmp_p=p
print(ac_cnt, wa_cnt)

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

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

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

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



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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
def inputS(): return input().rstrip().decode()
readlines = sys.stdin.buffer.readlines 

N, M = map(int, input().split())
AC = [False]*(N+1)
WA = [0]*(N+1)
WAsum = 0

for _ in range(M):
  p, s = input().split()
  p = int(p)  
  if AC[p]:
    continue
  if s == b"AC":
    AC[p] = True
    WAsum += WA[p]
  else:
    WA[p] += 1
print(sum(AC), WAsum)

Solution (Python):
n,m=map(int,input().split())
ss=set()
s3=set()
penality=0
l=[]
for _ in range(m):
  p,s=input().split()
  p=int(p)
  if s=="AC":
    s3.add(p)
  l.append([p,s])
for i in range(len(l)):
  p=l[i][0]
  s=l[i][1]
  if (p not in ss) and s=="WA" and (p in s3):
    penality+=1
  if s=="AC":
    ss.add(p)
print(len(ss),penality)

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

ac = 0
wa = 0
status = [0 for i in range(n)]

for i in lst:
    if status[i[0]-1]!="AC" and i[1]=="AC":
        ac += 1
        wa += status[i[0]-1]
        status[i[0]-1] = "AC"
    elif status[i[0]-1]!="AC" and i[1]=="WA":
        status[i[0]-1] += 1

print(ac,wa)

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

ac = 0
wa = 0
status = [0 for i in range(n)]

for i in lst:
    if status[i[0]-1]!="AC":
        if i[1]=="AC":
            ac += 1
            wa += status[i[0]-1]
            status[i[0]-1] = "AC"
        else:
            status[i[0]-1] += 1

print(ac,wa)

Solution (Python):
n, m = [int(i) for i in input().split()]
p = []
s = []
for i in range(m):
    q, t = input().split()
    p.append(int(q))
    s.append(t)

is_ac = [0] * (n+1)
wa = [0] * (n+1)
count_ac = count_penalty = 0
for pp, ss in zip(p, s):
    if not is_ac[pp]:
        if ss == 'WA':
            wa[pp] += 1
        else:
            count_ac += 1
            count_penalty += wa[pp]
            is_ac[pp] = 1

print(count_ac, count_penalty)

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

ac=[0]*n
ac_cnt=0
wa_cnt=[0]*n
for i in range(len(l)):
    num = int(l[i][0])-1
    acwa= l[i][1]
    if ac[num]==0:
        if acwa == "AC":
            ac_cnt+=1
            ac[num]=1
        elif acwa=="WA":
            wa_cnt[num]+=1

wa_ans=0
for i in range(n):
    if ac[i] == 1:
        wa_ans+=wa_cnt[i]
print(ac_cnt,wa_ans)

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

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC':
        if not ac[p]:
            ac[p] = True
    else:
        if not ac[p]:
            wa[p] += 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 = [int(elem) for elem in input().split()]
ac = [0] * n
wa = [0] * n
 
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC':
        ac[p] = 1
    if not ac[p] and s == 'WA':
        wa[p] += 1

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

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

aced_state = [False for i in range(N+1)]
wa_state = [0 for i in range(N+1)]

for i in range(M):
    p,s = map(str,input().split())
    p = int(p)
    if aced_state[p] == True:
        continue
    else:
        if s == "AC":
            cnt_ac += 1
            cnt_wa += wa_state[p]
            aced_state[p] = True
        else:
            wa_state[p] += 1

print(cnt_ac,cnt_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) - 1
    if s == 'AC':
        ac[p] = 1
    if not ac[p] and s == 'WA':
        wa[p] += 1

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

Solution (Python):
N, M = map(int, input().split())
missed = {str(i): 0 for i in range(1, N + 1)}
answered = {}
for _ in range(M):
    idx_q, status = input().split()
    if status == 'AC':
        answered[idx_q] = 'AC'
    else:
        if idx_q not in answered:
            missed[idx_q] += 1
answered_num = len(answered)
missed_num = 0
for idx in answered.keys():
    missed_num += missed[str(idx)]
print(answered_num, missed_num)

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

ac_cnt=[False]*n
wa_cnt=[0]*n

for _ in range(m):
    a,b=input().split()
    a=int(a)-1
    if b == "AC":
        ac_cnt[a] = True
    else:
        if ac_cnt[a] == False:
            wa_cnt[a] += 1
c=0
d=0

for i in range(n):
    if ac_cnt[i]:
        c += 1
        d += wa_cnt[i]

print(c,d)

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

ans=dict()
AC=0
WA=0

for i in range(M):
    P,S= map(str,input().split())
    if((P in ans)==False):
        ans[P]=[S]
    else:
        ans[P].append(S)

for i in ans.values():
    tmp=0
    for value in i:
        if(value=='AC'):
            AC+=1
            WA+=tmp
            break
        else:
            tmp+=1
print(AC,WA)

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

x = [False]*n
y = [0]*n

for i in range(m):
  a,b = input().split()
  a = int(a) - 1
  if b =='AC' and x[a] == False:
    x[a] = True
  elif b == 'WA' and x[a] == False:
    y[a] += 1

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

Solution (Python):


def main():
    n, m = map(int, input().split())
    li_answers = [[] for i in range(n + 1)]
    for i in range(m):
        p, s = input().split()
        li_answers[int(p)].append(s)
    acs = 0
    pens = 0
    for i in range(n + 1):
        for j, s in enumerate(li_answers[i]):
            if s == "AC":
                acs += 1
                pens += j
                break
    print(acs, pens)

main()

Solution (Python):

n, m = map(int, input().split())
o = [[0] * 2 for i in range(n)]
acCount = 0
penalty = 0
for i in range(m):
    p, s = input().split()
    if o[int(p)-1][0] == 1:
        pass
    else:
        if s == 'AC':
            o[int(p)-1][0] = 1
        elif s == 'WA':
            o[int(p)-1][1] += 1

for j in range(n):
    if o[j][0] == 1:
        acCount += 1
        penalty += o[j][1]
    else:
        pass

print(acCount, penalty)

Solution (Python):
n, m = map(int, input().split())
wa = [0 for _ in range(n)]
ac = [0 for _ in range(n)]

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

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

print(ac_ans, wa_ans)

Solution (Python):
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)


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


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]


def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,m = get_nums_l()
qqq = list(map(lambda s: s.strip().split(), sys.stdin.readlines()))
qqq = list(map(lambda q: (int(q[0]), q[1]), qqq))
qqq.sort(key=lambda q: q[0])

prev = None
wa = 0
accepted = set()
ans_wa = 0
for q in qqq:
    no = q[0]
    ju = q[1]
    if no != prev:
        wa = 0
    if ju == "AC":
        if no not in accepted:
            accepted.add(no)
            ans_wa += wa
    if ju == "WA":
        wa += 1
    prev = no

print(len(accepted), ans_wa)

Solution (Python):
import sys
N, M, *PS = sys.stdin.read().strip().split()
N = int(N)
ac = [0] * N
wa = [0] * N
for p, s in zip(*[iter(PS)] * 2):
  p = int(p) - 1
  if s == "AC":
    ac[p] = 1
  elif ac[p] == 0:
    wa[p] += 1
penalties = sum(w * a for a, w in zip(ac, wa))
print(sum(ac), penalties)

Solution (Python):
import sys
N, M, *PS = sys.stdin.read().strip().split()
N = int(N)
ac = [0] * N
wa = [0] * N
for p, s in zip(*[iter(PS)] * 2):
  p = int(p) - 1
  if s == "AC":
    ac[p] = 1
  elif ac[p] == 0:
    wa[p] += 1
penalties = sum(w if a > 0 else 0 for a, w in zip(ac, wa))
print(sum(ac), penalties)

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

N=[]

for i in range(n):
    N.append([0,0])

co=0
pe=0
for i in range(m):
    p,s=input().split()
    p=int(p)
    if s=='WA':
        N[p-1][0]+=1
    elif N[p-1][1]!=1:
        pe+=N[p-1][0]
        co+=1
        N[p-1][1]=1

print(str(co)+' '+str(pe))

Solution (Python):
N, M = list(map(int, input().split()))
pen_tot = 0
corr_tot = 0
ac = [0 for _ in range(N)]
pen = [0 for _ in range(N)]

for _ in range(M):
  pi, ans = input().split()
  pi = int(pi) - 1
  if ac[pi] == 0:
    if ans == 'WA':
        pen[pi] += 1
    else:
      corr_tot += 1
      ac[pi] = 1
      pen_tot += pen[pi]
    
  
print('{} {}'.format(corr_tot, pen_tot))

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

s = {i + 1 for i in range(n)}

ac = 0
wa = {i + 1:[0, False] for i in range(n)}


for i in range(m):
  if int(p[i][0]) in s:
    if p[i][1] == 'WA':
      wa[int(p[i][0])][0] += 1
    else:
      ac += 1
      s.discard(int(p[i][0]))
      wa[int(p[i][0])][1] = True
      
wa_wa = 0
for i in range(1, n + 1):
  if wa[i][1]:
    wa_wa += wa[i][0]
print(ac, wa_wa)

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

s = {i + 1 for i in range(n)}

ac = 0
wa = {i + 1:[0, False] for i in range(n)}


for i in range(m):
  if int(p[i][0]) in s:
    if p[i][1] == 'WA':
      wa[int(p[i][0])][0] += 1
    else:
      ac += 1
      s.discard(int(p[i][0]))
      wa[int(p[i][0])][1] = True
      
wa_wa = 0
for i in range(1, n + 1):
  if wa[i][1]:
    wa_wa += wa[i][0]
print(ac, wa_wa)

Solution (Python):
from collections import defaultdict

N,M=map(int,input().split())
P=[]
S=[]
for i in range (M):
	A,B=input().split()
	P.append(int(A))
	S.append(B)
Q=defaultdict(lambda:0)
R=defaultdict(lambda:0)
count=0
for i,j in zip(P,S):
  if Q[i]==0:
    if j=="AC":
      Q[i]=1
      count+=R[i]
    elif j=="WA":
      R[i]+=1
print(sum(Q.values()),count)

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

AC = 0
WA = 0
PS = {}
for _ in range(M):
    p, S = input().split()
    tmp = PS.get(p)
    
    if tmp == None:
        if S == "AC":
            PS[p] = S
            AC += 1
        else:
            PS[p] = 1
    elif tmp != "AC":
        if S == "AC":
            PS[p] = S
            AC += 1
            WA += tmp
        else:
            PS[p] += 1
print(AC, WA)

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


















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




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

    if AC[p-1] == False:
        if S == "AC":
            AC[p-1] = True
        else:
            WA[p-1] += 1


a = 0
w = 0
for i in range(N):
    if AC[i]:
        a += 1
        w += WA[i]

print(a, w)

Solution (Python):

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

print(sum(flag),ans)

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

is_acs = [False] * n
wa_counts = [0] * n

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

    if s == "AC":
        is_acs[p] = True

    elif not is_acs[p]:
        wa_counts[p] += 1


ac_count = 0
penalty_count = 0

for a, w in zip(is_acs, wa_counts):
    if a:
        ac_count += 1
        penalty_count += w

print(ac_count, penalty_count)

Solution (Python):
from collections import defaultdict
n,m=map(int,input().split())
p,s=[],[]
for i in range(m):
    P,S=input().split()
    p.append(int(P))
    s.append(S)

pena=0
cnt_ac=defaultdict(lambda :0)
cnt_wa=defaultdict(lambda :0)
for x,y in zip(p,s):
    if cnt_ac[x]==0:
        if y=='AC':
            cnt_ac[x]=1
            pena+=cnt_wa[x]

        elif y=='WA':
            cnt_wa[x]+=1

print(sum(cnt_ac.values()),pena)

Solution (Python):
import sys

def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import math
import heapq
import fractions
from collections import defaultdict, Counter, deque
MOD = 10**9 + 7
INF = 10**15

def getyaku(n):
    res = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            res.append(i)
            res.append(n // i)

    return(sorted(list(set(res))))

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def main():
    n,m = getlist()
    wa = [0 for i in range(n)]
    ac = [0 for i in range(n)]
    ansa = 0
    ansp = 0
    for i in range(m):
        p, s = input().split()
        p = int(p) -1
        if s == "AC":
            if not ac[p]:
                ansa += 1
                ansp += wa[p]
                ac[p] = 1
        else:
            wa[p] += 1

    print(ansa, ansp)

    return

if __name__ == '__main__':
    main()

"""
9999
3

2916
"""

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

AC = {}
WA = {}

if M == 0:
    print("0 0")
    exit()
for i in range(M):
    prob,sub = input().split()
    if sub == "WA":
        if (prob in AC) == False:
            if (prob in WA) == False:
                WA[prob] = 1
            else:
                WA[prob] += 1
    
    if sub == "AC":
         if (prob in AC) == False:
            AC[prob] = 1
         else:
            AC[prob] += 1
            
ans_WA = 0
for prob,sub in WA.items():
    if (prob in AC) == True:
        ans_WA += int(sub)
            
print(len(AC.values()),ans_WA)

Solution (Python):
n, m = map(int, input().split())
d = {}
s_ac = set()
ac = 0
pen = 0
for i in range(m):
    p, s = map(str, input().split())
    p = int(p)
    if s == 'AC':
        if p not in s_ac:
            ac += 1
            s_ac.add(p)
            if p in d:
                pen += d[p]
    else:
        if p not in d:
            d[p] = 1
        else:
            d[p] += 1
print(ac, pen)

Solution (Python):
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
t = [0] * (N + 1)
vis = set()
res = 0
for i in range(M):
  p, s = input().split()
  p = int(p)
  if s == "WA": t[p] += 1
  else:
    if p in vis: continue
    res += t[p]
    vis.add(p)
print(len(vis), res)

Solution (Python):
N, M = map(int, input().split())
ac = [False] * N
wa = [0] * N
ac_count = 0
wa_count = 0
for i in range(M):
    p, S = input().split()
    p = int(p)
    p -= 1
    if ac[p]:
        continue
    if S == 'AC':
        ac[p] = True
        ac_count += 1
        wa_count += wa[p]
    else:
        wa[p] += 1
print(ac_count, wa_count)

Solution (Python):
N, M = map(int,input().split())
L = [0 for k in range(N)]
a = 0
p = 0
for k in range(M):
    s, t = input().split()
    if t == "WA":
        L[int(s)-1] += 1
    else:
        if L[int(s)-1] >= 0:
            a += 1
            p += L[int(s)-1]
            L[int(s)-1] = -100001
print(a,p)

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

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

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

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

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n, m = na()
wa = [0] * n
ac = [0] * n
ans = 0
for _ in range(m):
    p, s = ns().split()
    p = int(p) - 1
    if s == "WA" and ac[p] == 0:
        wa[p] = wa[p] + 1
    if s == "AC" and ac[p] == 0:
        ans += wa[p]
        ac[p] = 1
print(sum(ac), ans)

Solution (Python):
n,m=map(int,input().split())
ac_list=[None]*n
wa_list=[0]*n
ans=0
for i in range(m):
    q,status=input().split()
    q=int(q)
    if status=="AC" and ac_list[q-1]==None:
        ac_list[q-1]=True
        ans+=wa_list[q-1]
    elif status=="WA" and ac_list[q-1]==None:
        wa_list[q-1]+=1
x=ac_list.count(True)
print(x,ans)

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    PS=[ST().split() for _ in range(M)]
    AC=set()
    WA=defaultdict(int)
    pena = 0
    for p,s in PS:
        if p in AC:
            continue
        if s == "AC":
            AC.add(p)
            pena += WA[p]
        else:
            WA[p]+=1
    print(len(AC), pena)
    

if __name__ == '__main__':
    main()

Solution (Python):



N, M = map(int, input().split())
result_list = []
for i in range(M):
    result_list.append(input().split())

ans_num = 0 
penalty_num = 0 

correct_memo = {} 
penalty_memo = [0 for i in range(N+1)] 

for r in result_list:
    key = int(r[0])
    if key in correct_memo: 
        continue

    if r[1]=='WA': 
        penalty_memo[key] = penalty_memo[key] + 1
    elif r[1]=='AC':
        correct_memo[key] = 1 
        ans_num = ans_num + 1
        penalty_num = penalty_num + penalty_memo[key]

print(ans_num, penalty_num)

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


AC = [False] * N
WA_cnt = [0] * N

pena = 0
for p,S in pS:
    p = int(p) - 1

    if AC[p]:
        continue

    if S == "WA":
        WA_cnt[p] += 1
    else:
        AC[p] = True
        pena += WA_cnt[p]
    
ac = sum(AC)
print(ac,pena)

Solution (Python):
N,M = map(int,input().split())
PS = [input().split() for i in range(M)]
penas = {}
acs = set()
pena = 0
for p,s in PS:
    if s=='AC':
        if p in acs: continue
        acs.add(p)
        if p in penas:
            pena += penas[p]
    else:
        if p in penas:
            penas[p] += 1
        else:
            penas[p] = 1
print(len(acs), pena)

Solution (Python):
def main():
    N, M = (int(i) for i in input().split())
    PS = [[i for i in input().split()] for j in range(M)]
    dic = {i: ["?", 0] for i in range(1, N+1)}
    for p, s in PS:
        p = int(p)
        if dic[p][0] != "AC" and s == "WA":
            dic[p][1] += 1
        elif s == "AC":
            dic[p][0] = "AC"
    ans = [0, 0]
    for k, v in dic.values():
        if k == "AC":
            ans[0] += 1
            ans[1] += v
    print(*ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    penalty = [0] * N
    accepted = [False for _ in range(N)] 
    totalPenalty = 0
    totalAccepted = 0
    for _ in range(M):
        p, s = map(str, input().strip("\n").split())
        if s == "WA" and not accepted[int(p) - 1]: penalty[int(p) - 1] += 1
        else:
            if not accepted[int(p) - 1]:
                accepted[int(p) - 1] = True
                totalAccepted += 1
                totalPenalty += penalty[int(p) - 1]
    print(totalAccepted, totalPenalty)

    return 0

if __name__ == "__main__":
    solve()

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

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

for i in range(M):
    p,S = list(map(str,input().split()))
    p = int(p)-1
    
    if S == 'AC' and AC[p] == 0:
        AC[p] = 1
        miss += WA[p]
        
    WA[p] += 1
        
print(sum(AC),miss)

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

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

for p, s in PS:
    p = int(p)
    if AC[p]:
        continue
    elif s == "WA":
        WA_cnt[p] += 1
        
    elif s == "AC":
        ans += 1
        pena += WA_cnt[p]
        AC[p] = True

print(ans, pena, sep=' ')

Solution (Python):
n, m = map(int, input().split())
l = [False] * n
c = [0] * n
ans = [0, 0]
for i in range(m):
  p, r = map(str, input().split())
  if l[int(p) - 1] == False:
    if r == "WA":
      c[int(p) - 1] += 1
    elif r == "AC":
      l[int(p) - 1] = True
      ans[0] += c[int(p) - 1]
      ans[1] += 1
print(ans[1], ans[0])

Solution (Python):
def main():
    k, n = map(int, input().split())
    dp = [0] * (k+1)
    dq = [0] * (k+1)
    pen = 0
    for i in range(n):
        p,q = input().split()
        p = int(p)
        if dp[p] == 0:
            if q == 'WA':
                dq[p] += 1
            elif q == 'AC':
                dp[p] = 1
                pen += dq[p]
    print(sum(dp), pen)

if __name__ == '__main__':
    main()

Solution (Python):
N,M = map(int,input().split())
p = ['0']*M
S = ['0']*M
for i in range(M):
  p[i],S[i]= map(str,input().split())
AC = [0]*(N+1)
WA = [0]*(N+1)
i = 0
for i in range(M):
  if S[i] == 'WA':
    if AC[int(p[i])] == 0:
      WA[int(p[i])] = WA[int(p[i])]+1
    else:
      None
  else:
    AC[int(p[i])]=1
count = 0
for i in range(N+1):
  if AC[i]==0:
    count = count+WA[i]
print(sum(AC),sum(WA)-count)

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

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

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

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

a = 0
b = 0

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