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=[input().split() for i in range(M)]

WA=[]
AC=[]
for i in range(N):
    WA.append(0)
    AC.append(0)

for i in range(M):
    if P[i][1]=="WA" and  AC[int(P[i][0])-1]==0:
        WA[int(P[i][0])-1]+=1
    elif P[i][1]=="AC":
        AC[int(P[i][0])-1]=1
for i in range(N):
    if AC[i]==0:
        WA[i]=0

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

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

Problem = [[] for _ in range(N)]

for i in  range(M):
    p,S = input().split()
    p = int(p) - 1
    if (len(Problem[p])==0) or (len(Problem[p])>0 and Problem[p][-1]=='WA'):
        Problem[p].append(S)
ans_AC = 0
ans_WA = 0

for i in range(N):
    if 'AC' in Problem[i]:
        ans_AC += 1
        ans_WA += Problem[i].count('WA')

print('{} {}'.format(ans_AC,ans_WA))

Solution (Python):
n, m = map(int, input().split())
tmp  = [0]*n
wtmp = [0]*n
for _ in range(m):
    P, s = map(str, input().split())
    p = int(P)
    p -= 1
    if not tmp[p] == 0:
        continue
    if s == 'AC':
        tmp[p] = 1
    else:
        wtmp[p] += 1
ans1 = sum(tmp)
ans2 = 0
for i in range(n):
    if tmp[i] == 1:
        ans2 += wtmp[i]
print(ans1, ans2)

Solution (Python):






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





mydict = {}
for i in range(N):
    mydict[i+1] = {}
    mydict[i+1]["time"] = 0
    mydict[i+1]["AC"] = False
for x in pS:
    if x[1] == "AC":
        mydict[int(x[0])]["AC"] = True
    else: 
        if mydict[int(x[0])]["AC"] == False:
            mydict[int(x[0])]["time"] += 1
t = sum([d["time"] for d in list(mydict.values()) if d["AC"]])
ac = sum([1 for d in list(mydict.values()) if d["AC"]])
print(ac, t)

Solution (Python):
N, M = map(int, input().split())
countAC = 0
countPena = 0
if M:

    pS = [input().split() for _ in range(M)]
    p, S = [list(i) for i in zip(*pS)]

    dic = {}

    for i in range(M):
        if not p[i] in dic:
            dic[p[i]] = {
                'AC': 0,
                'WA': 0
            }

        if S[i] == 'AC':
            dic[p[i]]['AC'] += 1
        if S[i] == 'WA' and dic[p[i]]['AC'] == 0:
            dic[p[i]]['WA'] += 1

    for k, v in dic.items():
        if v['AC'] > 0:
            countAC += 1
            countPena += v['WA']

print(countAC, countPena)

Solution (Python):
n,m=map(int,input().split())
tmp=[0]*n
wtmp=[0]*n
for _ in range(m):
    P,s=map(str,input().split())
    p=int(P)
    p-=1
    if not tmp[p]==0:
        continue
    if s=='AC':
        tmp[p]=1
    else:
        wtmp[p]+=1
ans1=sum(tmp)
ans2=0
for i in range(n):
    if tmp[i]==1:
        ans2+=wtmp[i]
print(ans1,ans2)

Solution (Python):
import numpy as np
N,M = map(int, input().split())
p, S = [], []
for i in range(M):
  tmp = input().split()
  p.append(int(tmp[0]))
  S.append(tmp[1])

answer = np.zeros([N,2], dtype=int)
for i in range(M):
  if S[i] == 'AC' and answer[p[i]-1][0] == 0:
    answer[p[i]-1][0] += 1
  elif S[i] == 'WA' and answer[p[i]-1][0] == 0:
    answer[p[i]-1][1] += 1

total = [0, 0]
for i in range(N):
  if answer[i][0] == 1:
    total[0] += answer[i][0]
    total[1] += answer[i][1]
print(total[0], total[1])

Solution (Python):
import numpy as np
N,M = map(int, input().split())
p, S = [], []
for i in range(M):
  tmp = input().split()
  p.append(int(tmp[0]))
  S.append(tmp[1])

past_p = 0
tmp_AC, tmp_WA = 0, 0
total_AC, total_WA = 0, 0
answer_AC = np.zeros(N)
answer_WA = np.zeros(N)
for i in range(M):
  if S[i] == 'AC' and answer_AC[p[i]-1] == 0:
    answer_AC[p[i]-1] += 1
  elif S[i] == 'WA' and answer_AC[p[i]-1] == 0:
    answer_WA[p[i]-1] += 1


total_AC, total_WA = 0, 0
for i in range(N):
  if answer_AC[i] == 1:
    total_AC += answer_AC[i]
    total_WA += answer_WA[i]
print(int(total_AC), int(total_WA))

Solution (Python):
n1, n2 = [int(i) for i in input().split()]

d1 = {}
r1 = 0
r2 = 0

for i1 in range(n2):
    t1, t2 = [i for i in input().split()]
    if t1 in d1:
        t3 = d1.get(t1)
        if t3 != 0:
            if t2 == "AC":
                r1 += 1
                r2 += t3
                d1[t1] = 0 
            else:
                d1[t1] =  t3 + 1
    else:
        if t2 == "AC":
            d1[t1] = 0 
            r1 += 1
        else:
            d1[t1] = 1
        
print(str(r1) + " " + str(r2))

Solution (Python):
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue



ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)


MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    ANS = [sl() for _ in range(M)]

    keys = set()
    for p, S in ANS:
        keys.add(p)

    ret = {key: False for key in keys}
    acwa = {key:[0, 0] for key in keys}
    for p, S in ANS:
        if ret[p]: continue
        if S == 'WA':
            acwa[p][1] += 1
        if S == 'AC':
            acwa[p][0] += 1
            ret[p] = True

    ac, wa = 0, 0
    for key in keys:
        if ret[key]:
            ac += acwa[key][0]
            wa += acwa[key][1]
    print(ac, wa)


if __name__ == '__main__':
    main()

Solution (Python):
import sys











def my_input(): return sys.stdin.readline().rstrip()





def main():

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

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

    
    

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

    print(str(sum(ac)) + " " + str(sum(wa)))


if __name__ == '__main__':
    main()

Solution (Python):
















def main():

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

    
    

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

    print(str(sum(ac)) + " " + str(sum(wa)))


if __name__ == '__main__':
    main()

Solution (Python):

def inp():
    return(int(input()))



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



def instr():
    s = input()
    return(list(s[:len(s)]))



def invr():
    return(map(int, input().split()))


N, M = invr()
WA = [0] * (N+1)
AC = [0] * (N+1)
penalty = 0
for i in range(M):
    p, s = map(str, input().split())
    p = int(p)
    if s == "AC" and AC[p] == 0:
        AC[p] = 1
        penalty += WA[p]
    elif s == "WA" and AC[p] == 0:
        WA[p] += 1

print(sum(AC), penalty)

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

List = []
ans = [0  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 ans[p] == 0:
    if S == "AC":
      ans[p] = 1
    else:
      WA[p] += 1
      
A = sum(ans)

W= 0

for i in range(N+1):
  W += ans[i] * WA[i]

print(A,W)

Solution (Python):
n,m = map(int,input().split())
PS = [list(input().split()) for _ in range(m)]
ac = 0
wa = 0
tac = [0]*n
twa = [0]*n
for ps in PS:
  if tac[int(ps[0])-1]==0:
    if ps[1]=='AC':
      ac += 1
      wa += twa[int(ps[0])-1]
      tac[int(ps[0])-1] = 1
    else:
      twa[int(ps[0])-1] += 1
print(ac,wa)

Solution (Python):
n,m = [int(x) for x in input().split(' ')]

info = {
    
}

for i in range(m):
    p,s = [x for x in input().split(' ')]
    if p not in info:
        if s == "WA":
            info[p] = [0, 1]
        elif s == "AC":
            info[p] = [1,0]
    else:
        if s == "WA":
            if info[p][0] == 0:
                info[p][1] += 1
        elif s == "AC":
            if info[p][0] == 0:
                info[p][0] = 1
    
ac = 0
wa = 0

for a in info.values():
    ac += a[0]
    if a[0] > 0:
        wa += a[1]

print(ac, wa)

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

for i in range(m):
  p,s = input().split()
  if s == 'AC':
    aclist[int(p)-1] = 1
  elif s == 'WA' and aclist[int(p)-1] == 0:
    walist[int(p)-1] += 1 
    
for i in range(n):
  if aclist[i] == 0:
    walist[i] = 0
    
print(sum(aclist),sum(walist))

Solution (Python):
import collections
k,n = map(int, raw_input().split(' '))
cc = {'AC': collections.Counter(), 'WA': collections.Counter()}
for _ in range(n):
	i,res = raw_input().split(' ')
	i = int(i)
	if res == 'AC':
		cc['AC'][i] += 1
	elif res == 'WA' and cc['AC'][i] == 0: 
		cc['WA'][i] += 1

print len(cc['AC']), sum([cc['WA'][p] for p in cc['AC']] or [0])

Solution (Python):
import collections
k,n = map(int, raw_input().split(' '))


cc = {'AC': collections.Counter(), 'WA': collections.Counter()}
for _ in range(n):
	i,res = raw_input().split(' ')
	i = int(i)
	if res == 'AC':
		cc['AC'][i] += 1
	elif res == 'WA':
		if cc['AC'][i] == 0:
			cc['WA'][i] += 1
s = 0
for p in cc['AC']:
	s += cc['WA'][p]
print len(cc['AC']), s

Solution (Python):
N, M = map(int, input().split())
dict={}
ans=[0, 0]
for i in range(M):
	P, S = input().split()
	if P not in dict:
		if S=="AC":
			ans[0]+=1
			dict[P]=S
		else:
			dict[P]=[S, 1]
	else:
		if dict[P][0]=="WA":
			if S=="WA":
				dict[P][1]+=1
			else:
				ans[0]+=1
				ans[1]+=dict[P][1]
				dict[P]=S
		else:
			continue

print(ans[0], ans[1])

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

for i in range(m):
    x = list(map(str,input().split(" ")))
    x0 = int(x[0])
    x1 = str(x[1])
    if ac_list[x0-1] == 1:
        pass
    else:
        if x1 == "AC":
            ac_count += 1
            ac_list[x0-1] = 1
        else:
            wa_list[x0-1] += 1

acnone =[i for i, x in enumerate(ac_list) if x == 0]
if not acnone:
    pass
else:
    for i in acnone:
        wa_list[i] = 0
wa_count = sum(wa_list)
print(ac_count,wa_count)

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

Solution (Python):
n,m=map(int,input().split())
acount=0
wcount=0
a=[False]*n
w=[0]*n
for i in range(m):
  p,m=input().split()
  p=int(p)
  if m=="AC":
    if a[p-1]==False:
      acount+=1
      a[p-1]=True
  else:
    if a[p-1]==False:
      w[p-1]+=1
      
for i in range(n):
  if a[i-1]==1:
    wcount+=w[i-1]
    
print(acount,wcount)

Solution (Python):
n,m=map(int,input().split())
acount=0
wcount=0
a=[0]*n
w=[0]*n
for i in range(m):
  p,m=map(str,input().split())
  p=int(p)
  if m=="AC":
    if a[p-1]==0:
      acount+=1
      a[p-1]+=1
  else:
    if a[p-1]==0:
      w[p-1]+=1
      
for i in range(n):
  if a[i-1]==1:
    wcount+=w[i-1]
    
print(acount,wcount)

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 ac[p] == False:
            wa[p] += 1

ac_cnt = 0
wa_cnt = 0

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

print(ac_cnt,wa_cnt)

Solution (Python):
N, M = map(int, input().split())
ans = []
for m in range(M):
    ans.append(input().split())

ac = [0 for n in range(N)]
wa = [0 for n in range(N)]
w = 0
for a in ans:
    if ac[int(a[0])-1] == 1:
        continue
    else:
        if a[1] == "AC":
            ac[int(a[0])-1] = 1
            w += wa[int(a[0])-1]
        else:
            wa[int(a[0])-1] += 1
        
print(sum(ac), w)

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

ps=[]
pena=[[0,False] for _ in range(n)]
for i in range(m):
    ps.append(input().split())
 
for i in range(m):
    if pena[int(ps[i][0])-1][1]==False and ps[i][1]=="WA":
        pena[int(ps[i][0])-1][0]+=1
    else:
        pena[int(ps[i][0])-1][1]=True
ans=0
for i in range(n):
    if pena[i][1]==True:
        ans+=pena[i][0]
        
t=[pena[i][1] for i in range(len(pena))]
print(t.count(True),ans)

Solution (Python):
N, M = map(int, input().split())
cleared = [0 for i in range(N)]
wrong = [0 for i in range(N)]
penalty = 0
for i in range(M):
  p, s = map(str, input().split())
  p = int(p) - 1
  if cleared[p] == 1:
    continue
  if s == "AC":
    cleared[p] = 1
    penalty += wrong[p]
  else:
    wrong[p] += 1
print(sum(cleared), penalty)

Solution (Python):
from collections import defaultdict

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

cleared = set()
penalties = defaultdict(int)

for _ in range(M):
    q, result = input().split(' ')
    if result == 'AC':
        cleared.add(q)
    elif q not in cleared:
        penalties[q] += 1

print(len(cleared), sum([penalties[q] for q in cleared]))

Solution (Python):
n,m=map(int,input().split())
p=[True]*n
y=[0]*n
i=0
l=0
for  _ in range(m):
    k,o=input().split()
    k=int(k)-1
    if p[k]==True:
        if o=="AC":
            i+=1
            p[k]=False
        else:
            y[k]+=1
for e in range(n):
    if p[e]==False:
        l+=y[e]
print(i,l)

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):
import sys
import math
import itertools
import numpy

rl = sys.stdin.readline

n, k= map(int, rl().split())
li = [[0, 0] for _ in range(n)]
for _ in range(k):
    a, b = rl().split()
    b = b.rstrip()
    a = int(a) - 1
    if li[a][1] == 0:
        if b == 'WA':
            li[a][0] += 1
        else:
            li[a][1] = 1
ac = 0
wa = 0
for lis in li:
    i, v = lis
    if v == 1:
        ac += 1
        wa += i
print(ac, wa)

Solution (Python):
n,m = map(int, input().split())
wa = [0]*n
ac = [0]*n
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]==0:
        wa[i] = 0
 
print(sum(ac), sum(wa))

Solution (Python):
n,m = map(int, input().split())
wa = [0]*n
ac = [0]*n
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]==0:
        wa[i] = 0

print(sum(ac), sum(wa))

Solution (Python):
def main():
    
    N,M=map(int,input().strip().split())
    cnt=[0 for n in range(N)]
    flag=[0 for n in range(N)]
    
    for _ in range(M):
        pS=list(input().strip().split())
        x=int(pS[0])
        y=pS[1]
        if flag[x-1]==0:
            if y=="WA":
                cnt[x-1]+=1
            else:
                flag[x-1]=1
                
    num_AC=sum(flag)
    num_WA=sum([cnt[n] for n in range(N) if flag[n]==1])
                
    print(str(num_AC)+" "+str(num_WA))

if __name__=="__main__":
   main()

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

miss=[[0,False] for _ in range(N)]

for p,s in PS:
  p=int(p)
  if miss[p-1][1]==False and s=="WA":
    miss[p-1][0]+=1
  if s=="AC":
    miss[p-1][1]=True
pena=0
ac=0
for m,tf in miss:
  pena+=m*tf
  ac+=tf

print(str(ac)+" "+str(pena))

Solution (Python):
N,M=map(int,input().split())
fin=set()
AC=0
WA=0
WAL=[0]*N
for i in range(M):
  p,s=input().split()
  p=int(p)
  if not p in fin:
    if s=="AC":
      AC+=1
      fin.add(p)      
    if s=="WA":
      WAL[p-1]+=1
for k in fin:
  WA+=WAL[k-1]
print(AC,WA)

Solution (Python):
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

acs = set()
wcs = dict()
wc = 0

n,m = nm()
for i in range(m):
  p,s = input().split()
  if s == 'AC':
    if p not in acs:
      if p in wcs:
        wc+=wcs[p]
    acs.add(p)
  elif p not in acs:
    if p not in wcs:
      wcs[p]=0
    wcs[p]+=1

print(len(acs))
print(wc)

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

num = [0]*n
flag = [False]*n

for _ in range(m):
  p,s = input().split()
  p = int(p)-1
  if flag[p]:
    continue
  else:
    if s == "AC":
      flag[p] = True
    else:
      num[p] += 1

for i in range(n):
  if flag[i] == False:
    num[i] = 0
    
print(flag.count(True),sum(num))

Solution (Python):
N,M=map(int,input().split())
P,S=[],[]
ans,pen=0,0
task=[0]*N
for _ in range(M):
    A,B=map(str,input().split())
    P.append(int(A))
    S.append(B)

for j in range(M):
    if task[P[j]-1]!=-1 and S[j]=="WA":
        task[P[j]-1]+=1
    elif task[P[j]-1]!=-1 and S[j]=="AC":
        ans+=1
        pen+=task[P[j]-1]
        task[P[j]-1]=-1
print(ans,pen)

Solution (Python):
from collections import defaultdict
n,m = map(int,input().split())
l = [input().split() for _ in range(m)]
d = defaultdict(int)
count1=0 
count2=0 
for i in l:
    if i[1]=="WA" and d[i[0]]!= "OK":
        (d[i[0]]) += 1
    if i[1] =="AC"and d[i[0]]!= "OK":
        count1 += 1
        count2 += int(d[(i[0])])
        d[i[0]] ="OK"
print(count1,count2)

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

print(ac, penalty)

Solution (Python):
n, m = map(int, input().split())
flag = [False]*n
wa = [0]*n
penalty = 0
corr = 0
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC':
        if flag[p]:
            continue
        else:
            corr += 1
            flag[p] = True
    else:
        if not flag[p]:
            wa[p] += 1
for j in range(n):
    if flag[j]:
        penalty += wa[j]

print(corr, 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 ac[p]==0:
    if s=='AC':
      ac[p]=1
    else:
      wa[p]+=1

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

print(sum(ac),wasum)

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

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

for i in range(m):
    if ac[int(ps[i][0])-1]==None and ps[i][1]=='AC':
        ac[int(ps[i][0])-1]=1
        wa_cnt+=wa[int(ps[i][0])-1]
    elif ac[int(ps[i][0])-1]==None and ps[i][1]=='WA':
        wa[int(ps[i][0])-1]+=1
print(ac.count(1), wa_cnt)

Solution (Python):
N, M = map(int,input().split()) 
p = [0]*M
S = [0]*M
T = [0]*(N+1) 
U = [0,0]
for i in range(M):
  p[i],S[i] = input().split()
  P = int(p[i])
  if T[P] != -1:
    if S[i] == 'WA':
      T[P] += 1
    elif S[i] == 'AC':
      U[0] += 1
      U[1] += T[P]
      T[P] = -1


print(U[0],U[1])

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)
    if s=='AC' and a[p-1]==0:
        a[p-1]+=1
    elif s=='WA' and a[p-1]==0:
        b[p-1] +=1
for j in range(n):
    if a[j]==0:
        b[j]=0
        
print(sum(a),sum(b))

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

for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == "AC":
        if ACc[p - 1] == 0:
            ACc[p - 1] += 1
    else:
        if ACc[p - 1] != 1:
            WAc[p - 1] += 1
for j in range(n):
    if ACc[j] == 0:
        WAc[j] = 0

print(sum(ACc), sum(WAc))

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

for i in range(m):
    p,s = input().split()
    p = int(p)
    if s == "AC":
        if ACc[p-1] == 0:
            ACc[p-1] += 1
    else:
        if ACc[p-1] != 1:
            WAc[p-1] += 1
for j in range(n):
    if ACc[j] == 0:
        WAc[j] = 0

print(sum(ACc),sum(WAc))

Solution (Python):
n,m=map(int,input().split())
num = [1]*(n + 1)
pena = [0]*(n + 1)
AC_cnt = 0
WA_cnt = 0
for i in range(m):
    p,s=input().split()
    if s == 'AC':
        if num[int(p)]:
            num[int(p)] = 0
            AC_cnt += 1
            WA_cnt += pena[int(p)]
    else:
        pena[int(p)] += 1
print(AC_cnt,WA_cnt)

Solution (Python):
N, M = map(int, input().split())
ACs = [False]*N
WAs = [0]*N
for i in range(M):
  sp, S = input().split()
  p = int(sp)-1
  if S == "AC":
    ACs[p] = True
  elif S == "WA":
    if not ACs[p]:
      WAs[p] += 1
r1 = 0
r2 = 0
for i in range(N):
  if ACs[i]:
    r1 += 1
    r2 += WAs[i]
print(r1, r2)

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


correct = 0
penalty = 0
true_flag = [True] * (10 ** 5)
d = {}

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

    
    if p not in d and s == 'AC':
        d[p] = 1
        correct += 1
        true_flag[p] = False
    
    if not true_flag[p]:
        continue  

    if s == 'AC':
        penalty += d[p]
        correct += 1
        true_flag[p] = False
    
    elif p not in d:
        d[p] = 1
    else:
        d[p] += 1

print(correct, penalty)

Solution (Python):
N, M = map(int, input().split())
AC = [0]*N         
WA = [0]*N        
count_WA = 0
for i in range(M):
  P,s = map(str, input().split())
  p = int(P)
  if AC[p-1]==1:
    continue
  if s == "WA":
    WA[p-1] += 1
  else:           
    count_WA += WA[p-1]
    AC[p-1] = 1
print(AC.count(1), count_WA)

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


correct = 0
penalty = 0
true_flag = [True] * (10 ** 5)
d = {}

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

    
    if p not in d and s == 'AC':
        d[p] = 1
        correct += 1
        true_flag[p] = False
        
        
    
    if true_flag[p]:
        if s == 'AC':
            penalty += d[p]
            correct += 1
            true_flag[p] = False
            
            
        
        else:
            if p not in d:
                d[p] = 1
                
                
            else:
                d[p] += 1
                
                

print(correct, penalty)

Solution (Python):
N, M = map(int, input().split())
ans = 0
pen = 0
w = [0]*(N+1)
ac = [False]*(N+1)
for _ in range(M):
    p, s = input().split()
    if s == "AC" and not ac[int(p)]:
        pen += w[int(p)]
        ac[int(p)] = True
        ans += 1
    elif s == "WA":
        w[int(p)] += 1
print(ans, pen)

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

baselis = []

for _ in range(M):
    temp = [x for x in input().split()]
    baselis.append(temp)

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

for i in range(M):
    result = baselis[i][1]
    question = int(baselis[i][0])

    if result == 'AC' and ac[question] == 0:
        ac[question] = 1
    elif result == 'WA' and ac[question] == 0:
        wa[question] += 1

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

print(sum(ac), sum(wa))

Solution (Python):
N, M = map(int,input().split())
ac = [False] * N
wa = [0] * N
for _ in range(M):
    p_, s_ = map(str,input().split())
    p = int(p_)-1
    if s_ == 'AC':
        ac[p] = True
    else:
        if not ac[p]:
            wa[p] += 1

ans_ac,ans_wa = 0,0
for  i in range(N):
    if ac[i]:
        ans_ac += 1
        ans_wa += wa[i]
print(ans_ac,ans_wa)

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

Solution (Python):
N,M = list(map(int,input().split()))
PS = [input().split() for _ in range(M)]
status = {i[0]:[False,0] for i in PS}
countac = 0
countwa = 0
for ps in PS:
    if ps[1] == 'AC':
        if status[ps[0]][0] == False:
            status[ps[0]][0] = True
            countac += 1
            countwa += status[ps[0]][1]
    else:
        if status[ps[0]][0] == False:
            status[ps[0]][1] += 1
print(str(countac)+' '+str(countwa))

Solution (Python):
n,m=map(int,input().split())
a=[[] for ii in range(n)]
for ii in range(m):
  p,s=input().split()
  p=int(p)-1
  a[p].append(s)
r=0
q=0
for ii in range(n):
  
  if "AC" in a[ii]:
    r+=1
    q+=a[ii].index("AC")
print(r,q)

Solution (Python):
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N,M = LI()
pS = [LS() for _ in range(M)]
set_AC = set()
count_WA = collections.defaultdict(int)
ans_AC,ans_WA = 0,0
for x in pS:
    p,S = int(x[0]),x[1]
    if p in set_AC:
        continue
    if S=='AC':
        set_AC.add(p)
        ans_AC += 1
        ans_WA += count_WA[p]
    else:
        count_WA[p] += 1
print(ans_AC,ans_WA)

Solution (Python):
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N,M = LI()
pS = [LS() for _ in range(M)]
count_AC = collections.defaultdict(int)
count_WA = collections.defaultdict(int)
for x in pS:
    p,S = int(x[0]),x[1]
    if p in count_AC:
        continue
    if S=='AC':
        count_AC[p] += 1
    else:
        count_WA[p] += 1
print(sum(count_AC.values()),sum([count_WA[k] for k in count_AC]))

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

ans_dic = {}
pen_dic = {}
for ps in ps_list:
    p = int(ps[0])
    ans_dic[p] = 0
    pen_dic[p] = 0
ans = 0
pen = 0

for ps in ps_list:
    p, s = ps
    p = int(p)
    if s == 'AC':
        if ans_dic[p] == 0:
            ans += 1
            pen += pen_dic[p]
        ans_dic[p] = 1
    elif s == 'WA':
        pen_dic[p] += 1

print(ans, pen)

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

ac=[True]*n
d=[0]*n
tw=0
ta=0
for i in a:
  j=int(i[0])-1
  if (ac[j]):
    if (i[1]=="WA"):
      d[j]+=1
    else :
      tw+=d[j]
      ta+=1
      ac[j]=False
print(ta,tw)

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

Solution (Python):




def input_int():
    return int(input())



def int1(x):
    return int(x) - 1



def input_to_int_map():
    return map(int, input().split())



def input_to_int_tuple():
    return tuple(map(int, input().split()))



def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    n, m = input_to_int_map()
    ps = [input().split() for i in range(m)]

    success_cnts = [0] * (n + 1)
    wrong_cnts = [0] * (n + 1)

    for p, s in ps:
        if success_cnts[int(p)] > 0:
            continue

        if s == "AC":
            success_cnts[int(p)] += 1
        elif s == "WA":
            wrong_cnts[int(p)] += 1

    success_cnt = 0
    wrong_cnt = 0
    for i, success in enumerate(success_cnts):
        if success > 0:
            success_cnt += 1
            wrong_cnt += wrong_cnts[i]

    print(" ".join([str(success_cnt), str(wrong_cnt)]))


if __name__ == "__main__":
    main()

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

ac = [False] * N
wa = [0] * N
for _ in range(M):
    q, res = input().split()
    q = int(q) - 1
    if res == 'AC':
        ac[q] = True
    else:
        if not ac[q]:
            wa[q] += 1

num_corr, num_wro = 0, 0
for q in range(N):
    if ac[q]:
        num_corr += 1
        num_wro += wa[q]

print(num_corr, num_wro)

Solution (Python):
N,M = map(int,input().split())
AC = 0
WA = 0
tmp_WA = [0]*N
lst = []
for _ in range(M):
    lst.append(list(input().split()))



ques = [0]*N



for i in range(M):


    if ques[int(lst[i][0])-1] != 1:
        if lst[i][1] == 'WA':
            tmp_WA[int(lst[i][0])-1] += 1
        else:
            AC += 1
            ques[int(lst[i][0])-1] = 1
for j in range(N):
    if ques[j] != 1:
        tmp_WA[j] = 0

print(str(AC) + ' ' + str(sum(tmp_WA)))

Solution (Python):
n,m = map(int,input().split())
ac_c = [False]*(n+1)
wa_c = [0]*(n+1)

for i in range(m):
    p,s=input().split()
    p = int(p)
    if(ac_c[p]):
        continue
    if(s=='WA'):
        wa_c[p] += 1
    if(s=='AC'):
        ac_c[p] = True

wa_ans = 0
for i in range(1,n+1):
    if(ac_c[i]):
        wa_ans += wa_c[i]
print(sum(ac_c),wa_ans)

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=="WA":
    if AC[p]==0:
      WA[p]+=1
  else:
    AC[p]=1

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

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=="WA":
    if AC[p]==0:
      WA[p]+=1
  else:
    AC[p]=1

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

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=="WA":
        if AC[p]==0:
            WA[p]+=1
    else:
        AC[p]=1

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