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

list = [True for i in range(n)]
cnt = [0 for i in range(n)]
for i in range(m):
	tmp, s = input().split()
	p = int(tmp)
	if s == "AC":
		list[p-1] = False
	elif s == "WA":
		if list[p-1]:
			cnt[p-1] += 1

for i in range(n):
	if list[i]:
		cnt[i] = 0

print(list.count(False), sum(cnt))

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

Solution (Python):
n, m = map(int, input().split(' '))
problem = [0] * n
ok=0
pen=0
i=0

while i < m:
    p, result = input().split(' ')
    p = int(p) - 1
    if problem[p] < 0:
        pass
    else:
        if result == 'WA':
            problem[p] += 1
        else:
            ok += 1
            pen += problem[p]
            problem[p] = -1
    i+=1
print('{} {}'.format(ok, pen))

Solution (Python):
def main():
    n,m=map(int,input().split())
    p =[[] for i in range(n)]
    for i in range(m):
        pp,ss=input().split()
        ppp=int(pp)
        p[ppp-1].append(ss)


    cntA = 0
    cntW = 0
    for i,a in enumerate(p):
        flg = 0
        cnt=0
        for j,s in enumerate(a):
            if  s == 'WA':
                cnt += 1
            elif s == 'AC':
                cntA += 1
                cntW+=cnt
                break
    print(str(cntA) + ' ' + str(cntW))
    
    
if __name__=='__main__':
    main()

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

acList = [False] * n
waList = [0] * n
waCount = 0
for i in range(m):
  p, s = map(str, input().split())
  p = int(p) - 1 
  if acList[p]:
    continue
  if s == 'WA':
    waList[p] += 1
    continue
  waCount += waList[p]
  acList[p] = True

print(sum(acList), waCount)

Solution (Python):
N, M = map(int, input().split())
penas = [0] * N
acs, pena = set(), 0
for _ in range(M):
    p, stat = input().split()
    p = int(p) - 1
    if stat == "AC" and p not in acs:
        acs.add(p)
        pena += penas[p]
    else:
        penas[p] += 1
print(len(acs), pena)

Solution (Python):
N,M = map(int,input().split())
pis=[]
wa,ac={},{}
for i in range(M):
    p  = input().split()
    pis += [(int(p[0]),p[1])]
for p in pis:
    wa[p[0]]=0
    ac[p[0]]=0
if __name__ == '__main__':
   for p in pis:
      if ac[p[0]]<1:
         if p[1]=='WA':
              wa[p[0]]+=1
         elif p[1]=='AC':
              ac[p[0]]=1
   for p in pis:
      if ac[p[0]]<1:
        wa[p[0]]=0
   a=sum(ac.values())
   w=sum(wa.values())
   print('{} {}'.format(a,w))

Solution (Python):
import sys

def input():
    return sys.stdin.readline()[:-1]

N,M = map(int,input().split(' '))
L = []
for i in range(M):
    L.append(list(map(str, input().split())))
VISITED = [0]*N
AC = 0
p = 0
for i in range(M):
    n,s = L[i]
    n = int(n) - 1
    if VISITED[n]==-1:
        continue
    if s=='AC':
        p += VISITED[n]
        VISITED[n] = -1
        AC += 1
    else:
        VISITED[n] += 1
print(AC,p)

Solution (Python):
n,m=[int(x) for x in input().split()]
right=[0]*(n+1)
wrong=[0]*(n+1)
d=dict()
pnt=0
crt=0
for i in range(0,m):
    a,v=[x for x in input().split()]
    a=int(a)
    if right[a]==0:
        if v=='AC':
            right[a]=1
            pnt+=wrong[a]
            crt+=1
        else:
            wrong[a]+=1

print(crt,pnt)

Solution (Python):

import numpy as np
import sys
sys.setrecursionlimit(100000)



def acinput():
    return list(map(int, input().split(" ")))


N,M=acinput()
d=[[]for i in range(N+1)]
for i in range(M):
    p, s = input().split(" ")
    p=int(p)
    d[p].append(s)



pen=0

nsolve=0
for sd in d:
    
    
    pem_tmp = 0
    for ssd in sd:
    
        if ssd=="AC":
            nsolve+=1
            pen+=pem_tmp
            break
        else:
            pem_tmp+=1

print(nsolve,pen)

Solution (Python):
N,M = map(int, input().split())
s,p = [False]*N, [0]*N
for i in range(M):
  tmp = input().split()
  pi,Si = int(tmp[0])-1, tmp[1]
  s[pi] |= Si == "AC"
  p[pi] += 1 if not s[pi] else 0
print(sum(s), sum([pi for si,pi in zip(s,p) if si]))

Solution (Python):
N, M = map(int, input().split())
ans = {}
ac = 0
wa = 0
flag = False
for i in range(M):
    p, s = input().split()
    if p not in ans:
        if s == "AC":
            ans[p] = []
            ans[p].append("AC")
        else:
            ans[p] = []
            ans[p].append("WA")
    else:
            if s == "WA":
                ans[p].append("WA")
            elif s == "AC":
                ans[p].append("AC")
for val in ans.values():
    count = 0
    for i in val:
        if flag != True:
            if i == "WA":
                count += 1
            if i == "AC":
                ac += 1
                wa += count
                flag = True
    flag = False
print(ac, wa)

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

fails = collections.defaultdict(int)
acstatus = collections.defaultdict(bool)

successct, failct = 0,0
for p, s in ps:
    if s == "AC":
        if not acstatus[p]:
            failct += fails[p]
            acstatus[p] = True
            successct += 1
    else:
        fails[p] += 1
print(successct, failct)

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

answers = [0] * (n + 1)
penalties = [0] * (n + 1)
ac = set()
for num, r in scores:
    n = int(num)
    if r == 'AC':
        answers[n] = 1
        ac.add(n)
    elif r == 'WA' and answers[n] == 0:
        penalties[n] += 1

ans = sum(answers)
p = 0
for a in ac:
    p += penalties[a]

print(ans, p)

Solution (Python):
n, m = map(int, input().split(" "))
nac = 0
npe = 0
cp = 0
is_ac = [False]*n
np_list = [0]*n
for i in range(m):
  p_s, s = input().split(" ")
  p = int(p_s)-1
  cis_ac = is_ac[p]
  
  if cis_ac:
    continue
  if s == "AC":
    nac += 1
    is_ac[p]=True
  else:
    np_list[p] += 1

for i, a in enumerate(is_ac):
  if a:
    npe += np_list[i]
print(str(nac)+" "+str(npe))

Solution (Python):
n, m = map(int, input().split(' '))
problem = [0] * n
ok=0
pen=0
i=0

while i < m:
    p, result = input().split(' ')
    p = int(p) - 1
    if problem[p] < 0:
        pass
    else:
        if result == 'WA':
            problem[p] += 1
        else:
            ok += 1
            pen += problem[p]
            problem[p] = -1
    i+=1
print('{} {}'.format(ok, pen))

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

Solution (Python):
n,m=map(int, input().split())
li_1=list(range(m))
li_2=list(range(m))
pr=list(range(n))
wr=list(range(n))
wa=0
ac=0
for i in range(n):
    pr[i]=0
    wr[i]=0
for i in range(m):
    li_1[i],li_2[i]=map(str, input().split())
    li_1[i]=int(li_1[i])

for i in range(m):
    if li_2[i]=='AC':
        a=li_1[i]-1
        if pr[a]==0:
            wa=wr[a]+wa
            pr[a]=1
            ac=ac+1
    else:
        a = li_1[i] - 1
        wr[a]=wr[a]+1
print(ac,wa)

Solution (Python):
N, M = map(int, input().split())
ac_count = 0
penalty_count = 0
all_number_list = dict()
ac_number_list = dict()
for i in range(M):
    temp_number, temp_result = map(str, input().split())
    if temp_number in all_number_list :
        if temp_number not in ac_number_list :
            temp_count = all_number_list[temp_number]
            if temp_result == 'AC' :
                ac_number_list[temp_number] = temp_count
            else :
                all_number_list[temp_number] = temp_count + 1
    else :
        if temp_result == 'AC' :
            all_number_list[temp_number] = 0
            ac_number_list[temp_number] = 0
        else :
            all_number_list[temp_number] = 1

ac_count = len(ac_number_list)
penalty_count = sum(ac_number_list.values())
print('{} {}'.format(ac_count, penalty_count))

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

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

result = set()
wr = {}
c_cnt = 0
w_cnt = 0
for i in range(m):
    p, s = input().split()
    if (p in result):
        continue

    if (s == 'AC'):
        result.add(p)
        w_cnt = wr.get(p, 0) + w_cnt
    else:
        wr[p] = wr.get(p, 0) + 1

print('{} {}'.format(len(result), w_cnt))

Solution (Python):
n, m = map(int, input().split())
ps = [[0, 0] for i in range(n)]  
wa_count = 0
ac_count = 0
for i in range(m):
    input_p, input_s = input().split()
    if ps[int(input_p)-1][0] <= 0:
        if input_s == 'AC':
            ps[int(input_p)-1][0] += 1
        else:
            ps[int(input_p)-1][1] += 1
for i in ps:
    if i[0] == 1:
        ac_count += 1
        wa_count += i[1]

print(ac_count, wa_count)

Solution (Python):
def solve(n, m, p_list, s_list):

    res_ac = 0
    res_wa = 0

    ac_dict = dict()
    wa_dict = dict()

    for i in range(m):
        p = p_list[i]
        s = s_list[i]

        if s == "AC":
            if p not in ac_dict.keys():
                ac_dict[p] = 1
                res_ac += 1
                if p in wa_dict.keys():
                    res_wa += wa_dict[p]
        else:
            if p not in wa_dict.keys():
                wa_dict[p] = 1
            else:
                wa_dict[p] += 1
    return str(res_ac) + " " + str(res_wa)


def main():
    n, m = map(int, input().split())
    p_list = [0] * m
    s_list = ["AC"] * m
    for i in range(m):
        p, s = input().split()
        p_list[i] = int(p)
        s_list[i] = s
    res = solve(n, m, p_list, s_list)
    print(res)


def test():
    assert solve(2, 5, [1, 1, 2, 2, 2], ["WA", "AC", "WA", "AC", "WA"]) == "2 2"
    assert solve(100000, 3, [7777, 7777, 7777], ["AC", "AC", "AC"]) == "1 0"
    assert solve(6, 0, [], []) == "0 0"


if __name__ == "__main__":
    test()
    main()

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

wa = [0 for _ in range(n)]
ac = set()

for i, j in ps:
    if j == "AC":
        ac.add(i)
    else:
        if i not in ac:
            wa[int(i) - 1] += 1

for k in range(n):
    if str(k + 1) not in ac:
        wa[k] = 0

print(len(ac), sum(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 = list(map(int, input().split()))
ac = {}
wa = {}
wrong = 0
for i in range(m):
  p,s  = list(map(str, input().split()))
  if s == "AC":
    if p not in ac:
      ac[p] = 1
      if p in wa:
        wrong += wa[p]
  elif s == "WA":
    if p not in ac:
      if p not in wa:
        wa[p] = 1
      else:
        wa[p] += 1
print("{} {}".format(len(ac),wrong))

Solution (Python):
n,m = map(int, input().split())
AC = 0
WA = 0
ACflag = [False for i in range(n)]
thisWA = [0 for i in range(n)]
for i in range(m):
    p,S = map(str, input().split())
    if ACflag[int(p)-1] == False:
        if S == 'AC':
            AC+=1
            ACflag[int(p)-1] = True
        if S == 'WA':
            thisWA[int(p)-1]+=1
            
for i in range(n):
    if ACflag[i] == True:
        WA+=thisWA[i]

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

Solution (Python):
N,M = map(int,input().split())
AC_flag = [False]*N
WA_count = [0]*N
for m in range(M):
    P,S = map(str,input().split())
    p = int(P)
    if AC_flag[p-1] == False and S == "AC":
        AC_flag[p-1] = True
    elif AC_flag[p-1] == False and S == "WA":
        WA_count[p-1] += 1

AC = 0
WA = 0
for n in range(N):
  if AC_flag[n] == True:
    AC += 1
    WA += WA_count[n]

print(*[AC,WA])

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

p_list=[0]*(n+1)
cnt=[0]*(n+1)
ans=0
plt=0
for i in range(m):
    p,s=map(str,input().split())
    if s == "WA":
        cnt[int(p)] += 1;
    if s == "AC":
        if p_list[int(p)] == 0:
                ans+=1
                plt+=cnt[int(p)]
                p_list[int(p)] += 1
        
print(str(ans) + " " + str(plt))

Solution (Python):
from operator import itemgetter


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

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

l = []
for i in range(m):
    p, s = map(str, input().split())
    l.append([int(p), s])
l.sort(key = itemgetter(0))

numAC = 0
numWA = 0
countWA = 0
AC = False
last = l[0][0]

for i in range(m):
    if last == l[i][0]:
        if AC:
            continue
        elif l[i][1] == "AC":
            numAC += 1
            numWA += countWA
            AC = True
        else:
            countWA += 1
    else:
        last = l[i][0]
        AC = False
        if l[i][1] == "AC":
            numAC += 1
            AC = True
        else:
            countWA = 1

print(numAC, numWA)

Solution (Python):
n, m = map(int, input().split())
tocni = [0 for i in range(n + 1)]
correct = wrong = 0
for i in range(m):
    p, s = map(str, input().split())
    p = int(p)
    if s == "AC" and tocni[p] != 1:
        correct += 1
        wrong -= tocni[p]
        tocni[p] = 1
    if s == "WA" and tocni[p] != 1:
        tocni[p] -= 1
print(correct, wrong)

Solution (Python):

from collections import defaultdict
n,m = map(int, input().split())
a = []
dic = defaultdict(list)
for _ in range(m):
  x,y = map(str, input().split())
  dic[int(x)].append(y)

acc=0
for j in dic.values():
  if 'AC' in j:
    acc+=1;


cnt=0
for li in dic.values():
  if 'AC' in li:
    for j in li:
      if j == 'AC':
        break
      cnt+=1

ans = str(acc) + ' ' + str(cnt)
print(ans)

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 = list(map(int, input().split(' ')))
r = [0] * N
pp = [0] * N

pena = 0
co = 0

for i in range(M):
  pi, Si = input().split(' ')
  p = int(pi)
  if r[p-1] == 0:
    if Si == 'WA':
      pp[p-1] += 1
    else:
      co += 1
      pena += pp[p-1]
      r[p-1] = 1

print (str(co) + ' ' + str(pena))

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from copy import deepcopy
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = float('INF')
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n, m = LI()
ac_set = set()
ac = 0
wa = 0
D = defaultdict(int)
for _ in range(m):
    p, s = LS()
    if s == 'AC':
        if p not in ac_set:
            ac_set.add(p)
            wa += D[p]
            ac += 1
    else:
        if p not in ac_set:
            D[p] += 1


print(ac, wa)

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

RES = []

for i in range(M):
    RES.append(list(input().split()))

WA = [0]*(M+N)
ACed = [0]*(N+M)
tmp_num = [0]*(M+N)
tmp = 0
for i in range(M):
    num = int(RES[i][0])
    if RES[i][1] == "WA" and not ACed[num]:
        tmp_num[num] += 1
    elif RES[i][1] == "WA" and ACed[num]:
        tmp += 1
    else:
        ACed[num] = 1
        WA[num] = tmp_num[num]

print(sum(ACed),end=" ")
print(sum(WA))

Solution (Python):
N,M = list(map(int,input().split()))
AC_list = [[0] * 2 for i in range(N)]
WA_count = 0
AC_count = 0
for i in range(M):
    A = list(input().split())
    if AC_list[int(A[0])-1][0] == 1:
        pass
    else:
        if A[1] == "AC":
            AC_list[int(A[0])-1][0] = 1
        else:
            AC_list[int(A[0])-1][1] += 1
for i in range(N):
    if AC_list[i][0] == 1:
        if 0 < AC_list[i][1]:
            WA_count += AC_list[i][1]
        AC_count += 1
print(AC_count,WA_count)

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

A = [0] * N
Pen = [0] * N

for i, j in zip(p, S):
    if A[i] == 0 and j == "AC":
        A[i] = 1
    elif A[i] == 0 and j == "WA":
        Pen[i] += 1
    elif A[i] == 1:
        continue

penalty = 0
for i in range(N):
    if A[i] == 1:
        penalty += Pen[i]
print(sum(A), penalty)

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

l = [list(input().split()) for _ in range(M)]

answers = {}
wrongs = {}

for a in l:
    if a[1] == "AC":
        answers[a[0]] = a[1]
    elif a[1] == "WA":
        
        if not a[0] in answers and not a[0] in wrongs:
            wrongs[a[0]] = 1
        elif not a[0] in answers and a[0] in wrongs:
            wrongs[a[0]] = wrongs[a[0]] + 1


wc = 0
for k, v in wrongs.items():
    if k in answers.keys():
        wc += v
result = [len(answers.keys()), wc]

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

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

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

pS = [list(input().split()) for _ in range(M)]
ACed = [0] * (N+1)
pena_memo = [0] * (N+1)
n_pena = [0] * (N+1)

for i in range(M):
    if ACed[int(pS[i][0])] == 0:
        if pS[i][1] == "AC":
            ACed[int(pS[i][0])] = 1
            n_pena[int(pS[i][0])] = pena_memo[int(pS[i][0])]
        else:
            pena_memo[int(pS[i][0])] += 1

print(sum(ACed), sum(n_pena))

Solution (Python):
from sys import stdin
def main(pS):
    ans = {}
    ac = 0
    wa = 0
    for i in pS:
        if i[0] not in ans.keys():
            ans[i[0]] = [0, 0] 
        if i[1] == "AC":
            if ans[i[0]][0] == 0:
                    ans[i[0]][0] += 1
                    ac += 1
                    wa += ans[i[0]][1]
        elif i[1] == "WA":
            if ans[i[0]][0] == 0:
                ans[i[0]][1] += 1
    return [ac, wa]

"""
for i in ans.values():
    ac += i[0]
    if i[0] >= 1:
        wa += i[1]
"""
if __name__ == "__main__":
    N, M = input().split()
    pS = [stdin.readline().rstrip().split() for _ in range(int(M))]
    ac, wa = main(pS)
    print(ac, wa)

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

n, m = map(int, input().split())
ac = {str(i): 0 for i in range(n+1)}
wa = {str(i): 0 for i in range(n+1)}
ok = 0
ng = 0

for _ in range(m):
    p, s = input().split()
    if ac[p] == 0:
        if s == "AC":
            ac[p] += 1
            ok += 1
            if wa[p] > 0:
                ng += wa[p]
        else:
            wa[p] += 1

print(ok, ng)

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(' '))
ans = {}

p = {} 
p_ = 0
for i in range(m):
  arr = list( input().split(' '))
  if not arr[0] in ans :
    if not arr[0] in p:
      p[arr[0]] = 0
    if arr[1] == 'WA':
      p[arr[0]] += 1
    if arr[1] == 'AC':
      ans[arr[0]] = 0
      p_ += p[arr[0]]
      p.pop(arr[0])
      
      
print(len(ans),p_)

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

aclist={}
wclist={}

p=0
ac=wa=0

for i in [input() for i in range(m)]:
    x,y=i.split()
    if not aclist.get(x):
        if y=='AC':
            aclist[x] = aclist.get(x,0) +1
            ac+=1
        elif y=='WA':
            wclist[x] = wclist.get(x,0) +1
            wa+=1
    
for k,v in wclist.items():
    if not aclist.get(k):
        wa-=v

print(ac,wa)

Solution (Python):
mondai, kaitou = map(int, input().split())


clearNo = [0] * (mondai+1)

wrong = [0] * (mondai+1)
cleard = 0
pena = 0

kaitous = [input().split() for _ in range(kaitou)]
for i in kaitous:
    qNo = int(i[0])
    result = i[1]
    if clearNo[qNo] == 1:
        continue
    else:
        if result == 'WA':
            wrong[qNo] += 1
        else:
            clearNo[qNo] = 1
            cleard += 1
            pena += wrong[qNo]

print(str(cleard) + ' ' + str(pena))

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


array_flag = [False] * N
array_cnt = [0] * N
for i in p:
    (pos, result) = i.split()
    pos = int(pos) - 1
    
    if result == 'AC':
        array_flag[pos] = True
    else:
        if array_flag[pos] == True:
            continue
        else:
            array_cnt[pos] += 1

answerd_cnt = 0
penalty_cnt = 0
for i in range(len(array_flag)):
    if array_flag[i] == True:
        answerd_cnt += 1
        penalty_cnt += array_cnt[i]

print(answerd_cnt, penalty_cnt)

Solution (Python):
n,m=map(int,input().split())
d={}
ans=0
pen=0

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

for i in d:
  if d[i][2]==0:
    pen+=d[i][1]
  ans+=d[i][0]    
print(ans,pen)

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


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

for _ in range(M):
    p,S=stdin.readline().split()

    if S=='AC':

        if AC[int(p)-1]==0:

            AC[int(p)-1]+=1
        else:

            pass
    elif S=='WA':

        if AC[int(p)-1]==0:

            WA[int(p)-1]+=1
        else:

            pass
for i in range(N):
    if AC[i]==0:
        WA[i]=0

print(sum(AC), sum(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 = [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())
a=0
b=0
if m==0:
    print(0,0)
    exit()
p = [[str(i) for i in input().split()] for _ in range(m)]

c = sorted(p,key=lambda x:x[0])

now = c[0][0]
d = 1
aa=0
bb=0
f = 0

for i in c:
    if i[0] == now:
        if i[1]=='AC':
            if d:
                a += 1
                f = 1
                d = 0
        else:
            if not f:
                bb+=1
    else:
        now = i[0]
        d = 1
        if f:
            b += bb
            f = 0
        bb = 0
        if i[1]=='AC':
            if d:
                a+=1
                f=1
                d = 0
        else:
            if not f:
                bb+=1
if f:
  b+=bb
print(a,b)

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

n, m = map(int, input().split())
p_s = [list(map(str, input().split())) for _ in range(m)]

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

for i in range(m):
    if p_s[i][1] == 'WA':
        if ac[int(p_s[i][0]) - 1] == 0:
            wa[int(p_s[i][0]) - 1] += 1
    else:
        ac[int(p_s[i][0]) - 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())
dw=dict()
da=dict()
for i in range(M):
    k,v=input().split()
    if k not in da.keys():
        if v=="WA":
            if k in dw.keys():
                dw[k]+=1
            else:
                dw[k]=1
        else:
            da[k]=1
for k in dw.keys():
    if k not in da.keys():
        dw[k]=0
print(sum(da.values()),sum(dw.values()))

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

ACSet = set([])
WAList = []
WAcnt = 0

for i in range(M):
    s = input().split()
    
    if len(ACSet) != N:
        if s[1] == 'AC':
            ACSet.add(s[0])
        
        elif s[1] == 'WA' and s[0] not in ACSet:
            WAList.append(s[0])


for i in range(len(WAList)):
    if WAList[i] in ACSet:
        WAcnt += 1

print("{} {}".format(len(ACSet), WAcnt))

Solution (Python):
def main():
  AC = 0
  WA = 0
  
  solving = {}
  solved = {}
  
  N,M = map(int, input().split())
  
  for i in range(M):
    p, s = input().split()
    if p in solved:
      continue
    elif s == 'WA':
      if p in solving:
        _wa = solving[p]
        solving[p] = _wa + 1
      else:
        solving[p] = 1
    else:
      AC += 1
      if p in solving:
      	WA += solving[p]
      solved[p] = True
  
  print(AC, WA)
  return 0
 
if __name__ == "__main__":
  main()

Solution (Python):
n,m=map(int,input().split())
TF=[0]*n
p=[0]*n
for _ in range(m):
    i,s =map(str,input().split())
    i=int(i)-1
    if (s=="WA") and (TF[i]==1):
        pass
    elif (s=="WA") and (TF[i]==0):
        p[i]+=1
    elif (s=="AC") and (TF[i]==0):
        TF[i]=1
    elif (s=="AC") and (TF[i]==1):
        pass
for i in range(n):
    if TF[i]==0:
        p[i]=0
ac=sum(TF)
pe=sum(p)
print(ac,pe)

Solution (Python):
N, M = map(int, input().split())
p = [0] * M
S = [''] * M
for i in range(M):
    p_i, S[i] = input().split()
    p[i] = int(p_i)




penal_ct = 0
ac_count = 0

ac_list = [False] * N
pos = 0

wa_count = [0] * N

for i in range(M):
    if S[i] == 'WA':
        wa_count[p[i] - 1] += 1
        
    elif (not ac_list[p[i] - 1]) and S[i] == 'AC': 
        ac_list[p[i] - 1] = True
        ac_count += 1
        if i == 0:
            continue
        penal_ct += wa_count[p[i] - 1]
        
        
        
    
        

print(ac_count, penal_ct)

Solution (Python):
N,M = map(int,input().split())
seito = 0
penarty = 0
pena = [False for i in range(N+1)]
pena2 = [0 for i in range(N+1)]
for i in range(M):
    p,s = input().split()
    p = int(p)
    if not pena[p]:
        if s == "AC":
            pena[p]=True
            seito += 1
        else:
            pena2[p] += 1

for i in range(N+1):
    if pena[i]:
        penarty += pena2[i]
print(seito,penarty)

Solution (Python):
from collections import defaultdict as dd

ac = dd(bool);pen,cor=0,0
wc = dd(int)
n,m = map(int,input().split())
for i in range(m):
	l = input().split()
	p = int(l[0]);ans=l[1]
	if ac[p]==False and ans=='WA':
		wc[p]+=1
	elif ac[p]==False and ans=='AC':
		pen+=wc[p]
		cor+=1
		ac[p]=True
		
print(cor,"",pen)

Solution (Python):
if __name__ == "__main__":
    N, M = [int(s) for s in input().split()]
    accepted = [False] * N
    penalties = [0] * N
    for _ in range(M):
        p, S = input().split()
        p = int(p)
        
        if S == "AC":
            accepted[p - 1] = True
        if S == "WA" and not accepted[p - 1]:
            penalties[p - 1] += 1

    N_accepted = len([a for a in accepted if a])
    sum_penalties = sum([p for p, a in zip(penalties, accepted) if a])
    print(N_accepted, sum_penalties)

Solution (Python):

import sys


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    wa_flag = [0] * N
    num_penalty = 0
    for i in range(M):
        if S[i] == "WA":
            if wa_flag[p[i]-1] != -1:
                wa_flag[p[i]-1] += 1
        else:
            if wa_flag[p[i]-1] != -1:
                num_penalty += wa_flag[p[i]-1]
                wa_flag[p[i]-1] = -1
    num_ac = wa_flag.count(-1)
    print(num_ac, num_penalty)

def main():
    N, M = map(int, input().split())
    p = [None] * M
    S = [None] * M
    for i in range(M):
        pi, si = input().split()
        p[i] = int(pi)
        S[i] = str(si)
    solve(N, M, p, S)

if __name__ == '__main__':
    main()

Solution (Python):
question_num, my_submit = list(map(int, input().split(' ')))
sub_list = [[]]*my_submit

for i in range(my_submit):
    sub_list[i] = input().split(' ')

question_results = ['hoge'] + [[False, 0, 0] for i in range(question_num)] 

for j in sub_list:
    if question_results[int(j[0])][0] == False:
        if j[1] == 'WA':
            question_results[int(j[0])][1] += 1
        elif j[1] == 'AC':
            question_results[int(j[0])][0] = True
            question_results[int(j[0])][2] += 1

ac = 0
wa = 0
for k in question_results:
    if k is not 'hoge':
        if k[0] == True:
            ac += 1
            wa += k[1]

print(ac, wa)