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):
import numpy as np
n,m = map(int,input().split())

p = []
s = []
ans_a = np.zeros(n)
ans_p = np.zeros(n)

for i in range(m):
    pi ,si = map(str,input().split())
    p.append(int(pi))
    s.append(si)

for i in range(m):
    if s[i] == "AC":
        ans_a[p[i]-1] = 1
    elif ans_a[p[i]-1] == 0:
        ans_p[p[i]-1] += 1

for i in range(n):
    if ans_a[i] == 0:
        ans_p[i] = 0

print(int(np.sum(ans_a)),int(np.sum(ans_p)))

Solution (Python):
N,M = map(int,input().split())
F = [0 for _ in range(N)]
W = [0 for _ in range(N)]
w = 0
for i in range(M):
  p,s = map(str,input().split())
  if F[int(p)-1] == 1:
    continue
  if s == 'WA':
    W[int(p)-1] += 1
  elif s == 'AC':
    F[int(p)-1] = 1
    w += W[int(p)-1]
print(sum(F),w)

Solution (Python):
N,M = map(int,input().split())
D = [[]for i in range(N)]
AC = 0
WA = 0
for i in range(M):
  plobNum,res = input().split()
  D[int(plobNum)-1].append(res)

for prob in D:
  wa_ = 0
  for submit in prob:
    if submit == "WA" :
      wa_+=1
    elif submit == "AC":
      AC+=1
      WA +=wa_
      break

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

Solution (Python):
import numpy as np

def main():
    N, M = map(int, input().split())
    PS = {}
    for i in range(M):
        row = input().split()
        row[0] = int(row[0])
        if row[0] not in PS:
            PS[row[0]] = [row[1]]
        else:
            PS[row[0]].append(row[1])

    n_correct = 0
    n_penalty = 0
    for p in PS:
        if 'AC' in PS[p]:
            n_correct += 1
            for result in PS[p]:
                if result == 'AC':
                    break
                if result == 'WA':
                    n_penalty += 1
    
    print('{} {}'.format(n_correct, n_penalty))
        


if __name__ == '__main__':
    main()

Solution (Python):
n,m=map(int,input().split())
d=dict()
c=0
p=0
for _ in range(m):
    a,b=map(str,input().split())
    if a not in d:
        if b=="WA":
            d[a]=["WA",1]
        else:
            c+=1
            d[a]=["AC",1]
    else:
        if b=="WA":
            if d[a][0]=="AC":
                continue
            else:
                d[a][1]+=1
        else:
            
            if d[a][0]=="AC":
                continue
            c+=1
            
            d[a][0]="AC"
            p+=d[a][1]

print(c,p)

Solution (Python):
class Item():
    def __init__(self, state, wrongCount):
        self.state = state
        self.wrongCount = wrongCount


N, M = map(int, input().split())
items = {}
pena = 0
correct = 0
for i in range(0, M):
    p, S = input().split()

    if p not in items:
        items[p] = Item("", 0)

    if items[p].state == "AC":
        continue

    if S == "AC":
        items[p].state = S
    else:
        pena = pena + 1
        items[p].state = S
        items[p].wrongCount = items[p].wrongCount + 1

items = {k: v for k, v in items.items() if v.state == "AC"}
print("{0} {1}".format(len(items), sum(v.wrongCount for v in items.values())))

Solution (Python):
N,M = [int(x) for x in input().split()]
ac = [0]*(N+1)
wa = [0]*(N+1)
for i in range(M):
  p,s = input().split()
  if s =="AC" and ac[int(p)]==0:
    ac[int(p)]=1
  if s=="WA" and ac[int(p)]==0:
    wa[int(p)]+=1
ans = 0
answa = 0
for i in range(N+1):
  if ac[i]==1:
    ans+=1
    answa+=wa[i] 
print(ans,answa)

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())
list_penalties = {str(i): 0 for i in range(1, N+1)}
list_correct = {str(i): 0 for i in range(1, N+1)}
total_penalty = 0
for _ in range(M):
  p, s = input().split()
  if list_correct[p] == 0:
    if s == "WA": list_penalties[p] += 1
    elif s == "AC":
      list_correct[p] = 1
      total_penalty += list_penalties[p]
print(sum(value for key, value in list_correct.items()), total_penalty)

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

for _ in range(m):
    tmp, s = input().split()
    p = int(tmp)
    
    if(ac[p-1]):
        continue
    
    if(s == "AC"):
        ans[0] += 1
        ans[1] += wa[p-1]
        ac[p-1] = True
    
    else:
        wa[p-1] += 1
 
print("{} {}".format(*ans))

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

ac = 0
wa = 0

challengable = [True] * n
wa_cnt = [0] * n

for _ in range(m):
    num, res = input().split()
    num = int(num)

    if not challengable[num-1]:
        continue

    if res == "AC":
        ac += 1
        challengable[num-1]=False
        wa += wa_cnt[num-1]
    else:
        wa_cnt[num-1]+=1

print(ac,wa)

Solution (Python):
n,m=map(int,input().split())
ps=[list(input().split()) for i in range(m)]
pen=[0]*n
rig=[0]*n

for i in range(m):
    if ps[i][1]=="AC":
        rig[int(ps[i][0])-1]=1
    else:
        if rig[int(ps[i][0])-1]==0:
            pen[int(ps[i][0])-1]+=1
cnt1,cnt2=0,0
for i in range(n):
    if rig[i]==1:
        cnt1+=rig[i]
        cnt2+=pen[i]

print(str(cnt1)+" "+str(cnt2))

Solution (Python):
N,M = map(int,input().split())
dp = [0]*(N+1)
li = []
kaku = [0]*(N+1)
dpp = [0]*(N+1)
count =0
for m in range(M):
    p,s = input().split()
    p = int(p)
    li.append([p,s])
    
for i in li:
    if i[1]=="WA":
        dp[i[0]] += 1
    
    else:
        if dpp[i[0]] ==0:
            dpp[i[0]]=1
            kaku[i[0]] = dp[i[0]]


print(sum(dpp),sum(kaku))

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

wa_total = [0]*N
wa_count = [0]*N 
ac_flg = [False]*N

for p,s in p_s:
    p = int(p)-1
    if not ac_flg[p]:
        if s == 'AC':
            ac_flg[p] = True
            wa_count[p] = wa_total[p]
        else:
            wa_total[p] += 1

print(ac_flg.count(True),sum(wa_count))

Solution (Python):
N, M = map(int, input().split())
P = []
S = []
flag = [False for i in range(0, N)]
for i in range(0, M):
    x, y = map(str, input().split())
    P.append(int(x)-1)
    S.append(y)
ans = [0, 0]
wa = [0 for i in range(0, N)]
for i in range(0, M):
    if not flag[P[i]]:
        if S[i] == 'AC':
            flag[P[i]] = True
            ans[0] += 1
            ans[1] += wa[P[i]]
        else:
            wa[P[i]] += 1
print(*ans)

Solution (Python):
N, M = map(int, input().split())
pS = [list(input().split()) for i in range(M)]
c = [0 for _ in range(N)]
penalty = [0 for _ in range(N)]
ac = 0
sum_penalty = 0

for i in range(M):
    num = int(pS[i][0])
    if c[num - 1] == 0:
        if pS[i][1] == 'WA':
            penalty[num - 1] += 1
        else:
            c[num - 1] = 1
            sum_penalty += penalty[num - 1]
            ac += 1

print(ac, sum_penalty)

Solution (Python):


import numpy as np


def main():
    N, M = map(int, input().split())

    AC = np.array([0] * N)
    WA = np.array([0] * N)

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

        if AC[int(p) - 1] == 0 and S == 'WA':
            WA[int(p) - 1] += 1
        else:
            AC[int(p) - 1] = 1
    print(sum(AC), sum(AC * WA))


if __name__ == "__main__":
    main()

Solution (Python):
n, m = map(int, input().split())
x = [[0] * 2 for _ in range(n)]
AC = WA = 0
for _ in range(m):
    a, b = input().split()
    if x[int(a) - 1][0] == 0 and b == 'WA':
        x[int(a) - 1][1] += 1
    elif x[int(a) - 1][0] == 0 and b == 'AC':
        AC += 1
        WA += x[int(a) - 1][1]
        x[int(a) - 1][0] = 1
print(AC, WA)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

def indexs(l, x, default=-1):
    if x in l:
        return l.index(x)
    else:
        return -1

if M == 0:
	print(0, 0)
else:
	temp = [input().split() for _ in range(M)]
	temp.append([N+1, "WA"])
	temp.sort(key=lambda x:int(x[0]))
	temp = [list(x) for x in zip(*temp)]
	p, S = list(map(int, temp[0])), temp[1]

	index = 0
	AC = 0
	WC = 0
	a = []
	for i in range(M):
		if p[i]!=p[i+1]:
			a.append(indexs(S[index:i+1], "AC"))
			index = i+1
	index = 0
	for i in range(M):
		if p[i]!=p[i+1]:
			if a[index]>=0:
				AC += 1
				WC += a[index]
			index += 1	
	print(AC, WC)

Solution (Python):
N,M=map(int,input().split())
if M!=0:
  pS=[list(input().split()) for i in range(M)]
else:
  print(0,0)
  exit()

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

for i in range(M):
  n=int(pS[i][0])-1
  if pS[i][1]=="WA" and ac[n]==0:
    wa[n]+=1
  elif pS[i][1]=="AC" and ac[n]==0:
    ac[n]+=1
    penalty+=wa[n]

print(sum(ac),penalty)

Solution (Python):
n, m = map(int, input().split())
prob = {}
for i in range(m):
  pi, si = input().split()
  prob.setdefault(int(pi), [])
  prob[int(pi)].append(si)

ac_cnt = 0
pen_cnt = 0
for key, val in prob.items():
  if 'AC' not in val:
    continue
  ac_idx = val.index('AC')
  ac_cnt += 1
  pen_cnt += ac_idx
print(ac_cnt, pen_cnt)

Solution (Python):
from collections import defaultdict
N, M = map(int, input().split())

aced = [False]*N
D = defaultdict(int)
ac = 0
pena = 0
for _ in range(M):
    id, judge = input().split()
    id = int(id)-1
    if judge == "WA":
        D[id] += 1
    else:
        if not aced[id]:
            aced[id] = True
            ac += 1
            pena += D[id]
print(ac, pena)

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

if M == 0:
  print(0,0)
  exit();

x = {}  
for _ in range(M):
  a,w = map(str,input().split())
  x.setdefault(int(a),[]).append(w)
  
ac = at = wa = wt = 0  
for k,v in x.items():
  for j in v:
    if j == 'AC':
      at += 1
      break
    elif j =='WA':
      wt += 1
  if at == 0:
    wt = 0
  else:
    ac += at
    wa += wt
    at = 0
    wt = 0
      
print(ac,wa)

Solution (Python):
N,M = map(int, input().split())
AC = [0]*N
WA = [0]*N
for _ in range(M):
    p,s = input().split()
    if AC[int(p)-1] == 0:
        if s == "WA":
            WA[int(p)-1] += 1
        elif s == "AC":
            AC[int(p)-1] = 1
print(sum(AC),sum(w*a for w,a in zip(WA,AC)))

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

Solution (Python):
N, M = map(int, input().split())
AC = [0]*(N+1)
WA = [0]*(N+1)
for i in range(M):
    P, S = input().split()
    P = int(P)
    if S == "AC" and AC[P] == 0:
        AC[P] = 1
    elif S == "WA" and AC[P] == 0:
        WA[P]+=1
print(sum(AC), sum(w*a for w, a in zip(AC, WA)))

Solution (Python):
def main():
    n,m=map(int,input().split())
    r=set()
    x={}
    for _ in range(m):
        p,s=input().split()
        if p not in r:
            if s=='WA':
                x[p]=x.setdefault(p,0)+1
            else:
                x[p]=x.setdefault(p,0)
                r.add(p)
    print(len(r),sum(x[p] for p in r)) 

main()

Solution (Python):
import numpy as np

n, m = map(int, input().split())
suc = np.array([0]*(n+1))
pen = np.array([0]*(n+1))

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

    if suc[p] == 0 and s == "WA":
        pen[p] += 1
    else:
        suc[p] = 1

print(sum(suc), sum(suc*pen))

Solution (Python):
n,m=map(int,input().split())
ans=0
l=[0] * n
d={}
for i in range(m):
  p,s=input().split()
  q=int(p)-1
  if q in d:
    continue
  if s=="AC":
    ans+=l[q]
    d[q]=s
  else:
    l[q]+=1
print(len(d),ans)

Solution (Python):
n,m = map(int,input().split())
acs = [0] * n 
was = [0] * n
for i in range(m):
    question , result = map(str,input().split())
    question_int= int(question) -1 
    if acs[question_int] == 0:
        if result == "AC":
            acs[question_int] = 1
        else:
            was[question_int] += 1

cnt_ac = sum(acs)
cnt_wa = 0

for i in range(n):
    if acs[i] == 1:
        cnt_wa += was[i]

print(cnt_ac,cnt_wa)

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())
d = defaultdict(list)
penalty = 0
accepted = 0

for p, S in (input().split() for _ in range(M)):
    d[p].append(S)

for k, v in d.items():
    tmp = 0
    for i in v:
        if i=="AC":
            accepted += 1
            penalty += tmp
            break
        else:
            tmp += 1

print(accepted, penalty)

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

seikai = [False] * (n + 1)
wa_list = [0] * (n + 1)
ac = 0
wa = 0
for i in range(m):
    p, s = input().split()

    if not seikai[int(p)]:
        if s == "WA":
            wa_list[int(p)] += 1
        else:
            ac += 1
            wa += wa_list[int(p)]
            seikai[int(p)] = True
print(ac, wa)

Solution (Python):
def read_line():
    tokens = input().split()
    p = int(tokens[0])
    S = tokens[1]
    return p, S

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

wa_counters = [0 for _ in range(N + 1)]
correct_answers = 0
penalties = 0
for _ in range(M):
    p, S = read_line()
    if wa_counters[p] == -1:
        continue

    if S == "AC":
        penalties += wa_counters[p]
        correct_answers += 1
        wa_counters[p] = -1
    else:
        wa_counters[p] += 1

print(correct_answers, penalties)

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

for _ in range(m):
    i,j = map(str,input().split())
    i = int(i)
    i -= 1
    if prbs[i][-1] != "AC":
        prbs[i].append(j)
pen = 0
for i in range(n):
    if prbs[i][-1] == "AC":
        pen += prbs[i].count("WA")
ans = 0
for i in range(n):
    ans += prbs[i].count("AC")

print(ans,pen)

Solution (Python):
n, m = list(map(int, input().split()))
dic = {}

for _ in range(m):
  pi, si = input().split()
  pi = int(pi)
  if pi in dic:
    dic[pi].append(si)
  else:
    dic[pi] = [si]

a = 0
p = 0

for s in dic.values():
  if 'AC' in s:
    a += 1
    p += s.index('AC')

print('%s %s'%(int(a), int(p)))

Solution (Python):
n,m = map(int,input().split())
p = [0]*m
s = [""]*m
for i in range(m):
  p[i],s[i] = input().split()
  
p = [int(j) for j in p]

u = [[0 for i in range(2)]for j in range(n)]

for k in range(0,m):
  if(s[k] == "WA" and u[p[k]-1][1] == 0):
    u[p[k]-1][0] += 1
  elif(s[k] == "AC"):
    u[p[k]-1][1] = 1

ans = 0
ac = 0
for i in range(n):
  if(u[i][1] == 1):
    ac += 1
    ans += u[i][0]
print(ac,ans)

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

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

for _p, _s in ps:
    if ac[_p-1]:
        continue

    if _s == "AC":
        ac[_p-1] = True
    elif _s == "WA":
        wa[_p-1] += 1

ans = [0, 0]
for _ac, _wa in zip(ac, wa):
    if _ac:
        ans[0] += 1
        ans[1] += _wa

print(*ans)

Solution (Python):
N, M = list(map(int, input().split()))
ACL = [0 for i in range(N)]
WAL = [0 for i in range(N)]
for i in range(M):
  p, s = input().split()
  p = int(p)-1
  if ACL[p] > 0:
    continue
  if s == "AC":
    ACL[p] = 1
    continue
  if s == "WA" and ACL[p] == 0:
    WAL[p] += 1
  
print(sum(ACL), sum([ACL[i] * WAL[i] for i in range(N)]))

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
    elif AC[p] == 0:
        WA[p] += 1

print(sum(AC), sum( [AC[i] * WA[i] for i in range(N)] ) )

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

Solution (Python):
N, M = map(int, input().split())
p, S = [], []
for i in range(M):
    _p, _s = input().split()
    p.append(int(_p)-1)
    S.append(_s)

ac, wa = [0]*N, [0]*N
for i in range(M):
    if ac[p[i]] == 1:
        continue
    if S[i] == "AC":
        ac[p[i]] = 1
    else:
        wa[p[i]] += 1

acs, was = 0, 0
for i in range(N):
    if ac[i] == 1:
        acs += 1
        was += wa[i]
print(acs, was)

Solution (Python):
N,M = map(int,input().split())
A = [0]*(N+1)
mod = 10**8

for i in range(M):
    p,S = input().split()
    p = int(p)
    if S == 'AC':
        if A[p]//mod==0:
            A[p] += mod
    else:
        if A[p]//mod==0:
            A[p] += 1
            
AC = sum(A)//mod
WA = 0
for i in A:
    if i//mod!=0:
        WA += i%mod
print(AC,WA)

Solution (Python):
def main():
    n, m = [int(x) for x in input().strip().split()]

    
    flag = [False] * n
    
    trial = [0] * n
    for _ in range(m):
        tmp = input().strip().split()
        idx = int(tmp[0])-1
        
        if flag[idx]:
            continue
        
        flag[idx] = (tmp[1] == "AC")
        if flag[idx]:
            continue
        
        trial[idx] += 1

    
    pen = 0
    for f, t in zip(flag, trial):
        if not f:
            continue
        pen += t

    print(flag.count(True), pen)


if __name__ == "__main__":
    main()

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
    elif AC[p] == 0:
        WA[p] += 1

print(sum(AC), sum( [AC[i] * WA[i] for i in range(N)] ) )

Solution (Python):
import numpy as np

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

ifAC = np.zeros(N, dtype='bool')
WAcount = np.zeros(N, dtype='int')

for i in range(M):
    pi, Si = input().split()
    pi = int(pi) - 1
    if Si == 'AC':
        ifAC[pi] = True
    if ifAC[pi] == False and Si == 'WA':
        WAcount[pi] += 1

print(np.sum(ifAC), np.sum(np.dot(WAcount, ifAC)))

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

flag_ac = [0]*n
cnt_wa = [0]*n
cnt_penalty = 0

for _ in range(m):
    p, s = input().split()
    if s == "WA":
        cnt_wa[int(p)-1] += 1
    elif s == "AC" and flag_ac[int(p)-1] == 0:
        flag_ac[int(p)-1] = 1
        cnt_penalty += cnt_wa[int(p)-1]
        
print(sum(flag_ac), cnt_penalty)

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


Nac = 0
Nwa = 0
for i in range(N[1]):
    M = input().split()
    p = int(M[0])
    judge = str(M[1])

    if(Pi[p-1][1] == 0):
        if(judge == 'AC'):
            Pi[p-1][1] = 1
        else:
            Pi[p-1][0] += 1

for i in range(N[0]):
    if(Pi[i][1] == 1):
        Nac += Pi[i][1]
        Nwa += Pi[i][0]
print(Nac, Nwa)

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

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

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

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

    penalty = 0


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

    correct = len(correct_set)

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


            

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

Solution (Python):
nm = [int(i) for i in input().split()]
dic = {}

co = 0
pe = 0

for i in range(0,nm[1]):
  tmp = [j for j in input().split()]
  val = dic.setdefault(tmp[0],['NEW', 0])
  
  if (val[0] == 'NEW') or (val[0] == 'WA'):	
    if tmp[1] == 'WA':
      dic[tmp[0]][1] += 1
      dic[tmp[0]][0] = 'WA'
    elif tmp[1] == 'AC':
      co += 1
      pe += dic[tmp[0]][1]
      dic[tmp[0]][0] = 'AC'

print(co, pe)

Solution (Python):
n, m = [int(i) for i in input().split()]
solved = [False for _ in range(n)]
failures = [0 for _ in range(n)]

total_success = 0

for _ in range(m):
    res = input().split()
    p = int(res[0])
    if not solved[p - 1]:
        if res[1] == "AC":
            solved[p - 1] = True
            total_success += 1
        else:
            failures[p - 1] += 1

total_fail = sum([f for i, f in enumerate(failures) if solved[i]])
print(total_success, total_fail)

Solution (Python):
n,m=map(int, input().split())
acceted=set()
penalty=0
wa_cnt=[0]*(n+1)
for i in range(m):
    p,s=map(str, input().split())
    p=int(p)
    if p in acceted:
        continue
    if s=="AC":
        penalty+=wa_cnt[p]
        acceted.add(p)
    else:
        wa_cnt[p]+=1
print(len(acceted),penalty)

Solution (Python):
from collections import defaultdict

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

d = defaultdict(int)

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

ans = 0
penalty = 0

for i in range(1, N + 1):
    if d[(i, 'AC')]:
        ans += d[(i, 'AC')]
        penalty += d[(i, 'WA')]
        

print('{} {}'.format(ans, penalty))

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

wa_cnt = [0]*N
ac_flag = [False]*N

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

    if not ac_flag[p]:
        if S == 'WA':
            wa_cnt[p] += 1
        else:
            ac_flag[p] = True


print(sum(ac_flag), sum(c for c,f in zip(wa_cnt,ac_flag) if f))

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

A = sorted(A, key=lambda a: a[0])
ac = set()
wa = {}

total_ac_cnt = 0
total_wa_cnt = 0

for a in A:
    if a[1] == 'AC':
        if not a[0] in ac:
            ac.add(a[0])
            if a[0] in wa:
                total_wa_cnt += wa[a[0]]
            total_ac_cnt += 1
    else:
        if not a[0] in ac:
            if a[0] in wa:
                wa[a[0]] += 1
            else:
                wa[a[0]] = 1

print(total_ac_cnt, total_wa_cnt)

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

if M == 0:
  print(0,0)
  exit()
  
a = [0]*(N + 1)
p = [0]*(N + 1)
wa = [0]*(N + 1)

for i in range(M):
  P, S = input().split()
  P = int(P)
  if S == "WA":
    wa[P] += 1
  elif a[P] == 0:
    a[P] += 1
    p[P] = wa[P]

print(sum(a),sum(p))

Solution (Python):
N, M = map(int, input().split())
rec = []
for i in range(M):
    p, S = map(str, input().split())
    p = int(p)
    rec.append([p,S])
N_list = [False for i in range(N)]
WA_cnt=[0 for i in range(N)]
penalty = AC_cnt = 0
for i in range(M):
    if rec[i][1] == "AC":
        if N_list[rec[i][0]-1] == False:
            AC_cnt += 1
            N_list[rec[i][0]-1] = True
            penalty += WA_cnt[rec[i][0]-1] 
    if rec[i][1] == "WA":
        if N_list[rec[i][0]-1] == False:
            WA_cnt[rec[i][0]-1] += 1
print(AC_cnt, penalty)

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

ps = [(int(p)-1, s) for p, s in PS]

ac = [0]*N
wa = [0]*N
for p, s in ps:
    if s == "AC":
        ac[p] = 1
    else:
        if ac[p] == 0:
            wa[p] += 1

print(sum(ac), sum([a*w for a, w in zip(ac, wa)]))

Solution (Python):
import sys, heapq
from collections import defaultdict
from itertools import product, permutations, combinations
from bisect import bisect_left 

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

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

ac_num = defaultdict(int) 
wa_num = defaultdict(int) 
wass = 0 
for ps in pS:
    p, S = int(ps[0]), ps[1]
    
    if ac_num[p] == 1:
        continue
    else:
        if S == 'AC':
            ac_num[p] = 1
            
            wass += wa_num[p]
        elif S == 'WA':
            wa_num[p] += 1
    

print(sum(list(ac_num.values())), wass)

Solution (Python):
def solve():
    N, M = map(int, input().split())
    WAnum = 0
    ACnum = 0
    WA = [0]*(N+1)
    AC = [False]*(N+1)

    for _ in range(M):
        p, S = map(str, input().split())
        p = int(p)
        if AC[p] == True:
            continue
        if S == 'AC':
            AC[p] = True
            ACnum += 1
            WAnum += WA[p]
        elif S == 'WA':
            WA[p] += 1
        
    
    print(ACnum, WAnum)

solve()

Solution (Python):
import sys, heapq
from collections import defaultdict
from itertools import product, permutations, combinations
from bisect import bisect_left 

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

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

was = defaultdict(int) 
chk = defaultdict(int) 
wass = 0
for ps in pS:
    p, S = int(ps[0]), ps[1]
    if chk[p] == 1:
        continue
    else:
        if S == 'AC':
            chk[p] = 1
            wass += was[p]
        else:
            was[p] += 1

print(sum(list(chk.values())), wass)

Solution (Python):
n,m = map(int,input().split())
plist=[]
slist=[]
isAc_list = [False for _ in range(n+1)]
penalty_list = [0 for _ in range(n+1)]
for i in range(m):
  inputs = input().split()
  plist.append(int(inputs[0]))
  slist.append(inputs[1])

correct = 0
penalty = 0
for problem,result in zip(plist,slist):
  if isAc_list[problem]:
    continue
  elif result == 'AC':
    isAc_list[problem] = True
    correct+=1
    penalty+=penalty_list[problem]
  else:
    penalty_list[problem]+=1
print(correct,penalty)

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

Solution (Python):
a=[int(i) for i in input().split()]
s = [input().split() for i in range(a[1])]
al=[[] for i in range(a[0])]
for i in range(a[1]):
    al[int(s[i][0])-1].append(s[i][1])
ac=0
wa=0
for j in range(a[0]):
    if al[j].count('AC')!=0:
        wa+=al[j].index('AC')
        ac+=1
print(ac,wa)

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

ps = []
for i in range(m):
    ps.append(list(input().split()))
    ps[i][0] = int(ps[i][0])

cnt_correct = 0
cnt_penalty = 0
cnt_penalty_buf = 0

juge = [1]*n
buf = [0]*n

for i in range(m):
    if ps[i][1] == "AC" and juge[ps[i][0] - 1] == 1 :
        cnt_correct += 1
        cnt_penalty += buf[ps[i][0] - 1]
        juge[ps[i][0] - 1] = 0
        cnt_penalty_buf = 0

    if ps[i][1] == "WA" and juge[ps[i][0] - 1] == 1:
        buf[ps[i][0] - 1] += 1

print(cnt_correct, cnt_penalty)

Solution (Python):
def solve(n, m, PS):
    d = {}
    scores = [0, 0]
    for p, s in PS:
        if p not in d:
            d[p] = {'wa': 0, 'ac': 0}
        if d[p]['ac'] > 0:
            continue
        if s == 'AC':
            d[p]['ac'] = 1
            scores[0] += 1
            scores[1] += d[p]['wa']
        else:
            d[p]['wa'] += 1
    return scores

_n, _m = map(int, input().split())
_PS = [input().split() for _ in range(_m)]
print(*solve(_n, _m, _PS))

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

if M == 0:
    print(0, 0)
    exit()

wacount = [0]*(N+1)
wa = [0]*(N+1)
ac = [0]*(N+1)

for _ in range(M):
    pi, Si = map(str, input().split())
    pi = int(pi)
    if Si == "WA":
        wacount[pi] += 1
    elif ac[pi] == 0:
        wa[pi] = wacount[pi]
        ac[pi] += 1

print(sum(ac), sum(wa))

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

P, S = [], []
for i in range(M):
    _p, _s = list(input().split())
    P.append(int(_p))
    S.append(_s)

Q = []
Q_ans = []
for i in range(N):
    Q.append(0)
    Q_ans.append(False)

for i in range(M):
    q_num = P[i]
    if Q_ans[q_num-1]:
        continue
    if S[i] == "WA":
        Q[q_num-1] += 1
    if S[i] == "AC":
        Q_ans[q_num-1] = True

num_AC, num_WA = 0, 0
for i in range(N):
    if Q_ans[i]:
        num_WA += Q[i]
        num_AC += 1

print(num_AC, num_WA, sep=' ')

Solution (Python):
N, M = map(int, input().split())
p, S = [], []

if M == 0:
    print(0, 0)
    exit()

wacount = [0]*(N+1)
wa = [0]*(N+1)
ac = [0]*(N+1)

for _ in range(M):
    pi, Si = map(str, input().split())
    pi = int(pi)
    if Si == "WA":
        wacount[pi] += 1
    elif ac[pi] == 0:
        wa[pi] = wacount[pi]
        ac[pi] += 1

print(sum(ac), sum(wa))