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 math

N, M = map(int, input().split())
wa_list = [0] * N
ac_list = [False] * N
for i in range(M):
    p, s = map(str, input().split())
    p = int(p) - 1
    if s == 'AC':
        ac_list[p] = True
    else:
        if not ac_list[p]:
            wa_list[p] += 1
for i in range(N):
    if not (ac_list[i]):
        wa_list[i] = 0

print(sum(i == True for i in ac_list), sum(wa_list))

Solution (Python):
N,M = map(int,input().split(" "))
L = [0] * M
for i in range(M):
    L[i] = input().split(" ")
    
memoAC = [0] * N
memoWA = [0] * N
for list in L:
    if list[1] == "AC":
        memoAC[int(list[0])-1] = 1
    else:
        if memoAC[int(list[0])-1] != 1:
            memoWA[int(list[0])-1] += 1

for j in range(N):
    if memoAC[j] == 0:
        memoWA[j] = 0

AC = sum(memoAC)
WA = sum(memoWA)
print(AC,WA)

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

for i in range(M):
  p,s = map(str,input().split())
  p = int(p)-1
  if s == "AC" and AC_list[p] == 0:
    AC += 1
    AC_list[p] = 1
    penalty += WA_list[p]
  elif s == "WA":
    WA_list[p] += 1
  if AC == N:
    break
print(AC,penalty)

Solution (Python):
def get_ints():
    return map(int, input().split())

n, m = get_ints()
penalty = 0
oks = 0
ac = []
penalty = []
for i in range(n):
    ac.append(False)
    penalty.append(0)
for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    if ac[p]:
        continue
    if s == 'AC':
        ac[p] = True
        oks += 1
    else:
        penalty[p] += 1

ans = 0
for i in range(n):
    if ac[i]:
        ans += penalty[i]

print(str(oks) + ' ' + str(ans))

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

WA_counts = [0] * N
AC_list = [False] * N
for i in sys.stdin:
    p, S = i.split()
    p = int(p) - 1
    if S == 'WA' and not AC_list[p]:
        WA_counts[p] += 1
    elif S == 'AC':
        AC_list[p] = True
for i in range(len(AC_list)):
    if not AC_list[i]:
        WA_counts[i] = 0

print('{} {}'.format(sum(AC_list), sum(WA_counts)))

Solution (Python):
n,m = [int(x) for x in input().split()]
ans = [0]*(n+1)
w = [0]*(n+1)
for _ in range(m):
    a,b = input().split()
    a = int(a)
    if ans[a] == 1:
        continue
    if b == "AC":
        ans[a] = 1
    else:
        w[a] += 1

aa = 0
ww = 0
for i in range(1,n+1):
    if ans[i]==1:
        aa += 1
        ww += w[i]
print(aa,ww)

Solution (Python):
n,m = [int(x) for x in input().split()]
ans = [0]*(n+1)
w = [0]*(n+1)
for _ in range(m):
    a,b = input().split()
    a = int(a)
    if ans[a] == 1:
        continue
    if b == "AC":
        ans[a] = 1
    else:
        w[a] += 1

aa = 0
ww = 0
for i in range(1,n+1):
    if ans[i]==1:
        aa += 1
        ww += w[i]
print(aa,ww)

Solution (Python):
import sys

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

WA = [0] * N
isAC = [False] * N

for _ in range(M):
	p, S = input().split()
	if S == "AC":
		isAC[int(p) - 1] = True
	elif not isAC[int(p) - 1]:
		WA[int(p) - 1] += 1

ACsum, WAsum = 0, 0
for i in range(N):
	if isAC[i]:
		ACsum += 1
		WAsum += WA[i]

print(ACsum, WAsum)

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

ac = [0]*N
pena = [0]*N

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

    if ac[p] == 1:
        continue

    if s == "WA":
        pena[p] += 1
    if s == "AC":
        ac[p] = 1

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

print(AC, PENA)

Solution (Python):
N, M = map(int, input().split())
lst = []
ans_list = list([0, False] for i in range(N))
ans = [0, 0]

for i in range(M):
    tup = tuple(input().split())
    lst.append(tup)

for submit in lst:
    if ans_list[int(submit[0]) - 1][1] == True:
        continue
    else:
        if submit[1] == "AC":
            ans_list[int(submit[0]) - 1][1] = True
        if submit[1] == "WA":
            ans_list[int(submit[0]) - 1][0] += 1

for quest in ans_list:
    if quest[1] == True:
        ans[0] += quest[1]
        ans[1] += quest[0]

print(*ans)

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

AC = 0
WA = 0

for meta in info:
    if meta.count('AC') == 0:
        continue
    for s in meta:
        if s == 'AC':
            AC += 1
            break
        else:
            WA += 1
        

print(AC, WA)

Solution (Python):
N, M = map(int, input().split())
res = [[0 for i in range(2)] for j in range(N)]
ac = 0
wa = 0

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

for i in range(N):
  if res[i][0] == 1:
    wa += res[i][1]

print(ac, wa)

Solution (Python):
mondaisu, teishutsusu = map(int, input().split())
kekka =[input().split() for i in range(teishutsusu)]
l = [0] * mondaisu
p = [0] * mondaisu
for n, a in kekka:
  if a == 'AC':
    l[int(n) - 1] = 1
  else:
    if l[int(n) - 1] == 0:
      p[int(n) - 1] += 1
for i in range(len(p)):
  if l[i] == 0:
    p[i] = 0  
      
print(sum(l), sum(p))

Solution (Python):
input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]

N = Line[0]

M = Line[1]
 
AC_Lists = [""]*N

 
for i in range(M):
    input_line = input()
    Line = input_line.split()
    
    AC_Lists[int(Line[0])-1] += Line[1][0]
 
AC_count = 0
WA_count = 0
 
for s in AC_Lists:
    
    if 'A' in s:
        AC_count += 1
        my_str = s.split("A")
        
        
        WA_count += len(my_str[0])
    
    
    

 
print(AC_count,WA_count)

Solution (Python):
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd



import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    
    n, m = map(int, input().strip().split())
    n_AC = 0
    n_penalty = 0
    l_penalty = [0 for _ in range(n)]
    l_status = [-1 for _ in range(n)]

    
    for i in range(m):
        id, res = input().strip().split()
        id = int(id) - 1
        if res == "AC" and l_status[id] == -1:
            n_penalty += l_penalty[id]
            l_status[id] = 1
            n_AC += 1
        else:  
            l_penalty[id] += 1

    
    print(n_AC, n_penalty)


if __name__ == '__main__':
    main()

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

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

print(ac, wa)

Solution (Python):
x,y=list(map(int, input().split()))
z=[0]*x
for i in range(y):
	a,b=list(map(str, input().split()))
	a=int(a)
	if b=='AC' and z[a-1]<10**6:
		z[a-1]=z[a-1]+10**6
	if b=='WA' and z[a-1]<10**6:
		z[a-1]=z[a-1]+1
for i in range(x):
	if z[i]//(10**6)==0:
		z[i]=0
ansa=str(sum(z)//(10**6))
ansb=str(sum(z)%(10**6))
print(ansa+' '+ansb)

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

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

penalty=[0]*N
correct=[False]*N

for i in range(M):

    p,s = input().split()
    p = int(p)

    if s=="AC":
        correct[p-1]=True

    else:
        if correct[p-1]==False:
            penalty[p-1] += 1

for i in range(N):
    if correct[i]==False:
        penalty[i]=0

print(sum(i == True for i in correct),sum(penalty))

Solution (Python):


def solve():
    N, M = list(map(int, input().split()))

    ac_dic = {}
    wa_lst = [0 for _ in range(N+1)]
    ac_score, wa_score = 0, 0
    for i in range(M):
        p, s = input().split()
        p = int(p)

        if not p in ac_dic:
            if s == "WA":
                wa_lst[p] += 1
                ac_dic[p] = False
            else:
                ac_score += 1
                ac_dic[p] = True
        else:
            if s=="WA" and not ac_dic[p]:
                wa_lst[p] += 1
            elif s=="AC" and not ac_dic[p]:
                ac_score += 1
                ac_dic[p] = True

    
    for i, score in enumerate(wa_lst):
        if i in ac_dic and ac_dic[i]:
            wa_score += wa_lst[i]

    print(ac_score, wa_score)


if __name__ == "__main__":
    solve()

Solution (Python):
import sys
import numpy as np

i = list(map(int, input().split()))
N = i[0]
M = i[1]
ac = np.array([0]*N)
wa = np.array([0]*N)
for i in range(M):
    line = sys.stdin.readline().split()
    p = int(line[0])
    s = line[1]
    if ac[p - 1] == 0:
        if s == 'AC':
            ac[p - 1] = 1
        else:
            wa[p - 1] += 1
    

print(str(sum(ac)) + " " + str(sum(ac * wa)))

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

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

for p,s in S:
    if cntAC[int(p)-1] == 0:
        if s == "AC":
            cntAC[int(p)-1] = 1
        elif s == "WA":
            cntWA[int(p)-1] += 1

sumWA = sum([cntWA[p] for p in range(N) if cntAC[p]==1])

print(sum(cntAC),sumWA)

Solution (Python):
N,M=map(int,input().split())
AC=[False for i in range(0,N)]
WA=[0 for i in range(0,N)]
for i in range(0,M):
    p,S=map(str,input().split())
    p=int(p)
    if AC[p-1]:
        continue
    if S=="AC":
        AC[p-1]=True
    else:
        WA[p-1]+=1

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

Solution (Python):








def resolve():

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

    ac=[0]*N
    wa=[0]*N
    for i in range(M):
        if P[i]=='AC':
            ac[S[i]-1]=1
        else:
            if ac[S[i]-1]==0:
                wa[S[i]-1]+=1
            else:
                continue


    print(sum(ac),sum([wa[i] for i in range(N) if ac[i]==1]))






resolve()

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

AC = {}
WA = {}
PE = {}
for x in range(M):
    p, S = input().split()
    if S == "AC":
        AC[p] = {"AC"}
        if p in WA:
            PE[p] = WA[p]
    else:
        if p not in AC:
            if p not in WA:
                WA[p] = 1
            else:
                WA[p] += 1

print(len(AC), sum(PE.values()))

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

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

for i, s in ps:
    if ac[int(i)-1]==0:
        if s=='AC':ac[int(i)-1]=1
        elif s=='WA':wa[int(i)-1] += 1
answa = sum([wa[i] for i in range(N) if ac[i]==1])
print(sum(ac), answa)

Solution (Python):

import numpy as np
def main():
    
    n,m = map(int, input().split())
    
    pena_list = np.zeros(n)
    ac_list = np.zeros(n)

    for i in range(m):
        p,s = map(str, input().split())
        if s == 'WA':
            if ac_list[int(p)-1] == 0:
                pena_list[int(p)-1] += 1
        
        elif s == 'AC':
            ac_list[int(p)-1] = 1
    
    ans = 0
    for j in range(n):
        if ac_list[j] == 1:
            ans += pena_list[j]
    
    print(str(int(sum(ac_list))), str(int(ans)))



    


if __name__ == '__main__':
    main()

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

state = {}
wa_count = {}
wa = 0
ac = 0
for i in range(m):
  no, result = input().split()
  if result == 'AC':
    if not state.get(no):
      ac += 1
      wa += wa_count.get(no, 0)
    state[no] = True
  elif result == 'WA':
    if not state.get(no):
      if no in wa_count.keys():
        wa_count[no] += 1
      else:
        wa_count[no] = 1

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

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

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

cnt_ac=0
cnt_wa=0

for p,s in li:
  p=int(p)
  if s=="WA":
    wa[p]+=1
  elif s=="AC" and ac[p]==0:
    ac[p]+=1
    cnt_ac+=1
    cnt_wa+=wa[p]
  else:
    continue

print(cnt_ac,cnt_wa)

Solution (Python):






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



ans0,ans1 = 0,0
ac = [False] * n
mis = [0] * n
if m>0:
    for i in range(m):
        p,s = input().split()
        p = int(p)-1
        if not ac[p] and s == 'WA':
            mis[p] += 1
        elif ac[p] == False and s == 'AC':
            ans0 += 1
            ac[p] = True

for i in range(n):
    if not ac[i]:
        mis[i] = 0
print(ans0, sum(mis))

Solution (Python):
import numpy as np
from collections import Counter
import fractions
import math

def main():
  n, m = map(int, input().split())
  p_list, s_list = ["a"] * m, ["a"] * m
  for i in range(m):
    p_list[i], s_list[i] = map(str, input().split())
    p_list[i] = int(p_list[i])
  pena = 0
  mon_list, pena_list = [0] * n, [0] * n
  for i in range(m):
    if s_list[i] == "AC":
      mon_list[p_list[i] - 1] = 1
    if mon_list[p_list[i] - 1] == 0:
      if s_list[i] == "WA":
        pena_list[p_list[i] - 1] += 1
  for i in range(n):
    if mon_list[i] == 1:
      pena += pena_list[i]
  ac = mon_list.count(1)
  print(ac, pena)

main()

Solution (Python):

n, m = map(int, input().split())
penalty = 0
ac = [0] * n
wa = [0] * n
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == "AC":
        if ac[p] == 0:
            penalty += wa[p]
        ac[p] += 1
    else:
        wa[p] += 1
print(sum(x > 0 for x in ac), penalty)

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

Solution (Python):
n,m = map(int,input().split())
p = [0] * m
s = ["WA"] * m
result = [[] for _ in range(n)]
for i in range(m):
    p[i],s[i] = input().split()
    p[i] = int(p[i])
    result[p[i]-1].append(s[i])

def my_index(l,x,default=False):
    if x in l:
        return str(l.index(x))
    else:
        return default

ac = 0
penalty = 0
for j in range(len(result)):
    if my_index(result[j],"AC") != False:
        ac += 1
        penalty += int(my_index(result[j],"AC"))
print(ac,penalty)

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

judges = [str(arr[h][1]) for h in range(m)]
results = [False]*n
wa_cnt = [0]*n
total_wa = 0
for k in range(m):
    if results[q[k]-1] == False:
        if judges[k] == "AC":
            results[q[k]-1] = True
            total_wa += wa_cnt[q[k]-1]
        else:
            wa_cnt[q[k]-1] += 1
    else:
        continue
print("{} {}".format(results.count(True), total_wa))

Solution (Python):


def submit():
    n, m = map(int, input().split())
    wa_count = {i: 0 for i in range(1, n + 1)}
    ac_status = {i: False for i in range(1, n + 1)}
    
    penalty = 0
    for _ in range(m):
        p, s = input().split()
        p = int(p)

        if ac_status[p]:
            continue
        
        if s == "AC":
            ac_status[p] = True
            penalty += wa_count[p]
        else:
            wa_count[p] += 1

    print("{} {}".format(sum(ac_status.values()), penalty))


if __name__ == "__main__":
    submit()

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

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

result_ac, result_wa = 0, 0

for p, s in ps:
    p = int(p)
    if s=="WA":
        wa[p] += 1
    elif ac[p] == 0:
        ac[p] += 1
        result_ac += 1
        result_wa += wa[p]
    else:
        continue
print(result_ac, result_wa)

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

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

a=0
p=0
al=[0]*n
pl=[0]*n

for i in range (m):
  if al[int(l[i][0])-1]==0:
    if l[i][1]=='AC':
      a+=1
      al[int(l[i][0])-1]=1
    else:
      pl[int(l[i][0])-1]+=1
      
for k in range (n):
  if al[k]==1:
    p+=pl[k]
    
print (a,p)

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

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

wac = 0
acc = 0

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

Solution (Python):
from sys import stdin
import math

n, m = [int(x) for x in stdin.readline().rstrip().split()]

flag = [0] * n
mm = [0] * n
clear = 0
miss = 0
for i in range(m):
    p, s = stdin.readline().rstrip().split()
    if flag[int(p)-1] == 0:
        if s == "AC":
            clear += 1
            flag[int(p)-1] += 1
            miss += mm[int(p)-1]
        else:
            mm[int(p)-1] += 1

print(str(clear) + ' ' + str(miss))

Solution (Python):
import numpy as np
N,M=map(int,input().split())
wa=np.zeros(N+1)
ac=np.zeros(N+1)
for _ in range(M):
    p,S=input().split()
    if S=='AC' and ac[int(p)]==0:
        ac[int(p)]+=1
    elif S=='AC' and ac[int(p)]>0:
        pass
    elif ac[int(p)]==0:
        wa[int(p)]+=1
print(int(sum(ac)), int(np.dot(ac>0,wa)))

Solution (Python):
n,m=map(int,input().split())
lst=[list(input().split()) for _ in range(m)]
pena_lst=[0]*n
acn_lst=[0]*n

for p,s in lst:
    p=int(p)-1
    if acn_lst[p]==1:
        continue
    if s =="AC":
        acn_lst[p]=1
    else: pena_lst[p]+=1
pena=0
acn=0
for i in range(n):
    acn+=acn_lst[i]
    if acn_lst[i]==1:
        pena+=pena_lst[i]
print(acn,pena)

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M = map(int,input().split())
PS = (input().split() for _ in range(M))

ac = [False] * N
wa_cnt = [0] * N
penal = 0
for P,S in PS:
    p = int(P)-1
    if ac[p]:
        pass
    elif S == 'WA':
        wa_cnt[p] += 1
    else:
        ac[p] = True
        penal += wa_cnt[p]

ac = sum(ac)
print(ac, penal)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M = map(int,readline().split())
PS = (line.split() for line in readlines())

ac = [False] * N
wa_cnt = [0] * N
penal = 0
for P,S in PS:
    p = int(P)-1
    if ac[p]:
        pass
    elif S == b'WA':
        wa_cnt[p] += 1
    else:
        ac[p] = True
        penal += wa_cnt[p]

ac = sum(ac)
print(ac, penal)

Solution (Python):
def solve():
    N, M = map(int, input().split())
    isAC = [False] * N
    errCnt = [0] * N

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

        if S == 'WA':
            if not isAC[p]:
                errCnt[p] += 1
        
        if S == 'AC':
            isAC[p] = True
    
    n_penalty = 0
    for i in range(N):
        if isAC[i]:
            n_penalty += errCnt[i]

    print(sum(isAC), n_penalty)

if __name__ == '__main__':
    solve()

Solution (Python):
n, m = map(int, input().split())
answered = [0] * n
ans = 0
pena = 0
for _ in range(m):
    p, s = input().split()
    pidx = int(p) - 1
    if answered[pidx] == -1:
        continue
    if s == "AC":
        ans += 1
        pena += answered[pidx]
        answered[pidx] = -1
    else:
        answered[pidx] += 1
print("{} {}".format(ans, pena))

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

Solution (Python):
import math

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

AC_count = 0
WA_count =  0

check_list = [0 for i in range(N+1)]

for _ in range(M):
  i, res =  map(str,input().split())
  i = int(i)
  if check_list[i] == "AC":
    pass
  else:
    if res == "WA":
      check_list[i] += 1
    else:
      AC_count += 1
      WA_count += check_list[i]
      check_list[i] = "AC"
    
  
print(AC_count,WA_count)

Solution (Python):
N,M=[int(s) for s in input().split()]
WAls=[0 for _ in range(N)]
ACls=[0 for _ in range(N)]
wa=0
for i in range(M):
  a,b=input().split()
  a=int(a)-1
  if b=='AC':
    if ACls[a]==0:
      wa+=WAls[a]
      ACls[a]=1
  else:
    if ACls[a]==0:
      WAls[a]+=1
ans=[sum(ACls),wa]
print(*ans)

Solution (Python):
n,m = map(int,input().split())
ll = [list(input().split()) for _ in [0]*m]
ac = set()
pena = 0
d = dict(zip(map(str,range(1,n+1)),[0]*n))
for l in ll:
  if l[0] not in ac:
    if l[1] == 'AC':
      ac.add(l[0])
      pena += d[l[0]]
    else:
      d[l[0]]+=1
print(' '.join(map(str,[len(ac),pena])))

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

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

ANS = 0
PEN = 0
for i in range(N):
	ANS += ans[i]
	PEN += ans[i] * pen[i]

print(ANS, PEN)

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

ac, wa = 0, 0
ac_wa_table = [[0, 0] for _ in range(n)]
for p, s in x:
    index = int(p) -1
    if ac_wa_table[index][0] != 0:
        continue
    if s == 'AC':
        ac_wa_table[index][0] +=1
        ac += 1
        wa += ac_wa_table[index][1]
    elif s == 'WA':
        ac_wa_table[index][1] +=1
print(ac, wa)

Solution (Python):
N, M = map(int, input().split())
question = {}
wa = {}
ac_count = 0
wa_count = 0
for i in range(M):
    q, s = input().split()
    question.setdefault(q, '')
    wa.setdefault(q, 0)
    if s == 'AC':
        if question[q] == 'AC':
            continue
        else:
            question[q] = 'AC'
            ac_count += 1
            wa_count += wa[q]
    else:
        wa[q] += 1
print(ac_count, wa_count)

Solution (Python):
import sys
import fractions
from functools import reduce
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

n, m = na()
flgs = [False for i in range(n)]
tmp = [0 for i in range(n)]
for i in range(m):
    p, s = stdin.readline().split()
    p = int(p)
    if flgs[p-1] is False:
        if s == 'WA':
            tmp[p-1] += 1
        else:
            flgs[p-1] = 1
wa = 0
ac = 0
for i in range(n):
    if flgs[i]:
        ac += 1
        wa += tmp[i]
print(ac, wa)

Solution (Python):
def solve():
    n, m = list(map(int, input().split()))
    
    ac_list = [0 for i in range(n + 1)]
    wa_before_ac_list = [0 for i in range(n + 1)]
    
    for _ in range(m):
        p, s = input().split()
        p = int(p)
        
        if s == "AC":
            ac_list[p] = 1
        elif s == "WA" and ac_list[p] == 0:
            wa_before_ac_list[p] += 1

    wa_before_ac_num = 0
    for i in range(n+1):
        if ac_list[i] == 1:
            wa_before_ac_num += wa_before_ac_list[i]
    
    
    print("{} {}".format(sum(ac_list), wa_before_ac_num))
if __name__ == "__main__":
    solve()

Solution (Python):
import sys
N, M = map(int, input().split())
PS = sys.stdin.read().strip().split()
ac, wa = [0] * N, [0] * N
for p, s in zip(*[iter(PS)] * 2):
  p = int(p) - 1
  if s == "AC":
    ac[p] = 1
  elif ac[p] == 0:
    wa[p] += 1
penalties = sum(w if a > 0 else 0 for a, w in zip(ac, wa))
print(sum(ac), penalties)

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

def main():
    n,m=map(int,input().split())
    w=[0]*(n+1)
    a=[0]*(n+1)
    for i in range(m):
        p,s=map(str,input().split())
        p=int(p)
        if a[p]==0:
            if s=='WA':
                w[p]+=1
            else:
                a[p]=1
    wa=0
    for i in range(1,n+1):
        wa=wa+a[i]*w[i]
    print(sum(a),wa)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

N, M = i_l()
ac = 0
wa = 0
arr = []
h = {}
for _ in range(M):
    p, s = input().split()
    arr.append([int(p), s])
    if h.get(int(p)) is None:
        h[int(p)] = [s] 
    else:
        h[int(p)].append(s)
        
        
for k in h.keys():
    if all(x == 'WA' for x in h[k]):
        continue
    for v in h[k]:
        if v == 'AC':
            ac += 1
            break
        else:
            wa += 1

print(ac, wa)

Solution (Python):
def main():
    n, m = map(int, input().split())
    if m == 0:
        print(0, 0)
        return
    ps_list = [list(input().split()) for _ in range(m)]
    ps_list.sort(key=lambda x: x[0])
    now_p = ps_list[0][0]
    not_now_ac_flag = True
    ac_ans = 0
    now_wa = 0
    wa_ans = 0
    for p, s in ps_list:
        if p != now_p:
            now_p = p
            if not not_now_ac_flag:
                wa_ans += now_wa
            not_now_ac_flag = True
            now_wa = 0
        if s == "AC" and not_now_ac_flag:
            ac_ans += 1
            not_now_ac_flag = False
        if s == "WA" and not_now_ac_flag:
            now_wa += 1
    if not not_now_ac_flag:
        wa_ans += now_wa
    print(ac_ans, wa_ans)
main()

Solution (Python):
n,m = map(int,input().split())
ans = 0;pel = 0
ansArray = [0] * n
waArray = [0] * n
for i in range(m):
	a,b = map(str,input().split())
	a = int(a)
	if ansArray[a-1] == 0:
		if b == "AC":
			ans += 1
			pel += waArray[a-1]
			ansArray[a-1] = 1
		else:
			waArray[a-1] += 1
print(' '.join(map(str,[ans,pel])))

Solution (Python):
import math
N, M = map(int, input().split())
judge = [0]*N
ac = 0
wa = 0
for i in range(M):
  p, S = input().split()
  if judge[int(p)-1] == 'AC':
    pass
  elif S == 'AC':
    wa += judge[int(p)-1]
    judge[int(p)-1] = 'AC'
    ac += 1
  else:
    judge[int(p)-1] += 1
print(ac,wa)

Solution (Python):
n,m=map(int,input().split())
 
WA=[0]*n
AC=[0]*n
 
for i in range(m):
    problem,status=input().split()
    problem=int(problem)
 
    if status=='WA':
        if AC[problem-1]==1:
            continue
        else:
            WA[problem-1]+=1
    elif status=='AC':
        AC[problem-1]=1

for i in range(n):
    if AC[i]==0:
        WA[i]=0
print(sum(AC),sum(WA))

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

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

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

lisa = [0] * n
lisw = [0] * n
for i in range(m):
     if lisa[int(p[i])-1] == 0:
          if s[i] == 'WA':
               lisw[int(p[i]) - 1] += 1
          else:
               lisa[int(p[i])-1] = 1
num = 0
for i in range(n):
     if lisa[i] == 1:
          num += lisw[i]



print(sum(lisa),num)

Solution (Python):
from collections import defaultdict

def solve():
    N, M = map(int, input().split())
    d = defaultdict(int)
    e = set()
    for _ in range(M):
        a, b = input().split()
        a = int(a)
        if b == 'AC':
            e.add(a)
        if b == 'WA' and a not in e:
            d[a] += 1
    s = 0
    for a in e:
        s += d[a]
    ans = [len(e), s]
    print(*ans)




solve()

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

wa = [0] * N
pnt = [0] * N
ac = [False] * N

for _ in range(M):
    p, s = list(map(str, input().split()))
    if s == 'WA':
      wa[int(p) - 1] += 1
    elif s == 'AC' and not (ac[int(p) - 1]):
      ac[int(p) - 1] = not (ac[int(p) - 1])
      pnt[int(p) - 1] += wa[int(p) - 1]

print(ac.count(True), sum(pnt))

Solution (Python):

if __name__ == '__main__':

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

	A = [[0] * 3 for i in range(n)]

	for _ in range(m):
		x,y = input().split()
		x = int(x)
		A[x-1][0] = x
		if y == "AC":
			A[x-1][1] = 1
		else:
			
			if A[x-1][1] == 0:
				
				A[x-1][2] += 1

	ac = 0
	wa = 0

	for i in range(n):
		ac += A[i][1]
		if A[i][1] != 0:
			wa += A[i][2]

	print(ac,wa)