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())
P=[]
A=[]
for i in range(M):
    n,a=input().split()
    P.append(int(n))
    A.append(a)

D=['0']*N
Z=[0]*N
a=0
p=0
for i in range(M):
  if D[P[i]-1]!='AC'and A[i]=='WA':
    Z[P[i]-1]+=1
    D[P[i]-1]='WA'
  elif D[P[i]-1]!='AC' and A[i]=='AC':
    a+=1
    p+=Z[P[i]-1]
    D[P[i]-1]='AC'

print(a,p)

Solution (Python):
n,m=map(int,input().split())
accepted=[False for _ in range(n)]
submitted=[0 for _ in range(n)]
for _ in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=='AC':
        accepted[p]=True
    if not accepted[p]:
        submitted[p]+=1
print(sum(accepted),sum(submitted[p] for p in range(n) if accepted[p]))

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

ans = {}
if M > 0:
  for _ in range(M):
    key, value = input().split()
    if key not in ans:
      ans[key] = []
    ans[key].append(value)
else:
  print(0," ",0)
  exit()

ac = 0
wa = 0

for v in ans.values():
  if 'AC' in v: 
    for a in v:
      if a == 'WA':
        wa += 1
      else:
        ac += 1
        break
  else: 
    continue

print(ac, " ", wa)

Solution (Python):
n,m = map(int, input().split())
wa = 0
ac_list = {'AC':{}, 'WA':{}}
if m==0:
    print(0,0)
else:
    for i in range(m):
        p,s = input().split()
        ac_list[s][p] = ac_list[s].get(p, 0) + 1* int(not(p in ac_list['AC'].keys()))
    kyotu_key = list(set(ac_list['AC'].keys()) & set(ac_list['WA'].keys()))
    wa_list = [ac_list['WA'][p] for p in kyotu_key]
    print(len(ac_list['AC'].keys()), sum(wa_list))

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

ac_flag = [False]*n
wa_counts = [0]*n

for i in range(m):
  p,s = map(str,input().split())
  p = int(p)-1
  if s == 'AC':
    ac_flag[p] = True
  else:    
    if ac_flag[p] == False:
      wa_counts[p] += 1

wa_ans = 0
for i in range(n):
  if ac_flag[i]:
    wa_ans += wa_counts[i]
print('{} {}'.format(sum(ac_flag), wa_ans))

Solution (Python):
n, m = map(int, input().split())
ans_ac = 0
ans_wa = 0
lst = []
for i in range(n):
  lst.append([False, 0])
for i in range(m):
  p, s = input().split()
  p = int(p) - 1
  if lst[p][0]:
    continue
  if s == 'WA':
    lst[p][1] += 1
  else:
    ans_ac += 1
    ans_wa += lst[p][1]
    lst[p][0] = True
print(ans_ac, ans_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())
problems = [0 for _ in range(n)]
was = [0 for _ in range(n)]

for _ in range(m):
  num, ans = input().split()
  num = int(num) - 1
  if ans == 'AC':
    if problems[num] == 0:
      problems[num] = 1
  else:
    if problems[num] == 0:
      was[num] += 1
      
for i, problem in enumerate(problems):
  if problem == 0:
    was[i] = 0

print('{} {}'.format(sum(problems), sum(was)))

Solution (Python):
N,M=[int(_) for _ in input().split()]
PS=[input().split() for _ in range(M)]
count=[0]*(N+1)
isac=[0]*(N+1)
for p,s in PS:
 p=int(p)
 if isac[p]==1:
    continue
 if s=='AC':
  isac[p]=1
 else:
  count[p]+=1
wa=0
ac=0
for i in range(N+1):
 if isac[i]==1:
  ac+=1
  wa+=count[i]
print(ac,wa)

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

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()]
p = [0]*m
s = [False]*m
for i in range(0,m):
    p[i],s[i] = input().split()
    p[i] = int(p[i])
    s[i] = (s[i] == 'AC')
ac = [False]*(n+1)
numWA = [0]*(n+1)
numAC = 0
for i in range(0,m):
    if not(s[i]) and not(ac[p[i]]):
        numWA[p[i]] += 1
    elif s[i] and not(ac[p[i]]):
        numAC += 1
        ac[p[i]] = True
sumWA = 0
for i in range(1,n+1):
    if ac[i]:
        sumWA += numWA[i]

print(str(numAC) + ' ' + str(sumWA))

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

ac_list = [0]*(n+1)
wa_list = [0]*(n+1)
wa = 0
ac = 0
if m == 0:
    pass
else:
    for i in range(m):
        p, s = input().split()
        p = int(p)
        if ac_list[p] == 1:
            continue
        if ac_list[p] == 0 and s == 'AC':
            ac_list[p] = 1
        
        else:
            wa_list[p] += 1
    for t_ac, t_wa in zip(ac_list, wa_list):
        if t_ac == 1:
            wa += t_wa
            ac += t_ac
print(ac, wa)

Solution (Python):
N, M = map(int, input().split())
wacou = [0]*N
acchc = [0]*N
for i in range(M):
  p, s = input().split()
  p = int(p)
  if s=='WA' and acchc[p-1]<1:
    wacou[p-1] += 1
  elif s=='AC' and acchc[p-1]<1:
    acchc[p-1] = 1
  else:
    continue
print(acchc.count(1), sum([x*y for x, y in zip(acchc, wacou)]))

Solution (Python):
n, m = map(int, input().split())
ansFlag = [0 for i in range(n)]
waList = [0 for i in range(n)]
ac = 0
wa = 0
for i in range(m) :
  p, S = input().split()
  p = int(p)
  if str(S) == 'AC' and ansFlag[p-1] == 0 :
    ac += 1
    ansFlag[p-1] = 1
  elif ansFlag[p-1] == 0 :
    wa += 1
    waList[p-1] += 1
    
for i in range(len(ansFlag)) :
  if ansFlag[i] == 0 :
    wa -= waList[i]
print(str(ac) + ' ' + str(wa))

Solution (Python):

import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    
    dp = [[0, 0] for i in range(N+1)]
    for i in range(M):
        if S[i] == 'AC':
            dp[p[i]][0] = 1
            
        else:
            if dp[p[i]][0] == 0:
                dp[p[i]][1] += 1

    ac = len([dp[i][0] for i in range(1, N+1) if dp[i][0] > 0])
    wa = sum([dp[i][1] for i in range(1, N+1) if dp[i][0] > 0])
    
    
    print(ac, wa)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    p = [int()] * (M)  
    S = [str()] * (M)  
    for i in range(M):
        p[i] = int(next(tokens))
        S[i] = next(tokens)
    solve(N, M, p, S)

if __name__ == '__main__':
    main()

Solution (Python):
n,m=map(int,input().split())
p=[list(input().split())for _ in range(m)]
q=[0]*n
c=0
wc=0
for i in range(m):
  if p[i][1] == "WA":
    q[int(p[i][0])-1] += 1
  else:
    if q[int(p[i][0])-1] >= 0:
      c += 1
      wc += q[int(p[i][0])-1]
      q[int(p[i][0])-1] -= 10**6

print(c,wc)

Solution (Python):

class Question:
    def __init__(self, AC, WAcount):
        self.AC = AC
        self.WAcount = WAcount


def WelcomeTo():
    N, M = map(int, input().split())
    Qlist = []
    ACcount = 0
    WAcount = 0
    for _ in range(0, N + 1):
        Qlist.append(Question('False', 0))
    for _ in range(M):
        num, judge = input().split()
        num = int(num)
        if Qlist[num].AC == 'True':continue

        if judge == 'AC':
            ACcount += 1
            WAcount += Qlist[num].WAcount
            Qlist[num].AC = 'True'
        elif judge == 'WA':
            Qlist[num].WAcount += 1

    print('{} {}'.format(ACcount, WAcount))


WelcomeTo()

Solution (Python):
import numpy as np

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


A=[0 for _ in range(N)]
B=[0 for _ in range(N)]
C=[0 for _ in range(N)]

for i in range(M):
    p,S = input().split()
    p = int(p)-1
    if S == "AC":
        A[p] = 1
        C[p] = B[p]
    elif A[p]==0:
        B[p] += 1
    
A = np.array(A)
C = np.array(C)
print(np.sum(A), np.sum(C))

Solution (Python):
N,M = map(int,input().split())
q = ["WA" for i in range(N)]
wa_list = [0 for i in range(N)]
ac_list = [0 for i in range(N)]
wa = 0
ac = 0
for i in range(M):
    p,s = map(str,input().split())
    if s == "WA" and q[int(p)-1] == "WA":
        wa_list[int(p)-1]+=1
    elif s == "AC" and q[int(p)-1] == "WA":
        q[int(p)-1] = "AC"
        ac_list[int(p)-1] = wa_list[int(p)-1]
        
ac = q.count("AC")
wa = sum(ac_list)
print(ac,wa)

Solution (Python):
from operator import itemgetter
N,M = map(int,input().split())
p = [0] * M
S = [0] * M
BUF = [[0 for i in range(2)] for i in range(M)]

for i in range(M) :
    p[i],S[i] = map(str,input().split())
    p[i] = int(p[i])
    BUF[i][0] = p[i]
    BUF[i][1] = S[i]
BUF_new = sorted(BUF,key=itemgetter(0))


Flag = False
buf_goal = 0
buf_pena = 0
buf = -1
buf_2 = 0
buf_3 = -1

for i in range(M) : 
    if Flag == True :
        if BUF_new[i][0] == buf :
            
            BUF_new[i][1] = 'NULL'
        else :
            Flag = False
            buf = -1
    if Flag == False :
        if BUF_new[i][1] == 'AC' :
            Flag = True
            buf = BUF_new[i][0]

for i in range(M) :
    if BUF_new[i][1] == 'WA' :
        if buf_3 == BUF_new[i][0] :
            buf_2 += 1
        else :
            buf_2 = 0
            buf_2 += 1
        buf_3 = BUF_new[i][0]

    if BUF_new[i][1] == 'AC' :
        if buf_3 == BUF_new[i][0] :
            buf_pena += buf_2
            buf_goal += 1
            buf_2 = 0
            buf_3 = -1
        else :
            buf_goal += 1
            buf_2 = 0
            buf_3 = -1

print(buf_goal,buf_pena)

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

list_correct = [0] * n
list_pena = [0] * n
for i in range(m):
  if s[i] == "AC":
    if list_correct[p[i]-1] == 0:
      list_correct[p[i]-1] = 1
  else:
    if list_correct[p[i]-1] == 0:
      list_pena[p[i]-1] = list_pena[p[i]-1] + 1
      
sum_correct = sum(list_correct)
combined = [x * y for (x, y) in zip(list_correct, list_pena)]
sum_pena = sum(combined)

print (sum_correct, sum_pena)

Solution (Python):
mondaisu,kaitosu=map(int, input().split())
kuroji=[0]*mondaisu
akaji=[0]*mondaisu
for i in range(kaitosu):
    a,kekka = input().strip().split()
    a=int(a)
    if kuroji[a-1]==1:
        pass
    elif kuroji[a-1]==0:
        if kekka=="WA":
            akaji[a-1]+=1
        else:
            kuroji[a-1]=1
for i in range(mondaisu):
    if kuroji[i]==0:
        akaji[i]=0
kurojisum=sum(kuroji)
akajisum=sum(akaji)
print(kurojisum,akajisum)

Solution (Python):
N, M = map(int, input().split())
penalty = 0
answers = 0
mydict  = {}
for i in range(M):
    tmp1,tmp2 = input().split()
    if tmp1 in mydict.keys():
        if mydict[tmp1][0] == "WA" and tmp2 == "WA":
            mydict[tmp1][1] = mydict[tmp1][1] + 1
        elif mydict[tmp1][0] == "WA" and tmp2 == "AC":
            penalty = penalty + mydict[tmp1][1] 
            mydict[tmp1][0] = tmp2
            answers = answers + 1
        else:
            continue 
    else:
        mydict[tmp1] = [tmp2,0] 
        if tmp2 == "WA":
            mydict[tmp1][1] = mydict[tmp1][1] + 1
        else:
            answers = answers + 1
    
print(answers,end=" ")
print(penalty)

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

ac = 0
wa = 0

for m in range(M):
    p, S = input().split()
    if p not in dic and S == 'WA':
        dic[p] = {'AC' : 0, 'WA' : 1}
    elif p not in dic and S == 'AC':
        dic[p] = {'AC' : 1, 'WA' : 0}
    elif p in dic and dic[p]['AC'] == 1:
        continue
    elif p in dic and dic[p]['AC'] != 1:
        if S == 'AC':
            dic[p]['AC'] += 1
        else :
            dic[p]['WA'] += 1 

for i in dic:
    if dic[i]["AC"] != 0:
        ac += dic[i]["AC"]
        wa += dic[i]["WA"] 


print('{0} {1}'.format(ac, wa))

Solution (Python):
from collections import Counter

x = input().split()
n = int(x[0])
m = int(x[1])

d = {}

ac = 0
pe = 0

c = Counter()

for i in range(m):
    k = input().split()
    pi = int(k[0])
    s = k[1]
    if pi in d:
        continue
    if s == "AC":
        ac += 1
        d[pi] = True
        pe += c[pi]
    else:
        c[pi] += 1

print("{} {}".format(ac, pe))

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

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

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

print(ac,wa,sep=' ')

Solution (Python):
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, M = list(map(int, readline().split()))
pS = [readline().decode('utf-8').split() for _ in range(M)]
cnt_list = [0] * (N + 1)
ACed_list = [0] * (N + 1)

for p_, s in pS:
    p_ = int(p_)

    if s == 'AC':
        if ACed_list[p_] == 0:
            ACed_list[p_] = 1
    else:
        if ACed_list[p_] == 0:
            cnt_list[p_] += 1

for i in range(N + 1):
    if ACed_list[i] == 0:
        cnt_list[i] = 0

print(sum(ACed_list), sum(cnt_list))

Solution (Python):
pro_number, submit_number = [s for s in input().split()]
AC = [0] * int(pro_number)
WA = [0] * int(pro_number)
for i in range(int(submit_number)):
  section,output = [s for s in input().split()]
  if AC[int(section)-1]==0 and output=="WA":
    WA[int(section)-1]=WA[int(section)-1]+1
  
  elif output=="AC":
    AC[int(section)-1]=1

AC_number=0
WA_number=0
for i in range(int(pro_number)):
  if AC[i]==0:
    WA[i]=0
    
  AC_number=AC_number+AC[i]
  WA_number=WA_number+WA[i]

print(AC_number,WA_number)

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

wa = 0
ac = 0


from collections import defaultdict
dict = defaultdict(list)
for i in range(m):
    dict[p[i][0]].append(p[i][1])

for i in dict:
    if "AC" not in dict[i]:
        continue
    for j in range(len(dict[i])):
        result = dict[i][j]
        if result == "WA":
            wa += 1
        if result == "AC":
            ac += 1
            break

print(ac, wa)

Solution (Python):
from operator import itemgetter
N, M = map(int, input().split())
list = []

for k in range(M):
    p, S = map(str, input().split())
    p = int(p)
    if S == 'WA':
        S = 0
    else:
        S = 1
    list.append([k, p, S])

list.sort(key=itemgetter(1))


if M != 0:
    wacount = 0
    correct = 0
    
    if list[0][2] == 0:
        w_count = 1
        c_count = 0
        mark = 1
        ans=[0, 0]
    else:
        w_count = 0
        c_count = 1
        mark = 0
        ans = [1, 0]

    for i in range(1, M):
        if list[i][1] == list[i-1][1]:
            if mark == 1:
                if list[i][2] == 0:
                    w_count += 1
                else:
                    ans = [ans[0]+1, ans[1]+w_count]
                    mark *= 0

        else:
            if list[i][2] == 0:
                w_count = 1
                c_count = 0
                mark = 1
            else:
                w_count = 0
                c_count = 1
                mark = 0
                ans = [ans[0]+1, ans[1]]
else:
    ans = [0, 0]
print(ans[0], ans[1])

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

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

for i in range(M):
	p, S = input().split()
	p = int(p)
	if ac_chk[p] == 0:
		if S == "AC":
			ac_chk[p] = 1
			ac += 1
			wa += wa_chk[p]
			continue
		if S == "WA":
			wa_chk[p] += 1
			continue
	else:
		continue
print(ac, wa)

Solution (Python):

 
import math
import itertools
import sys
import copy
 





N, M = map(int, input().split())
L = []
for _ in range(M) :
  L.append(list(map(str, input().split())))


A = [[0 for _ in range(2)] for _ in range(N+1)]

for i in range(M) :
  if L[i][1] == "WA" and A[int(L[i][0])][1] != 1:
    A[int(L[i][0])][0] += 1
  else :
    A[int(L[i][0])][1] = 1


ACsum = 0
WAsum = 0
for j in range(N+1) :
  if A[j][1] == 1 :
    ACsum += 1
    WAsum += A[j][0]
  
print(str(ACsum) + " " + str(WAsum))

Solution (Python):
def sum(arg):
  ans = 0
  for i in arg:
    ans += i
  return ans

N, M = map(int, input().split())
ac = [0]*N
wa = [0]*N
pe = [0]*N
for i in range(M):
  pi, si = input().split()
  pi = int(pi)
  if si == "AC" and ac[pi-1] == 0:
    ac[pi-1] = 1
    pe[pi-1] = wa[pi-1]
  if si == "WA" and ac[pi-1] == 0:
    wa[pi-1] += 1
print(sum(ac), sum(pe))

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

temp = {}
acs = set()
for no, result in submits:
  if result == 'AC':
    temp[no] = temp.get(no, 0)
    acs.add(no)
  else:
    if no not in acs:
      temp[no] = temp.get(no, 0) + 1
      
print(len(acs), sum([temp[no] for no in acs]))

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

ans_list = [0]*(N+1)
pen_list = [0]*(N+1)

for i in range(M):
  p_i, S_i = input().split()
  p_i = int(p_i)
  
  if (ans_list[p_i] == 0):
    if(S_i == "WA"):
      a = pen_list[p_i]
      a += 1
      pen_list[p_i] = a
    elif(S_i == "AC"):
      ans_list[p_i] = 1

pen_lis_ans = list(itertools.compress(pen_list, ans_list))
cor_num = sum(ans_list)
pen_num = sum(pen_lis_ans)
                   
print("{} {}".format(cor_num,pen_num))

Solution (Python):
n, m = map(int, input().split())
p_list = []
s_list = []
ac_list = [0] * (n + 1)
ac, wa = 0, 0
if m == 0:
    print(0, 0)
else:
    for i in range(m):
        p, s = map(str, input().split())
        p = int(p)
        p_list.append(p)
        s_list.append(s)
        if s == "WA":
            if ac_list[p] == 0:
                wa += 1
            else:
                continue
        elif s == "AC":
            if ac_list[p] == 0:
                ac += 1
                ac_list[p] = 1
            else:
                continue
    for i in reversed(p_list):
        if ac_list[i] == 0:
            wa -= 1
    print(ac, wa)

Solution (Python):
n,m=map(int,input().split())
l=[list(input().split()) for i in range(m)]
from collections import defaultdict
cnt_ac=defaultdict(lambda:0)
cnt_wa=defaultdict(lambda:0)

count_wa=0
count_ac=0
for i in range(m):
    if cnt_ac[l[i][0]]==0:
        
        if l[i][1]=='WA':
            cnt_wa[l[i][0]]+=1
        
        elif l[i][1]=='AC':
            cnt_ac[l[i][0]]=1
            count_ac+=1
            count_wa+=cnt_wa[l[i][0]]
print(count_ac,count_wa)

Solution (Python):
n, m = list(map(int, input().split()))
d = dict()
score = 0
penalty = 0
pencount = dict()
for i in range(m):
	p, stat = input().split()
	p = int(p)
	
	
	if p not in d:
		d[p] = 0
		pencount[p] = 0
	if stat == "AC" and d[p] == 0:
		d[p] = 1
		score += 1
	elif stat == "WA" and d[p] != 1:
		d[p] = 0
		pencount[p] += 1
	elif d[p] == 1:
		pass
for problem in d.keys():
	if d[problem] == 1:
		penalty += pencount[problem]









print("{0} {1}".format(score, penalty))

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

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

for _ in range(m):
    p, s = input().split()
    p = int(p)-1
    if not d[p] and s == 'AC':
        ac += 1
        d[p] = True
    elif not d[p] and s == 'WA':
        wa[p] += 1
p = 0
for i in range(n):
    if d[i]:
        p += wa[i]
print(ac, p)

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


r = ['WA']*(N+1)
wa_li = [0]*(N+1)
o = []
c = 0
ac_c = 0

for ps in li:
    index = int(ps[0])
    if ps[1] == 'WA':
        if r[index] == 'WA':
            wa_li[index]+=1

    else: 
        if r[index] == 'WA':
            r[index] = 'AC'
            ac_c += 1
        else:
            pass

p_c =0
for i,v in enumerate(r):
    if v == 'AC':
        p_c+=wa_li[i]

print(ac_c, p_c)

Solution (Python):
N, M =[int(n) for n in input().split()]
p = {}
s = {}
for i in range(M):
    P, S = input().split()
    if S=='WA' and P not in p:
        c = s.setdefault(P, 0)
        c += 1
        s[P] = c
    else:
        if not p.setdefault(P, 0):
            p[P] = 1
for k in s:
    if k not in p:
        s[k] = 0 
print(sum(p.values()), sum(s.values()))

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

correct = [0] * n
penalty = [0] * n
for i in range(m):
    tgt = p[i] - 1
    if correct[tgt] == 1:
        continue
    if s[i] == 'AC':
        correct[tgt] += 1
    elif s[i] == 'WA':
        penalty[tgt] += 1

for i in range(m):
    tgt = p[i] - 1
    if correct[tgt] == 0:
        penalty[tgt] = 0

print('{0} {1}'.format(sum(correct), sum(penalty)))

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

solved = set()
correct = 0
penalty = 0
penalty_memo = [0] * (n+1)

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

    if p not in solved:
        if s == "WA":
            penalty_memo[p] += 1
        else:
            correct += 1
            penalty += penalty_memo[p]
            solved.add(p)

print(correct, penalty)

Solution (Python):
import sys
from collections import defaultdict
 
N,M = list(map(int, sys.stdin.readline().strip().split()))
counter = {"WA":0, "AC":0}
solv = defaultdict(list)
for i in range(M):
  p, s = sys.stdin.readline().strip().split()
  if len(solv[p])==0:
    solv[p].append(0)
    solv[p].append(0)
  if solv[p][1]==1: continue
  elif s=="WA":
    solv[p][0] += 1
  elif s=="AC" and solv[p][1]==0:
    solv[p][1] = 1
    counter["WA"] += solv[p][0]
    counter["AC"] += solv[p][1]

print(counter["AC"], counter["WA"])

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

N,M = map(int, readline().decode("utf-8").split())

aclist = [0 for _ in range(0, N+1)]
walist = [0 for _ in range(0, N+1)]

for _ in range(0, M):
    p,s = readline().decode('utf-8').split()
    p = int(p)

    if s == "AC":
        aclist[p] = 1
    if s == "WA" and aclist[p] == 0:
        walist[p] += 1

sum_wa = 0
for i,x in enumerate(walist):
    if aclist[i] == 1:
        sum_wa += x

print(sum(aclist), sum_wa)

Solution (Python):
n, m = map(int, input().split())
abc = {}
ac_cnt = 0
wa_cnt = 0
for i in range(m):
    p, s = map(str, input().split())
    abc.setdefault(p, []).append(s)
for key in abc.keys():
    if "AC" in abc[key]:
        idx = abc[key].index("AC")
        ac_cnt += 1
        wa_cnt += idx
    else:
        ac_cnt += 0
        wa_cnt += 0
print(ac_cnt, wa_cnt)

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

submit = []
results = [0] * n

for i in range(m):
  p, s = input().split()
  p = int(p)
  if type(results[p-1]) is int:
    results[p-1]=[s]
  else:
    results[p-1].append(s)

ok = 0
penalty = 0
for result in results:
  if type(result) == int:
    pass
  elif 'AC' in result: 
    for r in result:
      if r == 'AC':
        ok = ok + 1
        break
      else:
        penalty = penalty + 1
      
print(ok, penalty)

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

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

for i in range(m):
    pi,si = input().split( )
    if si == "AC":
        AC[int(pi)] = 1
    elif not AC[int(pi)]:
        WA[int(pi)] += 1
print(sum(AC),end = " ")

ANS = [AC[i]*WA[i] for i in range(n+1)]
print(sum(ANS))

Solution (Python):
N, M = [int(i) for i in input().split()]
corrects = [0 for _ in range(N)]
wrongs = [0 for _ in range(N)]
for m in range(M):
  p, s = input().split()
  p = int(p)
  if corrects[p-1] == 0:
    if s == "WA":
      wrongs[p-1] += 1
    elif s == "AC":
      corrects[p-1] = 1
      corrects.append(p)
  
total_wrongs = 0
total_correct = 0
for i in range(N):
  if corrects[i] > 0:
      total_wrongs += wrongs[i]
      total_correct += 1
  
print(total_correct, total_wrongs)

Solution (Python):
n,m = map(int,input().split())
tmp,p,s = [],[],[]

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

pas = [0] * n
pena = [0] * n

for i in range(m):
  if pas[p[i]] == 0:
    if s[i] == 'WA':
      pena[p[i]] += 1
    elif s[i] == 'AC':
      pas[p[i]] = 1


print('{} {}'.format(sum(pas),sum([pas[i]*pena[i] for i in range(n)])))

Solution (Python):
import sys

scan = sys.stdin.readline
n, m = map(int, scan().split(' '))
ans = [0] * n
ac = 0
for i in range(m):
    q, r = map(str, scan().strip('\n').split(' '))
    if r == 'AC':
        if ans[int(q) - 1] >= 0:
            ans[int(q) - 1] = -ans[int(q) - 1] - 1
            ac += 1
    else:
        if ans[int(q) - 1] >= 0:
            ans[int(q) - 1] += 1

wa = -sum(filter(lambda x: x < 0, ans)) - ac
print(ac, wa, sep=' ')

Solution (Python):
N, M = map(int, input().split(' '))
wa_count = [0] * N
ac = [False] * N
ac_count = 0

WA = 'WA'
AC = 'AC'
for i in range(M):
    
    
    
    
    

    _p, S = input().split(' ')
    p = int(_p) - 1

    if ac[p]:
        continue

    if S == WA:
        wa_count[p] += 1
    elif S == AC:
        ac[p] = True
        ac_count += 1

    
    

wa_total = 0
for i, c in enumerate(wa_count):
    if ac[i]:
        wa_total += c

print(ac_count, wa_total)

Solution (Python):



test = ""

"""
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
ans 2 2
"""

"""
100000 3
7777 WA
7777 WA
7777 WA
ans 0 0
"""

"""
6 0
ans 0 0
"""

"""
2 10
1 WA
1 AC
2 WA
2 AC
2 WA
1 WA
1 AC
2 WA
2 AC
2 WA
ans 2 2
"""

test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()


n, m = map(int, input2().split())
ps = [None] * m
for i in range(m):
    tmp = input2().split()
    ps[i] = int(tmp[0]), tmp[1]

aced = [0] * (n + 1)
wabfac = [0] * (n + 1)

for item in ps:
    if item[1] == "AC":
        aced[item[0]] = 1
    if item[1] == "WA":
        if aced[item[0]] == 0:
            wabfac[item[0]] += 1

penaans = 0
for j in range(1, n+1):
    if aced[j] == 1:
        penaans += wabfac[j]

print(aced.count(1), penaans)

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

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

ac_list = [0] * N
wa_list = [0] * N

for i in range(M):
  if list[i][1] == "AC":
    ac_list[int(list[i][0])-1] = 1
    
    
  else:
    
    
    if ac_list[int(list[i][0])-1] == 0:
      wa_list[int(list[i][0])-1] += 1

for i in range(N):
  if ac_list[i] == 0:
    wa_list[i] = 0

print(sum(ac_list), sum(wa_list))

Solution (Python):
class Question:
    def __init__(self, num, result):
        self.num = int(num)
        self.result = result


n, m = map(int, input().split())
p_list = [input().split() for _ in range(m)]
questions = [Question(num, result) for num, result in p_list]


ac_list = set()
wa_dict = {}
wa_count = 0

for q in questions:
    if not(q.num in ac_list):
        if q.result == 'AC':
            ac_list.add(q.num)
            wa_count += wa_dict[q.num] if q.num in wa_dict else 0
        elif q.num in wa_dict:
            wa_dict[q.num] += 1
        else:
            wa_dict[q.num] = 1
print('{} {}'.format(len(ac_list), wa_count))

Solution (Python):
n,m=map(int,input().split())
p=[]
s=[]
t=[]
crc=0
wrg=0
for i in range(m):
    li=input().split()
    p.append(int(li[0]))
    s.append(li[1])
    
for j in range(n):
    t.append(0)
for k in range(m):
    if s[k]=="AC":
        if t[p[k]-1]>=0:
            crc+=1
            wrg+=t[p[k]-1]
            t[p[k]-1]=-1
    else:
        if t[p[k]-1]>=0:
            t[p[k]-1]+=1
print(str(crc)+" "+str(wrg))

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

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

x = 0
for i in range(n):
    x += wa[i] * ac[i]
        
print ("%d %d" % (sum(ac),x))

Solution (Python):
n,m = map(int,input().split())
li=[]
ac_li=[0]*n
wa_li=[0]*n
ac = 0
wa = 0
for _ in range(m):
    a,b = input().split()
    li.append([int(a),b])

for i in li:
    if i[1] == "AC":
        if ac_li[i[0]-1] == 0:
            ac_li[i[0]-1] = 1
            ac +=1
    else:
        if ac_li[i[0]-1] == 0:
            wa_li[i[0]-1] += 1

for j in range(n):
    if ac_li[j]==1:
        wa += wa_li[j]
print(ac,wa)

Solution (Python):
N, M = map(int, input().split())
Alist = [[]]*M
for i in range(M):
  Alist[i] = list(map(str, input().split()))
collect = [False]*N
NP = 0
NAC = 0
results = [False]*N
for k in range(M):
  if Alist[k][1] == 'AC':
    results[int(Alist[k][0])-1] = True

for j in range(M):
  if Alist[j][1] == 'WA' and results[int(Alist[j][0])-1] == True and collect[int(Alist[j][0])-1] == False:
    NP += 1
  elif collect[int(Alist[j][0])-1] == False and Alist[j][1] == 'AC':
    NAC += 1
    collect[int(Alist[j][0])-1] = True
print(NAC, " ", NP)

Solution (Python):
nm = input().split()
wa = 0
ac = 0
db = [[0 for i in range(2)] for j in range(int(nm[0]))]

for i in range(int(nm[1])):
 tmp = input().split()
 if db[int(tmp[0])-1][1] == 0:
  if tmp[1] == "AC":
   db[int(tmp[0])-1][1]=1
   ac+=1
   wa+=db[int(tmp[0])-1][0]
  elif tmp[1] == "WA":
   db[int(tmp[0])-1][0]+=1
print(ac,wa)

Solution (Python):
n = input()
m = n.split()
P = [int(i) for i in m]
if P[1] == 0:
    for i in range(P[1]): 
        n = input()    
    print("0 0")
else:
    
    AC = [0] * P[0]
    WA = [0] * P[0]

    for i in range(P[1]): 
        n = input()    
        m = n.split()
        p = [i for i in m] 
        if p[1] == "AC":
            AC[int(p[0])-1] = 1
        else:
            if AC[int(p[0])-1] == 0:
                WA[int(p[0])-1] = WA[int(p[0])-1] +1
            else:
                pass
    A1 = 0
    A2 = 0
    for i in range(P[0]):
        if AC[i] == 1:
            A1 = A1+1
            A2 = A2 + WA[i]
    print(str(A1)+" "+str(A2))