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 sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) 
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    


MOD = 10**9 + 7
INF = 2**31  

from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  


N, M = read_ints()
is_ac = [False] * N
n_wa = [0] * N
for _ in ra(M):
    p, S = read().split()
    p = int(p) - 1
    if is_ac[p]:  
        continue
    if S == 'WA':
        n_wa[p] += 1
    else:
        is_ac[p] = True
n_pena = 0
for ac, n in zip(is_ac, n_wa):
    if ac:
        n_pena += n

print(sum(is_ac), n_pena)

Solution (Python):
n, m = map(int, input().split())
ps = []
for _ in range(m):
    p, s = input().split()
    ps.append((int(p), s))
was = [0]*(n+1)
total_ac = 0
total_wa = 0
for p, s in ps:
    if was[p]<0:
        continue
    if s=='AC':
        total_wa += was[p]
        total_ac += 1
        was[p] = -1
    else:
        was[p] += 1
print(total_ac, total_wa)

Solution (Python):
n,m = map(int,input().split())
AC = [0] * n
WA = [0] * n
penalty = 0

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

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

problem = [0] * n
pp = [0]*n
b = ""
for p,s in ps:
    if problem[int(p)-1] == 0:
        if s == "WA":pp[int(p)-1] += 1
        else: problem[int(p)-1] = 1
ac = 0
pe = 0
for i in range(n):
    if problem[i] == 1:
        ac += 1
        pe += pp[i]
print(ac,pe)

Solution (Python):
n,m=map(int,input().split())
use=[0]*n
pen=[0]*n
ans=0
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=="AC":
        if use[p]==0:
            use[p]=1
            ans+=1
    else:
        if use[p]==0:
            pen[p]+=1
pe=0
for i in range(n):
    pe+=use[i]*pen[i]
print(ans,pe)

Solution (Python):
def main():
    n, m = map(int, input().split())
    questions = [[0, False] for _ in range(n)]
    for _ in range(m):
        p, s = input().split()
        p = int(p) - 1
        if not questions[p][1]:
            if s == "WA":
                questions[p][0] += 1
            else:
                questions[p][1] = True
    ac = 0
    wa = 0
    for wa_num, is_accepted in questions:
        if is_accepted:
            ac += 1
            wa += wa_num
    print(ac, wa)


if __name__ == '__main__':
    main()

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

AC = 0
pena = 0

lst = [0] * N
for _ in range(M):
    a, b = map(str, input().split())
    a = int(a) - 1
    if lst[a] < 0:
        continue
    else:
        if b == 'WA':
            lst[a] += 1
        else:
            AC += 1
            pena += lst[a]
            lst[a] = -1

print (AC, pena)

Solution (Python):
def examA():
    N = I()
    ans = 0
    print(ans)
    return

def examB():
    N, M = LI()
    P = [0]*N
    S = [LSI()for _ in range(M)]
    pena = 0
    ac = set()
    for p,s in S:
        p = int(p)-1
        if s=="WA":
            P[p] += 1
        else:
            if p in ac:
                continue
            ac.add(p)
            pena += P[p]

    print(len(ac),pena)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Solution (Python):
def main():
    N, M = (int(i) for i in input().split())
    from collections import defaultdict
    waCnt = defaultdict(int)
    ac = set()
    for _ in [0]*M:
        p, s = (i for i in input().split())
        if s == "WA" and p not in ac:
            waCnt[p] += 1
        else:
            ac.add(p)
    sumWA = sum(waCnt[p] for p in ac)
    print(len(ac), sumWA)


if __name__ == '__main__':
    main()

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

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

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

ac_cnt=l.count(-1)
print(ac_cnt,cnt)

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

B = [0]*n
C = [0]*n
ans = 0
pna = 0
for i in range(m):
    a,b= input().split()
    a = int(a)
    if b=="AC":
        if B[a-1]==0 :
            B[a-1] =1
            ans += 1
            pna += C[a-1]
    else:
        C[a-1] = C[a-1]+1 
print(ans,pna)

Solution (Python):
N,M = [int(x) for x in input().split()]
count = [0]*N
ac = 0
wa = 0
ireta = []
for i in range(M):
    a,b = input().split()
    a = int(a)
    if b == "AC" and count[a-1] == 0:
        count[a-1] = 1
        ac += 1
    elif count[a-1] == 0:
        ireta.append(a)
        wa += 1
for i in range(len(ireta)):
    if count[ireta[i]-1] == 0:
        wa -= 1
print(ac,wa)

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

score = [0] * 1000000
countWA = 0
countAC = 0

for i in range(m):
    pi, si = input().split()
    pi = int(pi)
    if score[pi] == -1:
        continue
    if si == "WA":
        score[pi] += 1
    if si == "AC":
        countWA += score[pi]
        countAC += 1
        score[pi] = -1

print(countAC, countWA)

Solution (Python):
N,M = map(int, input().split())
p = []
S = []
acnum = [-1]*N
for i in range(M):
    tmp1,tmp2 = input().split()
    p.append(int(tmp1))
    S.append(tmp2)
account = 0
wacount = [0]*N
waans = 0
for i in range(M):
    if acnum[p[i] - 1] == -1:
        if S[i] == "AC":
            acnum[p[i] - 1] = 1
            account += 1
            waans += wacount[p[i] - 1]
        else:
            wacount[p[i] - 1] += 1
print(account,waans)

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

d_1=[0]*N
d_2=[0]*N

for i in range(M):
    p_i,S_i = input().split()
    p_i =int(p_i)-1
    if S_i=='WA' and d_2[p_i]==0:
        d_1[p_i]+=1
    elif S_i=='AC' and d_2[p_i]==0:
        d_2[p_i]=1

penalty=0
for j in range(N):
    if d_2[j]==1:
        penalty+=d_1[j]

print(sum(d_2),penalty)

Solution (Python):


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

flag = [0 for _ in range(n)]
wa_num_list = [0 for _ in range(n)]

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

pen = 0
for i in range(n):
    if flag[i] == 1:
        pen += wa_num_list[i]

print(sum(flag), pen)

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

Submittion = [None]*M
for i in range(M):
    Submittion[i] =input().split()
    Submittion[i][0] =int(Submittion[i][0])

answer = [0]*(N)
WA = [0]*N
for i in range(M):
    if Submittion[i][1] == "AC":
        answer[Submittion[i][0]-1] +=1
    else:
        if answer[Submittion[i][0]-1] == 0:
            WA[Submittion[i][0]-1]+=1

print_ans = 0
print_wa = 0
for i in range(len(answer)):
    if answer[i] >0:
        print_ans+=1

    if answer[i] >0:
        print_wa +=WA[i]

print(print_ans,print_wa)

Solution (Python):
N,M = [int(x) for x in input().split()]
count = [0]*N
ac = 0
wa = 0
ireta = []
for i in range(M):
    a,b = input().split()
    a = int(a)
    if b == "AC" and count[a-1] == 0:
        count[a-1] = 1
        ac += 1
    elif count[a-1] == 0:
        ireta.append(a)
        wa += 1
for i in range(len(ireta)):
    if count[ireta[i]-1] == 0:
        wa -= 1
print(ac,wa)

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

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

for m in range(M):
    p,s = input().split()
    p = int(p)-1
    if task[p] != -1 and s == "WA":
        task[p] += 1
    elif task[p] != -1 and s == "AC":
        ac += 1
        wa += task[p]
        task[p] = -1

print(ac,wa)

Solution (Python):
n, m = map(int,input().split())
q = [0 for i in range(n)]
alist = []
ac = 0
pe = [0 for i in range(n)]
be = 0
for i in range(m):
    a,b=input().split()
    alist.append((int(a), b))
for i in range(m):
    if q[alist[i][0]-1] == 0:
        if alist[i][1] == 'AC':
            ac += 1
            be = be + pe[alist[i][0]-1]
            q[alist[i][0]-1] = 1
        else:
            pe[alist[i][0]-1] +=  1
    else:
        continue
print(ac,be)

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

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

for i in a:
    if i[1] == 1:
        wa += i[0]

print(ac,wa)

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

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

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

Solution (Python):
from collections import defaultdict

N ,M = map(int,input().split())
PS = defaultdict(lambda:[0,0])
for _ in range(M):
    p, s = input().split()
    if s == 'AC':
        PS[p][0] = 1
    else:
        if PS[p][0] == 0:
            PS[p][1] += 1

AC = 0
WA = 0
for v in PS.values():
    AC += v[0]
    WA += v[0]*v[1]


print(AC,WA)

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

q = [False for _ in range(n)]
wa = [0] * n

for i, s in ps:
    if q[int(i)-1] == False:
        if s == "WA":
            wa[int(i)-1] += 1
        else:
            q[int(i)-1] = True

print(sum(q), sum([v for k, v in enumerate(wa) if q[k]==True]))

Solution (Python):

def main():
    n, m = list(map(int, input().split()))
    ret = {}
    for i in range(m):
        q, res = list(input().split())
        if q in ret:
            if ret[q][-1] == 'WA':
                ret[q].append(res)
        else:
            ret[q] = [res]
    ans = 0
    pena = 0
    for k in ret:
        if ret[k][-1] == 'AC':
            ans += 1
            pena += ret[k].count('WA')
    print(ans, pena)


if __name__ == '__main__':
    main()

Solution (Python):
test,submit=map(int,input().split())
ac_wa_map={}
ac=0
wa=0
wa_counter=[0]*test
for i in range(submit):
    test_no,acwa=input().split()
    if test_no not in ac_wa_map:
        ac_wa_map[test_no]=acwa
        if acwa=="AC":
            ac+=1
        elif acwa=="WA":
            wa_counter[int(test_no)-1]+=1
    elif acwa=="AC" and ac_wa_map[test_no]=="WA":
        ac+=1
        ac_wa_map[test_no]=acwa
        wa+=wa_counter[int(test_no)-1]
    elif acwa=="WA" and ac_wa_map[test_no]=="WA":
        wa_counter[int(test_no)-1]+=1
    

print(ac,wa)

Solution (Python):
n, m = map(int, input().split())
list_num = list([] for i in range(n))
test = [input().split() for i in range(m)]
for i in test:
  list_num[int(i[0]) - 1].append(i[1])
count = 0
count_ac = 0
count_wa = 0
check = 0
for i in list_num:
  for j in range(len(i)):
    if(i[j] =='WA'):
      count += 1
    elif(i[j] == 'AC'):
      count_ac += 1
      check = 1
      break
  if(check == 1):
    count_wa += count
    check = 0 
  count = 0
print(count_ac , count_wa)

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

x=[True]*n
cnt=[0]*n
y=0
z=0

for i in range(m):
    p,s=input().split()
    if s=="AC":
        x[int(p)-1]=False
    elif x[int(p)-1]:
        cnt[int(p)-1]+=1


for i in range(n):
    if x[i]==False:
        z+=cnt[i]
        y+=1

print(y,z)

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):


import sys



















def main():
    mod = 1000000007                  
    inf = float('inf')
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, m = mi()
    wa_count = [0] * n
    ac = [False] * n
    for _ in range(m):
        p, s = input().split()
        p = int(p) - 1
        if s == 'AC':
            ac[p] = True
        else:
            
            if not ac[p]:
                wa_count[p] += 1
    
    ac_num = 0
    penalty_num = 0
    for problem in range(n):
        if ac[problem]:
            ac_num += 1
            penalty_num += wa_count[problem]
    print("{} {}".format(ac_num, penalty_num))

    

if __name__ == "__main__":
    main()

Solution (Python):
n,m=map(int,input().split())
a=[-1]*n
for i in range(m):
	p,s=input().split()
	p=int(p)-1
	if s=="AC" and a[p]<0:
		a[p] = a[p]*(-1)
	if s=="WA" and a[p]<0:
		a[p] -= 1
ac=0
wa=0
for i in range(n):
	if a[i] > 0:
		ac += 1
		wa += a[i] - 1

print(ac,wa)

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

ac,wa = 0,0
cnt_ac = [0]*(n+1)
cnt_wa = [0]*(n+1)

for i in range(m):
    temp_num = int(s[i][0])
    temp_ans = s[i][1]
    if temp_ans == "WA":
        if cnt_ac[temp_num] != 1:
            cnt_wa[temp_num] += 1
    else:
        if cnt_ac[temp_num] != 1:
            cnt_ac[temp_num] = 1
            ac += 1
            wa += cnt_wa[temp_num]  
        
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())
ac = [0]*n
wa = [0]*n
x=0
y=0
for i in range(m):
    p , s = input().split()
    p = int(p)
    if s=='WA' and ac[p-1]==0:
        wa[p-1]+=1
    elif s=='AC' and ac[p-1]==0:
        ac[p-1]=1
        y+=wa[p-1]
        x+=1
print(x,y)

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

    for i in range(M):
        no, sta = input().split()
        commit[int(no)-1].append(sta)

    AC_total = 0
    WA_total = 0

    for i in range(len(commit)):
        WA = 0
        if len(commit[i]) == 0:
                continue
        else:
            for j in range(len(commit[i])):
                if commit[i][j] == "WA":
                    WA += 1
                elif commit[i][j] == "AC":
                    AC_total += 1
                    WA_total += WA
                    break
    print(AC_total, WA_total)
if __name__ == "__main__":
    main()

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

    for i in range(M):
        no, sta = input().split()
        commit[int(no)-1].append(sta)

    AC_total = 0
    WA_total = 0

    for i in range(len(commit)):
        WA = 0
        for j in range(len(commit[i])):
            if len(commit[i]) == 0:
                continue
            else:
                if commit[i][j] == "WA":
                    WA += 1
                elif commit[i][j] == "AC":
                    AC_total += 1
                    WA_total += WA
                    break
    print(AC_total, WA_total)
if __name__ == "__main__":
    main()

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

    for i in range(M):
        no, sta = input().split()
        commit[int(no)-1].append(sta)

    AC_total = 0
    WA_total = 0

    for i in range(len(commit)):
        AC = 0
        WA = 0
        for j in range(len(commit[i])):
            if len(commit[i]) == 0:
                continue
            else:
                if commit[i][j] == "WA":
                    WA += 1
                elif commit[i][j] == "AC":
                    AC += 1
                    AC_total += AC
                    WA_total += WA
                    break
    print(AC_total, WA_total)

if __name__ == "__main__":
    main()

Solution (Python):
N, M = map(int, input().split())
ac_counter = [0 for _ in range(N)]
wa_counter = [0 for _ in range(N)]
wa_sum = 0
for _ in range(M):
    line = input().split()
    problem = int(line[0])
    result = line[1]
    if not ac_counter[problem-1] == 1:
        if result == 'AC':
            ac_counter[problem-1] = 1
            wa_sum += wa_counter[problem-1]
        else:
            wa_counter[problem-1] += 1

answer = []
answer.append(str(sum(ac_counter)))
answer.append(str(wa_sum))
print(" ".join(answer))

Solution (Python):
n,m=map(int,input().split())
a=[[i for i in input().split()] for j in range(m)]
WANum=[0]*(n+1)
EndFlag=[0]*(n+1)
for x in a:
    if x[1]=="WA" and EndFlag[int(x[0])]==0:WANum[int(x[0])]+=1
    if x[1]=="AC":EndFlag[int(x[0])]=1
c=0
for i,x in enumerate(EndFlag):
    if x==1:c+=WANum[i]
print(sum(EndFlag),c)

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

for i in range(m):
    question, result=input().split()
    num = int(question) - 1
    if result == "AC" and ans[num]:
        ans[num]=False
        ac+=1
    
    elif result == "WA" and ans[num]:
        wa[num] += 1
 
wa_sum = 0

for i in range(n):
    
    if not ans[i]:
        wa_sum += wa[i]
 
print(ac, wa_sum)

Solution (Python):
n,m = map(int,input().split())
ac = 0
wa = 0
wa_d = {}
ac_d = {}
for i in range(1,n+1):
    ac_d[str(i)] = False
    wa_d[str(i)] = 0

for _ in range(m):
    p,s = input().split()
    if s == "AC":
        if ac_d[p]:
            pass
        else:
            wa += wa_d[p]
            ac += 1
            ac_d[p] = True 
    else:
        wa_d[p] += 1

print (ac,wa)

Solution (Python):


N, M = map(int, input().split())
ps = [list(input().split()) for _ 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(cnt1, cnt2)

Solution (Python):
N,M=map(int,input().split())
keep=[]
lis=[]
ac=[0]*N
wa=[0]*N
WA=0
for i in range(M):
    ps=input().split()
    keep.append(ps)
    
for j in range(M):
    if keep[j][1]=="AC":
        ac[int(keep[j][0])-1]=1
    elif ac[int(keep[j][0])-1]==0:
        wa[int(keep[j][0])-1]+=1
AC=sum(ac)
for k in range(N):
    WA+=ac[k]*wa[k]
    
print(AC,WA)

Solution (Python):
n,m=map(int,input().split())
ac=0
ans=[True]*n
wa=[0]*n
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=="AC" and ans[p]:
        ans[p]=False
        ac+=1
    elif s=="WA" and ans[p]:
        wa[p]+=1

cnt=0
for i in range(n):
    if not ans[i]:
        cnt+=wa[i]

print(ac,cnt)

Solution (Python):
n,m=map(int,input().split())
ac=0
ans=[True]*n
wa=[0]*n
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=="AC" and ans[p]:
        ans[p]=False
        ac+=1
    elif s=="WA" and ans[p]:
        wa[p]+=1

cnt=0
for i in range(n):
    if not ans[i]:
        cnt+=wa[i]

print(ac,cnt)

Solution (Python):
N,M = map(int,input().split())
PS = [list(map(str,input().split())) for i in range(M)]
A_num = [0]*N
W_num = [0]*N
w=0

for j in range(M):
    
    if PS[j][1] == 'WA'and A_num[int(PS[j][0])-1]==0:
        W_num[int(PS[j][0])-1]+=1 
    if PS[j][1]== 'AC' and A_num[int(PS[j][0])-1]==0:
        A_num[int(PS[j][0])-1]=1
s = sum(A_num)
for k in range(N):
    if A_num[k] == 0:
        W_num[k]=0
w = sum(W_num)
print(s,w)

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

aclist = [0] * n
walist = [0] * n

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

    if aclist[int(p)] == 1:
        continue
    if s == 'AC':
        aclist[int(p)] = 1
    if s == 'WA':
        walist[int(p)]+=1
print(sum(aclist), sum(j for idx, j in enumerate(walist) if aclist[idx] == 1))

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

wa=0
ac=0


from collections import defaultdict
acwa = defaultdict(lambda: [0,0]) 

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

    if s=="AC":
        if acwa[p][0]==0:
            ac+=1
            wa+=acwa[p][1]
            acwa[p][0]=1
    else:
        acwa[p][1]+=1

print(ac,wa)

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

Solution (Python):
n, m = map(int, input().split())
penalty_num = [0 for i in range(n)]
acc = 0
ac_flag = [False for i in range(n)]

for i in range(m):
    p, s = input().split()
    q_num = int(p) - 1
    
    if s == 'WA':
        if ac_flag[q_num]:
            continue
        else:
            penalty_num[q_num] += 1
    
    else:
        if ac_flag[q_num]:
            continue
        else:
            ac_flag[q_num] = True
            acc += 1
penalty = 0
for n, flag in zip(penalty_num, ac_flag):
    if flag:
        penalty += n
print('{} {}'.format(acc, penalty))

Solution (Python):
import collections
n, m = map(int, input().split())
wa = []
submission = set()
for i in range(m):   
    p, s = input().split()
    if p in submission:
        continue

    if s == "AC":
        submission.add(p)
    else:
        wa.append(p)
wa_count = collections.Counter(wa)
pena = 0
for j in submission:
    x = wa_count[j]
    pena += x

print(len(submission), pena)

Solution (Python):
n,m = map(int,input().split()) 
x=['0']*m 
y=['0']*m 
for i in range(m): 
    x[i],y[i] = map(str,input().split())

num = 0 
pena = 0

lis=[0]*n 
sw = [0]*n

for i in range(m): 
    if y[i] == 'WA':
        lis[int(x[i])-1] += 1
    else:
        if sw[int(x[i])-1] == 0:
            num += 1
            pena = pena + lis[int(x[i])-1]
            sw[int(x[i])-1] = 1

        else:
            pass
        
print(num,pena)

Solution (Python):

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

ac_flg = [0]*N
wa_flg = [0]*N
wa_count = 0
ac_count = 0

for i in range(M):
    p, s = input().split()
    if s == 'WA' and ac_flg[int(p)-1] == 0:
        wa_flg[int(p)-1] += 1

    if s == 'AC' and ac_flg[int(p)-1] == 0:
        ac_count += 1
        ac_flg[int(p)-1] =1
        wa_count += wa_flg[int(p)-1]

print(ac_count, wa_count)

Solution (Python):
n,m = map(int,input().split())
l = [[0,0] for i in range(n)]
for i in range(m):
  p,s = map(str,input().split())
  p = int(p)-1
  if l[p][1] == 0:
    if s == 'WA':
      l[p][0] += 1
    else:
      l[p][1] += 1
cor = 0
pen = 0
for k in l:
  if k[1] == 1:
    cor += 1
    pen += k[0]
print(cor,pen)

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

point = 0
answer_problems = set()
wrong_count = Counter()
for _ in range(M):
    p, s = input().split()
    
    if p in answer_problems:
        continue
    
    if s == 'AC':
        point += wrong_count[p]
        answer_problems.add(p)
    else:
        wrong_count[p] += 1

print(len(answer_problems), point)

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

point = 0
answer_problems = set()
wrong_count = Counter()
for _ in range(M):
    p, s = input().split()
    
    if p in answer_problems:
        continue
    
    if s == 'AC':
        point += wrong_count[p]
        answer_problems.add(p)
    else:
        wrong_count[p] += 1

print(len(answer_problems), point)

Solution (Python):
n, m = map(int, input().split())
p, s = [], []
pslist = []
for i in range(m):
  row = list(input().split( ))
  pslist.append(row)
aclist = [0] * n
walist = [0] * n
for j, k in pslist:
  j = int(j)
  if k == 'AC':
    if aclist[j - 1] == 0:
      aclist[j - 1] = 1
  if k == 'WA':
    if aclist[j - 1] == 0:
      walist[j - 1] += 1
wacountlist = [x * y for (x, y) in zip(aclist, walist)]
print(sum(aclist), sum(wacountlist))

Solution (Python):
import numpy as np
from collections import Counter
n, m = map(int, input().split())
mistake = [0] * (n + 1)
done = [False] * (n + 1)
for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'WA':
        if done[p] == False:
            mistake[p] += 1
    else:
        done[p] = True
counter = Counter(done)
print(counter[True], sum(np.multiply(mistake, done)))

Solution (Python):
stdin = open(0).read().split('\n')
N, M = map(int,stdin[0].split())
AC = 0
WA = 0
d = {}
for i in range(1,M+1):
    p, S = stdin[i].split()
    if p in d:
        if d[p]!=0:
            if S=='AC':
                AC += 1
                WA += d[p]
                d[p] = 0
            else:
                d[p] += 1
    else:
        if S=='AC':
            d[p] = 0
            AC += 1
        else:
            d[p] = 1
print(AC,WA)

Solution (Python):
from collections import Counter
N, M = map(int, input().split())
correct_cnt = 0
pena_cnt = 0
pena_counter = Counter()

is_AC = dict()
for i in range(N):
    is_AC[i] = False

for i in range(M):
    p, s = input().split()
    p = int(p) - 1
    if is_AC[p] == False:
        if s == "AC":
            is_AC[p] = True
            correct_cnt += 1
        else:
            pena_counter[p] += 1

for key, value in is_AC.items():
    if is_AC[key]:
        pena_cnt += pena_counter[key]
print(str(correct_cnt), str(pena_cnt))

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

flag = [0] * n
WA_count = [0] * n
total_WA = 0
for i in range(m):
    P, s = input().split()
    p = int(P) - 1
    if s == "WA" and flag[p] == 0:
        WA_count[p] += 1
    elif s == "AC" and flag[p] == 0:
        flag[p] = 1
        total_WA += WA_count[p]
print(sum(flag), total_WA)

Solution (Python):
result = [0]*2
N,M = map(int,input().split())
checker = [[0]*2 for i in range(N)]

for i in range(M):
    que, res = input().split()
    que = int(que)

    if res =="WA" and checker[que-1][0]== 0:
        checker[que-1][1] +=1
    
    if res =="AC" and checker[que-1][0]==0:
        checker[que-1][0] = 1
        result[1]+= checker[que-1][1]
        result[0] +=1
print(*result)

Solution (Python):
n, m = map(int, input().split())
if m == 0:
  print(0, 0)
else:
  wa_dic = {}
  ac_dic = {}
  for _ in range(m):
    p, s = input().split()
    if s == 'WA' and (p not in ac_dic):
      if p in wa_dic:
        wa_dic[p] += 1
      else:
        wa_dic[p] = 1
    elif s == 'AC' and (p not in ac_dic):
      ac_dic[p] = 1
  ac = 0
  for v in ac_dic.values():
    ac += v
  wa = 0
  for k, v in wa_dic.items():
    if k in ac_dic:
      wa += v
  print(ac, wa)

Solution (Python):

N,M = (int(x) for x in input().split(" "))
S = []


mondai_acwa ={i:list() for i in range(1,N+1) }
q_id =0
result =""
for i in range(M):
    q_id_str,result = (x for x in input().split())
    mondai_acwa[int(q_id_str)].append(result)


ac_sum=0
wa_sum=0

for i,v_wa in mondai_acwa.items():
    if 0 < len(v_wa):
        if "AC" in v_wa: 
            ac_i =v_wa.index("AC") 
            ac_sum +=1
            wa_sum += ac_i
print(ac_sum,wa_sum)

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

penalty = [0] * n
isAC = [False] * n

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == "WA":
        if not isAC[p]:
            penalty[p] += 1
    else:
        isAC[p] = True
for i in range(n):
    if not isAC[i]:
        penalty[i] = 0
print(sum(isAC), sum(penalty))

Solution (Python):
import sys

readline = sys.stdin.readline

def main():
    N, M = map(int, readline().split())
    aclist = [0] * N
    wrongcount = [0] * N
    for _ in range(M):
        p, S = readline().split()
        q = int(p)-1
        if aclist[q] == 0 and S == 'WA':
            wrongcount[q] += 1
        if S == 'AC':
            aclist[q] = 1

    pena = 0
    for i in range(N):
        if aclist[i] == 1:
            pena += wrongcount[i]
    ac = sum(aclist)

    print(ac, pena)


if __name__ == "__main__":
    main()