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
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def my_round(a,dig=0):
    p = 10 ** dig
    return (a * p * 2 + 1) // 2 / p

def gcd(a,b): 
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): 
    return a/gcd(a,b)*b

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

def is_prime(a): 
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): 
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): 
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    n,m = map(int,input().split())
    p = []
    s = []
    for i in range(m):
        a,b = input().split()
        p.append(int(a) - 1)
        s.append(b)
    ac = [[0,False] for i in range(n)]
    for i in range(m):
        if ac[p[i]][1]:
            continue
        else:
            if s[i] == 'WA':
                ac[p[i]][0] += 1
            else:
                ac[p[i]][1] = True
    ans = 0
    pena = 0
    for i in range(n):
        if ac[i][1]:
            ans += 1
            pena += ac[i][0]
    print(ans,pena)
    return

if __name__=='__main__':
    main()

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

for i in range(m):
    k[s[i][0]].append(s[i][1])

pena =0
ac =0

for i in k.keys():
    if "AC" not in k[str(i)]:
       continue
    else:
        for j in k[str(i)]:
            if j== "AC":
                ac+= 1
                break
            else: 
                pena+=1

print(ac,pena)

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

Solution (Python):
N, M=list(map(int, input().split()))
problem = []
result  = []
for _ in range(M):
    str_list = input().split(' ')
    problem.append(int(str_list[0]))
    result.append(str_list[1])



first_AC = [0 for i in range(N)]
pena     = [0 for i in range(N)]
for (p, r) in zip(problem, result):
    if first_AC[p-1]==0:
        if r=='WA':
            pena[p-1] += 1
        elif r=='AC':
            first_AC[p-1]=1
collect    = sum(first_AC)
temp       = [x * y for (x, y) in zip(first_AC, pena)]
total_pena = sum(temp)

print(str(collect)+' ', end='')
print(total_pena)

Solution (Python):
def main():
    n, m = list(map(int, input().split()))
    p = []
    s = []
    for i in range(m):
        a, b = input().split()
        p.append(int(a))
        s.append(b)
    buff = {}
    memo = set()
    wans = 0
    for i in range(m):
        
        if p[i] in memo:
            continue
        else:
            if s[i] == "AC":
                if p[i] in buff:
                    wans += buff[p[i]]
                memo.add(p[i])
            else:
                if p[i] in buff:
                    buff[p[i]] = buff[p[i]] + 1
                else:
                    buff[p[i]] = 1
    print(len(memo), wans)
if __name__ == "__main__":
    main()

Solution (Python):
N, M = map(int, input().split())
P, S = list(), list()
for _ in range(M):
    p, s = input().split()
    P.append(int(p))
    S.append(s)

AC_flags = [[0, 0] for _ in range(N)]

for p, s in zip(P, S):
    if AC_flags[p - 1][0] == 0 and s == "WA":
        AC_flags[p - 1][1] += 1
    elif AC_flags[p - 1][0] == 0 and s == "AC":
        AC_flags[p - 1][0] += 1

sum_ac, sum_wa = 0, 0
for ac, wa in AC_flags:
    if ac == 1:
        sum_ac += ac
        sum_wa += wa
    else:
        pass

print(sum_ac, sum_wa)

Solution (Python):
import numpy as np

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

ac = np.zeros(N, dtype = np.int64)
wa = np.zeros(N, dtype = np.int64)

for i in range(M):
    P, S = input().split()
    P = int(P) -1
    if S == "AC":
        ac[P] = 1
    if S == "WA":
        if ac[P] == 1:
            pass
        else:
            wa[P] += 1

for i in range(N):
    if ac[i] == 0:
        wa[i] = 0

print(int(np.sum(ac)), int(np.sum(wa)))

Solution (Python):
import sys
import math
import functools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, m = na()
p = [0] * (n+1)
c = 0
penalty = [0] * (n+1)
ans2 = 0
for _ in range(m):
    ps = stdin.readline().rstrip().split(" ")
    pi, si = int(ps[0]), ps[1]
    if p[pi]==0:
        if si == "AC":
            p[pi] = 1
            ans2 += penalty[pi]
        else:
            penalty[pi]+=1
print(sum(p), ans2)

Solution (Python):
N, M = map(int, input().split())
l = []
for i in range(M):
  l.append(list(map(str, input().split())))
for i in range(M):
  l[i][0] = int(l[i][0])
check_l = [0] * N
temp_penalty = [0] * N

penalty = 0
ans_count = 0

for i in range(M):
  if check_l[l[i][0]-1] == 0:
    if l[i][1] == 'AC':
      check_l[l[i][0]-1] = 1
      ans_count += 1
      penalty += temp_penalty[l[i][0]-1]
    else:
      temp_penalty[l[i][0]-1] += 1

print(ans_count, penalty)

Solution (Python):
N,M = map(int,input().split())
AC = {}
WA = {}
for i in range(M):
    prb ,ans = input().split()
    if ans == "AC":
        AC[prb] = 1
    else:
        if (prb in WA) == False and (prb in AC) ==  False:
            WA[prb] = 1
        else:
            if (prb in AC) ==  False:
                WA[prb] +=1
wa = 0
for i,v in WA.items():
    if (i in AC):
        wa += v
print("{} {}".format(len(AC),wa))

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

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

for i in range(M):
    num = int(List[i][0])-1
    result = List[i][1]
    if ac[num] == 0:
        if result == 'AC':
            ac[num] = 1
        else:
            wa[num] += 1

total_ac = 0
total_wa = 0

for i in range(N):
    if ac[i] == 1:
        total_ac += ac[i]
        total_wa += wa[i]
    
print(total_ac, total_wa)

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

ans_list = [["WA", 0] for i in range(N)]

AC_count = 0
for i in range(M):
    p, S = map(str, input().split())
    p = int(p)
    if S == "WA":
        if ans_list[p-1][0] == 'WA':
            ans_list[p-1][1] += 1
        else:
            pass
    else:
        if ans_list[p-1][0] == 'WA':
            ans_list[p-1][0] = 'AC'
            AC_count += 1
        else:
            pass

WA_count = 0
for i in range(N):
    if ans_list[i][0] == 'AC':
        WA_count += ans_list[i][1]

print(AC_count, WA_count)

Solution (Python):

"""
Created on Sun Jan 12 21:16:15 2020

@author: masat
"""

N, M = map(int, input().split())
p_list = []
s_list = []
for i in range(M):
    p, s = input().split()
    p_list.append(int(p))
    if s == "AC":
        s_list.append(True)
    else:
        s_list.append(False)


bucket_list = []
for i in range(N):
    bucket_list.append([])

"""
p_listのi番目の問題番号を取り出し、
bucket_listの対応する番号（問題番号-1）のリストに
s_listのi番目の結果をappendする。
"""
for i in range(M):
    bucket_list[p_list[i]-1].append(s_list[i])

"""
"""
accepted_answer = 0
penalty = 0

for i in range(N):
    penalty_candidate = 0
    for k in bucket_list[i]:
        if k:
            accepted_answer += 1
            penalty += penalty_candidate
            break
        else:
            penalty_candidate += 1

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

Solution (Python):
n, m = map(int, input().split())
sub_ls = []
for i in range(m):
    p, s = list(map(str, input().split()))
    p = int(p)-1
    sub_ls.append([p,s])
ac_cnt = []
wa_cnt = []
for i in range(n):
    ac_cnt.append(0)
    wa_cnt.append(0)

for i in range(m):
    if ac_cnt[sub_ls[i][0]] == 0:
        
        if sub_ls[i][1] == "AC":
            ac_cnt[sub_ls[i][0]] = 1
        else:
            wa_cnt[sub_ls[i][0]]+=1
ac_sum = 0
wa_sum = 0
for i in range(n):
    
    ac_sum+=ac_cnt[i]
    if ac_cnt[i] == 1:
        wa_sum+=wa_cnt[i]
print(ac_sum, wa_sum)

Solution (Python):
n,m= map(int, input().split()) 
judge=[0]*n
cor=0
pen=0
inf=10**6

for i in range(m):
  a,s = input().split()
  a=int(a)
  if s=='WA':
    judge[a-1]+=1
    
  else:
    if judge[a-1]>-1:
      cor+=1
      pen+=judge[a-1]
      judge[a-1]=-inf

print(cor,pen)

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

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

for i in range(m):
  p_number, p_status = input().split()
  p_number =int(p_number)
  if (p_status =='WA') & (AC[p_number]==0):
    WA[p_number]+=1
  if (p_status =='AC') & (AC[p_number]==0):
    AC[p_number] +=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())

from collections import defaultdict
d = defaultdict(list)
ab = [tuple(input().split()) for i in range(m)]

nAC = 0
nWA = 0


for a,b in ab:
    a = int(a)


    if len(d[a]) == 0:
        flag = 0
        num = 0
        d[a].append((flag, num))
    else:
        flag, num = d[a]


    if flag == 1:
        continue

    if flag == 0 and b == 'AC':
        flag = 1

    if flag == 0 and b == 'WA':
        num += 1

    d[a] = (flag, num)


for flag, num in d.values():
    if flag == 1:
        nAC += 1
        nWA += num

print(nAC, nWA)

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

submit = []
for i in range(m):
    temp = [x for x in input().split()]
    submit.append(temp)

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

for i in range(m):
    result = submit[i][1]
    question = int(submit[i][0])

    if result == 'AC' and ac[question] == 0:
        ac[question] = 1
    elif result == 'WA' and ac[question] == 0:
        wa[question] += 1

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

print(sum(ac), sum(wa))

Solution (Python):
n,m = map(int,input().split())
lis = []
clis = set()
for _ in range(m):
    x, y = input().split()
    x = int(x)
    if y == "AC":
        clis.add(x)
    elif x in clis:
        continue
    else:
        lis.append(x)
count = 0
for i in lis:
    if i in clis:
        count += 1
print(len(clis), count)

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

a.sort()
ac = 0
wa = 0
tmp = "dummy"
tmp2 = 9999

for x,y,z in a:
    if y == "AC" and x != tmp:
        ac += 1
        tmp = x
        tmp2 = z
    elif y == "AC" and x == tmp:
        continue
    elif y == "WA" and x != tmp:
        continue
    elif y == "WA" and x == tmp:
        if z < tmp2:
            wa += 1
        else:
            continue

print(ac,wa)

Solution (Python):
import math
import sys


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

nwa = 0
nac = 0

ac = [ "" for _ in range(N+1)]
wa = [ 0 for _ in range(N+1)]
for i in range(0,M):
    (x,S)  = input().split()
    p = int(x)
    
    if ac[p] == "AC":
        continue
    if S == "AC":
        nac = nac + 1
        ac[p] = "AC"
    else:
        wa[p] = wa[p] + 1


for i in range(1,N+1):
    if ac[i] == "AC":
        nwa = nwa + wa[i]

print(nac,nwa)

Solution (Python):
from sys import stdin

if __name__ == '__main__':
    N, M = [ int(x) for x in stdin.readline().rstrip().split() ]
    probs = {}
    for i in range(M):
        a, b = [x for x in stdin.readline().rstrip().split()]
        s = (a, b)
        if not s in probs:
            probs[s] = 0
        if b == 'AC':
            probs[s] = 1
        else:
            if (a, 'AC') in probs:
                pass
            else:
                probs[s] += 1

    AC = 0
    WA = 0

    for key, value in probs.items():
        if key[1] == 'WA':
            if (key[0], 'AC') in probs:
                WA += value
        else:
            AC += 1
    print(AC, WA)

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

AC=[0]*N
WA=[0]*N
OK = 0
NG = 0
for i in range(M):
    p,S=input().split() 
    p = int(p)
    
    if AC[p-1] == 0:        
        if S=='AC':
            AC[p-1]=1
            OK+=1        
        else:
            WA[p-1]+=1
    
for i in range(N):
    if AC[i]==1:
        NG +=WA[i]
        
print(OK,NG)

Solution (Python):


N, M = map(int, input().split())
plist = [[] for i in range(N)]
for i in range(M):
    p, S = input().split()
    
    plist[int(p) - 1].append(str(S))



count_AC = 0
sum_penalty = 0
for l in plist:
    penalty = 0
    if 'AC' in l:
        count_AC += 1
        penalty = l.index('AC')
    sum_penalty += penalty

print(count_AC, sum_penalty)

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

for i in range(M):
    p, S = input().split()
    p = int(p) - 1
    if pS[p][0] == 0 and S == 'WA':
        pS[p][1] += 1
    elif pS[p][0] == 0 and S == 'AC':
        pS[p][0] = 1
        pS[p][2] = 1

AC = 0
penatly = 0
for i in range(N):
    if pS[i][0] == 1:
        penatly += pS[int(i)][1]
        AC += pS[int(i)][2]
print(AC, penatly)

Solution (Python):
l = {}
aac = 0
awa = 0
n, m = map(int, input().split())
for _ in range(m):
  pi, si = input().split()
  pi = int(pi)
  ac, wa = l.get(pi, (False, 0))
  if si == 'AC' or ac:
    l[pi] = (True, wa)
  else:
    l[pi] = (False, wa + 1)

for iac,iwa in l.values():
  if iac:
    aac += 1
    awa += iwa

print("%d %d" % (aac, awa))

Solution (Python):
import collections
import itertools as it
import math
import numpy as np









N, M = map(int, input().split())
nAC = [False for i in range(N)]
nWA  = [0 for i in range(N)]

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

    if S == 'AC':
        if nAC[p]:
            pass
        else:
            nAC[p] = True
    else: 
        if nAC[p]:
            pass
        else:
            nWA[p] += 1

for i in range(N):
    if nAC[i]:
        pass
    else:
        nWA[i] = 0

print(sum(nAC), sum(nWA))

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

ls_ac = [0] * n
ls_ng = [0] * n
ac = 0
ng = 0


for i in range(m):
    p = int(ls[i][0])
    if ls[i][1] == "AC":
        if ls_ac[p - 1] == 0:
            ac += 1
            ng += ls_ng[p - 1]
            ls_ac[p - 1] = 1
    elif ls[i][1] == "WA":
        if ls_ac[p - 1] == 0:
            ls_ng[p - 1] += 1

print(ac, ng)

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

D = [0] * N
W = [0] * N
for p, S in ps:
  p = int(p) - 1
  if D[p] == 0:
    if S == "WA":
      W[p] += 1
    else:
      D[p] = 1

cnt = 0
for i in range(N):
  if D[i] == 1:
    cnt += W[i]

print(sum(D), cnt)

Solution (Python):





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


ans_p = [0] * N
ans_s = [0] * N

for i in range(M):
    input_sp = input().split()
    P = int(input_sp[0]) - 1
    S = input_sp[1]

    if S == 'AC':
        ans_s[P] = 1
    elif S == 'WA' and ans_s[P] == 0:
        ans_p[P] += 1

for i in range(len(ans_p)):
    if ans_s[i] == 0 and ans_p[i] != 0:
        ans_p[i] = 0

print(str(sum(ans_s)) + " " + str(sum(ans_p)))

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


state = [-1 for i in range(N)]
pena = [0 for i in range(N)]
WA = [0 for i in range(N)]

for i in range(M):
    s = raw_input().split()
    p = int(s[0])
    sc = s[1]
    
    p -= 1
    if (state[p] == 0):
        continue
    if sc == 'WA':
        pena[p] += 1
    else:
        state[p] = 0

ok = 0
pn = 0
for i in range(N):
    if state[i] == 0:
        ok += 1
        pn += pena[i]

print ok, pn

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

dwa = {}
dac = {}

for i in range(m):
    p, s = input().split()
    if s == "AC":
        if int(p) not in dac:
            dac[int(p)] = 1
        
        
    else:
        if (int(p) not in dac) and (int(p) not in dwa):
            dwa[int(p)] = 1
        elif int(p) not in dac:
            dwa[int(p)] += 1



ans1 = sum(dac.values())

ans2 = 0
for i in dac.keys():
    if i in dwa:
        ans2 += dwa[i]

print(ans1, ans2)

Solution (Python):
nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]

a = []
for i in range(m):
    a.append(input().split())

result_dic = {}

for i in range(n):
    result_dic[str(i+1)] = {'AC': 0, 'WA': 0}

for aa in a:
    if result_dic[aa[0]]['AC'] == 0:
        result_dic[aa[0]][aa[1]] += 1


ac_sum = 0
wa_sum = 0
for i in range(n):
    if result_dic[str(i+1)]['AC'] > 0:
        ac_sum += 1
        wa_sum += result_dic[str(i+1)]['WA']

print(str(ac_sum) + ' ' + str(wa_sum))

Solution (Python):
n, m = map(int, input().split())
source_list = []
for i in range(m):
    instr = input()
    source_list_mini = []
    source_list_mini.append(instr.split(" ")[0])
    source_list_mini.append(instr.split(" ")[1])
    source_list.append(source_list_mini)

finish_dic = {}
pena_count_dic = {}
for source in source_list:
    pena_count_dic[source[0]] = 0
    finish_dic[source[0]] = False

for source in source_list:
    if source[1] == "AC":
        finish_dic[source[0]] = True
    else:
        if finish_dic[source[0]] == False:
            pena_count_dic[source[0]] += 1
        
ans_count = 0
for flag in finish_dic.values():
    if flag == True:
        ans_count += 1

pena_count = 0
for pro_num, pena in pena_count_dic.items():
    if finish_dic[pro_num] == True:
        pena_count += pena
     
print(ans_count, pena_count)

Solution (Python):
from collections import Counter

N, M = map(int, input().split())
pS = [input().split() for _ in range(M)]

ac = 0
state = Counter()
penalty = 0
for p, S in pS:
    if state[p] != -1:
        if S == "WA":
            state[p] += 1
        else:
            penalty += state[p]
            ac += 1
            state[p] = -1

print(ac, penalty)

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())
cnt_pena = 0 
cnt_ac = 0
cnt = [0]*n 
for i in range(m):
    p,s = map(str,input().split())
    if cnt[int(p)-1] >= 0 and s == "WA": 
        cnt[int(p)-1] += 1 
    elif cnt[int(p)-1] >= 0 and s == "AC": 
        cnt_pena += cnt[int(p)-1]
        cnt[int(p)-1] = -1
        cnt_ac += 1
    
print(cnt_ac,cnt_pena)

Solution (Python):
n, m = [int(x) for x in input().split()]
nac = 0
nwa = 0
past = {}
for i in range(m):
    p, s = [x for x in input().split()]
    d = p + s
    if (p + 'AC') in past:
        next
    else:
        if s == 'WA':
            past[d] = 1 if d not in past else past[d] + 1
        else:
            past[d] = 1
            nac += 1
            nwa += 0 if (p + 'WA') not in past else past[p + 'WA']
print(nac, nwa)

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

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

flag = [0 for i in range(n)]
wa_count = [0 for i in range(n)]
count_ac = 0
count_wa = 0

for i in range(m):
    p, s = map(str, input().split(' '))
    p = int(p)
    if s == 'AC':
        if not flag[p-1]: 
            count_ac += 1
            flag[p-1] = 1
            count_wa += wa_count[p-1]
    else: 
        if not flag[p-1]:
            wa_count[p-1] += 1

print('{} {}'.format(count_ac, count_wa))

Solution (Python):
def main():
    N, M = map(int, input().split())
    ans = [False for _ in range(N)]
    wa_list = [0 for _ in range(N)]

    ac = 0
    wa = 0

    for _ in range(M):
        i, result = input().split()
        i = int(i)
        if result == "AC":
            if ans[i-1] == False:
                ac += 1
                ans[i - 1] = True
                wa += wa_list[i-1]
        else:
            if ans[i - 1] == False:
                wa_list[i - 1] += 1
    if sum(ans) == 0:
        wa = 0

    print(ac, wa)
    return 0
if __name__ == '__main__':
    main()

Solution (Python):
n,m = map(int,input().split())
problems = [False]*n
pen = [0]*n
for i in range(m):
    a,b = input().split()
    a = int(a)-1
    if not problems[a]:
        if b[0] == 'A':
            problems[a] = True
        else:
            pen[a] += 1
ngo = 0
ans = 0
for i in range(n):
    if problems[i]:
        ngo += pen[i]
        ans += 1
print(ans,ngo)

Solution (Python):
import math
n,m = map(int,input().split())
ps_ls = [list(input().split()) for i in range(m)]
ans_wa = 0
ans_ac = 0
strk_wa = 0
frag = 1
for i in range(m):
    ps_ls[i][0] = int(ps_ls[i][0])
ps_ls.sort(key=lambda x: x[0])

for i in range(m-1):
    if ps_ls[i][1] == "WA" and frag == 1:
        strk_wa += 1

    if ps_ls[i][1] == "AC":
        if frag == 1:
            ans_ac += 1
        frag = 0
        ans_wa += strk_wa
        strk_wa = 0
    if ps_ls[i][0] != ps_ls[i+1][0]:
        strk_wa = 0
        frag = 1
if ps_ls != []:
    if ps_ls[-1][1] == "AC":
        if frag == 1:
                ans_ac += 1
        ans_wa += strk_wa

print(ans_ac,ans_wa)

Solution (Python):
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
ans = [[] for i in range(N)]
for i in range(M):
    p,s = [(x) for x in stdin.readline().rstrip().split()]
    ans[int(p)-1].append(s)

ac = 0
pe = 0
tmp = 0
flag = False
for j in range(N):
    tmp = 0
    for k in ans[j]:
        if k == "WA":
            tmp += 1
        else:
            ac += 1
            pe += tmp
            tmp = 0
            break
print(ac,pe)

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

for i in range(m):
    check = input().split()
    if ac[int(check[0])-1]==0:
        if check[1]=='AC':
            ac[int(check[0])-1]=1
        else:
            wa[int(check[0])-1]+=1
for i in range(n):
    if ac[i]==0:
        wa[i]=0
ans = [sum(ac),sum(wa)]
print(*ans,sep=' ')

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

for i in range(M):
  P[i][0] = int(P[i][0])

ans_status = [0] * N
penalty = [0] * N
ans_count = 0

for i in range(M):
  if ans_status[P[i][0] - 1] != "AC":
    if P[i][1] == "AC":
      ans_status[P[i][0] - 1] = "AC"
      ans_count += 1
    else:
      penalty[P[i][0] - 1] += 1

penalty_count = 0

for i in range(N):
  if ans_status[i] == "AC":
    penalty_count += penalty[i]

print(ans_count, penalty_count)

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

ac = [0 for i in range(n+1)]
tmp = [0 for i in range(n+1)]

cnt_ac = 0
cnt_pen = 0

for i in range(m):
    p,s = map(str,input().split())
    p = int(p)
    
    
    
    if ac[p] == 0:
        if s == 'WA':
            if tmp[p] >= 0:
                tmp[p] += 1

        if s=='AC':
            ac[p] = 1
            cnt_ac += 1
            if tmp[p] > 0:
                cnt_pen += tmp[p]
                tmp[p] = -1

    
    else:
        continue

print(cnt_ac, cnt_pen)

Solution (Python):



l = input().split(" ")
N = int(l[0])
M = int(l[1])
 
wa_dict = {}
answered = set()
 
ac_count = 0
wa_count = 0
 
for n in range(M):
    result = [i for i in input().split(" ")]
    p = result[0]
    if p in answered:
        continue
    s = result[1]
    if s == "WA":
        if p not in wa_dict:
            wa_dict[p] = 1
        else:
            wa_dict[p] += 1
    else:
        ac_count += 1
        if p in wa_dict:
        	wa_count += wa_dict[p]
        answered.add(p)
        if len(answered) == N:
            break
 
print(ac_count, wa_count)

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

ac_count = 0
wa_count = 0
p_dict = {str(i):[0,0] for i in range(1, n+1)}

for m_i in range(m):
  p,s = input().split()
  if p_dict[p][1] == 0:
    if s=='WA':
      p_dict[p][0] += 1
    elif s=='AC':
      p_dict[p][1] += 1
  
for val in p_dict.values():
  if val[1] == 1:
    ac_count += 1
    wa_count += val[0]
    
print(ac_count, wa_count)

Solution (Python):
temp=list(map(int, input().split()))
N=temp[0]
M=temp[1]
f=[0]*N
cnt=0
ac=0
wa=[0]*N
for i in range(M):
  temp=input().split()
  if f[int(temp[0])-1]==0:
    if temp[1]=='WA':
      wa[int(temp[0])-1]+=1
    else:
      f[int(temp[0])-1]=1
      ac+=1
cnt=sum([wa[i] if f[i]==1 else 0 for i in range(N)])
print(str(ac)+' '+str(cnt))

Solution (Python):




def main():
    n,m = map(int,input().split())
    d = dict()
    for i in range(m):
        a,b = input().split()
        a = int(a)
        if a not in d:
            d[a] = [0]
        if d[a][-1] != "AC":
            d[a].append(b)
    ac = 0
    pe = 0
    
    for i in d.values():
        
        if i[-1] == "AC":
            ac += 1
            pe += i.count("WA")
    print(ac,pe)








if __name__ == '__main__':
    main()

Solution (Python):
N,M = map(int, input().strip().split())
PS = [input().strip().split() for _ in range(M)]
acset = set()
acc = 0
wacd = {str(i):0 for i in range(1, N+1)}
for p, s in PS:
    if s == "WA" and p not in acset:
        wacd[p] += 1
    if s == "AC" and p not in acset:
        acc += 1
        acset.add(p)
wac = sum([c for i, c in wacd.items() if i in acset])
print(acc, wac)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline

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

WA = [0] * (N + 1)
AC = [False] * (N + 1)
for _ in range(M):
    p, S = readline().split()
    p = int(p)
    if AC[p]:
        continue

    if S == 'AC':
        AC[p] = True
    else:
        WA[p] += 1

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

print(sum(AC), sum(WA))

Solution (Python):
N,M=map(int,input().split())
LIST=[0]*(10**5+1)
PLIST=[0]*(10**5+1)

C=0
P=0
for i in range(M):
    A=list(map(str,input().split()))
    if(A[1]=="WA"):
        if(LIST[int(A[0])]==0):
            PLIST[int(A[0])]+=1
    else:
        if(LIST[int(A[0])]==0):
            C+=1
            LIST[int(A[0])]=1

for i in range(len(LIST)):
    P+=LIST[i]*PLIST[i]

print(C,P)

Solution (Python):



import sys
input = sys.stdin.readline



def main():
    N,M = map(int,input().split())
    pS = [input().split() for _ in range(M)]

    ACWA = [[0,0] for _ in range(N)]
    res = [0,0]

    for i in range(M):
        pnum = int(pS[i][0]) - 1
        result = pS[i][1]
        if result == 'AC':
            if ACWA[pnum][0] == 0:
                ACWA[pnum][0] += 1
                res[0] += 1
                res[1] += ACWA[pnum][1]
        elif result == 'WA':
            ACWA[pnum][1] += 1

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





main()

Solution (Python):


N, M= (int(x) for x in input().split())

pS = [[] for x in range(M)]
for i in range(M):
	p, S = input().split()
	pS[i] = [int(p), S]

check = [[0, False] for x in range(N)]

for ps in pS:
	if ps[1] == "WA":
		if check[ps[0] - 1][1] == False:
			check[ps[0] - 1][0] += 1
	else: 
		check[ps[0] - 1][1] = True

ans = 0
penalty = 0
for c in check:
	if c[1] == True:
		ans += 1
		penalty += c[0]

print(str(ans) + " " + str(penalty))

Solution (Python):
from collections import defaultdict
N, M = map(int, input().split())
P = []
S = []
for i in range(M):
  p, s = input().split()
  P.append(int(p))
  S.append(s)
d = defaultdict(int)
d1 = defaultdict(int)
for i in range(M):
  if S[i] == "WA":
    if d[P[i]] != 1:
      d1[P[i]] += 1
  elif S[i] == "AC":
    d[P[i]] = 1
for i in range(M):
  if d[P[i]] == 0 and d1[P[i]] > 0:
    d1[P[i]] = 0
print(sum(d.values()), sum(d1.values()))

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

acd=[0 for i in range(N)]
walst=[0 for i in range(N)]
for p,S in pS:
    p=int(p)
    if not acd[p-1]:
        if S=="WA":
            walst[p-1]+=1
        else:
            ac+=1
            acd[p-1]=1
            wa+=walst[p-1]
print(ac,wa)

Solution (Python):
import numpy as np

n, m = map(int, input().split())
is_ac = np.zeros(n, dtype=bool)
wc_count = np.zeros(n, dtype=int)

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if not is_ac[p - 1]:
        if s == "WA":
            wc_count[p - 1] += 1
        else:
            is_ac[p - 1] = True
print(is_ac.sum(), wc_count[is_ac].sum())

Solution (Python):
N,M = map(int,input().split())
AC = [0 for i in range(N)]
WA = [0 for i in range(N)]
for i in range(M):
    li = input().split()
    p = int(li[0])
    S = li[1]
    if S == 'AC':
        AC[p-1] = 1
    elif S == 'WA' and AC[p-1] == 0:
        WA[p-1] += 1
WA2 = [AC[i]*WA[i] for i in range(N)]
print(sum(AC),sum(WA2))

Solution (Python):
N , M = map(lambda x: int(x),input().split())
isAC = ["WA"] * (N+1)
WAcount = [0] * (N+1)
score=0
penalty = 0
for i in range(M):
    p,r = input().split()
    
    p = int(p)
    
    if isAC[p] =="AC":
        continue
    if r == "WA":
        WAcount[p] += 1
        
    else:
        isAC[p] = "AC"
        score += 1
        
    
for i in range(N+1):
  if isAC[i]=="AC":
    penalty += WAcount[i]
print(score,penalty)

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

ans = [[0]*3 for _ in range(N)]
for ps in p_S:
  if ps[1] == "AC":
    ans[int(ps[0]) - 1][1] += 1
  elif ps[1] == "WA" and ans[int(ps[0]) - 1][1] == 0 :
    ans[int(ps[0]) - 1][2] += 1
ac = 0
pe = 0


for a in ans:
  if a[1] >= 1:
    ac += 1
    pe += a[2]
print(ac, pe)