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

ac_check = [False for i in range(n)]
wa_count = [0 for i in range(n)]

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

    if s == 'AC' and ac_check[p] == False:
        ac_check[p] = True
        error += wa_count[p]
    elif s == 'WA' and ac_check[p] == False:
        wa_count[p] += 1

for i in range(n):
    if ac_check[i]:
        clear += 1

print(clear, error)

Solution (Python):
def resolve():
    import sys
    input = sys.stdin.readline
    n, m = map(int, input().split())
    if m == 0:
        print("{} {}".format(0, 0))
        exit()

    a = list(input().split() for _ in range(m))
    flag = [[0] * n for i in range(2)]
    miss = 0
    correct = 0
    for i in range(m):
        if flag[0][int(a[i][0]) - 1] == 0:
            if a[i][1] == "WA":
                flag[1][int(a[i][0]) - 1] += 1
            elif a[i][1] == "AC":
                correct += 1
                miss += flag[1][int(a[i][0]) - 1]
                flag[0][int(a[i][0]) - 1] = 1
    print("{} {}".format(correct, miss))
resolve()

Solution (Python):
import sys
input = sys.stdin.readline
 
def main():
    N, M = map(int, input().split())
 
    ac_check = [False] * N
    p_counts = [0] * N
 
    for i in range(M):
        p, s = input().strip().split()
        p = int(p) - 1
        if s == "AC":
            if not ac_check[p]:
                ac_check[p] = True
        else:
            if not ac_check[p]:
                p_counts[p] += 1
 
    ac_count = 0
    p_count = 0
    for i in range(N):
        if ac_check[i]:
            ac_count += 1
            p_count += p_counts[i]
    print(ac_count, p_count)
 
 
if __name__ == "__main__":
    main()

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

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

    ac_check = [False] * N
    p_counts = [0] * N

    for i in range(M):
        p, s = input().strip().split()
        p = int(p) - 1
        if s == "AC":
            if not ac_check[p]:
                ac_check[p] = True
        else:
            if not ac_check[p]:
                p_counts[p] += 1

    ac_count = 0
    p_count = 0
    for i in range(N):
        if ac_check[i]:
            ac_count += 1
            p_count += p_counts[i]
    print(ac_count, p_count)


if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np

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

seikai = np.zeros(n)
matigai1 = np.zeros(n)
matigai2 = np.zeros(n)
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if seikai[p]==1:
        continue
    else:
        if s=='AC':
            seikai[p] = 1
            matigai2[p] = matigai1[p]

        else:
            matigai1[p] += 1

print(int(seikai.sum()), int(matigai2.sum()))

Solution (Python):
nm = [int(s) for s in input().split()]
ls = [0]*nm[0]
ac = [0]*nm[0]

for x in range(nm[1]):
  ps = [s for s in input().split()]
  p = int(ps[0])
  s = ps[1]
  if ac[p-1] == 0:
    if s == 'WA':
      ls[p-1] += 1
    else:
      ac[p-1] = 1
import numpy as np

print(' '.join(map(str,[sum(ac),np.dot(ac,ls)])))

Solution (Python):
N,M=map(int,input().split())
P=list(input().split() for _ in range(M))
manageDo={}
manageWa={}
for n in range(N):
    manageDo[str(n+1)] = 0
    manageWa[str(n+1)] = 0
wa=0
ac=0
for p in P:
    now=manageDo[p[0]]
    if p[1] == 'WA' and now == 0:
        manageWa[p[0]] += 1
    elif p[1] == 'AC' and now == 0:
        ac+=1
        wa+=manageWa[p[0]]
        manageDo[p[0]] = 1

print(ac,wa)

Solution (Python):
n,m=map(int,input().split())
l=[0]*n
s=set([])
for i in range(m):
  p,q=map(str,input().split())
  if int(p) in s:
    continue
  elif q=='AC':
    s.add(int(p))
  else:
    l[(int(p))-1]+=1
s_l=list(s)
an=len(s_l)
c=0
for i in range(an):
  c+=l[s_l[i]-1]
print(an,c)

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

a = [0]*n
b = [False]*n
for i in range(m):
    p,s = input().split()
    p = int(p) - 1
    if s == 'AC':
        b[p] = True
    elif b[p] == False:
        a[p] += 1

ac = b.count(True)
wa = 0
for i in range(n):
    if b[i] == True:
        wa += a[i]
print(ac,wa)

Solution (Python):
N, M = map(int, input().split())
dic = {}
ac = 0
wa = 0
for x in range(M):
    p, s = input().split()
    try:
        dic[p]
    except:
        dic[p] = [False, 0]
    
    if s == 'WA':
        if not dic[p][0]:
            dic[p][1] += 1
        
        
    else:
        if not dic[p][0]:
            dic[p][0] = True
            ac += 1
            wa += dic[p][1]

print(ac, wa)

Solution (Python):
import sys
N, M = map(int, input().split())
PS = sys.stdin.read().strip().split()
ac = [0] * N
wa = [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 math
import copy
from copy import deepcopy
import sys
import fractions

from functools import reduce

import heapq
import collections
import itertools
sys.setrecursionlimit(100001)






def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList




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

data = []
for i in range(m):
    input_data = input().split()
    tmp_int = int(input_data[0]) -1
    tmp_str = str(input_data[1])
    data.append([tmp_int, tmp_str])

table_cnt = [0]*n
table_bool = [False]*n

ans_ac = 0
ans_wa = 0

for index, result in data:
    if table_bool[index] == False:
        if result == "WA":
            table_cnt[index] += 1
        else:
            table_bool[index] = True
            ans_ac += 1
            ans_wa += table_cnt[index]

print(ans_ac, ans_wa)

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

n_ac=0
n_wa=0
for i in range(n):
    if "AC" in acwa[i]:
        n_ac +=1
        n_wa +=acwa[i].index("AC")
print(n_ac,n_wa)

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

a = [0]*n
b = [False]*n
for i in range(m):
  p,s = input().split()
  p = int(p) - 1
  if s == 'AC':
    b[p] = True
  elif b[p] == False:
    a[p] += 1

ac = b.count(True)
wa = 0
for i in range(n):
  if b[i] == True:
    wa += a[i]
print(ac,wa)

Solution (Python):
[n,m] = [int(i) for i in input().split()]
dic_AC = {}
dic_WA = {}
for i in range(1,n+1):
    dic_AC[i] = 0
    dic_WA[i] = 0

for i in range(m):
    [p,s] = [j for j in input().split()]
    if s == "AC":
        dic_AC[int(p)] = 1
    else:
        if dic_AC[int(p)] == 0:
            dic_WA[int(p)] += 1
ans_1 = sum(dic_AC.values())
ans_2 = 0
for i in range(1,n+1):
    if dic_AC[i] == 1:
        ans_2 += dic_WA[i]
print(ans_1,ans_2)

Solution (Python):
N,M = map(int,input().split())
s = sorted([list(map(str,input().split())) for i in range(M)], key = lambda x: x[0])
for i in range(M):
    s[i][0] = int(s[i][0])
clear = 0
pena = 0
pena_pre = 0
if(M == 0):
    print("0 0")
else:
    problem = s[0][0]
    AC_flag = 0
    for i in range(M):
        if(s[i][0] != problem):
            problem = s[i][0]
            AC_flag = 0
            pena_pre = 0
        if(s[i][1] == "AC" and AC_flag == 0):
            clear += 1
            AC_flag = 1
            pena += pena_pre
            pena_pre = 0
        elif(s[i][1] == "WA" and AC_flag == 0):
            pena_pre += 1

    print(str(clear) + " " + str(pena))

Solution (Python):
N,M = map(int, input().split())
ps = []
AC = [0]*N
WA = [0]*N
WA_sum = 0
for _ in range(M):
  ps.append(list(input().split()))
for i in range(M):
  if ps[i][1] == 'AC' and AC[int(ps[i][0])-1] == 0:
    AC[int(ps[i][0])-1] = 1
  if ps[i][1] == 'WA' and AC[int(ps[i][0])-1] == 0:
    WA[int(ps[i][0])-1] += 1
for i in range(N):
  if AC[i] == 1:
    WA_sum += int(WA[i])
print(sum(AC), WA_sum)

Solution (Python):
N,M=map(int,input().split())
ac=0
wa=0
a=[0]*N
w=[0]*N
for i in range(M):
    P,S=input().split()
    P=int(P)
    if S=="WA":
        w[P-1]+=1
    else:
        if a[P-1]==0:
            a[P-1]+=1
            ac=ac+1
            wa+=w[P-1]
        else:
            pass
print(ac,wa)

Solution (Python):
N,M=map(int,input().split())
ac=0
wa=0
a=[0]*N
w=[0]*N
for i in range(M):
    P,S=input().split()
    if S=="WA":
        w[int(P)-1]+=1
    else:
        if a[int(P)-1]==0:
            a[int(P)-1]+=1
            ac=ac+1
            wa+=w[int(P)-1]
        else:
            pass
print(ac,wa)

Solution (Python):

n,m=map(int,input().split())
f=False
ps=[]
AC=[0]*n
WA=[0]*n
for i in range(m):
    ps.append(list(input().split()))
for i in range(m):
    if ps[i][1]=='AC'and AC[int(ps[i][0])-1]==0:
        AC[int(ps[i][0])-1]=1
    if ps[i][1]=='WA'and AC[int(ps[i][0])-1]==0:
        WA[int(ps[i][0])-1]+=1
wasum=0
for i in range(n):
    if AC[i]==1:
        wasum+=WA[i]
print(sum(AC),wasum)

Solution (Python):
N,M = map(int, input().split())
ps = []
AC = [0]*N
WA = [0]*N
WA_sum = 0
for _ in range(M):
  ps.append(list(input().split()))
for i in range(M):
  if ps[i][1] == 'AC' and AC[int(ps[i][0])-1] == 0:
    AC[int(ps[i][0])-1] = 1
  if ps[i][1] == 'WA' and AC[int(ps[i][0])-1] == 0:
    WA[int(ps[i][0])-1] += 1
for i in range(N):
  if AC[i] == 1:
    WA_sum += int(WA[i])
print(sum(AC), WA_sum)

Solution (Python):
N,M=map(int,input().split())
Qnum=[0]*M
rslt=[" "]*M
Pnum=[0]*N 
Flag=[0]*N
ACnum=0
for i in range(M):
    Qnum[i],rslt[i]=input().split()
    Qnum[i]=int(Qnum[i])
    if Flag[Qnum[i]-1]==0:
        if rslt[i]=="AC":
            Flag[Qnum[i]-1]=1
            ACnum+=1
        else:
            Pnum[Qnum[i]-1]+=1

for j in range(N):
    if Flag[j]==0:
        Pnum[j]=0
print(ACnum,sum(Pnum))

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

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

P, S = [], []
solved = set({})
counter = {i: 0 for i in range(1, N + 1)}
value1 = 0
value2 = 0
for _ in range(M):
    p, s = input().split()
    p = int(p)
    P.append(p)
    S.append(s)

    if p in solved:
        continue

    if s == 'AC':
        solved.add(p)
        value1 += 1
        value2 += counter[p]

    else:
        counter[p] += 1

print(value1, value2)

Solution (Python):
N, M = map(int, input().split())
ps = [[] for _ in range(N)]
for i in range(M):
    p, s = input().split()
    p = int(p) - 1
    ps[p].append(s)
wa = 0
ac = 0
for ss in ps:
    tmp_wa = 0
    for s in ss:
        if s == "WA":
            tmp_wa += 1
        else:
            ac += 1
            wa += tmp_wa
            break
print("{} {}".format(ac, wa))

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

ac = 0
wa = 0
ac_status = [0 for i in range(N)]
wa_status = [0 for i in range(N)]

for _ in range(M):
    p_i, s_i = input().split()
    if s_i == "AC" and ac_status[int(p_i) - 1] == 0:
        ac += 1
        ac_status[int(p_i) - 1] += 1
        wa += wa_status[int(p_i) - 1]
    if s_i == "WA":
        wa_status[int(p_i) - 1] += 1

print(ac, wa)

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

wa = 0
for _ in range(M):
  p, s = input().split()
  index = int(p)-1
  if s == 'WA' and P[index] != -1:
      P[index] += 1
  elif P[index] > -1:
    wa += P[index]
    P[index] = -1
  
print(P.count(-1), wa)

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

p = [-1 for _ in range(m)]
s = [-1 for _ in range(m)]

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


dic_ac = {}
dic_wa = {}
dic_wa_num = {}

for i in range(m):
    if(s[i] == "AC"):
        if not (p[i] in dic_ac):
            dic_ac[p[i]] = 1
    
    if(s[i] == "WA" and p[i] not in dic_ac):
        if(p[i] in dic_wa):
            dic_wa_num[p[i]] += 1
        else:
            dic_wa[p[i]] = 1
            dic_wa_num[p[i]] = 1
            

wa = 0
ac = 0

for v in dic_ac.values():
    ac += v

for v in dic_ac:
    if(v in dic_wa_num):
        wa += dic_wa_num[v]

  
print(ac,wa)

Solution (Python):
from collections import defaultdict

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

cnt = defaultdict(int)
d = defaultdict()

for p, s in ps:
    if s == "AC":
        if d.get(p) is None:
            d[p] = cnt[p]
    else:
        cnt[p] += 1

correct = 0
pena = 0
for k, v in d.items():
    correct += 1
    pena += v

print(correct, pena)

Solution (Python):
N,M=map(int,input().split())
AC={}
WA={}
for i in range(M):
    a,b=input().split()
    if not(a in AC.keys()):
        if b=="AC":
            AC[a]=1
        else:
            if a in WA.keys():
                WA[a]+=1
            else:
                WA[a]=1
y=0
for i in AC.keys():
    if i in WA.keys():
        y+=WA[i]
print(sum(AC.values()),y)

Solution (Python):

"""
Created on Wed Mar  4 18:22:36 2020

@author: Kanaru Sato
"""

N, M = list(map(int, input().split()))
submits = [input().split() for i in range(0,M)]

D = {}

for ans in submits:
    if ans[1] == "AC":
        if ans[0] not in D:
            D[ans[0]] = 0

D_flag = D.copy()

for ans in submits:
    if (ans[0] in D) and (D_flag[ans[0]] == 0):
        if ans[1] == "WA":
            D[ans[0]] += 1
        if ans[1] == "AC":
            D_flag[ans[0]] = 1

if M == 0:
    print(0,0)
else:
    print(len(D), sum(D.values()))

Solution (Python):
N, M = map(int, input().split())
AC = set()
wa = [0] * (N+1)

for _ in range(M):
    p, s = input().split()
    p = int(p)
    if not p in AC:
        if s == 'AC':
            AC.add(p)
        if s == 'WA':
            wa[p] += 1

wa_ans = 0
for i in AC:
    wa_ans += wa[i]

print(len(AC), wa_ans)

Solution (Python):
N, M = map(int, input().split())
AC = set()
wa = [0] * (N+1)

for _ in range(M):
    p, s = input().split()
    p = int(p)
    if not p in AC:
        if s == 'AC':
            AC.add(p)
        if s == 'WA':
            wa[p] += 1

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

print(len(AC), wa_ans)

Solution (Python):
n,m=map(int,input().split())
ok=[0]*(n+1)
pe=[0]*(n+1)
for _ in range(m):
    q,s=input().split()
    q=int(q)
    if s=="WA" and ok[q]==0:
        pe[q]+=1
    else:
        ok[q]=1
for i in range(n+1):
    if ok[i]==0:
        pe[i]=0
print(sum(ok),sum(pe))

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

Solution (Python):
n,m=map(int,input().split())
cnt=[0]*(n+1)
l=[0]*(n+1)
ac=0
wa=0
for i in range(m):
  p,s=input().split()
  p=int(p)
  if l[p]==1:
    continue
  if l[p]==0 and s=='WA':
    cnt[p]+=1
  if l[p]==0 and s=='AC':
    ac+=1
    l[p]=1
for i in range(1,n+1):
  if l[i]==1:
    wa+=cnt[i]
print(ac,wa)

Solution (Python):
def main():
  import sys
  input = sys.stdin.buffer.readline
  n,m=map(int,input().split())
  a,w,l,k=0,0,[0]*n,[0]*m
  for _ in k:
    p,s=input().split()
    p=int(p)-1
    if l[p]>=0:
      if s==b'AC':
        a+=1
        w+=l[p]
        l[p]=-1
      else:
        l[p]+=1
  print(a,w)
  
if __name__ == '__main__':
    main()

Solution (Python):
def main():
  import sys
  input = sys.stdin.buffer.readline
  n,m=map(int,input().split())
  ac,wa,l,k=0,0,[0]*n,[0]*m
  for _ in k:
    p,s=input().split()
    p=int(p)
    if type(l[p-1])==int:
      if s==b'AC':
        ac+=1
        wa+=l[p-1]
        l[p-1]=''
      else:
        l[p-1]+=1
  print(ac,wa)
  
if __name__ == '__main__':
    main()

Solution (Python):
def main():
  import sys
  input = sys.stdin.readline
  n,m=map(int,input().split())
  ac,wa,l=0,0,[0]*n
  for _ in [0]*m:
    p,s=input().split()
    if type(l[int(p)-1])==int:
      if s=='AC':
        ac+=1
        wa+= l[int(p)-1]
        l[int(p)-1]=str(l[int(p)-1])
      else:
        l[int(p)-1]+=1
  print(ac,wa)
  
if __name__ == '__main__':
    main()

Solution (Python):
n,m=map(int,input().split())
ac,wa,k,l=0,0,[0]*n,[0]*n
for _ in range(m):
  p,s=input().split()
  if k[int(p)-1]==0:
    if s=='AC':
      ac+=1
      k[int(p)-1]=1
      wa+= l[int(p)-1]
    else:
      l[int(p)-1]+=1
print(ac,wa)

Solution (Python):
N, M = map(int, input().split())
AC_or_not = [False] * N
n_penalty = [0] * N
cnt_ac = 0
cnt_pen = 0

for _ in range(M):
    prob, wa_ac = input().split()
    prob = int(prob) - 1
    if wa_ac == 'AC':
        if not AC_or_not[prob]:
            cnt_pen += n_penalty[prob]
            cnt_ac += 1
            AC_or_not[prob] = True
    else:
            n_penalty[prob] += 1

print(cnt_ac ,cnt_pen)

Solution (Python):
import numpy as np

N, M = map(int, input().split())
AC_or_not = np.array([0] * N)
n_penalty = np.array([0] * N)

for _ in range(M):
    prob, wa_ac = input().split()
    prob = int(prob) - 1
    if wa_ac == 'AC':
        AC_or_not[prob] = 1
    else:
        if not AC_or_not[prob]:
            n_penalty[prob] += 1

print(sum(AC_or_not), sum(n_penalty * AC_or_not))

Solution (Python):
"""
注意点：ACしていないWAはペナルティ数とはカウントされない
      また、ACの後にペナルティしたものはカウントされない
データ構造：
  WA:dict形式でカウントアップ
  AC:配列で末尾に挿入
一通り舐めた後AD配列をforで回してペナルティ数合計するか？
"""

N,M = list(map(lambda x: int(x), input().split()))
wa_count = [0] * N
ac_list = [False] * N
answer = 0

for _ in range(M):
  p,s = input().split()
  p = int(p)
  if s == 'WA':
    wa_count[p-1] += 1
  if s == 'AC' and ac_list[p-1] == False:
    answer += wa_count[p-1]
    ac_list[p-1] = True

ac_count = ac_list.count(True)

print(ac_count, answer)

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

eva = [[0, 0] for _ in range(n)]

ac = 0
penalty = 0

for i in range(m):
    q, s = input().split()
    if eva[int(q) - 1][1] == 0:
        if s == "WA":
            eva[int(q) - 1][0] += 1
        else:
            eva[int(q) - 1][1] += 1
            ac += 1
            penalty += eva[int(q) - 1][0]
    else:
        pass

print(ac, penalty)

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

Solution (Python):
n,m=map(int,input().split())
a=[]
c=[0]*n
cnt=0
b=[0]*n
for _ in range(m):
  p,s=input().split()
  p=int(p)
  p-=1
  if s=="AC":
    a.append(p)
    if c[p]==0:
          c[p]=1
  else:
        if c[p]==0:    
          b[p]+=1
a=list(set(a))
for i in a:
  cnt+=b[i]
print(len(set(a)),cnt)

Solution (Python):
n,m=map(int,input().split())
a=[]
c=[0]*n
cnt=0
b=[0]*n
for _ in range(m):
  p,s=input().split()
  p=int(p)
  p-=1
  if s=="AC":
    a.append(p)
    if c[p]==0:
          c[p]=1
  else:
        if c[p]==0:    
          b[p]+=1
a=list(set(a))
for i in a:
  cnt+=b[i]
print(len(set(a)),cnt)

Solution (Python):
N,M = [int(i) for i in input().split(" ")]
pS = [0]*N
ac,wa = 0,0
for _ in range(M):
    p,S = input().split(" ")
    p = int(p)-1
    if pS[p] != -1 and S == "WA":
        pS[p]+=1
    if pS[p] != -1 and S=="AC":
        ac+=1
        wa+=pS[p]
        pS[p]=-1
print(ac,wa)

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

flag = [False] * n
cnt = [0 for i in range(n)]
for i in ps:
    if i[1] == 'WA' and flag[int(i[0]) - 1] == False:
        cnt[int(i[0]) - 1] += 1
    elif i[1] == 'AC':
        flag[int(i[0]) - 1] = True
penal_cnt = 0
for i in range(len(flag)):
    if flag[i] == True:
        penal_cnt += cnt[i]
print(sum(flag), penal_cnt)

Solution (Python):
n,m = map(int,input().split())
a = [False]*n
b = [0]*n
for i in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'AC':
        a[p-1] = True
    if s == 'WA' and a[p-1] == False:
        b[p-1] += 1
correct = a.count(True)
penalty = 0
for i in range(len(a)):
    if a[i] == True:
        penalty += b[i]
print(correct, penalty)

Solution (Python):
N, M = map(int, input().split())
isAC = [False for _ in range(N)]
correct = 0
penalty = [0 for _ in range(N)]
for _ in range(M):
    tmp = input().split()
    pi, Si = int(tmp[0]), tmp[1]
    if not isAC[pi-1]: 
        if Si == 'AC':
            isAC[pi-1] = True
            correct += 1
        else:
            penalty[pi-1] += 1
pnl = 0
for idx in range(N):
    if isAC[idx]:
        pnl += penalty[idx]
print(correct, pnl)

Solution (Python):



import numpy as np



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

times = m
table = []
for _ in range(times):
    table.append(list(input().split()))

statusAC = {}
answer_status = {}

for question_num , ACorWA in table:
    question_num = int(question_num)
    if question_num in statusAC:
        continue
    else:
        if ACorWA == "AC":
            statusAC[question_num] = "AC"
            if question_num in answer_status:
                answer_status[question_num] += ACorWA
            else:
                answer_status[question_num] = ACorWA
        else:
            if question_num in answer_status:
                answer_status[question_num] += ACorWA
            else:
                answer_status[question_num] = ACorWA

def penalty_count(dic):
    penalty_count = 0
    for num in dic:
        if "AC" in dic[num]:
            penalty_count  += (len(dic[num])-2)//2
        else:
            continue
    return penalty_count


ans = len(statusAC)
penalty = penalty_count(answer_status)

print(ans,penalty)

Solution (Python):
n,m = map(int,input().split())
a = [False]*n
b = [0]*n
for i in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'AC':
        a[p-1] = True
    if s == 'WA' and a[p-1] == False:
        b[p-1] += 1
correct = a.count(True)
penalty = 0
for i in range(len(a)):
    if a[i] == True:
        penalty += b[i]
print(correct, penalty)

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

a = [False]*n
b = [0]*n

for i in range(m):
  x,y = input().split()
  x = int(x)
  if y == 'AC':
    a[x-1] = True
  elif y == 'WA' and a[x-1] == False:
    b[x-1] += 1

ac = 0
wa = 0
for i in range(n):
  if a[i] == True:
    ac += 1
    wa += b[i]
    
print(ac, wa)

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

ac_list = []
wa_list = [0 for i in range(n)]
num_wa = 0
num_ac = 0

for ps in ps_list:
    p = int(ps[0])
    s = ps[1]
    
    if s == 'AC' and wa_list[p-1] != -1:
        ac_list.append(p)
        num_wa += wa_list[p-1]
        num_ac += 1
        wa_list[p-1] = -1
    elif wa_list[p-1] != -1:
        wa_list[p-1] += 1
        
print(num_ac, num_wa)

Solution (Python):
N,M=map(int,input().split())
ac,wa=0,0
task=[0]*N
for m in range(M):
    p,S=input().split()
    p=int(p)-1
    if task[p]!=-1 and S=="WA":
        task[p]+=1
    elif task[p]!=-1 and S=="AC":
        ac+=1
        wa+=task[p]
        task[p]=-1
print(ac,wa)

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()
n,m=map(int,input().split())
wa=[0]*n
ac=[0]*n
for _ in range(m):
    x,y=map(str,input().split())
    x=int(x)
    if y=='WA':
        if ac[x-1]==0:
            wa[x-1]+=1
    if y=='AC':
        ac[x-1]=1
for i in range(n):
    if ac[i]==0: wa[i]=0
print(sum(ac),sum(wa))

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


ACflag=[0]*N
WAcount=[0]*N

for i in range(M):
    if ACflag[pS[i][0] -1] ==0:
        if pS[i][1]=="AC":
            ACflag[pS[i][0] -1] = 1
        else:
            WAcount[pS[i][0] -1] +=1

for j in range(N):
    WAcount[j] *= ACflag[j]

print(sum(ACflag), sum(WAcount))

Solution (Python):
n,m = map(int,input().split())
ACcount = 0
WAcount = 0
WA = []
AC = []
for i in range(n):
  WA.append(0)
  AC.append(1)
for i in range(m):
  p,s = input().split()
  p = int(p)
  if s == "WA":
    if WA[p-1] >= 0:
      WA[p-1] += 1
  if s == "AC":
    ACcount += AC[p-1]
    AC[p-1] = 0
    if WA[p-1] >= 0:
       WAcount += WA[p-1]
       WA[p-1] = -1
print(ACcount,WAcount)

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

for i in range(m):
    x[i], y[i] = map(str, input().split())




ans_ac = [0]*n
ans_wa = [0]*n
ac = 0
wa = 0


for i in range(m):
    a = int(x[i])-1
    
    if y[i] == "WA":
        ans_wa[a] += 1
    if y[i] == "AC" and ans_ac[a] == 0:
        ac += 1
        ans_ac[a] = 1
        wa += ans_wa[a]

print(ac, wa)

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

for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    if cnt[p] == -1:
        continue
    elif s == 'AC':
        ac += 1
        wa += cnt[p]
        cnt[p] = -1
    else:
        cnt[p] += 1
print(ac, wa)

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

w=0
for i in range (n):
  w+=ac[i]*wa[i]
print(sum(ac),w)

Solution (Python):
import numpy as np
n,m = map(int,input().split())
ac, wa = [0] * n, [0] * n
for i in range(m):
  p,s = input().split()
  p = int(p)-1
  if s == 'AC':
    ac[p] = 1
  if s == 'WA' and ac[p] == 0:
    wa[p] += 1
print('{} {}'.format(sum(ac), np.dot(ac, wa)))

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
def inputS(): return input().rstrip().decode()
readlines = sys.stdin.buffer.readlines 


N, M = map(int, input().split())
flag = ["WA"]*(N+1)
WAcnt = [0]*(N+1)
ans = {"AC":0, "WA":0}

for _ in range(M):
  i, s = input().split()
  ind = int(i)
  s = s.decode()
  if flag[ind] == "AC":
    continue
  if s == "AC":
    ans[s] += 1
    ans["WA"] += WAcnt[ind]
    flag[ind] = s
  else:
    WAcnt[ind] += 1
    

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

Solution (Python):
from collections import defaultdict

N, M = map(int, input().split())
submit = defaultdict(int)
ac = 0
penalty = 0
accepted = [False] * N

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

for i in range(N):
    if accepted[i]:
        penalty += submit[i]

print(" ".join(map(str, [ac, penalty])))

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

check = [0]*N
count_W = 0
count_A = 0
for i in range(M):
    p, S = input().split()
    p = int(p)
    if check[p-1] != -1:
        if S == "WA":
            check[p-1] = check[p-1] + 1
        else:
            count_A = count_A + 1
            count_W = count_W + check[p-1]
            check[p-1] = -1
print(count_A, count_W)

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

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

Solution (Python):
n,m=map(int,input().split())
A=[[0,0] for i in range(n)] 
AC=0
pen=0
for i in range(m):
    a,b=map(str,input().split())
    a=int(a)
    if b=="AC":
        A[a-1][0]=1
    elif b=="WA" and A[a-1][0]==0:
        A[a-1][1]+=1
for i in range(n):
    if A[i][0]==1:
        AC+=1
        pen+=A[i][1]
print(AC,pen)

Solution (Python):
f=lambda:input().split()
n,m=map(int,f())
sa,lw=set(),[0]*n
for _ in range(m):
  p,s=f()
  if p in sa: continue
  if s=='AC': sa.add(p)
  else: lw[int(p)-1]+=1
print(len(sa),sum(lw[int(p)-1] for p in sa))

Solution (Python):
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
sa,lw=set(),[0]*n
for _ in range(m):
  p,s=input().split()
  if p in sa: continue
  if s=='AC': sa.add(p)
  else: lw[int(p)-1]+=1
print(len(sa),sum(lw[int(p)-1] for p in sa))

Solution (Python):
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
lp,ls=[],[]
for _ in range(m):
  p,s=input().split()
  lp.append(int(p)-1)
  ls.append(s=='AC')
la,lw=[0]*n,[0]*n
for p,s in zip(lp,ls):
  if la[p]<1:
    if s: la[p]=1
    else: lw[p]+=1
print(sum(la),sum(w*a for a,w in zip(la,lw)))

Solution (Python):
N,M=map(int,input().split())
PS=[input().split() for i in range(M)]
ACzumi=set()
WA_count=[]
for i in range(M):
    if not PS[i][0] in ACzumi:
        if PS[i][1]=="AC":
            ACzumi.add(PS[i][0])
        else:
            WA_count.append(PS[i][0])
yokei=0            
for i in range(len(WA_count)):
    if not WA_count[i] in ACzumi:
        yokei+=1
        

print(len(ACzumi),len(WA_count)-yokei)

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

WAlist = [0]*N
ACflag = [0]*N

for i in range(M):
    p, s = input().split()
    p=int(p)
    if ACflag[p-1] == 0:
        if   s == "WA":
            WAlist[p-1] += 1
        elif s == "AC":
            ACflag[p-1] = 1
            
WA = 0
for i in range(N):
    if ACflag[i]==1:
        WA += WAlist[i]
    
print(sum(ACflag), WA)

Solution (Python):

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

AC = 0
WA = 0
A = [[0]*2 for _ in range(N)] 
for _ in range(M):
	p, S = input().split() 
	ip = int(p)
	if A[ip-1][1] == 0:
		if S == "WA":
			A[ip-1][0] += 1
		else:
			A[ip-1][1] = 1
			AC += 1
	else:
		continue

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

print(AC,WA)