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, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,m=map(int,input().split())
wa=0
data=[0]*(n+1)
AC=[0]*(n+1)
for i in range(m):
    p,s=input().split()
    p=int(p)
    if s=="WA":
        data[p]+=1
    else:
        AC[p]=1
        wa+=max(0,data[p])
        data[p]=-inf

print(sum(AC),wa)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n,m=MI()
    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
    s=sum(wa[i] for i in range(n) if ac[i])
    print(sum(ac),s)

main()

Solution (Python):
n,m=map(int,input().split())
li=[0]*(n+1)
cn=[0]*(n+1)
ac=wa=0
for _ in range(m):
  x,y=input().split()
  x=int(x)
  if y=="AC":
    if li[x]!=1:
      li[x]=1
      ac+=1
      wa+=cn[x]
  else:
    cn[x]+=1
print(ac,wa)

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

for _ in range(m):
    p, s = input().split()
    if s == "WA":
        if ac[int(p)-1] == 0:
            wa[int(p)-1] += 1
    else:
        ac[int(p)-1] += 1

print(n-ac.count(0), sum([wa[i] for i in range(n) if ac[i] >= 1]))

Solution (Python):

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

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

for i, (pi_str, Si) in enumerate(pS):
    pi = int(pi_str)
    if Si == 'AC':
        ac[pi - 1] = 1
    else:
        if ac[pi - 1] == 0:
            wa[pi - 1] += 1
        else:
            pass

ans_wa = 0
for i, wai in enumerate(wa):
    if ac[i] > 0: ans_wa += wai

print(sum(ac), ans_wa)

Solution (Python):


import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read




n,m = [int(i) for i in readline().split()]

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

ac_num = 0
wa_num = 0

for _ in range(m):
    p,s = [i for i in readline().split()]
    p = int(p)-1
    if ac[p] == 1:
        continue
    
    if s == "WA":
        wa[p] += 1
    else:
        ac[p] += 1
        ac_num += 1
        wa_num += wa[p]

print(ac_num,wa_num)

Solution (Python):

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

f = [0]*N
pena = [0]*N
for ps in PS:
    p,s = ps
    p = int(p)
    s = str(s)
    if f[p-1] == 0:
        if s == "AC":
            f[p-1] = 1
        else:
            pena[p-1]+=1
pe = 0        
for i in range(N):
    if f[i] == 1:
        pe+=pena[i]
print(sum(f),pe)

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

a = [0 for _ in range(n)]
b = [False for _ in range(n)]

ac_count = 0

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'WA' and not b[p-1]:
        a[p-1] += 1
    elif s == 'AC' and not b[p-1]:
        ac_count += 1
        b[p-1] = True

wa_count = 0

for i in range(n):
    if b[i] == True:
        wa_count += a[i]


print(ac_count, wa_count)

Solution (Python):
import sys
sys.setrecursionlimit(10**9)
N,M=map(int,input().split())
B = [0 for i in range(N)]
A = [False for i in range(N)]
for m in range(M):
  p,S=input().split()
  p = int(p)
  if S=="WA":
    if not A[p-1]:
      B[p-1] += 1
  else:
    A[p-1] = True
c = 0
for a,b in zip(A,B):
  if a:
    c+=b

print(sum(A),c)

Solution (Python):



def solve(n, m, subs):
    is_ac = [False] * n
    num_wa = [0] * n
    total_ac = 0
    total_wa = 0
    for p, s in subs:
        if s == "AC":
            if not is_ac[p]:
                is_ac[p] = True
                total_ac += 1
                total_wa += num_wa[p]
        else:
            if not is_ac[p]:
                num_wa[p] += 1
    return total_ac, total_wa


def main():
    n, m = (int(x) for x in input().split())
    subs = []
    for _ in range(m):
        p0, s = input().split()
        subs.append((int(p0) - 1, s))
    res = solve(n, m, subs)
    print(*res)


if __name__ == "__main__":
    main()

Solution (Python):
N, M = map(int, input().split())
pena = [0]*N
score = 0
flag = [False]*N
for _ in range(M):
    p, S = input().split()
    p = int(p)-1
    if flag[p]:
        continue
    if S == 'AC':
        flag[p] = True
        score+=1
    else:
        pena[p]+=1
res = 0
for i in range(N):
    if flag[i]:
        res+=pena[i]
print(score, res)

Solution (Python):
from collections import defaultdict
N, M = map(int, input().split())
D = defaultdict(int)
acd = set()
ac = 0
pen = 0
for i in range(M):
    p, S = input().split()
    p = int(p)
    if S == "WA":
        D[p] += 1
    else:
        if p not in acd:
            acd.add(p)
            ac += 1
            pen += D[p]
print(ac, pen)

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

accepted = set()
penalty = 0
wa_cnt = [0] * (n+1)

for i in range(m):
    p, s = input().split()
    p = int(p)
    if p in accepted:
        continue
    if s == "AC":
        penalty += wa_cnt[p]
        accepted.add(p)
    else:
        wa_cnt[p] += 1


print(len(accepted), penalty)

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

ans = [0 for _ in range(n)]
pe = [0 for _ in range(n)]
accnt = 0
pecnt = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if ans[p - 1] == 0 and s == "WA":
        pe[p - 1] += 1
    elif ans[p - 1] == 0 and s == "AC":
        ans[p - 1] = 1

for i in range(n):
    if ans[i] == 0:
        pe[i] = 0

print(sum(ans), end = " ")
print(sum(pe), end = "")
print()

Solution (Python):
def main():

    N, M = map(int, input().split())
    solved = [0 for _ in range(N)]
    penal = [0 for _ in range(N)]
    for _ in range(M):
        p, S = input().split()
        p = int(p)
        if S == "AC":
            solved[p-1] = 1
        else:
            if solved[p-1] == 0:
                penal[p-1] += 1
    pt = 0
    for i in range(N):
        if solved[i] == 1:
            pt += penal[i]
    return " ".join(map(str, [sum(solved), pt]))

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

Solution (Python):
n,m=map(int,input().split())
l=[0]*n
ac=[False]*n
cnt=0;acnt=0
for i in range(m):
  a,b=input().split()
  a=int(a)
  if ac[a-1]:continue
  if b=="AC":
    cnt+=l[a-1]
    acnt+=1
    ac[a-1]=True
  if b=="WA":
    l[a-1]+=1
print(acnt,cnt)

Solution (Python):
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]





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

ac = 0
wa = 0
memo = [0]*(N+1)

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

    if S == "AC":
        if memo[p] != -1:
            ac += 1
            wa += memo[p]
            memo[p] = -1
    else:
        if memo[p] != -1:
            memo[p] += 1

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):
    p,S = input().split()
    p = int(p)-1
    if not AC[p]:
        if S == 'AC':
            AC[p] = 1
        else:
            WA[p] += 1
    else:
        continue
WAcount = 0
for i in range(N):
    if AC[i]:
        WAcount += WA[i]
print(sum(AC),WAcount)

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

Solution (Python):
N,M = map(int,input().split())
score = [[False,0] for _ in [0]*N]
for _ in range(M):
    p,S = input().split()
    p = int(p)-1
    S = S=="AC"
    if S:
        score[p][0] = True
    else:
        if not score[p][0]:
            score[p][1] += 1
AC = sum(s[0] for s in score)
WA = sum(s[1] for s in score if s[0])
print(AC,WA)

Solution (Python):
N, M = map(int, raw_input().split())
A = [False]*N
C = [0]*N
for i in range(M):
  p, S = raw_input().split()
  p = int(p)-1
  if S=="AC":
    A[p] = True
  else:
    if not A[p]:
      C[p] += 1
print sum(A), sum(C[i] for i in range(N) if A[i])

Solution (Python):
N, M = list(map(int, input().split()))
wa = [0]*N
solved = [False]*N
for _ in range(M):
    p, S = input().split()
    p = int(p)-1
    if S=='WA' and not solved[p]:
        wa[p]+=1
    if S=='AC':
        solved[p] = True

ans1 = 0
ans2 = 0
for w, s in zip(wa, solved):
    if s:
        ans1 += 1
        ans2 += w

print(ans1, ans2)

Solution (Python):
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
num=[0]*(n+1)
numcnt=[0]*(n+1)
ans=0
cnt=0
for i in range(m):
    p,s=map(str,input().split())
    p=int(p)
    if s=="WA":
        num[p]+=1
    if s=="AC" and numcnt[p]!=1:
        ans+=num[p]
        cnt+=1
        numcnt[p]=1
print(cnt,ans)

Solution (Python):
import sys
import math
import bisect

def main():
    n, m = map(int, input().split())
    wa = [0] * n
    ac = [0] * n
    penalty = 0
    for _ in range(m):
        p, s = input().split()
        p = int(p) - 1
        if s == 'WA':
            wa[p] += 1
        else:
            if ac[p] == 0:
                ac[p] = 1
                penalty += wa[p]
            ac[p] = 1
    print('%d %d' % (sum(ac), penalty))

if __name__ == "__main__":
    main()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
p = [0]*M
S = [""]*M
for i in range(M):
	p[i], S[i] = input().split()
	p[i] = int(p[i])

ac = 0
wa = 0
dic = defaultdict(int)
for i in range(M):
	if S[i] == "AC":
		if dic[p[i]] == -1:
			continue
		ac += 1
		wa += dic[p[i]]
		dic[p[i]] = -1
	else:
		if dic[p[i]] == -1:
			continue
		dic[p[i]] += 1
print(ac, wa)

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



print(sum(sgn),pp)

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

wa = [0] * n
ac = [False] * n
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == "WA":
        if not ac[p]:
            wa[p] += 1
    else:
        ac[p] = True

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

print(sum(ac), wa_count)

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

from collections import defaultdict
dic = defaultdict(int)
wa = defaultdict(int)
ans1 = 0
ans2 = 0
for _ in range(m):
    p,s = map(str,input().split())
    p = int(p)
    if s == "AC":
        if dic[p] == 0:
            ans2 += wa[p]
            ans1 += 1
            dic[p] = 1

    else:
        if dic[p] == 0:
            wa[p] += 1
   
print(ans1)
print(ans2)

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

acs = [0 for i in range(n)]
was = [0 for i in range(n)]
ps = []
ss = []


for i in range(m):
    pa,sa = input().split()
    pa = int(pa)
    if sa == "AC":
        acs[pa-1] = 1
    if sa == "WA" and acs[pa-1] == 0:
        was[pa-1] += 1

wa_cnt = 0
for i in range(n):
    if acs[i] == 1:
        wa_cnt += was[i]


print(sum(acs), wa_cnt)

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,M = inpl()
cnts = [0]*N
pena = 0
for _ in range(M):
    p,s = input().split()
    p = int(p)-1
    if s == "WA" and cnts[p]!=-1:
        cnts[p] += 1
    elif s == "AC" and cnts[p]!=-1:
        pena += cnts[p]
        cnts[p] = -1


print(cnts.count(-1),pena)

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

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

print(ac, wa)

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

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

for i in range(M):
    p,res=input().split()
    p = int(p)-1
    if res=="AC":
        ac[p]=True
    else:
        if not ac[p]:
            wa[p]+=1
account = 0
wacount = 0
for i in range(N):
    if ac[i]:
        account+=1
        wacount+=wa[i]

print(account,wacount)

Solution (Python):
N, M = map(int, input().split())
flag = [False for i in range(N)]
WA = [0 for i in range(N)]
ans = 0
WA_count = 0
for _ in range(M):
    p, s = input().split()
    p = int(p)-1
    if flag[p]:
        pass
    else:
        if s == 'WA':
            WA[p] += 1
        else:
            flag[p] = True
            WA_count += WA[p]
            ans += 1
print(ans, WA_count)

Solution (Python):
N, M = map(int, input().split())
wls = [0]*N
ls = [0]*N
for i in range(M):
  p, s = input().split()
  p = int(p)-1
  if ls[p]==0:
    if s=='WA':
      wls[p] += 1
    else:
      ls[p] = 1
  else:
    continue
pena = 0
ac = 0
for i in range(N):
  if ls[i] == 1:
    ac += 1
    pena += wls[i]
print(ac, pena)

Solution (Python):
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
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(map(int, input().split())) for _ in range(n)]

def main():
    n,m = inpm()
    dic = defaultdict(int)
    x = 0
    y = 0
    for _ in range(m):
        ps = inpls()
        ps[0] = int(ps[0])
        if ps[1] == 'WA':
            dic[ps[0]] += 1
        elif ps[1] == 'AC' and dic[ps[0]]<10**6:
            x += 1
            y += dic[ps[0]]
            dic[ps[0]]= 10**6
    print(x,y)



if __name__ == "__main__":
    main()

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

p = []
a = []
flag = []
for i in range(n):
    p.append(0)
    a.append(0)
    flag.append(True)

for i in range(m):
    if ps[i][1] == 'WA' and flag[ps[i][0] - 1]:
        p[ps[i][0] - 1] += 1
    else:
        a[ps[i][0] - 1] = 1
        flag[ps[i][0] - 1] = False



pen = 0
ac = 0
for i in range(n):
    if a[i] > 0:
        pen += p[i]
        ac += 1
print(ac, pen)

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

    N, M = map(int, input().split())
    cnt = 0
    wa = 0
    flg = {i: 0 for i in range(1, N+1)}
    for _ in range(M):
        p, ver = input().split()
        p = int(p)
        if ver == 'AC':
            if flg[p] >= 0:
                cnt += 1
                wa += flg[p]
                flg[p] = -1
        else:
            if flg[p] >= 0:
                flg[p] += 1
    print(cnt, wa)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
A = [list(input().split()) for i in range(m)]

for i in range(m):
    A[i][0] = int(A[i][0])-1

P = [0] * n
AC = [0] * n

for i in range(m):
    if A[i][1] == "WA":
        if AC[A[i][0]] == 0:
            P[A[i][0]] += 1
    else:
        AC[A[i][0]] = 1
    
p=0
ac=sum(AC)
for i in range(len(P)):
    if AC[i] == 1:
        p += P[i]
print(ac,p)

Solution (Python):
def main():
    N, M = [int(n) for n in input().split()]
    was = [0]*N
    isAc = [False]*N
    acs = 0
    pes = 0
    for _ in range(M):
        p, s = input().split()
        p = int(p) -1
        if s == "AC":
            if isAc[p] == True:
                continue
            isAc[p] = True
            pes += was[p]
            acs+=1
        else:
            was[p] += 1
    print(" ".join([str(acs),str(pes)]))
main()

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

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m = LI()
f = defaultdict(int)
f1 = defaultdict(int)
ans1 = 0
ans2 = 0
for _ in range(m):
    p,s = input().split()
    if f1[p] == 1:
        continue
    if s == 'WA':
        f[p] += 1
    else:
        f1[p] = 1
        ans1 += f[p]
        ans2 += 1
print(ans2,ans1)

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

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

for _ in range(m):
  p, s = input().split()
  p = int(p) - 1
  if s == 'WA':
    if ac[p] == 0:
      pen[p] += 1
  else:
    ac[p] = 1

for p in range(n):
  if ac[p] == 0:
    pen[p] = 0
print(str(sum(ac)) + ' ' + str(sum(pen)))

Solution (Python):
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
t = [0] * (N + 1)
vis = set()
for _ in range(M):
  p, s = input().split()
  p = int(p)
  if p in vis: continue
  if s == "AC":
    vis.add(p)
  else:
    t[p] += 1
res = 0
for i in range(N + 1):
  if i in vis:
    res += t[i]
print(len(vis), res)

Solution (Python):
def main():
    n, m = map(int, input().split())
    ab = [input().split() for _ in [0]*m]
    cnt = 0
    ac_list = [False]*n
    cnt_list = [0]*n
    for a, b in ab:
        if b == "WA":
            cnt_list[int(a)-1] += 1
        else:
            if ac_list[int(a)-1] == False:
                cnt += cnt_list[int(a)-1]
                ac_list[int(a)-1] = True
    print(sum(ac_list), cnt)


main()

Solution (Python):
def examA():
    C = SI()
    ans = chr(ord(C)+1)
    print(ans)
    return

def examB():
    N,K,M = LI()
    A = LI()
    ans = N*M-sum(A)
    if ans>K:
        ans = -1
    elif ans<0:
        ans = 0
    print(ans)
    return

def examC():
    N, M = LI()
    ansT = 0; ansP = 0
    d = defaultdict(bool)
    WA = [0]*(N+1)
    for i in range(M):
        S, P = LSI()
        S = int(S)
        if P=="WA":
            WA[S] +=1
        elif P=="AC":
            if d[S]:
                continue
            else:
                d[S] = True
                ansT +=1
                ansP +=WA[S]
    print(ansT,ansP)
    return

def examE():
    return

def examF():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()

Solution (Python):
n, m = map(int, input().split())
l = [0] * n
f = [True] * n
for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'WA':
        if f[p]:
            l[p] += 1
    else:
        f[p] = False
ans = 0
for i in range(n):
    if not f[i]:
        ans += l[i]
print(f.count(False), ans)

Solution (Python):
from collections import defaultdict

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

aced = set()
d = defaultdict(int)
pen = 0
for i in xrange(m):
    p, s = raw_input().split()
    p = int(p)
    s = s.strip()

    if p in aced:
        continue

    if s == 'WA':
        d[p] += 1
    elif s == 'AC':
        aced.add(p)
        pen += d[p]
    else:
        assert False

print len(aced), pen

Solution (Python):
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    b=[False]*N
    c=[0]*N
    ans=0
    ans2=0
    for i in range(M):
        p,S=input().split()
        p=int(p)-1
        if S=='WA' and b[p]==False:
            c[p]+=1
        elif S=='AC' and b[p]==False:
            b[p]=True
            ans+=c[p]
            ans2+=1
    print(ans2,ans)
        
if __name__ == '__main__':
    main()

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

N, M = map(int, readline().split())
ACed = [False]*N
count = [0]*N

for _ in range(M):
    p, S = readline().strip().split()
    p = int(p)-1
    if S == 'AC':
        ACed[p] = True
    elif not ACed[p]:
        count[p] += 1

print(sum(ACed), sum(count[i] for i in range(N) if ACed[i]))

Solution (Python):
from collections import defaultdict

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

ac, wa = 0, 0
solved = defaultdict(int)
warning = defaultdict(int)

for p, S in pS :
  if solved[p] == 1 :
    continue
    
  if S == 'WA' :
    warning[p] += 1
    
  else :
    ac += 1
    solved[p] = 1
    wa += warning[p]
    
print(ac, wa)

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    AC=set()
    WA=defaultdict(int)
    ans = 0
    for _ in range(M):
        p,s = ST().split()
        if s=="AC":
            if p in AC:
                continue
            ans += WA[p]
            AC.add(p)
        else:
            WA[p]+=1
    print(len(AC),ans)
if __name__ == '__main__':
    main()

Solution (Python):


from collections import defaultdict


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


def main():
	N, M = getlist()
	D = defaultdict(int)
	AC = 0
	WA = 0
	for i in range(M):
		p, S = list(input().split())
		if S == "AC":
			if D[p] != -1:
				AC += 1
				WA += D[p]
				D[p] = -1
		else:
			if D[p] != -1:
				D[p] += 1

	print(AC, WA)


if __name__ == '__main__':
	main()

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

Solution (Python):
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))



N,M = II()
p = []
S = []
for i in range(M):
    a,b = map(str, input().split())
    p.append(int(a))
    S.append(b)

ac = [False]*N
pn = [0]*N
acn = 0
pnn = 0

for i in range(M):
    if S[i]=='WA':
        pn[p[i]-1] += 1
    else:
        if ac[p[i]-1]==False:
            acn += 1
            ac[p[i]-1] = True
            pnn += pn[p[i]-1]

print(acn,pnn)

Solution (Python):
n, m = [int(i) for i in input().split()]
pe = [0] * n
isok = [False] * n
for _ in range(m):
    p, s = [i for i in input().split()]
    p = int(p) - 1
    if s == "AC":
        isok[p] = True
    else:
        if not isok[p]:
            pe[p] += 1
pen = 0
ans = 0
for i in range(n):
    if isok[i]:
        ans += 1
        pen += pe[i]
print(ans,pen)

Solution (Python):
n,m=map(int,input().split())
j=[0]*n
c=[0]*n
pe=0
ac=0
for i in range(m):
  p,s=input().split()
  p=int(p)-1
  if s[0]=="A" and j[p]==0:
    j[p]=1
    ac+=1
    pe+=c[p]
  elif s[0]=="W":c[p]+=1
print(ac,pe)

Solution (Python):
import sys
from collections import defaultdict

n, m = map(int, input().split())
ac = 0
wa = defaultdict(lambda: 0)
already = set()
for line in sys.stdin:
    p, s = line.strip().split()
    p = int(p)
    if p in already:
        continue
    if s == 'AC':
        ac += 1
        already.add(p)
    else:
        wa[p] += 1

print(ac, sum(wa[i] for i in already))