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())
p = [list(input().split())for _ in range(m)]

q = [0]*n
count = 0
wacount = 0

for i in range(m):
  if p[i][1] == "WA":
    q[int(p[i][0])-1] += 1
  elif p[i][1] =="AC":
    if q[int(p[i][0])-1] < 0:
      continue
    else:
      count += 1
      wacount += q[int(p[i][0])-1]
      q[int(p[i][0])-1] -= 10**6

print("{} {}".format(count,wacount))

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]
N,M=map(int, input().split())
l=[0]*N
w=[0]*N
for i in range(M):
    p,S=input().split()
    p=int(p)
    if S=="AC":
        l[p-1]=1
    else:
        if not l[p-1]:
            w[p-1]+=1
W=0
for i in range(N):
    W+=l[i]*w[i]
print(sum(l),W)

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

ans = 0
flag = [0] * n

for _ in range(m):
    P, s = input().split(' ')
    p = int(P) - 1
    if s == 'AC':
        if flag[p] != -1:
            ans += flag[p]
            flag[p] = -1
    elif flag[p] != -1:
        flag[p] += 1

print(flag.count(-1), ans)

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

    cnt = [0] * n
    not_solved = [True] * n

    ac = 0
    wa = 0
    for _ in range(m):
        p, s = input().split()
        p = int(p) - 1
        if s == 'AC':
            if not_solved[p]:
                not_solved[p] = False
                ac += 1
                wa += cnt[p]
        else:
            if not_solved[p]:
                cnt[p] += 1

    print(ac, wa)


if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())
isAC = [False] * (N+1)
penalties = [0] * (N+1)
ac, penalty = (0, 0)
for _ in range(M):
  p, s = input().split()
  p = int(p)
  if s == "AC":
    if not isAC[p]:
      isAC[p] = True
      ac += 1
      penalty += penalties[p]
  else:
    penalties[p] += 1
print(ac, penalty)

Solution (Python):
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' and ac[p] == 0:
        wa[p] += 1
print(sum(ac), sum(ac[i] * wa[i] for i in range(N)))

Solution (Python):



from collections import Counter
def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n, m = rli()
    wa = [0 for _ in range(n)]
    ac = [0 for _ in range(n)]
    for i in range(m):
        p, s = rl()
        p = int(p)
        p -= 1
        if ac[p] > 0:
            continue
        if s == "WA":
            wa[p] += 1
        else:
            ac[p] = 1
    sac = sum(ac)
    swa = sum(wa[i] for i in range(len(wa)) if ac[i] > 0)
    print(sac, swa)


if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())
AC_q = [0] * N
WA_num = [0] * N
for _ in range(M):
    p, S = input().split()
    p = int(p)
    if S == "AC":
        AC_q[p - 1] = 1
    else:
        if AC_q[p - 1] == 0:
            WA_num[p - 1] += 1
AC = 0
WA = 0
for i in range(N):
    if AC_q[i] == 1:
        AC += 1
        WA += WA_num[i]
print(AC, WA)

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

lst = []
solved = set()
for i in range(M):
    pstr, s = list(input().split())
    pnum = int(pstr)
    lst.append((pnum, s))
    if s == 'AC':
        solved.add(pnum)

seen = set()
wa = 0
for (p, s) in lst:
    if p in solved and p not in seen:
        if s == 'AC':
            seen.add(p)
        else:
            wa += 1
print("{} {}".format(len(solved), wa))

Solution (Python):
from collections import defaultdict

n, m = map(int, input().split())
AC = defaultdict(int)
WA = defaultdict(int)

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC':
        AC[p] = 1
    elif s == 'WA' and AC[p] == 0:
        WA[p] += 1
num_ac, num_wa = 0, 0
for p, c in AC.items():
    if c == 1:
        num_ac += 1
        num_wa += WA[p]
print(num_ac, num_wa)

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):
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':
        if ac[p] == 0:
            wa[p] += 1

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

ac = sum([item>0 for item in ac])
wa = sum(wa)
print(ac, wa)

Solution (Python):
from heapq import heappush, heappop
from collections import deque
import re
import math
import functools
import itertools
import fractions

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29


def mk1d(n, val=INF):
    return [val for i in range(n)]

def mk2d(h, w, val=INF):
    return [[val for i in range(w)]for i in range(h)]

DIV = 998244353


def convolve(a, b):
    p, g = 1107296257, 5
    n0, n1 = len(a), len(b)
    n = 1 << (max(n0, n1) - 1).bit_length() + 1
    a = a + [0] * (n-n0)
    b = b + [0] * (n-n1)
    w = pow(g, (p - 1) // n, p)
    invw = pow(w, p-2, p)

    def fft(f):
        d = n // 2
        v = w
        while d >= 1:
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, u * (f[j] - f[j+d]) % p
                u = u * v % p
            v = v * v % p
            d //= 2

    def ifft(f):
        d = 1
        while d < n:
            v = pow(invw, n // (2 * d), p)
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j+d] *= u
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, (f[j] - f[j+d]) % p
                u = u * v % p
            d *= 2

    fft(a), fft(b)
    for i in range(n):
        a[i] = a[i] * b[i] % p
    ifft(a)
    invn = pow(n, p - 2, p)
    return [a[i] * invn % p for i in range(n0 + n1 - 1)]


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

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
    return functools.reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return functools.reduce(lcm_base, numbers, 1)

def main():
    N,M = isRaw()
    isAC = [False]*N
    pena = [0]*N
    for idx in range(M):
        p,S = ssRaw()
        p = int(p)
        if S=="AC":
            isAC[p-1]=True
        if S=="WA":
            if not isAC[p-1]:
                pena[p-1]+=1
    numPena = sum([pena[idx] for idx in range(N) if isAC[idx]])
    return str(sum(isAC))+" "+str(numPena)
        


if __name__ == "__main__":
    print(main())

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

Solution (Python):

import sys
INF = float("inf")


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    seito = 0
    pena = 0

    AC = [False] * (N+1)
    WA = [0]*(N+1)
    for pp, ss in zip(p, S):
        if ss == "AC":
            if AC[pp] == False:
                AC[pp] = True
        else:
            if AC[pp] == False:
                WA[pp] += 1
    tot = 0
    for i in range(N+1):
        if AC[i]:
            tot += WA[i]
    print(sum(AC), tot)

    return


def main():

    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)
    solve(N, M, p, S)


if __name__ == '__main__':
    main()

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

data = [0] * n
count = [0] * n
for i in range(m):
    p,s = input().split()
    p = int(p)
    p = p - 1
    if s == "AC":
        data[p] = 1
    elif s == "WA" and data[p] == 0:
        count[p] += 1

x = 0

for i in range(n):
    x += data[i] * count[i]

print(sum(data),x)

Solution (Python):
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
    elif ac[p] == 0:
        wa[p] += 1
    
print(sum(ac),sum([[0,wa[x]][ac[x]] for x in range(N)]),sep=" ")

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

seikai = set()
pena_num = 0
pena = [0] * (n + 1)

for i in range(m):
    p, s = map(str, input().split())
    if s == 'WA':
        if p not in seikai:
            pena[int(p)] += 1
        else:
            continue
    else:
        if p not in seikai:
            pena_num += pena[int(p)]
            seikai.add(p)
        else:
            continue
print(len(seikai), pena_num)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    res = [[] for _ in range(N)]
    for _ in range(M):
        p, s = LS()
        p = int(p)
        p -= 1
        res[p].append(s)
    seito = 0
    pena = 0
    for re in res:
        ac = False
        re_pena = 0
        for s in re:
            if s == 'AC':
                seito += 1
                ac = True
                break
            else:
                re_pena += 1
        if ac:
            pena += re_pena
    print(seito, pena)

main()

Solution (Python):
n, m = map(int, input().split())
a = set([])

n = [0] * 10 ** 5
ac, wa = 0, 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if p not in a:
        if s == "WA":
            n[p] += 1
        else:
            a.add(p)
            ac += 1
            wa += n[p]
print(ac, wa)

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

Solution (Python):
from collections import defaultdict

N ,M = list(map(int,input().split(" ")))
ac = 0
wa = 0
ac_probs = set()
wa_probs = set()
di =defaultdict(lambda :0)
for _ in range(M):
    p, s =  input().split(" ")
    if s == "AC":
        ac_probs.add(p)
    elif s == "WA":
        if p not in ac_probs:
            di[p] += 1

for temp in ac_probs:
    wa += di[temp]

print(len(ac_probs),wa)

Solution (Python):
import sys
sys.setrecursionlimit(10**9)
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int,input().split()))
N, M = inpl()
AC = [False]*N
WA = [0]*N
for i in range(M):
    p, S = input().split()
    p = int(p)
    if S == 'AC':
        AC[p-1] = True
    else:
        if not AC[p-1]:
            WA[p-1] += 1
ans = 0
acs = 0
pens = 0
for i in range(N):
    if AC[i]:
        acs += 1
        pens += WA[i]
print(acs, pens)

Solution (Python):


import sys
sys.setrecursionlimit(300000)


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    a = 0
    w = 0
    ac = [0] * (N + 1)
    wa = [0] * (N + 1)
    for i in range(M):
        if S[i] == 'WA' and not ac[p[i]]:
            wa[p[i]] += 1
        if S[i] == 'AC' and not ac[p[i]]:
            ac[p[i]] = 1
            a += 1
            w += wa[p[i]]
    print(a, w)
    return

def main():
    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)
    solve(N, M, p, S)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
n, m = [int(i) for i in sys.stdin.readline().split()]
_set = set()
ac = 0
wa = 0
ls = []
for i in range(m):
    p, s = [i for i in sys.stdin.readline().split()]
    if s == "AC":
        _set.add(p)
    ls.append([p, s])

new_set = set()
for p, s in ls:
    if s == "AC":
        new_set.add(p)
    if s == "WA" and p in _set and p not in new_set:
        wa += 1
print(len(_set), wa)

Solution (Python):

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

flag = [True] * N
wa = [0] * N

for i in range(M):

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

    if s == "WA":

        if flag[p]:
            wa[p] += 1

    if s == "AC":

        flag[p] = False

ac = 0
wa2 = 0
for i in range(N):
    if not flag[i]:
        ac += 1
        wa2 += wa[i]



print (ac,wa2)

Solution (Python):
import sys
input=sys.stdin.readline
a=b=0
n,m=map(int,input().split())
ans=[0]*n
for i in range(m):
	p,s=input().rstrip().split()
	p=int(p)
	if ans[p-1]<=0:
		if s=="AC":
			a+=1
			b+=-ans[p-1]
			ans[p-1]=1
		else:
			ans[p-1]-=1
print(a,b)

Solution (Python):
import sys
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep = ' ', end = '\n'):
    print(*var, file=sys.stderr, end = end, sep = sep)

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))

from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

n, m = I()

a = [0] * (n + 1)
b = [0] * (n + 1)

for i in range(m):
    p, v = input().split()
    p = int(p)
    if b[p] == 0 and v == 'WA':
        a[p] += 1
    elif b[p] == 0 and v == 'AC':
        b[p] = 1

ans = 0
for i in range(n + 1):
    if b[i] == 1:
        ans += a[i]
print(sum(b), ans)

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

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

for p, s in ps:
    p = int(p)

    if ac[p]:
        continue

    if s == "WA":
        wa[p] += 1
    else:
        ac[p] = 1

ans = [0, 0]

for a, w in zip(ac, wa):
    if a:
        ans[0] += 1
        ans[1] += w

print(*ans)

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

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)
    if s=="AC":
        AC[p-1]=1
    else:
        if AC[p-1]==0:
            WA[p-1]+=1
ans_AC=sum(AC)
ans_WA=0
for i in range(n):
    if AC[i]==1:
        ans_WA+=WA[i]
print(ans_AC,ans_WA)

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

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

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

acs = 0
total_p = 0
penalties = [0] * N
cleared = [False] * N
for _ in range(M):
	p, s = input().split()
	p = int(p) - 1
	if s == "AC":
		if not cleared[p]:
			cleared[p] = True
			total_p += penalties[p]
			acs += 1
	else:
		if not cleared[p]:
			penalties[p] += 1

print(acs, total_p)

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

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

num_penals = [0 for _ in range(n+1)]
seikai = 0
ayamari = 0
for _ in range(m):
    nn, res = input().split(" ")
    nn = int(nn)
    if num_penals[nn] is not None:
        if res == "AC":
            seikai += 1
            ayamari += num_penals[nn]
            num_penals[nn] = None
        else:
            num_penals[nn] += 1

out = "%d %d" % (seikai, ayamari)            
print(out)

Solution (Python):
N,M=map(int,input().split())
ac=[False for i in range(N+1)] 
wa=[0 for i in range(N+1)]
for i in range(M):
    p,S=input().split()
    p=int(p)
    if not ac[p]:
        if S=='AC':
            ac[p]=True
        elif S=='WA':
            wa[p]+=1
ans_ac=sum(ac)
ans_p=sum([wa[i] for i in range(N+1) if ac[i]])




print(ans_ac,ans_p)

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

cntAC = 0
cntWA = 0

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

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

    if AC[p] == 0:
        if s == 'AC':
            cntAC += 1
            cntWA += WA[p]
            AC[p] += 1
        else:
            WA[p] += 1

print(cntAC, cntWA, sep=' ')

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

ps = []
ans = [False for i in range(N)]
count = [0 for i in range(N)]
for i in range(M):
    p,s = list(input().split())
    p = int(p)
    if s == 'AC':
        ans[p-1] = True
    else:
        if not ans[p-1]:
            count[p-1] += 1
cans = 0
cac = ans.count(True)
for i in range(N):
    if ans[i]:
        cans += count[i]
print(cac,cans)

Solution (Python):
import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().strip().split()]
ac = [0] * n
cnt = [0] * n
for i in range(m):
    p, s = [x for x in input().strip().split()]
    p = int(p)
    if ac[p-1]:
        continue
    if s == 'AC':
        ac[p-1] = 1
    elif s == 'WA':
        cnt[p-1] += 1

for i in range(n):
    cnt[i] *= ac[i]
    
print(sum(ac), sum(cnt))

Solution (Python):
n, m = map(int, input().split())
ps, ss = list(), list()
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    ps.append(p)
    ss.append(s)


num = [0 for i in range(n)]
correct, penalty = 0, 0

for i in range(m):
    p, s = ps[i], ss[i]
    if num[p] == -1:
        continue

    num[p] += 1
    if s == 'AC':
        correct += 1
        penalty += (num[p] - 1)
        num[p] = -1

print(correct, penalty)

Solution (Python):
import sys, math

def input():
    return sys.stdin.readline()[:-1]

def main():
    N, M = map(int,input().split())
    A = [0 for k in range(N)]
    P = [0 for k in range(N)]
    b = 0
    for _ in range(M):
        p, S = input().split()
        if S == "AC":
            if A[int(p)-1] == 0:
                A[int(p)-1] = 1
                b += P[int(p)-1]
        else:
            if A[int(p)-1] == 0:
                P[int(p)-1] += 1
    print(sum(A),b)

if __name__ == '__main__':
    main()

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

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

check_AC = [False] * N
for i in range(M):
    p, s = map(str, input().split())
    p = int(p)
    if s == "AC":
        check_AC[p-1] = True
    P[i] = p
    S[i] = s

ans_AC = 0
ans_WA = 0
for i in range(M):
    if check_AC[P[i]-1]:
        if S[i] == "AC":
            ans_AC += 1
            check_AC[P[i] - 1] = False
        else:
            ans_WA += 1
    else:
        continue
print(ans_AC, ans_WA)

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

N, M = map(int, input().split())
P = [0]*(N+1)
Q = [0]*(N+1)

for _ in range(M):
    f, b = map(str, input().rstrip().split())
    a = int(f)
    if b == "WA":
        if not Q[a]:
            P[a] += 1
    else:
        Q[a] = 1

p = 0
for i in range(N+1):
    if Q[i]:
        p += P[i]
print(sum(Q), p)

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

N, M = map(int, input().split())
is_AC = [False]*N
pena = [0]*N

for _ in range(M):
    pi, si = input().split()
    pi = int(pi)
    
    if si=='AC':
        is_AC[pi-1] = True
    else:
        if is_AC[pi-1]:
            continue
        else:
            pena[pi-1] += 1

ans0 = is_AC.count(True)
ans1 = 0

for i in range(N):
    if is_AC[i]:
        ans1 += pena[i]

print(ans0, ans1)

Solution (Python):

import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    N,M = LMIIS()
    S = list()
    P = list()
    counts = [-1]*N
    for i in range(M):
        p,s = input().split()
        p = int(p)-1

        if s == 'AC' and counts[p] < 0:
            counts[p] *= -1
        else:
            if counts[p] < 0:
                counts[p] -= 1
    numac = 0
    nump = 0
    for c in counts:
        if c >= 0:
            numac += 1
            nump += c-1
    print(numac,nump)





if __name__ == '__main__':
    main()

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

Solution (Python):


import collections
get = lambda: int(raw_input().strip())
gets = lambda: map(int, raw_input().strip().split())
getss = lambda x: [gets() for _ in xrange(x)]


N, M = gets()
count = collections.Counter()
penalty = 0
ac = set()
for i in xrange(M):
    p, s = raw_input().split()
    p = int(p)
    if p in ac: continue
    if s == 'AC':
        ac.add(p)
        penalty += count[p]
    else:
        count[p] += 1
print len(ac), penalty

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

Solution (Python):
from collections import Counter
N, M = map(int, input().split())
acdict = {}
wacounter = Counter()

for m in range(M):
    p, s = input().split()
    if s == 'AC':
        acdict[p] = 1
    else:
        if acdict.get(p):
            continue
        wacounter[p] += 1
ans_ac = len(acdict)
ans_wa = sum([wacounter[key] for key in acdict.keys()])
print(ans_ac, ans_wa)

Solution (Python):
n, m = map(int,input().split())
alist=[0]*n
blist=[0]*n
pena=0
ok=0

for i in range(m):
    p, s =input().split()
    toi=int(p)-1
    if s=='AC':
        if alist[toi]!=1:
            alist[toi]=1
            pena+=blist[toi]
            ok+=1
    else:
        if alist[toi]!=1:
            blist[toi]+=1

print(ok, pena)

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

penalty = 0
nums = [0] * N
isACs = [False] * N
for _ in range(M):
    p, ss = input().split()
    p = int(p) - 1
    if ss == 'WA':
        nums[p] += 1
    else:
        if not isACs[p]:
            penalty += nums[p]
        isACs[p] = True

numAC = isACs.count(True)
print(numAC, penalty)

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

C=[0]*(N+1)
L=[0]*(N+1)
W=0

for x,y in S:
    if y=="AC":
        L[int(x)]=1

for x,y in S:
    x=int(x)
    if L[x]==0:
        continue

    if y=="AC":
        C[x]=1

    if C[x]==0 and y=="WA":
        W+=1

print(sum(L),W)

Solution (Python):
n,m = map(int,input().split())
a = [list(input().split()) for i in range(m)]
ans = [0,0]
solved = [0]*(n+1)
penalty = [0]*(n+1)
for i in range(m):
  x = int(a[i][0])
  if a[i][1] == "AC":
    if solved[x] == 0:
      ans[1] += penalty[x]
    solved[x] = 1
  else:
    penalty[x] += 1
ans[0] = solved.count(1)
print(*ans)

Solution (Python):
from collections import defaultdict
d = defaultdict(list)
N,M = list(map(int,input().split()))
for i in range(M):
  p,S = input().split()
  p = int(p)
  d[p].append(S)
AC = 0
penalty = 0
for key,value in d.items():
  if "AC" in value:
    AC+=1
    penalty += value.index("AC")
print(AC,penalty)

Solution (Python):
n,m=map(int,input().split())
data = [0 for i in range(n)]
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=='WA':
        if data[p]<10000000:
            data[p]+=1
    else:
        if data[p]<10000000:
            data[p]+=10000000

wa=0
ac=0
for i in range(n):
    if data[i]>=10000000:
        ac+=1
        wa+=data[i]-10000000
print(ac,wa)

Solution (Python):
problems, submissions= map(int, input().split())
lst = [[0,False] for i in range(problems)]
solved = 0
pen  = 0
for z in range(submissions):
    prob, stat = input().split()
    prob = int(prob) - 1
    if lst[prob][1] == False:
        if stat == "AC":
            lst[prob][1] = True
            pen += lst[prob][0]
            solved += 1
        else:
            lst[prob][0] += 1
print(solved,pen)

Solution (Python):
def main():
    import sys
    N,M=list(map(int,sys.stdin.readline().split()))
    dic={}
    st=set()
    for i in range(M):
        p,S=sys.stdin.readline().split()
        p=int(p)
        if S=='AC':
            st.add(p)
            try:
                dic[p]+=0
            except:
                dic[p]=0
        else:
            if p not in st:
                try:
                    dic[p]+=1
                except:
                    dic[p]=1
    
    pena=sum([dic[x] for x in list(st)])
    ac=len(list(st))
    print(' '.join([str(ac),str(pena)]))

main()

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    p = [0]*n
    f = [0]*n
    for i in range(m):
        a,b = input().split()
        a = int(a)-1
        if b == "WA" and not f[a]:
            p[a] += 1
        if b == "AC":
            f[a] = 1
    p = [p[i]*f[i] for i in range(n)]
    print(sum(f),sum(p))
    return


if __name__ == "__main__":
    solve()

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



def main():
    N, M = [int(x) for x in input().split()]
    ps = []
    ac = set()
    acnum = 0
    wanum = Counter()
    for _ in range(M):
        p, s = [x for x in input().split()]
        if s == "WA":
            if int(p) not in ac:
                wanum[int(p)] += 1
        if s == "AC":
            if int(p) not in ac:
                acnum += 1
                ac.add(int(p))
        

    wanum2 = 0
    for i in wanum.keys():
        if i in ac:
            wanum2 += wanum[i]

    print(acnum, wanum2)





if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N, M = map( int, input().split())
    PS = [tuple( input().split()) for _ in range(M)]
    AC = [False]*(N+1)
    C = [0]*(N+1)
    for p, s in PS:
        p = int( p)
        if AC[p]:
            continue
        if s == "AC":
            AC[p] = True
        else:
            C[p] += 1
    ansac = 0
    anspena = 0
    for i in range(N+1):
        if AC[i]:
            ansac += 1
            anspena += C[i]
    print(ansac, anspena)
    
if __name__ == '__main__':
    main()

Solution (Python):
n, m = map(int, input().split())
wa = [0 for i in range(100005)]
ac = [False for i in range(100005)]
for sa in range(m):
    p, v = input().split()
    p = int(p)
    if v == "WA":
        if ac[p] == False:
            wa[p] += 1
    else:
        ac[p] = True
w = 0
c = 0
for i in range(n+5):
    if ac[i]:
        w += wa[i]
        c += 1
print(c, w)

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 ac[p]:
    continue
  else:
    if s=="WA":
      wa[p]+=1
    if s=="AC":
      ac[p]=True
account=0
wacount=0
for i in range(len(ac)):
  account+=ac[i]
  if ac[i]:
    wacount+=wa[i]
    
print(account,wacount)

Solution (Python):
N,M = map(int,input().split())
PS = []
AC_counter = [0 for i in range(N)]
WA_counter = [0 for i in range(N)]
for i in range(M):
    p,s = input().split()
    p = int(p)-1
    if s == 'AC':
        AC_counter[p] = 1
    else:
        if AC_counter[p] == 0:
            WA_counter[p] += 1
WA_ans = 0
for a,b in zip(AC_counter,WA_counter):
    if a > 0:
        WA_ans += b
print(sum(AC_counter),WA_ans)