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())
k=[0]*(n+1)
wa_count=0
ac_count=0
for i in range(m):
    p,s=map(str,input().split())
    if s== "AC":
        if k[int(p)]!=-1:
            wa_count=wa_count+k[int(p)]
            k[int(p)]=-1
            ac_count += 1
    else:
        if k[int(p)]!=-1:
            k[int(p)]+= 1
            
ac=str(ac_count)
wa=str(wa_count)
print(ac+" "+wa)

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

for _ in range(m):
    sub = input().split()
    p, s = int(sub[0]), sub[1]
    lst = prb[p]
    if lst[-1] == 1:
        pass
    elif s == "WA":
        lst.append(0)
    elif s == "AC":
        lst.append(1)
    prb[p] = lst

ac_prb = [lst for lst in prb if lst[-1] == 1]
ac_num = len(ac_prb)
pe_num = -2*ac_num

for prb in ac_prb:
    pe_num += len(prb)

print(ac_num, pe_num)

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

for _ in range(m):
    sub = input().split()
    p, s = int(sub[0]), sub[1]
    lst = prb[p]
    if lst[-1] == 1:
        pass
    elif s == "WA":
        lst.append(0)
    elif s == "AC":
        lst.append(1)
    prb[p] = lst

ac_prb = [lst for lst in prb if lst[-1] == 1]
ac_num = len(ac_prb)
pe_num = -2*ac_num

for prb in ac_prb:
    pe_num += len(prb)

print(ac_num, pe_num)

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

resultdict = {}
count_ans,count_pena = 0,0

for sub in PS :
    resultdict.setdefault(sub[0],{"AC":0, "WA":0})
    if resultdict[sub[0]]["AC"] == 0 :
        resultdict[sub[0]][sub[1]] += 1

for v in resultdict.values() :
    count_ans += v["AC"]
    if v["AC"] == 1 :
        count_pena += v["WA"]

print(count_ans,count_pena)

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

ans = [0] * N
AC = 0
WA = 0

for P in Q:
    p = int(P[0])
    S = P[1]
    if ans[p - 1] == "END":
        continue
    if S == "WA":
        ans[p - 1] += 1
    if S == "AC":
        WA += ans[p - 1]
        AC += 1
        ans[p - 1] = "END"


print(AC, WA)

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

ans = [0] * N
AC = 0
WA = 0

for P in Q:
    p = int(P[0])
    S = P[1]
    if ans[p - 1] == "END":
        continue
    if S == "WA":
        ans[p - 1] += 1
    if S == "AC":
        WA += ans[p - 1]
        AC += 1
        ans[p - 1] = "END"


print(AC, WA)

Solution (Python):
N,M = map(int, input().split())
r = {}
a = {}
for i in range(M):
    l = input().split()
    p = int(l[0])
    q = l[1]
    w = q + str(p)
    if r.get(p) == 'AC':
        pass
    else:
        r.update([(p, q)])
        if a.get(w) != None:
            a[w] += 1
        else:
            a.update([(w, 1)])
ks = [k for k, v in r.items() if v == 'AC']
wa = 0
ac = 0
for i in ks:
    wk = 'WA' + str(i)
    ak = 'AC' + str(i)
    if a.get(wk) != None:
        wa += a[wk]
    ac += a[ak]
print(ac, wa)

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


problems = {}
correct = 0
penalty = 0
for i in range(M):
    p,s = map(str,input().split())
    p = int(p)
   
    if p not in problems.keys():
        if s == 'AC':
            problems[p] = -1
            correct += 1
        else: 
            problems[p] = 1
    else: 
        if s == 'AC' and problems[p] != -1: 
            penalty += problems[p]
            problems[p] = -1
            correct += 1
        elif s == 'WA' and problems[p] != -1:
            problems[p] += 1
            
print(correct,penalty)

Solution (Python):
from collections import defaultdict

n, m = map(int, input().split())
ac_dict = defaultdict(int)
wa_dict = defaultdict(int)
ac_p, wa_p = set(), set()
for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC':
        ac_p.add(p)
        ac_dict[p] = 1
    elif ac_dict[p] != 1:
        wa_p.add(p)
        wa_dict[p] += 1

wa = 0
for pi in ac_p:
    wa += wa_dict[pi]

print(sum(ac_dict.values()), wa)

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

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

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

    if s=="AC":
        ac[p]=True
    else:
        if not ac[p]:
            wa[p]+=1

a=0
b=0

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

print(a,b,sep=" ")

Solution (Python):
n,m=map(int,input().split())
dp=[0]*(n+1)
charge=[0]*(n+1)
cnt=0
ans=0
for i in range(m):
  q=input()
  if dp[int(q[:-3])]!="A" and q[-2]=="W":
    dp[int(q[:-3])]="W"
    charge[int(q[:-3])]+=1
  elif dp[int(q[:-3])]!="A" and q[-2]=="A":
    dp[int(q[:-3])]="A"
    ans+=1
    cnt+=charge[int(q[:-3])]
    charge[int(q[:-3])]=0
print(ans,cnt)

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



def main():
    n, m = [int(i) for i in input().strip().split()]
    accepted = [False] * (n + 1)
    WA_cnt = [0] * (n + 1)
    for _ in range(m):
        p, s = input().strip().split()
        p = int(p)
        if accepted[p]:
            continue
        else:
            if s == "AC":
                accepted[p] = True
            elif s == "WA":
                WA_cnt[p] += 1
    ac = 0
    wa = 0
    for res, cnt in zip(accepted, WA_cnt):
        if res:
            ac += 1
            wa += cnt

    print(ac, wa)

    return


if __name__ == "__main__":
    main()

Solution (Python):


from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float("inf")


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    ac = [0 for _ in range(N)]
    for i in set(x[0] for x in zip(p, S) if x[1] == "AC"):
        ac[i - 1] = 1
    wa = 0
    for x in zip(p, S):
        ac[x[0] - 1] &= x[1] == "WA"
        wa += ac[x[0] - 1]
    return f'{len(set(x[0] for x in zip(p,S) if x[1] == "AC"))} {wa}'


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    p = [int()] * (M)  
    S = [str()] * (M)  
    for i in range(M):
        p[i] = int(next(tokens))
        S[i] = next(tokens)
    print(f"{solve(N, M, p, S)}")


if __name__ == "__main__":
    main()

Solution (Python):
from collections import defaultdict


def mapt(fn, *args):
    return tuple(map(fn, *args))

  
def main():
    n, m = mapt(int, input().split(" "))
    
    ac = defaultdict(int)
    pena = defaultdict(int)
    for _ in range(m):
        index, symbol = input().split(" ")
        index = int(index)
        index -= 1
        if ac[index]: continue

        if symbol == "AC": ac[index] = 1
        elif symbol == "WA": pena[index] += 1
    
    AC = PENA = 0
    for i in range(n):
        AC += ac[i]
        if ac[i]: PENA += pena[i]
    print(AC, PENA)

main()

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

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

aced = [ False for _ in range( n ) ]
wa_cnt = [ 0 for _ in range( n ) ]

for i in range( m ):
    if s[ i ] == "AC":
        aced[ p[ i ] - 1 ] = True
    elif aced[ p[ i ] - 1 ] == False:
        wa_cnt[ p[ i ] - 1 ] += 1

ac_cnt = 0
penalty = 0

for i in range( n ):
    if aced[ i ] == True:
        ac_cnt += 1
        penalty += wa_cnt[ i ]

print( ac_cnt, penalty )

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush

sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,m = inpm()

P = []
S = []
for i in range(m):
    tmp = input().split()
    P.append(int(tmp[0]))
    S.append(tmp[1])

AC = [0]*100001
WA = [0]*100001

for i in range(m):
    if S[i] == 'AC':
        AC[P[i]] = 1
    elif S[i] == 'WA' and AC[P[i]] != 1:
        WA[P[i]] += 1

cnt_ac = 0
cnt_wa = 0
for i in range(1,n+1):
    if AC[i] == 1:
        cnt_ac += 1
        cnt_wa += WA[i]

print(cnt_ac,cnt_wa)

Solution (Python):
import sys
sys.setrecursionlimit(10**7) 
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque, defaultdict


from collections import Counter

from itertools import accumulate,combinations,permutations,product

from heapq import heapify,heappop,heappush

from functools import reduce,lru_cache

from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): 
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    

    
    N, M = map(int, input().split())
    
    
    S = tuple(tuple(input().split()) for i in range(M)) 
    l=[0]*N
    was=[0]*N
    for p,s in S:
        p=int(p)-1
        if s=="AC":
            l[p]=1
        else:
            if not l[p]:
                was[p]+=1
    wa=0
    for i in range(N):
        if l[i]:
            wa+=was[i]
            
    print(sum(l),wa)




if __name__ == "__main__":
    main()

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

ans, pen = 0, 0
for i in range(n):
    if ac[i]:
        ans += 1
        pen += wa[i]
print(ans, pen)

Solution (Python):
n,m = map(int,input().split())
if m != 0:
    l = [list(input().split()) for i in range(m)]
    p,s = [list(i) for i in zip(*l)]
t = [0] * n
ac = 0
wa = 0
for i in range(m):
    if s[i] == 'WA' and t[int(p[i])-1] != 'AC':
        t[int(p[i])-1] += 1
    elif s[i] == 'AC' and t[int(p[i])-1] != 'AC':
        ac += 1
        wa += t[int(p[i])-1]
        t[int(p[i])-1] = 'AC'
    else:
        pass
print(ac,wa)

Solution (Python):
import sys
from collections import defaultdict

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

is_ac = [False] * N
wa = [0] * N

for i in range(M):
    p, S = input().split()
    n = int(p) - 1
    if not is_ac[n] and S == "AC":
        is_ac[n] = True
    if not is_ac[n] and S == "WA":
        wa[n] += 1

cnt_ac = is_ac.count(True)
cnt_wa = 0
for i in range(N):
    if is_ac[i]:
        cnt_wa += wa[i]
print(cnt_ac, cnt_wa)

Solution (Python):
n,m=map(int,input().split())
p=[0 for i in range(n)]
penalty=[0 for i in range(n)]
acc=0
for i in range(m):
  a,b=input().split()
  a=int(a)
  a-=1

  if (p[a]==0 or p[a]=='WA') and b=='AC':
    acc+=1
    p[a]='AC'
  elif (p[a]==0 or p[a]=='WA') and b=='WA':
    penalty[a]+=1
    p[a]='WA'

for i in range(n):
  if p[i] == 'WA' or p[i] == 0:
    penalty[i]=0

print(acc,sum(penalty))

Solution (Python):
n,m=map(int,input().split())
a=[[0,0] for _ in range(n+1)]
x=[]
for i in range(m):
    x.append(list(input().split()))
    x[i][0]=int(x[i][0])
for i in range(m):
    if x[i][1]=="AC":
        a[x[i][0]][1]=1
    else:
        if a[x[i][0]][1]==1:
            continue
        else:
            a[x[i][0]][0]+=1
c=0
d=0
for i in range(n+1):
    c+=a[i][1]
    if a[i][1]:
        d+=a[i][0]
print(c,d)

Solution (Python):

n, m = (int(x) for x in input().split())


ans_list = [0] * (n + 1)

WA_list = [0] * (n + 1)

ans = 0
penalty = 0

for id in range(m):
    
    query = list(map(str, input().split()))
    
    if query[1] == 'AC':
        if ans_list[int(query[0])] == 0 :
            ans_list[int(query[0])] = 1
            ans += 1
            penalty = penalty + WA_list[int(query[0])]
    
    else:
        if ans_list[int(query[0])] == 0 :
            WA_list[int(query[0])] += 1

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

Solution (Python):
def main():
  N, M = list(map(lambda n: int(n), input().split(" ")))
  if M == 0:
    print("0 0")
    return 0

  AC = [0] * N
  WA = [0] * N

  for i in range(M):
    tmp = input().split(" ")
    No = int(tmp[0]) - 1
    if tmp[1] == "AC":
      AC[No - 1] = 1
    if tmp[1] == "WA" and AC[No - 1] == 0:
      WA[No - 1] += 1
  
  totAC = sum(AC)
  totWA = sum([AC[i] * WA[i] for i in range(len(AC))])
  print(totAC, end=" ")
  print(totWA)
    
main()

Solution (Python):
import numpy as np

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

P = []
S = []

for _ in range(M):
    p, s = input().split()
    P.append(int(p))
    S.append(s)

AC = np.zeros(N)
WA = np.zeros(N)

for i in range(M):
    if AC[P[i]-1] == 0:
        if S[i] == 'WA':
            WA[P[i]-1] += 1
        else:
            AC[P[i]-1] += 1

WA[AC == 0] = 0

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

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

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

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if ac_done[p-1]:
        continue
    else:
        if s == 'AC':
            ac += 1
            wa += l[p-1]
            ac_done[p-1] = True
        else:
            l[p-1] += 1 

print(ac,wa)

Solution (Python):
N, M = map(int, input().split())
a = [False] * N
w = [0] * N
for i in range(M):
    p, S = input().split()
    if S == 'AC':
        a[int(p)-1] = True
    elif not a[int(p)-1]:
        w[int(p)-1] += 1
print(a.count(True), sum([w[i] if a[i] else 0 for i in range(N)]))

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    P = [0] * M
    S = [""] * M
    for i in range(M):
        PS = input().split()
        P[i], S[i] = int(PS[0]), PS[1]

    AC = [False] * (N + 1)
    WA = [0] * (N + 1)
    n_AC = 0
    n_WA = 0
    for p, s in zip(P, S):
        if AC[p]:
            continue
        if s == "AC":
            n_AC += 1
            AC[p] = True
            n_WA += WA[p]
        else:
            WA[p] += 1

    print(n_AC, n_WA)


if __name__ == "__main__":
    main()

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

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

Solution (Python):
N, M = map(int, input().split())
lst = [input().split() for _ in range(M)]
pe = [0] * N 
wa = [0] * N 

for l in lst:
    if l[1] == "WA" and wa[int(l[0])-1] != -1:
        
        wa[int(l[0])-1] += 1
    if l[1] == "AC" and wa[int(l[0])-1] != -1:
        
        pe[int(l[0])-1] = wa[int(l[0])-1]
        wa[int(l[0])-1] = -1

ans = []
ans.append(str(wa.count(-1)))
ans.append(str(sum(pe)))
print(" ".join(ans))

Solution (Python):
N, M = map(int, input().split())
PS = [input().split() for _ in range(M)]
Pena = [0] * (N+1)
pena = 0
ac = 0
for p, s in PS:
    p = int(p)
    if s == "AC":
        if Pena[p] >= 0:
            ac += 1
            pena += Pena[p]
            Pena[p] = -999999999
    else:
        Pena[p] += 1
print(ac, pena)

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

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

for i in range(m):
    p,s = input().split()
    p = int(p)
    if ac[p-1]:
        continue
    
    if s == "WA":
        wa[p-1] += 1
    else:
        ac[p-1] = True
        count_ac += 1
        count_wa += wa[p-1]
        
print(count_ac,count_wa)

Solution (Python):
N, M = map(int, input().split())
corret_list = [False] * (N+1)
wa_number = [0] * (N+1)
true_ans = 0
penalty = 0
for _ in range(M):
    P, S = input().split()
    P = int(P)
    if S == 'AC':
        if not corret_list[P]:
            true_ans += 1
            corret_list[P] = True
            continue
        else:
            continue
    else:
        if not corret_list[P]:
            wa_number[P] += 1
            continue
for i in range(len(corret_list)):
    if corret_list[i]:
        penalty += wa_number[i]
print(true_ans, penalty)

Solution (Python):
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 not ac[p]:
            wa[p] += 1

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

Solution (Python):
from collections import defaultdict

def main():
    N, M = map(int, input().split())
    a = [input().split() for _ in range(M)]
    ac_count = [0] * (N + 1)
    wa_count = defaultdict(lambda:0)
    ac, wa = 0, 0

    for q_no, ans in a:
        q_no = int(q_no)
        if ac_count[q_no] == 0:
            if ans == "AC":
                ac_count[q_no] = 1
                ac += 1
                wa += wa_count.get(q_no, 0)
            else:
                wa_count[q_no] += 1
    
    print(ac, wa)

if __name__ == '__main__':
    main()

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

AC=[0]*(N+1)
WA=[0]*(N+1)
ans=0
for _ in range(M):
    p,s=input().split()
    p=int(p)
    if AC[p]==0:
       if s=='AC':
            AC[p]=1
            ans+=WA[p]
       else:
            WA[p]+=1
print(sum(AC),ans)

Solution (Python):
N,M,*f = open(0).read().split()
N = int(N)
M = int(M)
pS = [f[i*2:i*2+2] for i in range(M)]
accepted = [0] * (N+1)
wrong = [0] * (N+1)
penalty = [0] * (N+1)
for p,S in pS:
    i = int(p)
    if accepted[i] == 0:
        if S == 'AC':
            penalty[i] = wrong[i]
            accepted[i] = 1
        else:
            wrong[i] += 1
print(sum(accepted),sum(penalty))

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

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

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

ansac = pen = 0
answa = [0] * N
flg = [0] * N

for i in range(M):
    if flg[p[i]-1] == 1:
        continue
    if S[i] == 'WA':
        answa[p[i]-1] += 1
    elif S[i] == 'AC':
        ansac += 1
        pen += answa[p[i]-1]
        flg[p[i]-1] = 1

print(ansac, pen)

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

answa = 0
flg = [0] * N

for i in range(M):
    if flg[p[i]-1] == 1:
        continue
    if S[i] == 'WA':
        flg[p[i]-1] -= 1
    elif S[i] == 'AC':
        answa -= flg[p[i]-1]
        flg[p[i]-1] = 1

print(flg.count(1), answa)

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

ac_cnt = 0
wa_cnt = 0
d = {}

for _ in range(m):
  p, s = input().split()
  if p not in d:
    d[p] = [s]
  else:
    d[p].append(s)
    
for i in d:
  if 'AC' in d[i]:
    ac_cnt += 1
    wa_cnt += d[i].index('AC')
print(ac_cnt, wa_cnt)

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

for _ in range(M):
    p, s = sys.stdin.readline().split()
    p = int(p) - 1
    if s == "AC":
        ac[p] = 1
    else:
        if not ac[p]:
            wa[p] += 1
acnum = sum(ac)
wanum = sum([c for i, c in enumerate(wa) if ac[i] == 1])
print(acnum, wanum)

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

C={}
acc=0
wac=0
for i in range(m):
    p0,s = input().split()
    
    p = int(p0)
    if p in C :
        if C[p]!=-1:
            C[p]+=1
    else:
        C[p]=1

    if s=="AC" and C[p]!=-1:
        acc+=1
        wac+=C[p]-1
        C[p]=-1
        

print( acc, wac )

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

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

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

print(a.count(1),wa)

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

ac = wa = 0
ac_lis = [False] * N
wa_cnt = [0] * N
for _ in range(M):
  p, s = input().split()
  p = int(p) - 1

  if s == "AC":
    if not ac_lis[p]:
      ac += 1
      wa += wa_cnt[p]
      ac_lis[p] = True
  else:
    if not ac_lis[p]:
      wa_cnt[p] += 1

print(ac, wa)

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

AC=[0]*(N+1)
WA=[0]*(N+1)
ans=0
for _ in range(M):
    p,s=input().split()
    p=int(p)
    if AC[p]==0:
       if s=='AC':
            AC[p]=1
            ans+=WA[p]
       else:
            WA[p]+=1
print(sum(AC),ans)

Solution (Python):
n,m=list(map(int,input().split()))
ps=[input().split() for _ in range(m)]
plst=[0]*n
penlst=[0]*n
pen=0
ans=0

for p,s in ps:
    p=int(p)-1
    if plst[p]:
        continue
    if s=='AC':
        ans+=1
        pen+=penlst[p]
        plst[p]=1
    else:
        penlst[p]+=1

print('{} {}'.format(ans,pen))

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

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

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

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

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

wa = 0 
for a,w in zip(AC,WA):
  wa+=w*a

print(sum(AC),wa)

Solution (Python):
import sys
input()
ac,wa={*()},{}
nc=np=0
for ln in sys.stdin:
    p,S=ln.split()
    if p in ac:
        continue
    if p not in wa:
        wa[p]=0
    if S=='AC':
        ac.add(p)
        nc+=1
        np+=wa[p]
    else:
        wa[p]+=1

print(nc,np)

Solution (Python):
import sys
input()
d={}
nc=np=0
for ln in sys.stdin:
    p,S=ln.split()
    if p not in d:
        d[p]=[0,0]
    if not d[p][0]:
        if S=='AC':
            d[p][0]=1
            nc+=1
            np+=d[p][1]
        else:
            d[p][1]+=1

print(nc,np)

Solution (Python):
N, M = list(map(int, input().split()))
AC = set()
WA = {}

for _ in range(M):
	p, S = input().split()
	p = int(p)
	if S == 'AC':
		AC.add(p)
	else:
		if p not in AC:
			if p in WA:
				WA[p] += 1
			else:
				WA[p] = 1
wa = 0
for k, v in WA.items():
	if k in AC:
		wa += v

print(len(AC), wa)

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

acdic = {}

wadic = [0] * 10 ** 5

ac = 0
wa = 0

for ps in PS:
    p = int(ps[0])
    s = ps[1]

    if not p in acdic:
        if s == "WA":
            wadic[p] += 1
        else:
            ac += 1
            acdic[p] = True
            wa += wadic[p]


print(ac, wa)

Solution (Python):
N,M=map(int,input().split())
List = []
for i in range (M):
  List.append(list(map(str, input().split())))
resList= [False]*N
res = 0
waList = [0]*N
for i in range(M):
  if resList[int(List[i][0])-1] == False:
    if List[i][1] == "AC":
      resList[int(List[i][0])-1] = True
      res += waList[int(List[i][0])-1] 
    else:
      waList[int(List[i][0])-1] += 1
print(resList.count(True),res)

Solution (Python):
N, M = map(int, input().split())
ac = 0
pena = 0
count = [0 for _ in range(N+1)]
for _ in range(M):
  p, S = input().split()
  p = int(p)
  if S == 'AC':
    if count[p] > -1:
      pena += count[p]
      ac += 1
    count[p] = -10**5-1
  else:
    count[p] += 1
  
print(ac, pena)

Solution (Python):
import sys

input = sys.stdin.readline
_, m = map(int, input().split())

d = {}
for _ in range(m):
    p, s = input().split()
    p = int(p)
    if p in d:  
        if d[p][0]:  
            continue
        if s == "WA":
            d[p][1] += 1
        else:
            d[p][0] = True
    else:  
        if s == "WA":
            d[p] = [False, 1]  
        else:
            d[p] = [True, 0]

cnt_ac = 0
cnt_wa = 0
for v in d.values():
    if v[0]:
        cnt_ac += 1
        cnt_wa += v[1]

print(cnt_ac, cnt_wa)

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

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

solved = [False] * (n + 1)
wa = [0] * (n + 1)

for i in range(m):
    p_str, s = input().split()
    p = int(p_str)
    if s == "AC":
        solved[p] = True
    else:
        if not solved[p]:
            wa[p] += 1


ac = 0
pe = 0

for i in range(1, n+1):
    if solved[i]:
        ac += 1
        pe += wa[i]

print(ac, pe)

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

dic = {}
for p, s in pss:
    if p not in dic:
        dic[p] = (0, 0)
    ac, wa = dic[p]
    if ac == 0 and s == 'AC':
        dic[p] = (ac + 1, wa)
    elif ac == 0 and s == 'WA':
        dic[p] = (ac, wa + 1)

dic = {k:dic[k] for k in dic if dic[k][0] == 1}

ac = sum(dic[k][0] for k in dic)
wa = sum(dic[k][1] for k in dic)
print(ac, wa)

Solution (Python):
N, M = [int(s) for s in input().split(' ')]
ac = 0
wa = 0
result = dict()
fail = dict()
for m in range(M):
    p, s = input().split(' ')
    if p in result and result[p] == 'AC':
        continue
    if s == 'WA':
        fail[p] = fail.get(p, 0) + 1
        result[p] = s
    elif s == 'AC': 
        ac += 1
        wa += fail.get(p, 0) 
        result[p] = s
    
print(str(ac) + ' ' + str(wa))

Solution (Python):
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

def main():
    n,m = map(int, input().split())
    dic = {}
    for i in range(1,n+1):
        dic[i] = 0
    ac = 0
    wa = 0
    for i in range(m):
        p,s = input().split()
        p = int(p)
        if dic[p] == 0: 
            if s == "WA":
                dic[p] += 1
            else:
                dic[p] = "AC"
                ac += 1
        elif dic[p] == "AC":
            pass
        else: 
            if s == "WA":
                dic[p] += 1
            else:
                wa += dic[p]
                dic[p] = "AC"
                ac += 1
    print(ac,wa)



if __name__=="__main__":
    main()

Solution (Python):
n, m = [int(i) for i in input().split()]
lst_pena = [[False, 0] for i in range(n)]
cnt_pena = 0
cnt_ca = 0
for i in range(m):
	n, m = [j for j in input().split()]
	n = int(n) - 1
	if lst_pena[n][0] == False and m == 'AC':
		lst_pena[n][0] = True
		cnt_ca += 1
	elif lst_pena[n][0] == False and m == 'WA':
		lst_pena[n][1] += 1
sum_pena = sum([i[1] if i[0] else 0 for i in lst_pena])
print(f'{cnt_ca} {sum_pena}')

Solution (Python):
N, M = [int(s) for s in input().split()]
AC = [0] * 10 ** 5
WA = [0] * 10 ** 5

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

print(sum(AC), sum(map(lambda x: x[0] * x[1], zip(AC, WA))))

Solution (Python):
import os, sys, re, math

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

successes = [0] * N
penalties = [0] * N
for i in range(M):
    (p, s) = [n for n in input().split()]
    if s == 'AC':
        successes[int(p) - 1] = 1
    else:
        if successes[int(p) - 1] == 0:
            penalties[int(p) - 1] += 1

for i in range(N):
    if successes[i] == 0:
        penalties[i] = 0

print('%s %s' % (sum(successes), sum(penalties)))