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

WA=[0 for _ in range(N+1)]
solved=[False for _ in range(N+1)]
AC=0

for _ in range(M):
    P,S=input().split()
    P=int(P)
    
    if S=="AC" and solved[P]==False:
        AC+=1
        solved[P]=True
    elif S=="WA" and solved[P]==False:
        WA[P]+=1

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

print(AC,U)

Solution (Python):
n,m=map(int,input().split())
l1=[list(input().split()) for i in range(m)]
l2=["WA"]*n
l3=[0]*n
account=0
wacount=0
for i in range(m):
  if l1[i][1]=="WA" and l2[int(l1[i][0])-1]=="WA":
    wacount+=1
    l3[int(l1[i][0])-1]+=1
  if l1[i][1]=="AC":
    l2[int(l1[i][0])-1]="AC"

for i in range(n):
  if l2[i]=="AC":
    account+=1
  else:
    wacount-=l3[i]
print(account,wacount)

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N,M=map(int,input().split())
L=[0]*N
R=[0]*N
right=0
pena=0
for _ in range(M):
    p,s=input().split()
    p=int(p)
    p-=1
    if R[p]==0:
        if s=='AC':
          right+=1
          R[p]=1
          pena+=L[p]
        else:
            L[p]+=1

print(right,pena)

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

AC = {}
WA = {}

for i in range(M):
    if P[i][0] in AC:  
        continue
    if P[i][1] == "AC":  
        AC[P[i][0]] = True
        continue
    if not P[i][0] in WA:  
        WA[P[i][0]] = 1
    else:  
        WA[P[i][0]] += 1

WAsum = 0
for i in AC.keys():
    if i in WA:
        WAsum += WA[i]

print(len(AC), WAsum)

Solution (Python):
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
inf = 10**17
mod = 10**9+7

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

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

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

print(acn, wan)

Solution (Python):
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
inf = 10**17
mod = 10**9+7

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

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

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

print(acn, wan)

Solution (Python):
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
inf = 10**17
mod = 10**9+7

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

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

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

print(acn, wan)

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

Solution (Python):
N,M=map(int,input().split())
L=[0]*N
R=[0]*N
right=0
pena=0
for _ in range(M):
    p,s=input().split()
    p=int(p)
    p-=1
    if R[p]==0:
        if s=='AC':
          right+=1
          R[p]=1
          pena+=L[p]
        else:
            L[p]+=1

print(right,pena)

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

accepted = [False for _ in range(N)]
wa = [0 for _ in range(N)]

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

correct = sum(accepted)
penalty = sum([a * w for a, w in zip(accepted, wa)])

print(correct, penalty)

Solution (Python):
N,M = list(map(int,input().split()))
lis_AC = []
lis_WA = []
for i in range(M):
    p,s = input().split()
    if s == "AC":
        lis_AC.append(p)
    else:
        if p not in lis_AC:
            lis_WA.append(p)
lis_AC = set(lis_AC)
cnt_WA = 0
for i in lis_WA:
    if i in lis_AC:
        cnt_WA += 1

print(len(lis_AC), end = " ")
print(cnt_WA)

Solution (Python):
N,M = list(map(int,input().split()))
lis_AC = []
lis_WA = []
for i in range(M):
    p,s = input().split()
    if s == "AC":
        lis_AC.append(p)
    else:
        if p not in lis_AC:
            lis_WA.append(p)
lis_AC = set(lis_AC)
cnt_WA = 0
for i in lis_WA:
    if i in lis_AC:
        cnt_WA += 1

print(len(lis_AC), end = " ")
print(cnt_WA)

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

WA = [0] * (100000+1)
AC = [0] * (100000+1)

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

for i in range(100000+1):
    if AC[i] == 0:
        WA[i] = 0

print(sum(AC),end=' ')
print(sum(WA))

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

Solution (Python):
N,M = map(int,input().split())
 
ac = [0]*N
p = [0]*N
ans = 0
for _ in range(M):
    a,b = input().split()
    a = int(a)-1
 
    if not ac[a]:
        if b == "AC":
            ac[a] = 1
            ans += p[a]
        else:
            p[a] += 1
 
print(sum(ac),ans)

Solution (Python):
def main():
    n, m = map(int, input().split())
    indic = {}
    wadic = {}
    AC = 0
    for i in range(m):
        a, b = map(str, input().split())
        a = int(a)
        if a in indic:
            if indic[a] == "WA" and b == "WA":
                wadic[a] += 1
            elif indic[a] == "WA" and b == "AC":
                indic[a] = "AC"
                AC += 1
        else:
            if b == "AC":
                indic[a] = "AC"
                AC += 1
            else:
                indic[a] = "WA"
                wadic[a] = 1
    WA = 0
    for key in indic:
        if indic[key] == "AC" and key in wadic:
            WA += wadic[key]
    print(AC, WA)
                

if __name__ == "__main__":
    main()

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

    AC = [False] * N
    WA = [0] * N
    for _ in range(M):
        p, s = readline().split()
        p = int(p) - 1

        if AC[p]:
            continue
        if s == 'AC':
            AC[p] = True
        else:
            WA[p] += 1

    ac = sum(AC)
    wa = sum(p for flag, p in zip(AC, WA) if flag)

    print(ac, wa)
    return


if __name__ == '__main__':
    main()

Solution (Python):
import collections

n, m = map(int, input().split())
list_ac = set()
dic = collections.defaultdict(lambda:0)

ac = 0
wa = 0

for _ in range(m):
    p, s = input().split()
    if s == "WA" and p not in list_ac:
        dic[p] += 1
    elif s =="AC" and p not in list_ac:
        list_ac.add(p)
        ac += 1
        if p in dic:
            wa += dic[p]
            
print(ac, wa)

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


from collections import defaultdict
n,m = map(int, input().split())
d = {}
was = 0
acs = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if s=="WA":
        if p not in d:
            d[p] = 1
        elif d[p]==-1:
            pass
        else:
            d[p] += 1
    else:
        if p not in d:
            d[p] = -1
            acs += 1
        elif d[p]>=0:
            was += d[p]
            d[p] = -1
            acs += 1
print(acs, was)

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

li=[0]*M
for i in range(M):
    li[int(i)]=input().split()


count=[0]*N
flg=[0]*N 
for i in range(M):
    if li[int(i)][1] == "AC":
        flg[int(li[int(i)][0])-1]=1
    if flg[int(li[int(i)][0])-1] == 0:
        count[int(li[int(i)][0])-1]+=1

for i in range(N):
    if flg[int(i)] == 0:
        count[int(i)]=0

print(sum(flg), sum(count))

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

AC =[0]*n
WA = [0]*n
WA_ans = [0]*n

for i in range(m):
    if AC[int(ps[i][0])-1] == 0:
        if ps[i][1] == 'AC':
            AC[int(ps[i][0])-1] = 1
            WA_ans[int(ps[i][0])-1] = WA[int(ps[i][0])-1]

        elif ps[i][1] == 'WA':
            WA[int(ps[i][0])-1] += 1

print(sum(AC), sum(WA_ans))

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
a = [False] * (n+1)
cnt = [0] * (n+1)
for _ in range(m):
    x,y = input().split()
    x = int(x)
    if y == 'AC':
        a[x] = True
    else:
        if not a[x]:
            cnt[x] += 1
pena = 0
for i in range(1,n+1):
    if a[i]: pena += cnt[i]
print(sum(a), pena)

Solution (Python):
import numpy as np

N, M = map(int, input().split())
AC = np.zeros(N, dtype = int)
WA = np.zeros(N, dtype = int)

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

  if s == 'WA' and AC[int(p) - 1] == 0:
    WA[int(p) - 1] += 1
  else:
    AC[int(p) - 1] = 1

print(sum(AC), sum(AC * WA))

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

Solution (Python):
N,M = map(int,input().split())
A = [list(input().split()) for _ in range(M)]
C = {str(i):0 for i in range(1,N+1)}
D = {str(i):0 for i in range(1,N+1)}
for j in range(M):
    p,s = A[j]
    if s=="AC" and C[p]==0:
        C[p] += 1
wa = 0
for j in range(M):
    p,s = A[j]
    if s=="WA":
        if C[p]==1 and D[p]==0:
            wa += 1
    else:
        if D[p]==0:
            D[p] += 1
ac = 0
for i in range(1,N+1):
    ac += C[str(i)]
print(ac,wa)

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re











import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,m = readInts()
dic = defaultdict(int)
cnt = 0
ans = 0
for i in range(m):
    i,j = input().split()
    if dic[i] != -1:
        if j == 'WA':
            dic[i] += 1
        elif j == 'AC':
            cnt += 1
            ans += dic[i]
            dic[i] = -1
print(cnt,ans)

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

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

for i in range(m):
    p, s = map(str, input().split())
    p = int(p)
    p -= 1
    if s == 'AC':
        AC[p] = 1
    else:
        if AC[p] != 1:
            WA[p] += 1

a = 0
w = 0
for i in range(n):
    if AC[i] == 1:
        a += 1
        w += WA[i]
print(a, w)

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

ac = [0] * (n+1)
pena = [0] * (n+1)
for p,s in ps:
    p = int(p)
    if ac[p] == 0:
        if s == "WA": pena[p] += 1
        else: ac[p] = 1
ans = [0,0]
for i in range(1,n+1):
    if ac[i] == 1:
        ans[0] += 1
        ans[1] += pena[i]
print(" ".join(map(str, ans)))

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N, M = inm()


def solve():
    accepted = [False] * N
    wacount = [0] * N
    for i in range(M):
        p, s = ins().split()
        p = int(p) - 1
        if s == "AC":
            accepted[p] = True
            continue

        assert s == "WA"
        if accepted[p]:
            continue
        wacount[p] += 1
    ac = wa = 0
    for i in range(N):
        if accepted[i]:
            ac += 1
            wa += wacount[i]
    return ac, wa


print(*solve())

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

ac = [0]*N
p = [0]*N
ans = 0
for _ in range(M):
    a,b = input().split()
    a = int(a)-1

    if not ac[a]:
        if b == "AC":
            ac[a] = 1
            ans += p[a]
        else:
            p[a] += 1

print(sum(ac),ans)

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

ac = [0 for _ in range(n)]
wa = [0 for _ in range(n)]

for s in sub:
    if s[1] == 'AC':
        ac[int(s[0])-1] += 1
    elif ac[int(s[0])-1] == 0:
            wa[int(s[0])-1] += 1

ac_sum = 0
wa_sum = 0
for i in range(n):
    if ac[i] != 0:
        wa_sum += wa[i]
        ac_sum += 1
print(ac_sum, wa_sum)

Solution (Python):
n,m=map(int,input().split())
ac=[0]*(n+1)
wa=[0]*(n+1)
for i in range(m):
  a,b=map(str,input().split())
  a=int(a)
  if ac[a]==0:
    if b=='WA':
      wa[a]+=1
    else:
      ac[a]=1
print(sum(ac))
ans=0
for i in range(n+1):
  if ac[i]==1:
    ans+=wa[i]
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

def main():
    n,m = map(int, input().split())
    wa = 0
    ac = 0
    used = {}
    wa_tmp = {}
    for _ in range(m):
        p,s = map(str, input().split())
        if used.get(p):
            continue
        if s == 'WA':
            if not wa_tmp.get(p):
                wa_tmp[p] = 0
            wa_tmp[p] += 1
        if s == 'AC':
            ac += 1
            used[p] = True
            if wa_tmp.get(p):
                wa += wa_tmp[p]
    print(ac, wa)


if __name__ == '__main__':
    main()

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

questions = {i:[False, 0] for i in range(1, N + 1)}
count_AC = 0
count_WA = 0

for _ in range(M):
    p, S = input().split()
    if not questions[int(p)][0]:
        if S == "WA":
            questions[int(p)][1] += 1
        elif S == "AC":
            questions[int(p)][0] = True

for v in questions.values():
    if v[0]:
        count_AC += 1
        count_WA += v[1]
        
print(count_AC, count_WA)

Solution (Python):









import os
import sys




def main():
    n, m = map(int, input().split())
    which_ans = [0]*(n+1)
    penalty_cnt = [0]*(n+1)
    for _ in range(m):
        p, s = map(str, input().split())
        if which_ans[int(p)] == 0 and s == 'WA':
            penalty_cnt[int(p)] += 1
        elif which_ans[int(p)] == 0 and s == 'AC':
            which_ans[int(p)] = 1
    penalty_cnt = [0 if which_ans[i] == 0 else penalty_cnt[i] for i in range(1, n+1)]
    print(sum(which_ans), sum(penalty_cnt))

if __name__ == "__main__":
    main()

Solution (Python):
N, M = (int(x) for x in input().split())
B = [False]*N
cnt = [0]*N
ans = 0
pena = 0
for i in range(M):
  p, S = (str(x) for x in input().split())
  p = int(p)
  if S=="AC" and B[p-1]==False:
    B[p-1]=True
    ans+=1
  elif S=="WA" and B[p-1]==False:
    cnt[p-1]+=1
for i in range(N):
  if B[i]==True:
    pena+=cnt[i]
print(ans, end=" ")
print(pena)

Solution (Python):
n,m = map(int,input().split())
ac_d = {}
wa_d = {}
for i in range(m):
    p, s = input().split()
    if s == "WA":
        if p in wa_d:
            if wa_d[p] == 0:
                pass
            else:
                if p not in ac_d:
                    wa_d[p] += 1
        else:
            wa_d[p] = 1
    else:
        if p not in wa_d:
            wa_d[p] = 0
        ac_d[p] = 1

ac = len(ac_d.keys())

penalty = 0
for key in ac_d.keys():
    penalty += wa_d[key]
print(ac, penalty)

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

for _ in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'AC':
        ac_list[p] = 1
    elif s == 'WA' and ac_list[p] == 0:
        wa_list[p] += 1

for i in range(1,n+1):
    if ac_list[i] == 0:
        wa_list[i] = 0

print(sum(ac_list),sum(wa_list))

Solution (Python):
n, m=map(int, input().split())
l = [[] for _ in range(n+1)]
pl=list()
cnt=0
for _ in range(m):
  p, s=map(str, input().split())
  l[int(p)].append(s)
for i in range(1, n+1):
  pen=0
  for h in l[i]:
    if h=="AC":
      cnt+=1
      pl.append(pen)
      break
    else:
      pen+=1
      continue
print(cnt, sum(pl))

Solution (Python):
n,m = map(int,input().split())
p = [0]*m
s = [0]*m
ans = [0]*n
anp = 0
pe = [0]*n

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

	if s[i] == 'AC' and ans[p[i]-1] == 0:
		ans[p[i]-1] += 1
		
	if ans[p[i]-1] == 0 and s[i] == 'WA':
		pe[p[i]-1] += 1
for i in range(n):
	if ans[i] == 1:
		anp += pe[i]

print(*[sum(ans),anp])

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

print(' '.join(list(map(str,count))))

Solution (Python):
n,m=map(int,input().split())
ac = [0]*(n+1)
wa = [0]*(n+1)
for _ in range(m):
  p,s = tuple(input().split())
  p = int(p)
  if ac[p]==1: continue
  if s == 'WA': wa[p]+=1
  else: ac[p] = 1
pena = 0
for a,w in zip(ac,wa):
  pena += a*w
print(sum(ac),pena)

Solution (Python):








def main():
    N,M = map(int,input().split())
    accept =[0] *(N+1)

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

    for i in range(M):
        p, s = input().split()
        p = int(p)
        if accept[p] ==0:
            if s =="AC":
                accept[int(p)] =1
                ac +=1
            else:
                wa[p] +=1
    wrong =0
    for i in range(N+1):
        wrong += accept[i] * wa[i]

    print(ac,wrong)



if __name__ == "__main__":
    main()

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

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

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

count = 0
for i in range(n):
  if flag[i]: count += wa[i]

print(flag.count(True), count)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M = map(int, readline().split())
PS = [line.split() for line in readlines()]

AC = [False] * (N+1)
WA_cnt = [0] * (N+1)

penal = 0
for p,s in PS:
  p = int(p)
  if AC[p]:
    continue
  if s== b'WA':
    WA_cnt[p] += 1
  else:
    AC[p] = True
    penal += WA_cnt[p]
    
ac = sum(AC)
print(ac, penal)

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

co = 0
pe = 0

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

for _ in range(m):
    p, s = map(str, input().split())
    p = int(p)
    if ac[p]==0 and s == 'AC':
        co += 1
        ac[p] =1
        if wa[p]>0:
            pe += wa[p]
    elif ac[p] == 0 and s == 'WA':
        wa[p] += 1

print('{} {}'.format(co, pe))

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

pro = [0]*n

ac = set([])

ans = 0

pen = 0

for _ in range(m):
    l = input().split()
    s = l[1]
    p = int(l[0])    
    if s == "AC":
        if p not in ac:
            ans += 1
            pen += pro[p-1]
            ac.add(p)
            
    else:
        if p not in ac:
            pro[p-1] += 1
            
print(ans,pen)

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

ac = 0
wa = 0
for _ in range(M):
    a,b = input().split()
    a = int(a)

    if not solved[a]:
        if b == "AC":
            wa += penalty[a]
            solved[a] = 1
        else:
            penalty[a] += 1

print(sum(solved),wa)

Solution (Python):
N, M = map(int, input().split())
AC = [0 for i in range(N)]
WA = [0 for i in range(N)]
a = [0 for i in range(N)]
for i in range(M):
  p, S = input().split()
  p = int(p)
  if S == 'AC':
    AC[p-1] = 1
    a[p-1] = 0
  else:
    if AC[p-1] == 0:
      WA[p-1] += 1
      a[p-1] += 1
c = sum(AC)
wa = sum(WA) - sum(a)
print(c, wa, sep=' ')

Solution (Python):
N,M=map(int,input().split())
ac=[0]*(10**5+1)
temp=[0]*(10**5+1)
wa=[0]*(10**5+1)
for i in range(M):
  p,S=input().split()
  if ac[int(p)]==0:
    if S=="WA":
      temp[int(p)]+=1
    else:
      ac[int(p)]=1
for i in range(len(ac)):
  wa[i]=ac[i]*temp[i]
print(sum(ac),sum(wa))

Solution (Python):
from copy import deepcopy
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


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



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n, m = map(int, input().split())
tmp = [None]*(10**5+10)
for i in range(len(tmp)):
    tmp[i] = [None]*2
for i in range(len(tmp)):
    tmp[i][0] = False
    tmp[i][1] = 0
for _ in range(m):
    p, s = input().split()
    
    if tmp[int(p)][0] == False and s == 'WA':
        tmp[int(p)][1] += 1
    if s == 'AC':
        tmp[int(p)][0] = True
ans = 0
penalty = 0
for i in range(len(tmp)):
    if tmp[i][0]:
        ans += 1
    if tmp[i][0] == True and tmp[i][1] != None:
        penalty += tmp[i][1]
print(ans, penalty)

Solution (Python):
N, M = map(int, input().split())
AC_flags = [False] * N
WA_counter = [0] * N
for _ in range(M):
    p, s = input().split()
    p = int(p) - 1
    if AC_flags[p]:
        continue
    elif s == 'WA':
        WA_counter[p] += 1
    else:
        AC_flags[p] = True
penalty = 0
for i in range(N):
    penalty += AC_flags[i] * WA_counter[i]
print(sum(AC_flags), penalty)

Solution (Python):
N, M = map(int, input().split())
ifACL = [0]*N
cWAL = [0]*N
psL = []
AC = 0
WA = 0
p = 0
s = 0
for _ in range(M):
  p, s = map(str, input().split())
  p = int(p)
  if ifACL[p-1] == 0 and s == "WA":
    cWAL[p-1] += 1
  elif ifACL[p-1] == 0 and s == "AC":
    AC += 1
    WA += cWAL[p-1]
    ifACL[p-1] = 1

print(AC, WA)

Solution (Python):
N,M = map(int,input().split())
A = [0 for _ in range(N+1)]
B = [0 for _ in range(N+1)]
for _ in range(M):
    p,S = input().split()
    p = int(p)
    if S=="AC":
        if A[p]==0:
            A[p]=1
    else:
        if A[p]==0:
            B[p] += 1
for i in range(N+1):
    if A[i]==0:
        B[i]=0
print(sum(A),sum(B))

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal











import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,m = readInts()
dic = defaultdict(int)
A = set()
for i in range(m):
    a,b = input().split()
    if dic['AC'+a] != 1:
        if b == 'AC':
            dic['AC'] += 1
            dic['AC'+a] = 1
        else:
            dic['WA'] += 1
            dic['WA'+a] += 1
    A.add(a)
for a in A:
    if dic['AC'+a] != 1:
        dic['WA'] -= dic['WA'+a]
print(dic['AC'],dic['WA'])

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

P = [0] * (n+1)
pena = [0] * (n+1)
for p,s in ps:
    p = int(p)
    if s == "WA":
        if P[p] == 0: pena[p] += 1
    else:
        P[p] = 1
ans = [0,0]
for p,pe in zip(P,pena):
    p = int(p)
    if p == 0: continue
    ans[0] += 1
    ans[1] += pe
print(" ".join(map(str, ans)))

Solution (Python):
n,m=map(int,input().split())
ac=[0]*(n+1)
wa=[0]*(n+1)
for i in range(m):
  a,b=map(str,input().split())
  a=int(a)
  if ac[a]==0:
    if b=='WA':
      wa[a]+=1
    else:
      ac[a]=1
print(sum(ac))
ans=0
for i in range(n+1):
  if ac[i]==1:
    ans+=wa[i]
print(ans)

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

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

for i in range(m):
    p, s = map(str, input().split())
    p = int(p)
    p -= 1
    if s == 'AC':
        a[p] = 1
    else:
        if a[p] == 0:
            b[p] += 1

c = 0
d = 0
for i in range(n):
    if a[i] != 0:
        c += a[i]
        d += b[i]
print(c, d)

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

w_a = [0]*n
a_c = [0]*n
for i in range(m):
    p,s = list(input().split())
    p = int(p)
    if s == 'WA' and (a_c[p-1] == 0):
        w_a[p-1] += 1
    else:
        a_c[p-1] = 1

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

print(str(ac), str(wa))

Solution (Python):
n, m = map(int, input().split())
r = [False] * n
w = [0] * n
ok = 0
ng = 0
for i in range(m):
  p, s = input().split()
  p = int(p)
  p -= 1
  if s == 'AC':
    if r[p] == False:
      ok += 1
      ng += w[p]
      r[p] = True
  else:
    w[p] += 1
print(ok, ng)

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

for i in range(M):
  p, s = map(str, input().split())
  p = int(p)
  if (s=='WA') and (ac[p-1]==0):
    wa[p-1] += 1
  else:
    ac[p-1] = 1
    
    
ans_ac = 0
ans_wa = 0
for i in range(N):
  if ac[i] == 1:
    ans_ac += 1
    ans_wa += wa[i]
    
print(str(ans_ac), str(ans_wa))

Solution (Python):
N, M = map(int, input().split())
Q = [[0, 0] for i in range(N+1)]
AC = 0
WA = 0

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

print(AC, WA)

Solution (Python):
from collections import defaultdict
dic = defaultdict(int)
N, M = map(int, input().split())
P = []
S = []
wa = 0
ac = 0
for _ in range(M):
    p, s = input().split()
    p = int(p)
    if s=="AC":
        if not dic[p]==-1:
            wa+=dic[p]
            ac+=1
            dic[p]=-1
    elif s=="WA":
        if not dic[p]==-1:
            dic[p]+=1
print(ac, wa)

Solution (Python):
import numpy as np
n,m = map(int, input().split())

ac_ques = np.array([0]*n)
count = np.array([0]*n)

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

print(sum(ac_ques),sum(ac_ques * count))

Solution (Python):
def resolve():
    N, M = list(map(int, input().split()))
    isac = {}
    wa = {}
    ac = 0
    penalty = 0

    for _ in range(M):
        p, S = list(input().split())
        p = int(p)
        if p not in wa:
            wa[p] = 0
        if S == 'AC':
            if isac.get(p) != True:
                ac += 1
                penalty += wa[p]
                isac[p] = True
        else:
            wa[p] += 1

    print(ac, penalty)
    return


resolve()

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

isACs = [0] * N
numWAs = [0] * N
numPenalty = 0
for _ in range(M):
    p, res = input().split()
    p = int(p) - 1
    if res == 'AC':
        if not isACs[p]:
            numPenalty += numWAs[p]
        isACs[p] = 1
    else:
        numWAs[p] += 1

numAC = sum(isACs)
print(numAC, numPenalty)

Solution (Python):
n, m = map(int, input().split())
if m == 0:
  print('0 0')
  exit()
acornot = [False] * n
walst = [0] * n
acsum = 0
for i in range(m):
  subnum, res = input().split()
  subnum = int(subnum) - 1
  if acornot[subnum] == False:
    if res == 'AC':
      acornot[subnum] = True
      acsum += 1
    else:
      walst[subnum] += 1
for i in range(n):
  if acornot[i] == False:
    walst[i] = 0
print(acsum, sum(walst))

Solution (Python):




class Counter(dict):
    def __missing__(self, i):
        return 0

class BoolDict(dict):
    def __missing__(self, i):
        return False

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

passed = 0
penalties = Counter()

ac = BoolDict()

for i in range(m):
    p, s = input().split()
    if not ac[p]:
        if s == "WA": penalties[p] += 1
        elif s == "AC":
            passed += 1
            ac[p] = True

x = 0
for i in penalties:
    if ac[i]:
        x += penalties[i]

print(passed, x)