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 sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = MAP()
ac = [0] * N
pn = [0] * N
for i in range(M):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC':
        ac[p] = 1
    elif s == 'WA' and not ac[p]:
        pn[p] += 1

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

print(sum(ac), sum(pn))

Solution (Python):
from collections import defaultdict
n,m = map(int,input().split())
d = defaultdict(lambda:['WA',0])

for _ in range(m):
    i,j = input().split()
    if d[i][0] == 'WA':
        d[i][1] += 1
        d[i][0] = j
        
res = [d[x][1]-1 for x in d if d[x][0]=='AC']
print(len(res),sum(res))

Solution (Python):
import numpy as np

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

ac = 0
wa = 0
test = [0] * N
count = [0] * N
for i in range(M):
    p_i, s_i = input().split(" ")
    p_i = int(p_i) - 1
    if s_i == "AC":
        test[p_i] = 1
    elif test[p_i] != 1:
        count[p_i] += 1

test = np.array(test)
count = np.array(count)

score = np.sum(test)
pena = np.sum(test * count)
print(str(int(score)) + " " + str(int(pena)))

Solution (Python):
import collections
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, M = map(int, input().split())
        pS = []
        for _ in range(M):
            tmp = input().split()
            pS.append((int(tmp[0]), tmp[1]))

        ac = 0
        wa = 0
        s_dict = collections.defaultdict(lambda: True)
        wa_dict = collections.defaultdict(int)
        for i in range(M):
            p, s = pS[i]
            if s_dict[p]:
                if s == "AC":
                    ac += 1
                    wa += wa_dict[p]
                    s_dict[p] = False
                else:
                    wa_dict[p] += 1

        print(*[ac, wa])



if __name__ == '__main__':
    AtCoder().main()

Solution (Python):
n, m = map(int, input().split())
cnt = 0
ac_cnt = 0
wa_cnt = 0
ans_flag = 0
bp = -1
d = []
for i in range(m):
    a, b = map(str, input().split())
    d.append([a, b])
d.sort(key=lambda x: x[0])

for i in range(m):
    p, s = d[i][0], d[i][1]
    
    if bp != p:
        cnt = 0
        ans_flag = 0
    if s == 'WA' and ans_flag == 0:
        cnt += 1
    elif s == 'AC' and ans_flag == 0:
        ac_cnt += 1
        wa_cnt += cnt
        cnt = 0
        ans_flag = 1
    bp = p

print(ac_cnt, wa_cnt)

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

import numpy as np
a = np.zeros(N)
flag = np.zeros(N)

for i in range(M):
  p, S = map(str, input().split())
  p = int(p)
  if flag[p-1] == 0 and S == "WA":
    a[p-1] += 1
  if S == "AC":
    flag[p-1] = 1
a = [int(np.sum(flag)), int(np.sum(flag * a))]
print(*a)

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

for i in range(0,M):
    pi,si = input().split()
    pi = int(pi)
    if ac[pi-1] == 0:
        if si == "WA":
            pn[pi-1] += 1
        else:
            ac[pi-1] = 1

for i in range(0,N):
    if ac[i] == 0:
        pn[i] = 0
        
print(sum(ac),sum(pn))

Solution (Python):

import numpy as np


DEBUG = False
dprint = print if DEBUG else lambda x : x

N, M = [int(str) for str in input().strip().split()]
ps = [[int(str) if str.isdecimal() else str for str in input().strip().split()] for _ in range(M)]

wa_d = dict()
ac_d = dict()
true_count = 0
pena = 0
for i in ps:
    if not i[0] in ac_d:
        if i[1] == 'WA':
            wa_d[i[0]] = wa_d.get(i[0], 0) + 1
        else:
            ac_d[i[0]] = None
            true_count += 1
            pena += wa_d.get(i[0], 0)

print(true_count, pena)

Solution (Python):
n,m = map(int,input().split())
ps = []
for i in range(m):
  p,s = input().split()
  p = int(p)
  ps.append((p,s))
  
ans = [[0]*2 for _ in range(n)]
for i in range(m):
    if ans[ps[i][0]-1][1] == 1:
        continue
    if ps[i][1] == "AC":
        ans[ps[i][0]-1][1] = 1
        continue
    if ps[i][1] == "WA":
        ans[ps[i][0]-1][0]  += 1
        
p = 0
q = 0
for i in ans:
    if i[1] == 1:
        q += 1
        p += i[0]

print(q,p)

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

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

ac = 0
wa = dict()

done = dict()

for i in range(M):
    p, S = input().split()
    if p in done:
        continue
    if S == "AC":
        ac+= 1
        done[p] = True
    else:
        if p not in wa:
            wa[p] = 0
        wa[p] += 1

_wa = 0
for x in wa:
    if x in done:
        _wa += wa[x]

print(ac, _wa)

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

seikai_list = ['0'] * n
seikai_count = 0
penalty_count_list = [0] * n

for i in range(m):
    q_number = int(a_list[i][0]) - 1
    
    if seikai_list[q_number] == '0' and a_list[i][1] == 'AC':
        seikai_count += 1
        seikai_list[q_number] = '1'
    
    if seikai_list[q_number] == '0' and a_list[i][1] == 'WA':
        penalty_count_list[q_number] += 1 

penalty_count = 0
for i in range(n):
    if seikai_list[i] == '1':
        penalty_count += penalty_count_list[i]

print(seikai_count, penalty_count)

Solution (Python):

"""
Created on Sun Jan 12 21:17:12 2020

@author: over-
"""

N,M=map(int,input().split())
AC=[0]*N
WA=[0]*N
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]==0:
            WA[p]+=1
            
for i in range(N):
    if AC[i]==0:
        WA[i]=0
        
print(sum(AC),sum(WA))

Solution (Python):


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

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

matome = []
for i in range(N):
    matome.append([0, 0])

for (p, S) in answer:
    if S == 'AC':
        matome[p-1][0] = 1
    elif S == 'WA':
        if matome[p-1][0] == 0:
            matome[p-1][1] += 1


correct = 0
penalty = 0
for [ac, wa] in matome:
    if ac == 1:
        correct += 1
        penalty += wa

print('{} {}'.format(correct, penalty))

Solution (Python):
n, m = map(int, input().split())
is_ac = [False]*n
ac = 0
was = [0]*n
for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s=='AC' and (not is_ac[p]):
        ac += 1
        is_ac[p] = True
    if s=='WA' and (not is_ac[p]):
        was[p] += 1
wa = 0
for i in range(n):
    if is_ac[i]:
        wa += was[i]
print(ac, wa)

Solution (Python):
N, M = map(int,input().split())
list = [list(input().split()) for i in range(M)]
flag_ac = [0] * N
penalty_score = [0] * N
ans_seitou = 0
ans_penalty = 0
for i in range(M):
    if list[i][1] == "AC":
        if flag_ac[int(list[i][0]) - 1] == 0:
            flag_ac[int(list[i][0]) - 1] = 1
            ans_seitou += 1
            ans_penalty += penalty_score[int(list[i][0]) - 1]

    if list[i][1] == "WA":
        if flag_ac[int(list[i][0]) - 1] == 0:
            penalty_score[int(list[i][0]) - 1] += 1

print(ans_seitou,ans_penalty)

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


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

AC_set = set()
WA_dic = {}

AC_cnt = 0
WA_cnt = 0

for p, ans in sub:
    p = int(p)
    if ans == 'AC':
        if p not in AC_set:
            AC_cnt += 1
            AC_set.add(p)
    else:
        if p not in AC_set:
            if p not in WA_dic:
                WA_dic[p] = 1
            else:
                WA_dic[p] += 1

for p in AC_set:
    WA_cnt += WA_dic.get(p, 0)

print(AC_cnt, WA_cnt)

Solution (Python):
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
AC=[False]*n
WA=[0]*n
for _ in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=='AC':
        AC[p]=True
    else:
        if AC[p]:
            continue
        WA[p]+=1
ac=0
wa=0
for i in range(n):
    if AC[i]:
        ac+=1
        wa+=WA[i]
print(ac,wa)

Solution (Python):
n, m = map(int, input().split())
table = {}
ac = 0
pena = 0
pena_arr = [0 for _ in range(n + 1)]
for _ in range(m):
    a, b = input().split()
    a = int(a)
    if a in table:
        continue
    if b == "AC":
        ac += 1
        table[a] = True
    elif b == "WA":
        pena_arr[a] += 1
pena = 0
for i in range(1, n + 1):
    if pena_arr[i] > 0 and i in table:
        pena += pena_arr[i]
print(ac, pena)

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

Solution (Python):
N,M=map(int,input().split())
T=[]
frag=[0 for y in range(N)]
p=[0 for y in range(N)]
a=0
for i in range(M):
  s=list(map(str,input().split()))
  T.append(s)
for i in range(M):
  if T[i][1]=='WA' and frag[int(T[i][0])-1]==0:
    p[int(T[i][0])-1]=p[int(T[i][0])-1]+1
  elif T[i][1]=='AC' and frag[int(T[i][0])-1]==0:
    a=a+1
    frag[int(T[i][0])-1]=1
for i in range(N):
  if frag[i]==0:
    p[i]=0
print(a,sum(p))

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

for i in range(m):
    p, s = input().split()
    idx = int(p) -1
    if ac[idx]==1:
        continue
    else:
        if s == 'AC':
            ac[idx]=1
        else:
            wa[idx] += 1
w = sum([v for i, v in enumerate(wa) if ac[i]==1])
a = sum(ac)
print(a, w)

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

WA=[]
solved=[]
for i in range(1,N+1):
   a=[i,0]
   WA.append(a)
   b=[i,False]
   solved.append(b)

AC_count=0
WA_count=0
for i in range(M):
   if results[i][1]=="WA":
      if solved[results[i][0]-1][1]==False:
         WA[results[i][0]-1][1]+=1

   elif results[i][1]=="AC":
      if solved[results[i][0]-1][1]==False:
         AC_count+=1
         solved[results[i][0]-1][1]=True

for i in range(N):
   if solved[i][1]==True:
      WA_count+=WA[i][1]

print(AC_count,WA_count)

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

Solution (Python):
import numpy as np

def resolve():
    N, M = map(int, input().split())
    ACs = np.zeros(N)
    WAs = np.zeros(N)
    
    c_ac = 0
    c_wa = 0

    for i in range(M):
        p, s = input().split()
        if s == "WA":
            if ACs[int(p) - 1] == 0:
                WAs[int(p) - 1] += 1
        if s == "AC":
            ACs[int(p) - 1] += 1
            if ACs[int(p) - 1] == 1:
                c_ac += 1
                c_wa += WAs[int(p) - 1]

    print(int(c_ac), int(c_wa))
    

if __name__ == "__main__":
    resolve()

Solution (Python):
N,M=map(int,input().split())
p=[]
s=[]
for i in range(M):
  p0,S0=map(str,input().split())
  p0=int(p0)-1
  p+=[p0]
  s+=[S0]
awlist=[0 for i in range(N)]
walist=[0 for i in range(N)]
wacount=0
account=0
for i in range(M):
  if s[i]=='WA' and awlist[p[i]]==0:
    walist[p[i]]+=1
  elif s[i]=='AC' and awlist[p[i]]==0:
    account+=1
    awlist[p[i]]=1
    wacount+=walist[p[i]]
Answer=[account,wacount]
print(*Answer)

Solution (Python):
n, m = list(map(int, input().split()))
ac = [0]*n
wa = [0]*n
for i in range(m):
    pi, si = input().split()
    if si == 'AC':
        ac[int(pi)-1] += 1
    elif ac[int(pi)-1] == 0:
        wa[int(pi)-1] += 1

nac = 0
nwa = 0

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

print(nac, nwa)

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

p_list = [0]*N
cor_list = [0]*N 

cor_ans = 0
pen_ans = 0

for i in range(M):
    p,s = input().split()
    p = int(p)
    if (s == "AC") and (cor_list[p-1]) == 0:
        cor_ans += 1
        pen_ans = pen_ans + p_list[p-1]
        cor_list[p-1]  = 1
    elif s == "WA":
        p_list[p-1] += 1


print(cor_ans,pen_ans)

Solution (Python):



def solve(*args: str) -> str:
    n, m = map(int, args[0].split())
    AC = [False]*n
    WA = [0]*n
    for p, s in map(str.split, args[1:]):
        i = int(p)-1
        if s == 'AC':
            AC[i] |= True
        elif s == 'WA' and not AC[i]:
            WA[i] += 1

    penalty = 0
    for i, ac in enumerate(AC):
        if ac:
            penalty += WA[i]

    return '{} {}'.format(sum(AC), penalty)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Solution (Python):
n,m = list(map(int,input().split()))
lis = [[] for _ in range(n)]
for i in range(m):
    pc,s = input().split()
    p = int(pc)
    if s=='AC':lis[p-1].append(1)
    else:      lis[p-1].append(0)

a=w=0
for i in range(n):
    tempwa=0
    for j in lis[i]:
        if j==0:tempwa+=1
        elif j==1:
            a+=1
            w += tempwa
            break
print(a,w)

Solution (Python):


N, M = map(int, input().split(' '))
ac_stk = [0 for _ in range(N)]
wa_stk = [[True, 0] for _ in range(N)]
pair = []
for _ in range(M):
    p, s = input().split(' ')
    pair.append((int(p), s))
ac = 0
wa = 0

for p, s in pair:
    if s == 'WA':
        wa_stk[p-1][1] += 1
    elif s == 'AC':
        ac_stk[p-1] = 1
        if wa_stk[p-1][0]:
            wa += wa_stk[p-1][1]
            wa_stk[p-1][0] = False

print('{} {}'.format(sum(ac_stk), wa))

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

problems = [0]*n
accurate = 0
penalty = 0

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

    if s == "AC" and problems[p-1] != -1:
         
         penalty += problems[p-1]
         accurate += 1
         problems[p-1] = -1
    elif s == "WA" and problems[p-1] != -1:
        
        problems[p-1] += 1

print(accurate,penalty)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)

ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    n,m=mis()
    lis=[0]*(n+1)
    ww=[0]*(n+1)
    wa=0
    for _ in range(m):
        P,s=input().split()
        p=int(P)
        if lis[p]==0:
            if s=='WA': ww[p]+=1
            else:
                lis[p]+=1
                wa+=ww[p]
    print(sum(lis),wa)


if __name__ == "__main__":
    main()

Solution (Python):
N, M = list(map(int, input().split()))
NList = [0] * N
ACSum = 0
WASum = 0
for i in range(M):
  p, s = input().split()
  p = int(p)
  if s == 'WA' and NList[p-1] != -1:
    NList[p-1] += 1
  elif s == 'AC' and NList[p-1] != -1:
    ACSum += 1
    WASum += NList[p-1]
    NList[p-1] = -1
    
print(str(ACSum) + ' ' + str(WASum))

Solution (Python):
N, M = map(int, input().split())
ans = {}
for i in range(M):
    p, s = list(input().split())
    int(p)
    if p not in ans:
        ans[p] = {"AC": False, "WA": 0}
    if s == "AC":
        ans[p]["AC"] = True
        continue
    if s == "WA":
        if ans[p]["AC"] == True:
            continue
        ans[p]["WA"] += 1
ac = 0
wa = 0
for k, v in ans.items():
    if v["AC"]:
        ac += 1
        wa += v["WA"]
print(ac, wa)

Solution (Python):
N, M = [int(i) for i in input().split()]
pSlist = []
for i in range(M):
    buff = input().split()
    p = int(buff[0])-1
    S = str(buff[1])
    pSlist.append([p,S])

AClist = [0 for i in range(N)]
WAlist = [0 for i in range(N)]
AClist_dummy = [0 for i in range(N)]

for p,S in pSlist:
    if AClist[p]==0 and S=="AC":
        AClist[p]=1
    elif AClist[p]==0 and S=="WA":
        WAlist[p]+=1

sumWA = 0
for p in range(N):
    if AClist[p]==1:
        sumWA+=WAlist[p]

print(sum(AClist),sumWA)

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

for i in range(m):
    p[i],s[i]=input().split()

p=list(map(int,p))

for i in range(m):
    if k[p[i]-1]:
        if s[i]=="AC":
            k[p[i]-1]=False
            ac+=1
        else:
            wa[p[i]-1]+=1

for i in range(n):
    if k[i]:
        wa[i]=0

print(ac,sum(wa))

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

num = [0]*N
TorF = [False] * N

for i in range(M):
    p, S = map(str, input().split())
    p = int(p)
    if S == "WA" and TorF[p-1] == False:
        num[p-1] += 1
    elif S == "AC":
        TorF[p-1] = True

maru = 0
pena = 0

for i in range(N):
    if TorF[i]:
        maru += 1
        pena += num[i]

print(maru, pena)

Solution (Python):
n, m = map(int, (input().split()))
got = set()
watbl = [0]*n

ans = 0

for i in range(m):
    p, s = input().split()
    p = int(p)
    if p in got:
        continue
    else:
        if s == 'AC':
            got.add(p)
            ans += 1
        else:
            watbl[p - 1] += 1

pn = 0
for v in got:
    pn += watbl[v - 1]
print(ans, pn)

Solution (Python):
n,m=map(int,input().split())
ac=0
wa=0
ans=[True]*n
wa=[0]*n
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=="AC" and ans[p]:
        ans[p]=False
        ac+=1
    elif s=="WA" and ans[p]:
        wa[p]+=1
cnt=0
for i in range(n):
    if not ans[i]:
        cnt+=wa[i]
print(ac,cnt)

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

Solution (Python):
import collections


def solve(n, m, hist):
    cor = 0
    pen = 0
    for p, tries in hist.items():
        for i, t in enumerate(tries):
            if t == 'AC':
                cor += 1
                pen += i
                break
    return '{0} {1}'.format(cor, pen)


def input_to_int():
    return [int(r) for r in input().split(' ')]


if __name__ == "__main__":
    n, m = input_to_int()
    hist = collections.defaultdict(list)
    for _ in range(m):
        p, s = input().split(' ')
        hist[p].append(s)
    print(solve(n, m, hist))

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

for _ in range(M):
    x = input().split()
    p = int(x[0])
    s = x[1]
    if s == 'AC':
        if ac[p] == 0:
            ac[p] = 1
            ac_total += 1
            wa_total += wa[p]
    else:
        wa[p] += 1
print(ac_total, wa_total)

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

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

for i in range(m):
    p,s=ps[i]
    if s=="WA":
        if x[p][0]==0:
            x[p][1]+=1
        else:
            pass
    else:
        if x[p][0]==0:
            x[p][0]=1
            
        else:
            pass
c1,c2=0,0
for i in range(n):
    if x[i][0]==1:
        c1+=1
        c2+=x[i][1]
print(c1,end=" ")
print(c2)

Solution (Python):
import numpy as np
N, M = map(int,input().split())
ansAC = 0
ansWA = 0
zeros = np.zeros(N)
is_solved = set()
for _ in range(M):
    p, S = input().split()
    p = int(p)
    if S == "WA":
        if p-1 not in is_solved:
            zeros[p-1] += 1
    else:
        is_solved.add(p-1)
ansAC = len(is_solved)
ansWA = int(sum(zeros[list(is_solved)]))
print(ansAC, ansWA)

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())
  p[i] = int(p[i])

ng = [0]*n
ok = [0]*n
for i in range(m):
  if ok[p[i]-1] == 0 and s[i] =='AC':
    ok[p[i]-1] += 1
  elif ok[p[i]-1] == 0 and s[i] =='WA':
    ng[p[i]-1] += 1
result = [x * y for (x, y) in zip(ok, ng)]
print(str(sum(ok)) + ' ' + str(sum(result)))

Solution (Python):
N, M = map(int, input().split())
P = [0] * M
S = [""] * M
for i in range(M):
    p, s = input().split()
    P[i] = int(p)
    S[i] = s
ACP = [[0,0] for _ in range(N)]
for i in range(M):
    if ACP[P[i]-1][1] == 1:
        pass
    elif S[i] == "WA":
        ACP[P[i]-1][0] += 1
    else:
        ACP[P[i]-1][1] = 1
ac = 0
pena = 0
for i in range(N):
    ac += ACP[i][1]
    pena += ACP[i][0] * ACP[i][1]
print(ac, pena)

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

Solution (Python):
N, M = map(int, input().split())
ACflags = [False] * N
WAcounts = [0] * N
for _ in range(M):
    p, s = input().split()
    p = int(p) - 1
    if ACflags[p]:
        continue
    if s == 'AC':
        ACflags[p] = True
    else:
        WAcounts[p] += 1

ansAC = 0
ansWA = 0
for i in range(N):
    if ACflags[i]:
        ansAC += 1
        ansWA += WAcounts[i]
print(ansAC, ansWA)

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

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

Solution (Python):
import queue
import copy
import math


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

ac = set()
submits_count_until_AC = {} 

for i in range(0, M):
    p, S = input().split()

    prev = None

    if p in ac:
        continue

    if p in submits_count_until_AC:
        prev = submits_count_until_AC[p]
    else:
        prev = 0

    if S == "AC":
        ac.add(p)
    else:
        submits_count_until_AC[p] = prev + 1


ac_coount = len(ac)

pena = 0

for k, v in submits_count_until_AC.items():
    if k in ac:
        pena += v

print("{} {}".format(ac_coount, pena))

Solution (Python):
import numpy as np
N, M = map(int, input().split(' '))
suc_list = np.zeros(N, dtype=np.uint8)
fai_count = np.zeros(N, dtype=np.int32)
for i in range(M):
    p, s = input().split(' ')
    p = int(p) - 1
    if suc_list[p] == 0:
        if s == 'WA':
            fai_count[p] += 1
        else:
            suc_list[p] = 1

print('{} {}'.format(np.sum(suc_list), np.sum(fai_count[suc_list == 1])))

Solution (Python):
def A():
    c = input()
    print(chr(ord(c)+1))

def B():
    temp = [int(k) for k in input().split()]
    N = temp[0]
    K = temp[1]
    M = temp[2]
    A = [int(k) for k in input().split()]
    ans = M*N - sum(A)
    if ans <= K:
        print(max(0, ans))
    else:
        print(-1)

from collections import defaultdict
def C():
    temp = [int(k) for k in input().split()]
    N = temp[0]
    M = temp[1]
    penal = defaultdict(int)
    P = []
    S = []
    for i in range(M):
        temp = input().split()
        P.append(int(temp[0]))
        S.append(temp[1])
    ac_problems = set()

    for i in range(M-1, -1, -1):
        if P[i] not in ac_problems and S[i] == 'AC':
            ac_problems.add(P[i])
        elif P[i] in ac_problems:
            if S[i] == 'WA':
                penal[P[i]] += 1
            elif S[i] == 'AC':
                penal[P[i]] = 0
    
    print(len(ac_problems), sum(penal.values()))
C()

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

def main():
    n, m = map(int, input().split())
    ac = 0
    wa = 0
    b = defaultdict(lambda: 0)
    for _ in range(m):
        q, j = input().split()
        if b[q] != -1 and j == 'AC':
            ac += 1
            if q in b:
                wa += b[q]
                b[q] = -1
        else:
            if b[q] != -1:
                b[q] += 1
    print(ac, wa)

if __name__ == "__main__":
    main()

Solution (Python):
def main():
    n, m = list(map(int, input().split()))
    ac_list = [0] * n
    wa_list = [0] * n
    for _ in range(m):
        tmp = input().split()
        contest_num = int(tmp[0]) - 1
        if ac_list[contest_num]:
            continue
        ret = tmp[1]
        if ret == "AC":
            ac_list[contest_num] = 1
        else:
            wa_list[contest_num] += 1

    penalty = [wa_list[i] if ac_list[i] else 0 for i in range(n)]

    print(sum(ac_list), sum(penalty))


if __name__ == '__main__':
    main()

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

for i in range(M):
    p, s = input().split()

    if p in my_dict:
        my_dict[p].append(s)
    else:
        my_dict[p] = [s]

a_count = 0
w_count = 0

for key, items in my_dict.items():
    flag = False
    buf = 0
    for s in items:
        if s == "AC":
            a_count += 1
            flag = True
            break
        else:
            w_count += 1
            buf += 1
    if not flag:
        w_count -= buf

print(a_count, w_count)

Solution (Python):
n,m=map(int,input().split())
l=[]
ansac=0
answa=0
a=[0]*(n)
d=dict()
for i in range(m):
  p,s=input().split()
  l.append([int(p),s])
for i in range(m):
  if l[i][1]=='AC':
    if l[i][0] not in d:
      ansac+=1
      answa+=a[l[i][0]-1]
      d[l[i][0]]=0
  else:
    a[l[i][0]-1]+=1
print(ansac,answa)

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

Solution (Python):



def main():
    n, m = map(int, input().split())
    ac_count = [0 for _ in range(n)]
    wa_count = [0 for _ in range(n)]

    for i in range(m):
        pi, si = input().split()
        pi = int(pi)
        pi -= 1

        if si == 'WA':
            if ac_count[pi] == 0:
                wa_count[pi] += 1
        else:
            if ac_count[pi] == 0:
                ac_count[pi] = 1

    total_ac = sum(ac_count)
    total_wa = 0

    for ac, wa in zip(ac_count, wa_count):
        if ac == 1:
            total_wa += wa

    print(total_ac, total_wa)


if __name__ == '__main__':
    main()

Solution (Python):
from copy import deepcopy

if __name__ == '__main__':
    a,b  = map(int, input().split())
    count = [0]*a
    count2 = [-1]*a

    ans1 = 0
    ans2 =0
    for i in range(b):
        s = input()
        s = s.split(" ",)
        s1 = int(s[0])-1
        s2 = s[1]
        if count[s1]  >-1:
            if s2 == "AC":
                count2[s1] = deepcopy(count[s1])
                count[s1] = -1
            else:
                count[s1] = count[s1] +1

    for i in count2:
        if i > -1:
            ans1 = ans1+1
            ans2 = ans2 + i
    print(str(ans1) + " "+str(ans2) )

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

x = [0] * N
result = [0] * N

ans = 0
wa = 0

for i in range(M):
    p, S = input().split()
    if (result[int(p) - 1] == 0) and (S == "WA"):
        x[int(p)-1] += 1
    if (result[int(p) - 1] == 0) and (S == "AC"):
        result[int(p)-1] = 1

ans = sum(result)

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

print(ans, wa)

Solution (Python):
n,m = map(int, input().split())
p = [0]*n
q = [False]*n
for _ in range(m):
  v,s = input().split()
  v = int(v)-1
  if q[v]: continue
  if s == 'AC': q[v] = True
  else: p[v] += 1
print(sum(q),sum(p[i] for i in range(n) if q[i]))

Solution (Python):
import sys
from pprint import pprint

def solve(n, m, p, s):
    wrong = [0] * n
    solved = {}
    for i in range(n):
        solved[i] = False

    n_ac = 0
    n_wa = 0
    for i in range(m):
        if not solved[p[i]-1] and s[i] == "WA":
            wrong[p[i]-1] += 1
        if not solved[p[i]-1] and s[i] == "AC":
            n_ac += 1
            solved[p[i]-1] = True
            n_wa += wrong[p[i]-1]
    print(n_ac, n_wa)


if __name__ == '__main__':
    n, m = map(int,sys.stdin.readline().strip().split(" "))
    p = [0] * m
    s = [""] * m
    for i in range(m):
        p_i, s[i]  = sys.stdin.readline().strip().split(" ")
        p[i] = int(p_i)
    
    solve(n, m, p, s)

Solution (Python):
N ,M = map(int, input().split())
li = []
num = [0] * (N + 1)
for i in range(M):
    li.append(list(input().split()))
countAC = 0
countWA = 0
for i in range(M):
    if num[int(li[i][0])] != -1:
        if li[i][1] == "AC":
            countAC += 1
            countWA +=num[int(li[i][0])]
            num[int(li[i][0])] = -1
        else:
            num[int(li[i][0])] += 1

print(countAC, countWA)

Solution (Python):
from collections import defaultdict

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

submit = defaultdict(list)
for i in range(M):
    p,s = map(str, input().split())
    submit[p].append(s)


wa = 0
ac = 0
for k in submit.keys():
    if "AC" in submit[k]:
        for i in range(len(submit[k])):
            if submit[k][i] == "WA":
                wa += 1
            elif submit[k][i] == "AC":
                ac += 1
                break
        


print(ac, wa)

Solution (Python):
N,M = map(int,input().split())
AC = [False]*N
WA = [0]*N
for m in range(M):
    p,s = map(str,input().split())
    p = int(p)
    if AC[p-1] == False and s == 'WA':
        WA[p-1] += 1
    elif AC[p-1] == False and s == 'AC':
        AC[p-1] = True
indexes = [i for i, x in enumerate(AC) if x == False]
for i in indexes:
    WA[i] = 0
print(AC.count(True),sum(WA))