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):
from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

n, m = inpl()
l = [1] * n
a = 0
q = 0
for i in range(m):
    p, s = inpl_str()
    p = int(p)
    if l[p-1] > 0:
        if  s == 'AC':
            q += l[p-1]-1
            l[p-1] = 0
            a+=1
        else:
            l[p-1]+=1
print(a, q)

Solution (Python):
num, all_ans = [int(i) for i in input().split(" ")]
d_wa = [0 for _ in range(num)]
d_ac = [0 for _ in range(num)]
ans = 0

for _ in range(all_ans):
    ans_num, ac_wa = [i for i in input().split(" ")]
    if d_ac[int(ans_num) - 1] == 1: continue
    if ac_wa == "AC": 
        d_ac[int(ans_num) - 1] = 1
        continue
    if ac_wa == "WA":
        d_wa[int(ans_num) - 1] += 1
        continue

for num, i in enumerate(d_ac):
    if i:
       ans += d_wa[num]

print(sum(d_ac),ans)

Solution (Python):


def main():
     n, m = map(int, input().split())
     ac_list = [False for i in range(n)]
     wa_list = [0 for i in range(n)]
     ac_ans = wa_ans = 0

     for i in range(m):
          p, s = input().split()
          p = int(p) - 1
          if not ac_list[p]:
               if s == 'AC':
                    ac_list[p] = True
                    ac_ans += 1
                    wa_ans += wa_list[p]
               else:
                    wa_list[p] += 1
     
     print('{} {}'.format(ac_ans, wa_ans))

if __name__ == "__main__":
    main()

Solution (Python):
n, m = map(int, input().split())
p = [0]*(n+1)
q = [False]*(n+1)
for _ in range(m) :
  v,s = input().split()
  v = int(v)
  if q[v]:
      continue
  if s[0] == 'A':
      q[v] = True
  else :
      p[v] += 1
print(sum(q), sum(p[i] for i in range(n+1) if q[i]))

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

acl=[0]*n
wal=[0]*n
for p,s in ps:
    p=int(p)-1
    if s=='AC' and acl[p]==0:
        acl[p]+=1
    elif s=='WA' and acl[p]==0:
        wal[p]+=1

wa=0
for i,ac in enumerate(acl):
    if ac==1:
        wa+=wal[i]
print(sum(acl),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()
p = [0]*M
S = [0]*M
cnt_penalty = [0]*N
cnt_ac = [0]*N

for i in range(M):
  p[i], S[i] = input().split()
  p[i] = int(p[i])
  
for i in range(M):
  if cnt_ac[p[i]-1] == 0:
    if S[i] == "WA":
      cnt_penalty[p[i]-1] += 1
    elif S[i] == "AC":
      cnt_ac[p[i]-1] = 1
      
for i in range(N):
  if cnt_ac[i] == 0:
    cnt_penalty[i] = 0

print(sum(cnt_ac), sum(cnt_penalty))

Solution (Python):
n,m=[int(i) for i 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":
        if ac[p]==0:
            ac[p]=1
    else:
        if ac[p]==0:
            wa[p]+=1
    
for i in range(n):
    wa[i]=wa[i]*ac[i]
print(sum(ac),sum(wa))

Solution (Python):
a,b=map(int,input().split())
account=0
wacount=0
acbox=[0]*(a+1)
wabox=[0]*(a+1)
for i in range(b):
  p,q=input().split()
  p=int(p)
  if q=="WA":
    if acbox[p]==0:
      wabox[p]+=1
  else:
    if acbox[p]==0:
      account+=1
      wacount+=wabox[p]
      acbox[p]=+1
print(account,wacount)

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

l = [0]*(n + 1)
ac = 0
wa = 0

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

print(ac, wa)

Solution (Python):
N,M = [int(v) for v in input().split()]
wa_total = [0 for _ in range(N)]
ac_flag = [False for _ in range(N)]

for _ in range(M):
    p,ans = [v for v in input().split()]
    p = int(p) - 1

    if not ac_flag[p]:
        if ans == "AC":
            ac_flag[p] = True
        else:
            wa_total[p] += 1

ac_ans = 0
wa_ans = 0

for a,b in zip(wa_total,ac_flag):
    if b:
        ac_ans += 1
        wa_ans += a
print(ac_ans,wa_ans)

Solution (Python):
n, m = map(int, input().split())
ac = set()
npena = dict()
for i in range(m):
    np, res = input().split()
    if res == 'AC':
        ac.add(np)
    elif np not in ac:
        npena[np] = npena.get(np, 0) + 1
res2 = 0
for np in ac:
    res2 += npena.get(np,0)
print(len(ac), res2)

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 s == "AC":
        ac[p-1] = 1
    elif s == "WA":
        if ac[p-1] != 1:
            wa[p-1] += 1

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

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

Solution (Python):
n,m = map(int,input().split())
wa = [0]*n
flag = [False]*n
count = 0
for i in range(m):
  p,s = input().split()
  p = int(p)
  if s=='AC' and flag[p-1]==False:
    count += 1
    flag[p-1] = True
  if s=='WA' and flag[p-1]==False:
    wa[p-1] += 1
for i in range(n):
  if flag[i]==False: wa[i] = 0
print(count,' ',sum(wa))

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

correct_questions = [False] * N
incorrect_questions = [0] * N
num_of_correct = 0
num_of_penalties = 0
for pi, Si in pS:
    nth = int(pi) - 1
    
    if Si == 'AC' and correct_questions[nth] is False:
        correct_questions[nth] = True
        num_of_correct += 1
        num_of_penalties += incorrect_questions[nth]
    elif Si == 'WA' and correct_questions[nth] is False:
        incorrect_questions[nth] += 1

print("{} {}".format(num_of_correct, num_of_penalties))

Solution (Python):
def main():
    n, m = map(int, input().split())
    ary = [input().split() for _ in range(m)]
    ac_cnt = 0
    wa_cnt = 0
    ac_ary = [[0, 0] for i in range(n)]
    for toi_num, kekka in ary:
        num = int(toi_num) - 1
        if ac_ary[num][0] == 0:
            if kekka == 'WA':
                ac_ary[num][1] += 1
            elif kekka == 'AC':
                ac_ary[num][0] = 1
                ac_cnt += 1
                wa_cnt += ac_ary[num][1]
    print(ac_cnt, wa_cnt)

if __name__ == '__main__':
    main()

Solution (Python):

def input2():
	return map(int,input().split())


def input_array():
	return list(map(str,input().split()))





N,M=input2()
ps=[]
for _ in range(M):
	ps.append(input_array())
ans_dict={i:False for i in range(N)}
ans_list=[0]*N
wa_list=[0]*N

wa=0


for x in ps:
	num=int(x[0])-1
	ans=x[1]
	if ans_dict[num] ==True:
		continue
	elif ans=="WA" and ans_dict[num]==False:
		wa_list[num]+=1
	elif ans=="AC" and ans_dict[num]==False:
		wa+=wa_list[num]
		ans_dict[num]=True
		ans_list[num]=1

print(sum(ans_list),wa)

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

d = [0]*10**5
a = set()
w = 0


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

for p,s in ps:
    if "AC" == s and p not in a:
        w += d[p]
        a.add(p)
    if "WA" == s:
        d[p] += 1
print(len(a),w)

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

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

a = 0
b = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC' and dic[p] != 'AC':
        b += dic[p]
        dic[p] = 'AC'
    elif dic[p] != 'AC':
        dic[p] += 1
    
for i in range(1, n+1):
    if dic[i] == 'AC':
        a += 1
    
print(a, b)

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

N = a[0]
M = a[1]

AC = [0] * N 
WA = [0] * N 
WA_sum = 0
for i in range(M):
    a = list(map(str,input().split()))
    id_num = int(a[0])-1
    if AC[id_num] == 1:
        continue
    elif a[1] == 'WA':
        WA[id_num] += 1
    elif a[1] == 'AC':
        AC[id_num] = 1 
        WA_sum += WA[id_num]
        
print('{} {}'.format(sum(AC),WA_sum))

Solution (Python):
n,m=map(int,input().split())
if m==0:
  print(0,0)
else:
  q=[0]*(n+1)
  s=[0]*(n+1)
  t=0
  for i in range(m):
    p,u=map(str,input().split())
    p=int(p)
    if q[p]==1:
      continue
    
    elif u=='AC':
      q[p]=1
      
      t+=s[p]
      
      
    elif u=="WA":
      if q[p]==0:
        s[p]+=1
        
  
  
  
  
  print(sum(q),t)

Solution (Python):
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [[input().split()] for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,m=n1()
ps=s2(m)
OK=NG=0
d={str(i):[False,0] for i in range(1,n+1)}
for line in ps:
    num=line.split()[0]
    ans=line.split()[1]
    if d[num][0]==False:
        if ans=="AC":
            OK+=1
            d[num][0]=True
        else:
            d[num][1]+=1
for i,b in d.items():
    if b[0]:
        NG+=b[1]
print(OK,NG)

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

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

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

l = [0]*(n + 1)
ac = 0
wa = 0

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

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)
    
    if S == 'AC':
        
        AC[p-1] = 1
    
    elif S == 'WA' and AC[p-1] == 0:
        
        WA[p-1] += 1
 
AC_cnt = 0
WA_cnt = 0
for i in range(N):
    
    if AC[i] == 1:
        
        AC_cnt += 1
        
        WA_cnt += WA[i]
 
print(AC_cnt, WA_cnt)

Solution (Python):
n, m = map(int,input().split())
pS = [input().split() for _ in range(m)]
correct = 0
flag = [False] * n
pena = [0] * n
sum = 0
for p, s in pS:
    p = int(p)
    if flag[p-1] == True:
        continue
    else:
        if s == "WA":
            pena[p-1] += 1
        elif s == "AC":
            sum += pena[p-1]
            correct += 1
            flag[p-1] = True
print(correct, sum)

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

AC = set()
cnt = {i: 0 for i in range(1, N + 1)}
for _ in range(M):
    p, S = input().split()
    p = int(p)
    if (S == "AC"):
        AC.add(p)
    elif (S == "WA" and p not in AC):
        cnt[p] += 1

WA = sum([v for k, v in cnt.items() if k in AC])
print(len(AC), WA)

Solution (Python):
d = [0]*10**5

a = set()
w = 0

for t in open(0):
    p, s = t.split()
    p = int(p)
    if "AC" == s and p not in a:
        w += d[p]
        a.add(p)
    if "WA" == s:
        d[p] += 1

print(len(a), w)

Solution (Python):

import sys
import numpy as np


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    c = np.array([0] * N)
    penalty = np.array([0] * N)

    pp = 0

    for i in range(M):
        if S[i]=='AC':
            if c[p[i]-1]==1:
                pass
            else:
                c[p[i]-1] = 1
                pp+=penalty[p[i]-1]
        else:
            if c[p[i]-1]:
                pass
            else:
                penalty[p[i]-1]+=1
    
    print(c.sum(), pp)
    return



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())
rec = [[0,0] for _ in range(N)]
AC = 0
pe = 0

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

for i in range(N):
    if rec[i][1] == 1:
        AC += 1
        pe += rec[i][0]

print(AC,pe)

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

sx=0
sy=0
for i in range(n):
  sx+=x[i]
  if x[i]==1:
    sy+=y[i]
  
print(str(sx),str(sy))

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

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

print(ac, wa)

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

for i in range(m):
    p, s = input().split()
    p = int(p)
    if l[p][0] == 0: 
        if s == "AC":
            l[p][0] = 1
        else:
            l[p][1] += 1

for i in range(1, n + 1):
    ac += int(l[i][0])
    if int(l[i][0]) != 0:
        wa += int(l[i][1])
print(ac, wa)

Solution (Python):
N,M = list(map(int,input().split()))
p = []
for i in range(M):
    x,y = list(map(str, input().split()))
    p.append([int(x),y])
count = [[0,0]for i in range(N)]
ansac = 0
answa = 0
for i in range(M):
    if count[p[i][0]-1][1] != 0:
        pass
    else:
        if p[i][1] == 'AC':
            count[p[i][0]-1][1] += 1
        else:
            count[p[i][0]-1][0] += 1
for i in range(N):
    if count[i][1] > 0:
        answa += count[i][0]
    ansac += count[i][1]
print(str(ansac) + ' ' + str(answa))

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict
def main():
    n,m=map(int,input().split())
    ac=[False]*n
    wa=[0]*n
    pena=0
    for i in range(m):
        k,s=input().split()
        k=int(k)-1
        if s=="WA":wa[k]+=1
        elif ac[k]:continue
        else:
            ac[k]=True
            pena+=wa[k]
    print(sum(ac),pena)


if __name__=='__main__':
    main()

Solution (Python):
n, m = (int(x) for x in input().split())
sub = [0] * (n+1)
ok = ng = 0
for i in range(m):
  p, s = input().split()
  p = int(p)
  if sub[p] == -1:
    continue
  if s == 'WA':
    sub[p] += 1
  if s == 'AC':
    ok += 1
    ng += sub[p]
    sub[p] = -1
print(ok, ng)

Solution (Python):
x, y = map(int, input().split())
dd = {}
c = 0 
p = 0 
for i in range(x):
    dd[i+1] = 0
for _ in range(y):
    a, b = map(str, input().split())
    a = int(a)
    if b == 'WA':
        if dd[a] == 'o':
            continue
        else:
            dd[a] += 1
    else:
        if dd[a] == 'o':
            continue
        else:
            c += dd[a]
            p += 1
            dd[a] = 'o'
            
print(p, c)

Solution (Python):
import math
import sys

pena=0
N,M=map(int,input().split())
AClist=[0]*N
penalist=[0]*N
for i in range(M):
    pm,sm=input().split()
    pm=int(pm)
    if sm=="AC":
        AClist[pm-1]=1
    else:
        if AClist[pm-1]==0:
            penalist[pm-1]+=1
for i in range(N):
    if AClist[i]==1:
        pena+=penalist[i]



print(AClist.count(1),pena)

Solution (Python):
from itertools import groupby


n, m = map(int, input().split())
WA = [0] * (n + 1)
AC = [False] * (n + 1)
wanum = 0
acnum = 0
for i in range(m):
    p, s = input().split()
    if AC[int(p)]:
        continue
    if s == 'AC':
        acnum += 1
        wanum += WA[int(p)]
        AC[int(p)] = True
    elif s == 'WA':
        WA[int(p)] += 1
print(acnum, wanum)

Solution (Python):
from itertools import groupby


n, m = map(int, input().split())
WA = [0] * (n + 1)
AC = [False] * (n + 1)
wanum = 0
acnum = 0
for i in range(m):
    p, s = input().split()
    if AC[int(p)]:
        continue
    if s == 'AC':
        acnum += 1
        wanum += WA[int(p)]
        AC[int(p)] = True
    elif s == 'WA':
        WA[int(p)] += 1
print(acnum, wanum)

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

for i in range(N):
  AC += ac[i]
  if ac[i] >= 1:
    WA += wa[i]
print(AC,WA)

Solution (Python):
import os

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

	for i in range(N):
		AC += ac[i]
		if ac[i] >= 1:
			WA += wa[i]
	print(AC,WA)

if __name__ == '__main__':
	main()

Solution (Python):
n,m = map(int, input().split())
a = []
for _ in range(n):
  a.append(0)
w = a.copy()
x = a.copy()
for _ in range(m):
  q,r = input().split()
  q = int(q)-1
  if r == "WA" and a[q] != 1:
    w[q] += 1
  elif r == "AC" and a[q] != 1:
    x[q] = w[q]
    a[q] = 1
print(sum(a), sum(x))

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

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

print (AC, WA)

Solution (Python):
n,m = map(int, input().split())
la = []
lw = []
lwa = []
for i in range(n):
  la.append(0)
  lw.append(0)
  lwa.append(0)
for _ in range(m):
  q,a = input().split()
  if a == "WA" and la[int(q)-1] != 1:
    lw[int(q)-1] += 1
  elif a == "AC" and la[int(q)-1] != 1:
    la[int(q)-1] = 1
    lwa[int(q)-1] = lw[int(q)-1]
    
print(sum(la), sum(lwa))

Solution (Python):
from collections import deque

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

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

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

AC = 0
PENA = 0

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

print(AC,PENA)

Solution (Python):
n,m = map(int,input().split())
record = [[0,0] for _ in range(n)]
for i in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'AC':
        record[p-1][1] = 1
    else:
        
        if record[p-1][1] == 0:
            record[p-1][0] += 1

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

Solution (Python):
n,m=map(int,input().split())
pe=[-1 for i in range(n)]
for i in range(m):
    p,s=input().split()
    p=int(p)
    if s=='WA' and pe[p-1] < 0:
        pe[p-1] -= 1
    elif s =='AC' and pe[p-1] < 0:
        pe[p-1] = abs(pe[p-1])

print('{} {}'.format(len([i for i in pe if i > 0]),sum([i-1 for i in pe if i > 0])))

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":
		ac[p] = 1
	else:
		if ac[p]==0:
			wa[p]+=1

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

Solution (Python):


N, M = map(int, input().split())
Score = [[]*i for i in range(N)]
Count_AC = 0
Count_WA = 0


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

for i in range(N):
  for j in range(len(Score[i])):
    if Score[i][j] == "WA":
      continue
    else:
      Count_AC += 1
      Count_WA += j
      break

print(Count_AC, Count_WA)

Solution (Python):
N, M = map(int, input().split())
l = [[] for i in range(N)]
old_p = 0
for i in range(M):
    tmp = list(input().split())
    
    
    
    l[int(tmp[0]) - 1].append(tmp[1])
ac = 0
wa = 0

for i in range(N):
    wa_tmp = 0
    for j in range(len(l[i])):
        if l[i][j] == 'WA':
            wa_tmp += 1
        else:
            ac += 1
            wa += wa_tmp
            break
print('{} {}'.format(ac, wa))

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


AC = 0
WA = 0
WA_dict = {i: 0 for i in range(1, N+1)}
AC_dict = {i: 0 for i in range(1, N+1)}

for _ in range(M):
    p, s = input().split()
    if AC_dict[int(p)]==1:
        continue
    elif s=='WA':
        WA_dict[int(p)] += 1
    else:
        AC += 1
        AC_dict[int(p)] = 1
        WA += WA_dict[int(p)]
print(AC, WA)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
ps = [list(input().split()) for i in range(m)]
check = [True] * n
ac = 0
wa = [0] * n
cnt_wa = 0
for p, s in ps:
    p = int(p)
    if check[p - 1]:
        if s == 'AC':
            check[p - 1] = False
            ac += 1
        else:
            wa[p - 1] += 1
for i in range(n):
    if not check[i]:
        cnt_wa += wa[i]
print(ac, cnt_wa)

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

penal = {}
ac = 0
wa = 0
for i in range(m):
    p, s = input().split()
    
    
    if p not in penal:
        if s == 'AC':
            ac += 1
            penal[p] = -1
        elif s == 'WA':
            penal[p] = 1

    
    elif p in penal:
        
        if penal[p] == -1:
            continue
        
        if s == 'WA':
            penal[p] += 1
        if s == 'AC':
            wa += penal[p]
            penal[p] = -1
            ac += 1

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

A = [0] * (n+1)
AC = [0] * (n+1)
WA = [0] * (n+1)

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

t = 0
for i in range(len(AC)):
    if AC[i] == 1:
        t += WA[i]
print(sum(AC), t)

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

accepted = set()
pena = 0
wa_cnt = [0]*(n+1)

for i in range(m):
    p, s = input().split()
    p = int(p)
    if p in accepted:
        continue
    if s == "AC":
        pena += wa_cnt[p]
        accepted.add(p)

    else:
        wa_cnt[p] += 1

print(len(accepted), pena)

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":
        ac[p]=1
    else:
        if ac[p] ==0:
            wa[p]+=1
w = 0
for i in range(n+1):
    if ac[i] ==1:
        w+=wa[i]
print(sum(ac),w)

Solution (Python):
n, m = map(int, input().split())
counter = [0, 0]
ac = [False] * n
wa = [0] * n
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if ac[p] == True:
        continue
    if s == 'AC':
        ac[p] = True
    else:
        if not ac[p]:
            wa[p] += 1
for i in range(len(ac)):
    if ac[i]:
        counter[0] += 1
        counter[1] += wa[i]

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

Solution (Python):
from collections import Counter
N, M = list(map(int, input().split()))
results = []
for _ in range(M):
    p, s = input().split()
    results.append((int(p), s))

wa_counter = Counter() 
is_active = [True for _ in range(N)] 
for p, s in results:
    p -= 1
    if s == 'WA':
        if is_active[p]:
            wa_counter[p] += 1
        else:
            pass
    elif s == 'AC':
        if is_active[p]:
            is_active[p] = False
        else:
            pass

correct = 0 
incorrect = 0 
for i in range(N):
    if is_active[i] is False: 
        correct += 1
        incorrect += wa_counter[i]
print(correct, incorrect)

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

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

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

def main():
    sub = [0] * N
    pen = [0] * N
    for _ in range(M):
        p, s = input().split()
        if s == 'AC':
            sub[int(p)-1] += 1
        else:
            if sub[int(p)-1] == 0:
                pen[int(p)-1] += 1

    ac = len([s for s in sub if s > 0])
    pen = sum([p for i, p in enumerate(pen) if sub[i] > 0])
    print(ac, pen)

if __name__ == '__main__':
    main()

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

for i in range(m):
    p, s = input().split()
    if p not in p_dict:
        if s == 'AC':
            p_dict[p] = [1, 0]
        elif s == 'WA':
            p_dict[p] = [0, 1]
    else:
        if s == 'WA' and p_dict[p][0] == 0:
            p_dict[p][1] = p_dict[p][1] + 1
        if s == 'AC' and p_dict[p][0] == 0:
            p_dict[p][0] = 1

ac = 0
wa = 0
for key, value in p_dict.items():
    ac = ac + value[0]
    if value[0] == 1:
        wa = wa + value[1]

print(ac, wa)

Solution (Python):
n,m = map(int,input().split())
l = [list(map(str,input().split())) for _ in range(m)]
case  = ["WA"]*n
case1 = ["T"]*n
good = 0
bad = 0
for (a,b) in l:
  a = int(a)
  if b =="AC":
    case1[a-1]="AC"
    
for (a,b) in l:
  a = int(a)
  if b=="AC" and case[a-1]=="WA":
    case[a-1]="AC"
    good += 1
  elif b=="WA" and case[a-1]=="WA" and case1[a-1]=='AC':
    bad += 1
print(good,bad)

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

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

acCount = 0
penaltyCount = 0
wa = [0]*n
aced = [False]*n

for i in ps:
    ind = int(i[0])-1
    if i[1]=='WA' and not aced[ind]:
        wa[ind] += 1
    elif i[1]=='AC' and not aced[ind]:
        aced[ind] = True
        acCount += 1
        penaltyCount += wa[ind]

print(acCount, penaltyCount)

Solution (Python):
N,M = map(int, input().split())
f=[0]*(N+1)
ans_a=[0]*(N+1)
ans_w=0
for i in range(M):
    p,s = map(str, input().split())
    if s=='WA' and ans_a[int(p)]==0:
        f[int(p)]+=1
    else:
        if ans_a[int(p)]==0:
            ans_a[int(p)]+=1
            ans_w+=f[int(p)]
print(sum(ans_a),ans_w)

Solution (Python):
import numpy as np
N,M = map(int,input().split())
AC = np.zeros(N,np.int32)
WA = np.zeros(N,np.int32)
for j in range(M):
    p,S = input().split()
    i = int(p) - 1
    if AC[i] == 1:
        continue
    if S =='AC':
        AC[i] = 1
    else:
        WA[i] += 1
        
print(len(AC[AC == 1]),np.sum(WA[AC==1]))

Solution (Python):
n, m = (int(x) for x in input().split())
dic={}
for i in range(m):
    p, s = input().split()
    if p in dic:
        if dic[p][1]>0:
            pass
        elif s=="WA":
            dic[p][0]+=1
        elif s=="AC":
            dic[p][1]+=1
    else:
        if s=="WA":
            dic[p]=[1,0]
        else:
            dic[p]=[0,1]
for value in dic.values():
    if value[1]==0:
        value[0]=0
su_ac = 0
su_wa = 0
for value in dic.values():
    su_ac+=value[1]
    su_wa+=value[0]
print(su_ac, su_wa)

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

str_list = ["WA"] * n 
int_list = [0] * n    
num = 0
ac = 0    

for p_, s in  ps: 
    p = int(p_) - 1
    if s == "AC":
        str_list[p] = "AC" 
    else: 
        if str_list[p] !="AC": 
            int_list[p] += 1   

for i in range(n): 
    if str_list[i] == "AC": 
        num += int_list[i] 
        ac += 1            

print(ac, num)

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

Solution (Python):
from collections import defaultdict

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

d = defaultdict(int)
ans = 0
pena = 0

for _ in range(m):
    p, s = input().split()
    if s == "AC":
        if d[p] == -1:
            continue
        else:
            ans += 1
            pena += d[p]
            d[p] = -1
    else:
        if d[p] == -1:
            continue
        else:
            d[p] += 1

print(ans, pena)

Solution (Python):
import numpy as np

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

for i in range(M):
    a,b=input().split()
    A=int(a)
    if ac[A-1]==0 and b=="WA":
        wa[A-1]+=1
    else :
        ac[A-1]=1

cal=sum(ac)
ans=sum(ac*wa)
print(cal, ans)