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())
a=[]
for i in range(n):
    a.append([0,0])
b=[]
c=0
d=0
for i in range(m):
    b.append(list(input().split()))
    b[i][0]=int(b[i][0])
a=sorted(a,key=lambda x:x[0])
for i in range(m):
    if b[i][1]=='WA':
        if a[b[i][0]-1][0]==0:
            a[b[i][0]-1][1]+=1
    else:
        if a[b[i][0]-1][0]==0:
            a[b[i][0]-1][0]=1
for i in range(n):
    c+=a[i][0]
    if a[i][0]==1:
        d+=a[i][1]
print(c,d)

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

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

A = 0
P = 0

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

    if tasks[p-1][0] == 0:
        if s == "AC":
            A += 1
            tasks[p-1][0] = 1
            P += tasks[p-1][1]
        else:
            tasks[p-1][1] += 1
    else:
        continue

print(A, P)

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


ACd = [0] * N
whenACd = [0] * N

pena = 0
I,X=[],[]
for m in range(M):
    i, x = list(map(str, input().split()))
    I.append(i)
    X.append(x)

for m,(i,x) in enumerate(zip(I,X)):
    if x == 'AC' and ACd[int(i) - 1] == 0:
        ACd[int(i) - 1] = 1
        whenACd[int(i) - 1] = m

for m,(i,x) in enumerate(zip(I,X)):
    if x == 'WA' and whenACd[int(i) - 1] > m:
        pena += 1

print(sum(ACd), pena)

Solution (Python):
N, M = [int(i) for i in input().split()]
AC = [0] * (N + 1)
WA = [0] * (N + 1)
for i in range(M):
    p, S = input().split()
    if S == "AC":
        AC[int(p)] = 1
    else:
        if AC[int(p)] == 0:
            WA[int(p)] += 1
ans0 = 0
ans1 = 0
for i in range(N):
    ans0 += AC[i+1]
    if AC[i + 1] == 1:
        ans1 += WA[i+1]
print(ans0, ans1)

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

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

WAs = [0] * n
correct = 0
penalty = 0
for i in range(m):
    p, s = input().strip().split(' ')
    p = int(p) - 1
    if WAs[p] == -1:
        continue
    if s == 'AC':
        penalty += WAs[p]
        correct += 1
        WAs[p] = -1
    else:
        WAs[p] += 1

print(correct, penalty)

Solution (Python):
n, m = [int(v) for v in input().split()]

count_map = [0] * (n + 1)
miss_map = [0] * (n + 1)

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

    if count_map[p]:
        continue

    if s == 'AC':
        count_map[p] = True
        count += 1
        miss += miss_map[p]
    else:
        miss_map[p] += 1

print(count, miss)

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

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

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

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

	num = []
	ans = []
	for i in range(m):
		na,a = input().split()
		num.append(na)
		ans.append(str(a))
	
	ac = 0
	wa = 0
	ans_l = []
	for i in range(1,n+1):
		ans_l.append([i,1,0])
	ac_temp = []
	wa_temp = 0

	for i in range(m):
		if ans[i] == "WA":
			ans_l[int(num[i])-1][2] += 1
		elif ans[i] == "AC" and ans_l[int(num[i])-1][1] == 1:
			ac += 1
			ans_l[int(num[i])-1][1] = 0
			wa += ans_l[int(num[i])-1][2]
			ans_l[int(num[i])-1][2] = 0
	print(ac,wa)

if __name__ == '__main__':
	main()

Solution (Python):
n,m = map(int,input().split())
q = [0]*n
wa = [0]*n
for _ in range(m):
    pp,s = input().split()
    p = int(pp)

    if q[p-1] == 0:
        if s == "WA":
            wa[p-1] += 1
        else:
            q[p-1] = 1
qq = 0
wawa = 0
for i in range(n):
    if q[i] > 0:
        wawa += wa[i]
    qq += q[i]
print(qq,wawa)

Solution (Python):
N, M = map(int, input().split())
problem_right = {}
problem_pen = {}
score, penalty = 0, 0
for i in range(M):
	p_i, S_i = input().split()
	if S_i == 'WA' and p_i not in problem_right:
		if p_i not in problem_pen:
			problem_pen[p_i] = 1
		else:
			problem_pen[p_i] += 1
	elif S_i == 'AC' and p_i not in problem_right:
		score += 1
		problem_right[p_i] = True
		if p_i in problem_pen:
			penalty += problem_pen[p_i]
print(str(score)+' '+str(penalty))

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

def qa(s):
    qa_dict = {}
    WAs=0
    ACs=0
    for qa in s:
        qa_dict[qa[0]] = 0
    for qa in s:
        if qa_dict[qa[0]] <= 0:
            if qa[1] == 'WA':
                qa_dict[qa[0]] -= 1
            elif qa[1] == 'AC':
                if qa_dict[qa[0]] == 0:
                    qa_dict[qa[0]] += 0.001
                else:
                    qa_dict[qa[0]] *= -1
                ACs += 1
    for v in qa_dict.values():
        if v > 0:
            WAs += int(v)
    return ACs, WAs

if m == 0:
    ac, wa = 0, 0
else:
    ac, wa = qa(s)
print('{} {}'.format(ac, wa))

Solution (Python):
N, M = map(int, input().split())
lis = [list(input().split()) for _ in range(M)]
AC = [[0] * 2 for i in range(N)]
for i in range(M):
    if lis[i][1] == "AC":
        AC[int(lis[i][0])-1][1] = 1
    elif AC[int(lis[i][0])-1][1] == 0:
        AC[int(lis[i][0])-1][0] += 1
a = 0
w = 0
for i in range(N):
    if AC[i][1] == 1:
        a += 1
        w += AC[i][0]
print(a, w)

Solution (Python):
import numpy as np
N,M = map(int, input().split())
P = [input().split() for i in range(M)]
dic = {}
ans = 0
pen = 0

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

for i in range(M):
  if dic[int(P[i][0])][0] == False:
    if P[i][1] == "WA":
      dic[int(P[i][0])][1] += 1
    else:
      dic[int(P[i][0])][0] = True
      pen += dic[int(P[i][0])][1]
      ans += 1

print(ans,pen)

Solution (Python):
N, M = map(int, input().split())
d = [0]*(N+1)
d2 = [0]*(N+1)
r1=r2=0
for _ in range(M):
    p, j = input().split()
    p = int(p)
    j = j.strip()
    if j == "AC":
        if not d[p]:
            d[p] = 1
            r1 += 1
            r2 += d2[p]
    else:
        if not d[p]:
            d2[p] += 1
print(r1,r2)

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

ok = 0
ng = 0
ng_tmp = [0] * n
flag = [True] * n

for i in range(m):
  tmp = input().split()
  p = int(tmp[0])
  s = tmp[1]
  if flag[p-1]:
    if s == 'AC':
      flag[p-1] = False
      ok += 1
      ng += ng_tmp[p-1]
    if s == 'WA':
      ng_tmp[p-1] += 1

  
print(ok, ng)

Solution (Python):
import numpy as np
 
N, M = map(int, input().split())
 
suc = [0 for i in range(N+1)]
pen = [0 for i in range(N+1)]
 
for i in range(M):
    p, s = input().split()
    p = int(p)
    if s == "WA" and suc[p] == 0:
        pen[p] += 1
    elif s == "AC":
        suc[p] = 1

for i in range(N+1):
    if suc[i] == 0:
        pen[i] = 0

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

Solution (Python):
N, M = map(int, input().rstrip().split())
AC = 0
WA = 0
data = {}
for _ in range(M):
    tmp = input().rstrip().split()
    p, S =  int(tmp[0]), tmp[1]
    if p not in data.keys():
        if S == 'AC':
            data[p] = {'AC': True, 'WA': 0}
            AC += 1
        elif S == 'WA':
            data[p] = {'AC': False, 'WA': 1}
    else:
        if S == 'AC':
            if data[p]['AC'] is True:
                continue
            elif data[p]['AC'] is False:
                data[p]['AC'] = True
                WA += data[p]['WA']
                AC += 1
        elif S == 'WA':
            if data[p]['AC'] is True:
                continue
            elif data[p]['AC'] is False:
                data[p]['WA'] += 1
print('{} {}'.format(AC, WA))

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

solved = {}
failed = {}
for _ in range(M):
    p, S = input().split()
    p = int(p)
    if S == 'AC':
        if p in solved:
            pass
        else:
            solved[p] = 1
    else:
        if not (p in solved):
            if p in failed:
                failed[p] += 1
            else:
                failed[p] = 1

for p in failed:
    if not p in solved:
        failed[p] = 0

print(sum(solved.values()), sum(failed.values()))

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

pen= [0] * (n+1)
result=[False] * (n+1)
cnt = 0
pen_sum = 0
for i in range(m):
    p1, s1 = input().split()
    p1 = int(p1)
    if s1 == "AC" and not result[p1]:
        result[p1] = True
        cnt += 1
        pen_sum += pen[p1]
    if s1 == "WA" and not result[p1]:
        pen[p1] += 1

print("{} {}".format(cnt, pen_sum))

Solution (Python):
N, M = map(int, input().split())
if M > 0:
    S = [[i for i in input().split()] for _ in range(M)]
    w = [0] * (N+1)
    ac = set()
    for s in S:
        if int(s[0]) in ac:
            continue
        elif s[1] == "AC":
            ac.add(int(s[0]))
        else:
            w[int(s[0])] += 1
    wa = [w[i] for i in ac]
    print(len(ac), sum(wa))
else:
    print(0, 0)

Solution (Python):
n, m = map(int, input().split())
pi = []
si = []
for _ in range(m):
    p, s = input().split()
    pi.append(int(p))
    si.append(s)

ac = 0
wa = 0
c = {}
for i in range(m):
    if pi[i] in c.keys():
        if si[i] == 'AC' and c[pi[i]] != float("INF"):
            wa += c[pi[i]]
            ac += 1
            c[pi[i]] = float("INF")
        else:
            c[pi[i]] += 1
    else:
        if si[i] == 'AC':
            c[pi[i]] = float("INF")
            ac += 1
        else:
            c[pi[i]] = 1
print(ac, wa)

Solution (Python):
N,M = map(int,input().split())
pS = [list(input().split()) for _ in range(M)]
A = [0]*N
P = [0]*N
ans_A = 0
ans_P = 0
for p,S in pS:
    p = int(p)
    if S == 'AC':
        A[p-1] = 1
    else:
        if A[p-1] == 0:
            P[p-1] += 1
idx = 0
for a,p in zip(A,P):
    if a == 1:
        ans_A += 1
        ans_P += P[idx]
    idx += 1
print(ans_A,ans_P)

Solution (Python):
n, m = map(int, input().split())
ps = [input() for _ in range(m)]
p = [0] * m
s = [''] * m
for i in range(m):
  x, y = ps[i].split()
  p[i] = int(x)
  s[i] = y
ac_flag = [0]*n 
ac_count = 0
wa_count = [0]*n
for j in range(m):
  if ac_flag[p[j]-1] == 1:
    continue
  if s[j] == 'AC':
    ac_flag[p[j]-1] = 1
    ac_count+=1
  if s[j] == 'WA':
    wa_count[p[j]-1] += 1
true_wa_count=0
for k in range(n):
  if ac_flag[k] == 1:
    true_wa_count+=wa_count[k]
print(ac_count,true_wa_count)

Solution (Python):
import numpy as np
N,M = map(int,input().split())
pena = np.zeros(N)
clear = np.zeros(N)
for i in range(M):
    p,S = input().split()
    p = int(p)-1
    if S == "WA" and clear[p] == 0:
        pena[p] += 1
    else:
        clear[p] = 1
clear_num = np.where(clear == 1)[0]
new_pena = pena[clear_num]
print(int(np.sum(clear)),int(np.sum(new_pena)))

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

er_c = 0
ac_c = 0

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

flag = [0]*N

for i in reversed(range(M)):
    if ps[i][1] == 'AC':
        flag[int(ps[i][0])-1] = 1

for i in range(M):
    if flag[int(ps[i][0])-1] == 1:
        if i == 0:
            if ps[i][1] == 'WA':
                er_c += 1
            else:
                ac_c += 1
                flag[int(ps[i][0])-1] = -1
        elif ps[i][1] == 'WA':
            er_c += 1
        elif ps[i][1] == 'AC':
                ac_c += 1
                flag[int(ps[i][0])-1] = -1

print(ac_c, er_c)

Solution (Python):
n,m = map(int,input().split())
t = dict()
account,pena = 0,0
for i in range(m):
	s = input().split()
	if not s[0] in t.keys():
		t[s[0]] = s[1]
	else:
		if t[s[0]][-2::] == 'WA':
			t[s[0]] += s[1]
for j in t.values():
	if j[-2::] == 'AC':
		account += 1
		pena += j.count('WA')
print(account,pena)

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

lis = []

for _ in range(M):
    i, j = input().split()
    i = int(i)
    lis.append((i, j))


cntsAC = 0

inc = [i for i in range(1, N + 1)]
zeros = [0 for _ in range(N)]

flags = dict(zip(inc, zeros))
flags_forAC = dict(zip(inc, zeros))
flags_forWA = dict(zip(inc, zeros))

cntsWA = 0

for k, v in lis:
    if flags_forAC[k] == 0:
        if v == "AC":
            flags_forAC[k] = 1
            cntsAC += 1
            flags[k] = 1
        else:
            flags_forAC[k] = 1
    else:
        if v == "AC" and flags[k] == 0:
            cntsAC += 1
            flags[k] = 1


for k, v in lis:
    if flags[k] == 1 and v == "WA" and flags_forWA[k] == 0:
        cntsWA += 1
    elif v == "AC":
        flags_forWA[k] = 1

print(cntsAC, cntsWA, sep=" ")

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

SEIKAI = 0

PENALTI = 0

L = [0] * 100001

for i in range(M):
    _P,S = input().split()
    P = int(_P)
    if S == 'WA' and L[P] != -1:
        L[P] += 1
    elif S == 'AC' and L[P] != -1:
        SEIKAI += 1
        PENALTI += L[P]
        
        L[P] = -1

print(SEIKAI,PENALTI)

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

num = [0]*n
nn = [-1]*n
WA = 0
AC = 0

for i in range(m):
  text = input().strip().split()
  p = int(text[0])
  s = text[1]
  
  if nn[p-1] == -1:
    if s == 'AC':
      AC += 1
      WA += num[p-1]
      nn[p-1] = 1
    elif s == 'WA':
      num[p-1] += 1
      
print(AC, WA)

Solution (Python):
n,m = map(int,input().split())
ac = 0
wa = 0
p = []
s = []
flag = 0
ind_lists = [0]*(n)
for i in range(m):
    P,S = map(str,input().split())
    p.append(int(P))
    s.append(S)
mita = set()
for i in range(m):
    if p[i] in mita:
        pass
    elif s[i] == "AC":
        mita.add(p[i])
        ind_lists[p[i] - 1] = (i+1)
o_set = set()
for i in range(len(ind_lists)):
    if ind_lists[i]-1 < 0:
        o_set.add(i+1)
mita = set()
for i in range(m):
    if p[i] in o_set or p[i] in mita:
        pass
    elif s[i] == "AC":
        ac += 1
        mita.add(p[i])
    else:
        wa += 1

print(ac,wa)

Solution (Python):
N, M = map(int, input().split())
li = []
for i in range(M):
  liin = input().split()
  li.append([int(liin[0]), liin[1]])

ans1, ans2 = 0, 0
done = set([0])
miss = {}

for i in range(M):
  if li[i][0] in done:
    continue
  if li[i][1] == "AC":
    ans1 += 1
    done.add(li[i][0])
    if li[i][0] in miss:
      ans2 += miss[li[i][0]]
      del miss[li[i][0]]
  else: 
    if li[i][0] in miss:
      miss[li[i][0]] += 1
    else:
      miss[li[i][0]] = 1

print(ans1,ans2)

Solution (Python):
n,m = map(lambda x: int(x),input().split())
err = 0
ans_count = 0

dict = {}
dict_err = {}
for _ in range(m):
    p,s = input().split()
    p = int(p)
    if not (p in dict.keys()) :
        dict[p] = s
        if s == 'WA' :
            dict_err[p] = 1
        elif s == 'AC' :
            ans_count += 1

    elif (p, 'WA') in dict.items() and s == 'WA':
        err = dict_err[p] + 1
        dict_err[p] = err
    elif (p, 'WA') in dict.items() and s == 'AC':
        dict[p] = s
        ans_count += 1

for i,j in dict.items() :
    if j == 'WA' :
        dict_err.pop(i)
print(ans_count,sum(dict_err.values()))

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

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

fin=[0]*(N+1)
count_AC=0
count_WA=[0]*(N+1)

if(M!=0):
    for i in range(0,M):
        if(S[i]=="AC"):
            if(fin[int(p[i])]!=-1):
                count_AC+=1
                fin[int(p[i])]=-1
        else:
            if(fin[int(p[i])]!=-1):
                count_WA[int(p[i])]+=1
    
    for i in range(1,N+1):
        if(fin[i]!=-1):
            count_WA[i]=0
    
    print(count_AC,sum(count_WA))

else:
    print(count_AC,sum(count_WA))

Solution (Python):
N, M = map(int, input().split())
pi = []
Si = []
for i in range(M):
    p, S = map(str, input().split())
    pi.append(p)
    Si.append(S)
score = 0
penalty = 0
now_num = 1
AC_problem = [True] * N
WA_problem = [True] * N
penalty_num = [0] * N
for i in range(M):
    if Si[i] == 'AC' and AC_problem[int(pi[i]) - 1]:
        score += 1
        AC_problem[int(pi[i]) - 1] = False
        WA_problem[int(pi[i]) - 1] = False
    elif WA_problem[int(pi[i]) - 1]:
        penalty += 1
        penalty_num[int(pi[i]) - 1] += 1

for i in range(N):
    if AC_problem[i]:
        penalty -= penalty_num[i]
        
print(str(score) + ' ' + str(penalty))

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

ac = 0
wa = 0
ans = [{'AC': False, 'cnt': 0} for _ in range(n)]

if m == 0:
    print('0 0')
else:

    for _ in range(m):
        p,s = list(input().split())
        p = int(p)
        if s == 'AC':
            ans[p-1]['AC'] = True
        elif ans[p-1]['AC'] == False:
            ans[p-1]['cnt'] += 1

    for a in ans:

        if a['AC']:
            ac += 1
            wa += a['cnt']
    print('{} {}'.format(ac, wa))

Solution (Python):
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
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()))
MOD = 10**9 + 7

n, m = MAP()
submits = [[] for i in range(n)]
for i in range(m):
    p, S = input().split()
    p = int(p)
    submits[p-1].append(S)

ac = 0
wa = 0

for i in range(n):
    for j in range(len(submits[i])):
        if submits[i][j] == 'AC':
            ac += 1
            wa += len(submits[i][:j])
            break

print(str(ac) + ' ' + str(wa))

Solution (Python):
n, m = map(int, input().split())
q = [input().split() for _ in range(m)]
ac = [False for _ in range(n+1)]
wa = [0 for _ in range(n+1)]
for p, s in q:
	p = int(p)
	if s == "WA" and not ac[p]:
		wa[p] += 1
	if s == "AC":
		ac[p] = True
print(sum(ac), sum([wa[i] for i in range(n+1) if ac[i]]))

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

list_n = list(range(n))

l = [[] for i in range(n)]

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

ac = 0
wa = 0
for i in l:
    if 'AC' in i:
        ac += 1
        wa_l = i[0:(i.index('AC'))]
        wa += wa_l.count('WA')
        
print(ac,wa)

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

listA= []
for i in range(M):
    a,b= input().split()
    listA.append((int(a),b))

hantei = []
for j in range(0,N):
    hantei.append([0,0])


for i in range(0,M):
    num = listA[i][0]-1
    if listA[i][1]=='AC':

        hantei[num][0]=1

    elif listA[i][1]=='WA' and hantei[num][0]==0:

        hantei[num][1] += 1


pena = 0
corr=0
for y in range(0, N):
    if hantei[y][0]==1:
        corr += 1
        pena += hantei[y][1]

print(corr,pena)

Solution (Python):
N,M=map(int,input().split())
AC=[False]*N
P=[0]*N
pena=0
for i in range(M):
  p,s=map(str,input().split())
  p=int(p)-1
  if s=='WA' and AC[p]==False:
    P[p] +=1
  elif s=='AC' and AC[p]==False:
    AC[p]=True
    pena += P[p]
answer=0
for i in range(N):
  if AC[i]==True:
    answer +=1
print(answer,pena)

Solution (Python):
n, m = map(int, input().split())
dic = dict()
li = list()
for i in range(m):
    x1, y1 = input().split()
    if x1 not in dic.keys():
        dic[x1] = [0,0]
    if dic[x1][0] == 0:
        if y1 == "AC":
            dic[x1][0] = 1
        else:
            dic[x1][1] += 1
ac = 0
wa = 0
for key in dic.keys():
    if dic[key][0] == 1:
        ac += 1
        wa += dic[key][1]
print(ac, wa)

Solution (Python):
import numpy as np

N_M = input()
N = int(N_M.split(" ")[0])
M = int(N_M.split(" ")[1])

input_list = []
for i in range(M):
	input_list.append(tuple(input().split(" ")))

AC_list = np.zeros(N, dtype=bool)
WA_list = np.zeros(N, dtype=int)

for data in input_list:

	if data[1] == 'AC':
		AC_list[int(data[0]) - 1] = True
		if WA_list[int(data[0]) - 1] > 0:
			WA_list[int(data[0]) - 1] = -1 * WA_list[int(data[0]) - 1]

	if data[1] == 'WA':
		if not AC_list[int(data[0]) - 1]:
			WA_list[int(data[0]) - 1] += 1

print(np.count_nonzero(AC_list), np.sum((WA_list < 0) * WA_list) * -1)

Solution (Python):
n,m = map(int,input().split())
p = []
s = []
for i in range(m):
    P,S = map(str,input().split())
    p.append(int(P))
    s.append(S)
Bool = [0 for i in range(n)]
count = [0 for i in range(n)]

for i in range(m):
    if not Bool[p[i]-1]:
        if s[i] == "WA":
            count[p[i]-1] += 1
        else:
            Bool[p[i]-1] = 1
ans = 0
for i in range(n):
    if Bool[i]:
        ans += count[i]

print(sum(Bool),ans)

Solution (Python):
n,m=map(int,input().split())
l=[[0 for i in range(2)]for j in range(n+1)]
wa,ac=0,0
for i in range(m):
  p,s=input().split()
  p=int(p)
  if s=="WA" and l[p][1]==0:
    l[p][0]+=1
  elif s=="AC" and l[p][1]==0:
    l[p][1]+=1
    ac+=1
    wa+=l[p][0]
print(ac,wa)

Solution (Python):
import sys
input = sys.stdin.readline
from itertools import groupby
from operator import itemgetter
def print_ans(N, M, ar):
    """Test Case
    >>> print_ans(2, 5, [['1', 'WA'], ['2', 'WA'], ['2', 'AC'], ['2', 'WA'], ['1', 'AC']])
    2 2
    >>> print_ans(100000, 3, [['7777', 'AC'], ['7777', 'AC'], ['7777', 'AC']])
    1 0
    >>> print_ans(6, 0, [])
    0 0
    """
    correct = 0
    wrong = 0
    ar = sorted(ar, key=itemgetter(0))
    if M == 0:
        print(0, 0)
    else:
        for (k, g) in groupby(ar, key=itemgetter(0)):
            tmp_wrong = 0
            ac_flg = False
            for item in g:
                if item[1] == "AC":
                    correct += 1
                    ac_flg = True
                    break
                else:
                    tmp_wrong += 1
            if ac_flg == True:
                wrong += tmp_wrong
        print("{} {}".format(correct, wrong))
if __name__ == '__main__':
    N, M = map(int, input().rstrip().split())
    if M == 0:
        ar = []
    else:
        ar = [list(map(str, input().rstrip().split())) for i in range(M)]
    print_ans(N, M, ar)

Solution (Python):
def main():
    N, M = [int(s) for s in input().split()]
    p = []
    S = []
    for i in range(M):
        s_pn, Sn = input().split()
        p.append(int(s_pn))
        S.append(Sn)

    cleared = {}
    ng = {}
    for i in range(M):
        if S[i] == 'AC':
            cleared[p[i]] = True
        elif S[i] == 'WA':
            if p[i] not in cleared:
                if p[i] not in ng:
                    ng[p[i]] = 1
                else:
                    ng[p[i]] += 1

    ng_count = 0
    for pn in cleared.keys():
        if pn in ng:
            ng_count += ng[pn]
    print(len(cleared), ng_count)


if __name__ == "__main__":
    main()

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

idx = list(range(N+1))
wa = [0] * (N + 1)
AC = 0
WA = 0
for i in range(len(ps)):
    if idx[int(ps[i][0])] != "AC":
        if ps[i][1] == "AC":
            AC += 1
            idx[int(ps[i][0])] = "AC"
        else:
            wa[int(ps[i][0])] += 1

for i in range(N+1):
    if idx[i] == "AC":
        WA += wa[i] 

print(str(AC) + " " + str(WA))

Solution (Python):
n,m=map(int,input().split())
sl=[]
pl=[]
pena=0
ac=0
ac_p=[]
wa={}
acdic={}

for i in range(m):
    
    li = input().split()
    p=int(li[0])
    s=li[1]
    
    if s=="WA":
        wa[p]=wa.get(p,0)+1
    else:
        
        if acdic.get(p,False)==False:
            ac+=1
            acdic[p]=True
            pena+=wa.get(p,0)

print("{0} {1}".format(ac,pena))

Solution (Python):
N, M = map(int,input().split())
AC = 0
WA = 0
ACdata = [0]*100001
WAdata = [0]*100001
for i in range(M):
    x, y = map(str,input().split())

    if ACdata[int(x)] == 1:
        continue
    if y == 'WA':
        WAdata[int(x)] += 1
    else:
        AC += 1
        ACdata[int(x)] = 1
        WA += WAdata[int(x)]
print(AC,WA)

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

CA = 0
PN = 0
d = {key:0 for key in P}
for i in range(len(P)):
    if d[P[i]] >= 0:
        if S[i] == "WA":
            d[P[i]] += 1
        elif S[i] == "AC":
            PN += d[P[i]]
            CA += 1
            d[P[i]] = -1

print(CA, PN)

Solution (Python):
N,M = map(int, input().split())
list_point = ["NN"] * (N + 1)
list_wa = [0] * (N + 1)
for x in range(M):
    point,state = input().split()
    point = int(point)
    if(list_point[point]!='AC' and state == 'AC'):
        list_point[point]=state
    elif(list_point[point]!='AC' and state == 'WA'):
        list_wa[point] += 1


sum_wa =0
for x in range(N+1):
    if(list_point[x] == "AC"):
        sum_wa += list_wa[x]
print(list_point.count('AC'),sum_wa)

Solution (Python):
from fractions import gcd


import heapq
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors





def main():
    
    n, m = map(int, input().split())
    ps = [list(input().split()) for i in range(m)]

    c = 1
    ac, wa = 0, 0
    d = defaultdict(int)
    dwa = defaultdict(int)
    for i in range(m):
        if ps[i][1] == "AC" and d[int(ps[i][0])] == 0:
            ac += 1
            d[int(ps[i][0])] = 1
            wa += dwa[int(ps[i][0])]
        elif ps[i][1] == "WA" and d[int(ps[i][0])] == 0:
            
            dwa[int(ps[i][0])]+=1
    print(ac,wa)

    
    
    

            
    
    
    
    
    
    
    
    
    
    
    
    
    
                
        




    


if __name__ == '__main__':
    main()

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

c_l = [0 for i in range(N)]
a = 0
w = 0

for i in range(M):
  p,s = input().split()
  p = int(p)
  if c_l[p-1] != -1:
    if s == "AC":
      a += 1
      w += c_l[p-1]
      c_l[p-1] = -1
    else:
      c_l[p-1] += 1
print("{} {}".format(a,w))

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

if m == 0:
  print('0 0')
else:
  
  outputs = reversed([input().split(' ') for i in range(m)])

  problem_ac = set()  
  problem_wa = {}  
  for o in outputs:
    num = o[0]
    result = o[1]
    if result == 'AC':
      if num in problem_ac:  
        problem_wa[num] = 0
      problem_ac.add(num)
    else:  
      if num in problem_ac:
        problem_wa[num] = problem_wa[num] + 1 if num in problem_wa.keys() else 1
  
  ac_count = len(problem_ac)
  wa_count = sum(problem_wa.values()) if len(problem_wa) > 0 else 0
  print('{} {}'.format(ac_count, wa_count))

Solution (Python):
N,M = map(int,input().split())
lis = [tuple(map(str,input().split())) for i in range(M)]
ans = [0]*N
answ = [0]*N
ansin = [0]*N
for i in range(0,M):
    an = lis[i][1]
    if an == 'AC':
        ans[int(lis[i][0])-1] = 1
    elif an == 'WA' and ans[int(lis[i][0])-1] == 0:
        answ[int(lis[i][0])-1] += 1
for i in range(N):
    if ans[i] == 1:
        ansin[i] = answ[i]
print(sum(ans),end=' ')
print(sum(ansin))

Solution (Python):
import numpy as np

NM=np.array(input().split(" "),dtype=np.int32)

result={}
tmp=[]

for i in range(NM[1]):
    s=input().split(" ")
    result.setdefault(s[0],[]).append(s[1])

corrects=0
penalty=0
keys=result.keys()

for k in keys:
    L=result[k]
    if('AC' in L):
        idx=L.index('AC')
    else:
        idx=-1
    if(idx==-1):
        continue
    else:
        penalty+=idx
        corrects+=1

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

Solution (Python):
import numpy as np
n, m = list(map(int, input().split()))
p = np.zeros(m, dtype=np.int64)
s = np.zeros(m, dtype=np.bool)
for i in range(m):
    _p, _s = input().split()
    p[i] = int(_p) - 1
    s[i] = _s[0] == 'A'
isAc = np.zeros(n, dtype=np.bool)
waCount = np.zeros(n, dtype=np.int64)
for i in range(m):
    question = p[i]
    isAc[question] = isAc[question] or s[i]
    if (not isAc[question]) and (not s[i]):
        waCount[question] += 1
for j in range(n):
    if not isAc[j]:
        waCount[j] = 0
acCount = np.count_nonzero(isAc)
waSum = np.sum(waCount)
print('{} {}'.format(acCount, waSum))

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

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

count_wa = [0]*n
flag_ac = [False]*n
for i in l:
    if not flag_ac[int(i[0])-1]:
        if i[1] == "AC":
            flag_ac[int(i[0])-1] = True 
        elif i[1] == "WA":
            count_wa[int(i[0])-1] += 1

for i in range(n):
    if not flag_ac[i]:
        count_wa[i] = 0

print(sum(flag_ac), sum(count_wa))

Solution (Python):
N,M = [int(i) for i in input().split()]
submissions = {str(i):[] for i in range(1,N+1)}
AC,WA = 0,0
for i in range(M):
    P,S = [j for j in input().split()]
    submissions[P].append(S)
for i in submissions:
    if 'AC' not in submissions[i]:
        continue
    for j in submissions[i]:
        if j == 'AC':
            AC+=1
            break
        WA +=1
print(AC,WA)

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

question = [False for i in range(N)]
solved = [False for i in range(N)]
for i in range(M):
    posi = ps[i][0]-1
    if ps[i][1] =='AC':
        solved[posi] = True
pena = 0
AC = 0

for i in range(M):
    posi = ps[i][0]-1
    if ps[i][1] =='AC' and question[posi]==False:
        AC+=1
        question[posi] = True
    if ps[i][1] =='WA' and question[posi] == False and solved[posi]==True:
        pena+=1
        
print(AC,pena)

Solution (Python):
from functools import reduce
N, M = list(map(int, input().split()))
ps_list = [input().split() for _ in range(M)]

result = {}
for row in ps_list:
  if not row[0] in result:
    result[row[0]] = {
        "AC": 0,
        "WA": 0
    }
  if result[row[0]]["AC"] > 0:
    continue
  else:
    result[row[0]][row[1]] = result[row[0]][row[1]] + 1

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