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 = [int(x) for x in input().split()]

obj = {}
ii = 0
jj = 0

for i in range(M):
    p = [x for x in input().split()]
    key = p[0]
    res = p[1]
    if key not in obj:
        obj[key] = {'AC': 0, 'WA': 0}
    if res == 'WA' and obj[key]['AC'] == 0:
        obj[key]['WA'] = obj[key]['WA'] + 1
    if res == 'AC':
        obj[key]['AC'] = 1

for k in obj:
    ii = ii + obj[k]['AC']
    if obj[k]['AC'] > 0:
        jj = jj + obj[k]['WA']


print(ii, jj)

Solution (Python):
from collections import defaultdict

N, M = map(int, input().split())
res = defaultdict(list)
for _ in range(M):
    p, s = input().split()
    p = int(p) - 1
    res[p].append(s)

num_AC = num_WA = 0
for p, xs in res.items():
    wa = 0
    for i, x in enumerate(xs):
        if x == 'AC':
            num_AC += 1
            num_WA += wa
            break
        else:
            wa += 1

print(num_AC, num_WA)

Solution (Python):

N,M=map(int,input().split())
A=[[] for i in range(N)]
for i in range(M):
    Pi,Si=map(str,input().split())
    Pi=int(Pi)
    A[Pi-1].append(Si)




nAC=0
nWA=0
inWA=0
j=0
for i in range(N):
    
    if len(A[i])==0:
        pass
    else: 
        while A[i][j]=="WA":
            inWA+=1
            nWA+=1
            
            
            
            if j==len(A[i])-1:
                nWA-=inWA
                break
            else:
                pass
            j+=1
        if A[i][j]=="AC":
            nAC+=1
        else:
            pass
        inWA=0
        j=0
        
        
        


print("{0} {1}".format(nAC,nWA))

Solution (Python):
n, m = map(int, input().split())
if m == 0:
    print("0 0")
else:
    p = 0
    p_flag = [0] * n
    s = 0
    s_flag = [0] * n
    for i in range(m):
        b = input().split()
        b[0] = int(b[0])
        if b[1] == 'AC':
            if s_flag[b[0] - 1] == 0:
                s += 1
                s_flag[b[0] - 1] = 1
                p += p_flag[b[0] - 1]
        else:
            p_flag[b[0] - 1] += 1
    print(str(s) + " " + str(p))

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

pe=0

for i in range(M):
  num, result = map(str, input().split())
  num = int(num)-1
  
  if ac[num]==0 and result=='AC':
    ac[num] += 1
    pe += wa[num]
    
  elif ac[num]==0 and result=='WA':
    wa[num] +=1

print(sum(ac), pe)

Solution (Python):
N,M=map(int,input().split())
P=[0]*M
S=[0]*M
cor=[0]*N
ac,wa=0,0
for i in range(M):
    P[i],S[i]=input().split()
    P[i]=int(P[i])
    if(S[i]=="AC"):
        cor[P[i]-1]+=1
    else:
        pass
for i in range(M):
    if(cor[P[i]-1]>=1 and S[i]=="WA"):
        wa+=1
    elif(cor[P[i]-1]>=1 and S[i]=="AC"):
        cor[P[i]-1]=0
        ac+=1
    else:
        pass
print("{0} {1}".format(ac,wa))

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

Solution (Python):
NM = input().split()
N = int(NM[0])
M = int(NM[1])
prob = []
probStatus = []
for i in range(M):
    pS = input().split()
    prob.append(int(pS[0]))
    probStatus.append(pS[1])
correctAr = [0] * N
penaltyAr = [0] * N
submissions = [''] * N
for i in range(M):
    if probStatus[i] == 'AC' and submissions[prob[i] - 1] == '':
        correctAr[prob[i] - 1] += 1
        submissions[prob[i] - 1] = 'AC'
    elif probStatus[i] == 'WA' and submissions[prob[i] - 1] == '':
        penaltyAr[prob[i] - 1] += 1
correct = 0
penalty = 0
for i in range(N):
    if submissions[i] == 'AC':
        correct += correctAr[i]
        penalty += penaltyAr[i]

print(correct, penalty)

Solution (Python):
n, m = map(int, input().split())
won = set()
d = {}
penalties = 0
for i in range(m):
  x = input().split()
  ID = x[0]
  stat = x[1]
  if ID in won:
    continue
  if stat == "WA":
    if (d.get(ID, None)):
      d[ID] += 1
    else:
      d[ID] = 1
  else:
    won.add(ID)

for item in won:
    penalties += d.get(item,0)
print(len(won), penalties)

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

data = {}

for _ in range(M):
  p_i, result = map(str, input().split())
  if int(p_i) not in data.keys():
    data[int(p_i)] = [False if result == "WA" else True]
  else:
    data[int(p_i)].append(False if result == "WA" else True)

correct_answers = 0
penalties = 0
for prob in data.keys():
  if True in data[prob]:
    i = 0
    correct_answers += 1
    while not data[prob][i]:
      penalties += 1
      i+= 1
    
print(correct_answers, penalties)

Solution (Python):
N, M = map(int, input().split())
l = [0] * (N + 1)
ac = 0
wa = 0
for _ in range(M):
    p, S = input().split()
    if S == 'WA':
        if l[int(p)] >= 0:
            l[int(p)] += 1
    else:
        if l[int(p)] >= 0:
            wa += l[int(p)]
            ac += 1
            l[int(p)] = -1

print(ac, wa)

Solution (Python):












NM = list(map(int, input().split()))
ps = [list(input().split()) for i in range(NM[1])]
a=[0]*NM[0]
flg = [True]*NM[0]
for i in range(NM[1]):
    ps[i][0] = int(ps[i][0])

ans = [0]*NM[0]
ac = 0
for i in range(NM[1]):
    if ps[i][1] == "AC" and flg[ps[i][0]-1]:
        flg[ps[i][0]-1] = False
        ans[ps[i][0]-1] = a[ps[i][0]-1]
    if ps[i][1] == "WA" and flg[ps[i][0]-1]:
        a[ps[i][0]-1] += 1

for i in range(NM[0]):
    if flg[i]== False:
        ac += 1
print(ac,sum(ans))

Solution (Python):
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines







def main():
	n,m=map(int,input().split())
	
	li=[0]*(n+1)
	
	wa=0
	
	for i in range(m):
		p,s=input().split()
		p=int(p)
		s=s.rstrip().decode('utf-8')
		
		if li[p]==-1:
			continue
		if s=="WA":
			li[p]+=1
		else:
			wa+=li[p]
			li[p]=-1
	
	print(li.count(-1),wa)
	
	

if __name__ == "__main__":
	main()

Solution (Python):
n,m = map(int, input().split())
ps = [input().split() for i in range(m)]
al = [0] * (n+1)
pe = [0] * (n+1)
ans_a, ans_p = 0,0
for p,s in ps:
  p = int(p)
  if al[p]:
    continue
  if s == "AC":
    al[p] = 1
    ans_p += pe[p]
    ans_a += 1
  else:
    pe[p] += 1
print(ans_a, ans_p)

Solution (Python):
listA=[] 
while True:
    try:
        listA.append(input().split())
    except:
        break;
        
N = int(listA[0][0])
M = int(listA[0][1])

ans = [0] * N
pena = [0] * N

for i in range(1, M+1):
    num=int(listA[i][0]) -1
    res=listA[i][1]
    if res=="WA" and ans[num] == 0:
        pena[num] =  pena[num]+1
    if res=="AC" and ans[num] == 0:
        ans[num] = 1
        
print('%d %d' % (sum(ans), sum(x*y for x,y in zip(ans,pena)  ) ))

Solution (Python):



def pin(type=int):
    return map(type,input().split())




N,M = pin() 
p=[0 for j in range(0,M)]
S=[0 for j in range(0,M)]
for j in range(0,M):
    p[j],S[j] =pin(str) 
    




AC=[0 for i in range(0,N)]
Penalties = [0 for i in range(0,N)]


"""
for i in range(0,N):
    for j in range(0,M):
    
        
        if int(p[j])-1==i:
            if (S[j]) == 'WA':
                Penalties[int(p[j])-1] += 1
            else:
                AC[int(p[j])-1] = 1
                break
            
"""




for j in range (0,M):
    if S[j] == "AC":
        if AC[int(p[j])-1]==1:
            continue
        else:
            AC[int(p[j])-1]=1
    else:
        if AC[int(p[j])-1]==1:
            continue
        else:
            Penalties[int(p[j])-1]+=1
  

for i in range(0,N):
    if AC[i] == 0:
        Penalties[i]=0






print(AC.count(1),sum(Penalties))

Solution (Python):
import sys

N, M = [int(i) for i in input().split()]
wa_dict = {}
for line in sys.stdin:
  line = line.rstrip().split()
  if len(line) == 0: break
  p = int(line[0])
  S = line[1]
  if p not in wa_dict:
    if S == "WA":
      wa_dict[p] = 1
    else:
      wa_dict[p] = 0
  elif wa_dict[p] > 0:
    if S == "WA":
      wa_dict[p] += 1
    else:
      wa_dict[p] *= -1
ac = sum([1 for i in wa_dict.values() if i <= 0])
wa = sum([abs(i) for i in wa_dict.values() if i <= 0])
print("{} {}".format(ac, wa))

Solution (Python):


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

penalty = [0 for _ in range(n)]
result = [0 for _ in range(n)]

for i in range(m):
    p, s = input().split(' ')
    p = int(p)
    if s == 'AC':
        result[p-1] = 1
    elif s == 'WA' and result[p-1] != 1:
        penalty[p-1] += 1
    
penalty = [x * y for (x, y) in zip(penalty, result)]

print(sum(result), sum(penalty))

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

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

print("{} {}".format(AC , WA))

Solution (Python):
n,m=map(int,input().split())
anslis=set()
plis=[0]*n
acount=0
pcount=0
for i in range(m):
	p,s=map(str,input().split())
	if int(p) not in anslis:
		if s=="WA":
			plis[int(p)-1]+=1
		elif s=="AC":
			anslis.add(int(p))
			acount+=1
			pcount+=plis[int(p)-1]
print(acount,pcount)

Solution (Python):
N, M = map(int, input().split())
lis = [[] for _ in range(N)]
for _ in range(M):
  question, result = input().split()
  question = int(question)
  lis[question-1].append(result)  

AC_times = 0
WA_times = 0
for i in range(N):
  pre_WA_times = 0
  for j in lis[i]:
    passed = False
    if not passed:
      if j == "AC":
        passed = True
        WA_times += pre_WA_times
      elif j == "WA":
        pre_WA_times += 1
    if passed:
      AC_times += 1
      break
      
print(AC_times, WA_times)

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

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

for i in range(m):
    question, answer = input().split()
    question = int(question)
    if (answer == "AC") and (ac[question] == 0):
        ac[question] = 1
        pena += wa[question]
    elif (answer == "WA") and (ac[question] == 0):
        wa[question] += 1

print(sum(ac), pena)

Solution (Python):
n, m = map(int, input().split())
score = [(False, 0) for i in range(n)]
for i in range(m):
	problem, s = input().split()
	p = int(problem)-1
	if not score[p][0]:
		score[p] = (True, score[p][1]) if s=="AC" else (False, score[p][1]+1)
	

print(sum(i[0] for i in score), sum(j if i else 0 for i, j in score))

Solution (Python):
n,m = map(int, input().split())
ac,wa = [0]*n,[0]*n
ans = 0
miss = 0
for i in range(m):
  a,b = map(str, input().split())
  a = int(a)
  if b == "AC":
    if ac[a-1]==0:
      ans += 1
      miss += wa[a-1]
      ac[a-1] += 1
  else:
    if ac[a-1]==0:
      wa[a-1] += 1
    
print("%d %d" %(ans, miss))

Solution (Python):
n, m = map(int, input().split())
yes = [False for i in range(n)]
negative = [0 for i in range(n)]
score = [0 for i in range(n)]
for i in range(m):
	problem, s = input().split()
	p = int(problem)
	if s=="AC" and not yes[p-1]:
		yes[p-1] = True
		score[p-1] = negative[p-1]
	else:
		negative[p-1] += 1
	

print(sum(yes), sum(score))

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

results = {}

for i in range(m):
    line = input().split()
    
    if not line[0] in results:
        results[line[0]] = [0, 0]
    elif results[line[0]][1] == 1:
        continue
    
    if line[1] == "WA":
        results[line[0]][0] += 1
    elif line[1] == "AC":
        results[line[0]][1] = 1

ac_num = 0
wa_in_ac = 0

for key in results:
    if results[key][1] == 1:
        ac_num += 1
        wa_in_ac += results[key][0]

print(ac_num, wa_in_ac)

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

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

l.sort(key=lambda x:(x[0],x[2]))

f=""
q=""
a=0
w=0

for i in range(m):
    if l[i][0] != f:
        ww=0
    if l[i][1] == "AC":
        if l[i][0] != q:
            a+=1
            w+=ww
            q=l[i][0]
    else:
        ww+=1
    
    f=l[i][0]

print(a,w)

Solution (Python):
def main():
    n,m = map(int,input().split())
    flag = [False for i in range(n+5)]
    AC = 0
    WA = [0 for i in range(n+5)]
    _WA = 0
    for i in range(m):
        input_line = input().split()
        p,s = int(input_line[0]), input_line[1]
        if flag[p] == False:
            if s == "AC":
                AC += 1
                _WA += WA[p]
                flag[p] = True
            else:
                WA[p] += 1
    print(AC,_WA)
    return


if __name__ == "__main__":
    main()

Solution (Python):
import sys
input = sys.stdin.readline
n,m = map(int, input().split())
a_cnt,p_cnt = [0]*n,[0]*n 
for i in range(m):
	p,s = input().split()
	if a_cnt[int(p)-1] == 0: 
		if s == "AC":
			a_cnt[int(p)-1] = 1
		elif s== "WA": 
			p_cnt[int(p)-1] += 1
for i in range(n):
	if a_cnt[i] == 0:
		p_cnt[i] = 0
print(sum(a_cnt),sum(p_cnt))

Solution (Python):
N, M = map(int, input().split())
ACed = [False] * N
wa = [0] * N
for i in range(M):
  p, s = input().split()
  p = int(p)-1
  if s == "AC":
    if not ACed[p]:
      ACed[p] = True
  else:
    if not ACed[p]:
      wa[p] += 1

was = 0
for i in range(N):
  was += ACed[i] * wa[i]

print(sum(ACed), was)

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

ac = [False] * (n + 1)
wa = [0] * (n + 1)
for i in range(m):
    if not ac[ps[i][0]]:
        if ps[i][1] == "WA":
            wa[ps[i][0]] += 1
        elif ps[i][1] == "AC":
            ac[ps[i][0]] = True
wa_sum = 0
for i in range(n + 1):
    if ac[i]:
        wa_sum += wa[i]
print(str(ac.count(True)) + " " + str(wa_sum))

Solution (Python):
N,M = map(int,input().split())
k = {}
for i in range(M):
  p,s = input().split()
  if p not in k:
    k[p] = [s]
  else:
    k[p].append(s)
ac = 0
wa = 0
for l in k:
  now = 0
  for m in k[l]:
    if m == "WA":
      now += 1
    elif m == "AC":
      ac += 1
      wa += now
      break
print(ac,wa)

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

Solution (Python):
N,M = map(int,input().split())
check = [0]*N
ac = 0
penalty = 0
for i in range(M):
  pi, si = input().split()
  pi = int(pi)
  if check[pi-1] == -1:
    continue
  if si == 'WA':
    check[pi-1] += 1
  else:
    ac += 1
    penalty += check[pi-1]
    check[pi-1] = -1
print(ac,penalty)

Solution (Python):
n,m=map(int,input().split())
info=[]
for i in range(m):
    p,s=input().split()
    info.append([int(p),s])
ac,wa=0,0
plob=[[0,0] for i in range(n+1)] 
for i in range(m):
    if plob[info[i][0]][0]==0:
        if info[i][1]=="WA":
            plob[info[i][0]][1]+=1
        else:
            ac+=1
            plob[info[i][0]][0]=1
            wa+=plob[info[i][0]][1]
print(str(ac)+" "+str(wa))

Solution (Python):
N, M = map(int, input().split())
A = [[] for _ in range(N)]
ac_cnt, wa_cnt = 0, 0
for _ in range(M):
    p, s = input().split()
    if s == "AC":
        A[int(p) - 1].append(1)
    else:
        A[int(p) - 1].append(0)

for x in A:
    if x.count(1) >= 1:
        ac_cnt += 1
        wa_cnt += len(x[0:x.index(1)])
print(ac_cnt, wa_cnt)

Solution (Python):
n,m=map(int,input().split())
acf,waf=[0]*n,[0]*n
ac,wa=0,0
for i in range(m):
    x,y=input().split()
    x=int(x)
    if y=='AC':
        if acf[x-1]==0:
            ac+=1
            wa+=waf[x-1]
            acf[x-1]+=1
    else:
        waf[x-1]+=1
print(ac,wa)

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

ans = 0
pena = 0
for i in range(m):
    p,s = input().split()

    if s=="WA":
        li[int(p)][0] += 1
    else:
        if li[int(p)][1] == 0:
            ans += 1
            pena += li[int(p)][0]
            li[int(p)][1] = 1

print(ans,pena)

Solution (Python):
import copy
import heapq
import math
import fractions

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)


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


n,m = ips()
correct = [0 for i in range(n+1)]
wasu = [0 for i in  range(n+1)]
for loop in range(m):
    q,r = input().split()
    q = int(q)
    if r == "WA":
        if correct[q]==0:
            wasu[q]+=1
    else:
        correct[q] = 1
allwa = 0
for i in range(len(correct)):
    if correct[i]:
        allwa+=wasu[i]
print(sum(correct),allwa)

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

    for _ in range(M):
        p, c = input().split()
        p = int(p)
        if seen[p] == -1:
            continue
        if c == "WA":
            seen[p] += 1
        else:
            ac += 1
            wa += seen[p]
            seen[p] = -1
    print("{} {}".format(ac, wa))
abc151_c()

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

ac = 0
wa = 0
dwa = {}
d = {}

for i in range(m):
  p, s = input().split()
  if d.get(p) == "AC":
    continue
  if p not in dwa:
    dwa[p] = 0
  if s == "WA":
    dwa[p] += 1
  else:
    ac += 1
    wa += dwa[p]
  d[p] = s
  
print(ac, wa)

Solution (Python):
l = dict()
t, f = 0, 0
n, m = map(int, input().split(" "))
for _ in range(m):
  p, s = input().split(" ")
  if not p in l:
    l[p] = [None, 0]
  if s == "WA":
    l[p][1] += 1 
  elif s == "AC":
    if l[p][0] != True:
      l[p][0] = True
      t += 1
      f += l[p][1]

print(t, f)

Solution (Python):
n,m = (int(i) for i in input().split())

ac,wa = 0,0
score = {i+1:[] for i in range(n)}

for _ in range(m):
    p,s = (i for i in input().split())
    score[int(p)].append(s)

for v in score.values():
    if "AC" in v:
        wa += len(v[:v.index("AC")])
        ac += 1

print(ac,wa)

Solution (Python):

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

AC = 0
WA = 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):
N, M = map(int, input().split())
pS = []
for _ in range(M):
    pS.append(input().split())

current = 0
penaltyList = [0] * (N+1)
penalty = 0
state = [False] * (N+1)
for i in pS:
    if i[1] == "WA" and (not state[int(i[0])]):
        penaltyList[int(i[0])] += 1
    elif i[1] == "AC" and (not state[int(i[0])]):
        current += 1
        penalty += penaltyList[int(i[0])]
        state[int(i[0])] = True
print(current, penalty)

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

pen_cnt = [0] * n
ac_flg = [0] * n

cnt = 0
for _ in range(m):
    sub = input().split()
    p = int(sub[0]) - 1
    s = sub[1]
    if s == "WA":
        pen_cnt[p] += 1
    elif s == "AC" and ac_flg[p] == 0:
        ac_flg[p] = 1
        cnt += pen_cnt[p]

print(sum(ac_flg), cnt)

Solution (Python):
l = dict()
t, f = 0, 0
n, m = map(int, input().split(" "))
for _ in range(m):
  p, s = input().split(" ")
  if not p in l:
    l[p] = [None, 0]
  if s == "WA":
    if l[p][0] != True:
      l[p][1] += 1
  elif s == "AC":
    if l[p][0] != True:
      l[p][0] = True
      t += 1

for _, v in l.items():
  if v[0]:
    f += v[1]
print(t, f)

Solution (Python):
n, m = map(int, input().split())
ps = {}
for _ in range(m):
    _p, _s = map(str, input().split())
    _p = int(_p)
    ps.setdefault(_p, [])
    ps[_p].append(_s)

ac = 0
wa = 0
for v in ps.values():
    for i, _v in enumerate(v):
        if _v == "AC":
            ac += 1
            wa += i
            break

print(ac, wa)

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

WA = 0

for i in range(m):

    s = input().split()

    if a[int(s[0])] == 0:
        if s[1] == "AC":
            a[int(s[0])] = 1
            WA += b[int(s[0])]
        else:
            b[int(s[0])] += 1

print(sum(a), WA)

Solution (Python):
n, m = map(int, input().split())
if m == 0: print("{0} {1}".format(0, 0))
else:
    ps, ans = {}, [0, 0]
    for _ in range(m):
        p, s = map(str, input().split())
        if p not in ps.keys():
            ps[p] = 0
        if ps[p] == "AC": continue
        elif ps[p] != "AC":
            if s == "WA":
                ps[p] += 1
            else:
                ans[1] += ps[p]
                ans[0] += 1
                ps[p] = "AC"
    print(*ans)

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(sum(ac), sum(pen))

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

print(sum(ac),sum([wa[x] for x in range(n) if ac[x]==1]))

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

grid = []

for i in range(M):
    array = list(map(str, input().strip().split()))
    grid.append(array)

ac_list = [0] * N
wa_list = [0] * N

for a in grid:
    if a[1] == 'AC':
        ac_list[int(a[0]) - 1] = 1
    elif a[1] == 'WA' and ac_list[int(a[0]) - 1] == 0:
        wa_list[int(a[0]) - 1] += 1

for b in range(len(wa_list)):
    if ac_list[b] == 0:
        wa_list[b] = 0

print(str(sum(ac_list)) + ' ' + str(sum(wa_list)))

Solution (Python):
import sys

def main():
    N, M = list(map(int,input().split()))
    p_S = [None] * M

    wa_cnt = [0] * N
    ac_flags = [0] * N

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

    wa_ans, ac_ans = 0, 0

    for j in p_S:
        if j[1] == 'WA':
            wa_cnt[j[0] - 1] += 1

        if j[1] == 'AC' and ac_flags[j[0] - 1] == 0:
            wa_ans += wa_cnt[j[0] - 1]
            ac_ans += 1
            ac_flags[j[0] - 1] = 1


    print(ac_ans, wa_ans)

main()

Solution (Python):
class Stats:
    def __init__(self, is_AC=False, cnt=0):
        self.is_AC = is_AC
        self.cnt = cnt


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

S = [Stats() for _ in range(N)]

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

    if not S[p - 1].is_AC:
        S[p - 1].cnt += 1

    if s == 'AC':
        S[p - 1].is_AC = True

print(
    len(list(filter(lambda s: s.is_AC, S))),
    sum(map(lambda s: s.cnt - 1, (filter(lambda s: s.is_AC, S))))
)

Solution (Python):
n, m = map(int, input().split())
cur = []
kur = []
pen=0
ans=0
for i in range (n+1): cur.append(0)
for i in range (n+1): kur.append(0)
for i in range (m):
    a, b = input().split()
    a = int(a)
    if b=="AC":
        if cur[a]==0:
            pen+=kur[a]
            ans+=1
        cur[a]=1
    else: kur[a]+=1;
print(ans, pen, sep=' ')

Solution (Python):
n,m=map(int,input().split())
l=list(input().split() for _ in range(m))
l=sorted(l,key=lambda x:x[0])
import itertools
lll=[]
for (k,g) in itertools.groupby(l,key=lambda x:x[0]):
    lll.append(list(g))
a=0
w=0
for i in range(len(lll)):
    for j in lll[i]:
        if j[1]=="AC":
            a+=1
            w+=lll[i].index(j)
            break
print(a,w)

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

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

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

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

print( ac_cnt, wa_cnt )

Solution (Python):
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 1000001
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]

def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))

def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))

def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD

    return (num*(pow(den,MOD-2,MOD)))%MOD

def flush():
    return sys.stdout.flush()

'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''
n,m = arrIN()

d = defaultdict(list)

for i in range(m):
    a,b = input().split()
    d[int(a)].append(b)
ca = pe = 0
for i in range(1,n+1):
    if "AC" in d[i]:
        ca+=1
        pe+=d[i].index("AC")
print(ca,pe)

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

args = input().split()
n = int(args[0])
m = int(args[1])
ok = [False] * n
ng = [0] * n
for _ in range(m):
    target, score = input().split()
    target = int(target) - 1
    if score == 'AC':
        ok[target] = True
    else:
        if not ok[target]:
            ng[target] += 1

ok_cnt = 0
ng_cnt = 0
for i in range(n):
    if ok[i]:
        ok_cnt += 1
        ng_cnt += ng[i]
print(ok_cnt, ng_cnt)

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

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

wa = 0
clear = 0

for i in range(M):
  input_ = input().split()
  p = int(input_[0])
  S = input_[1]
  
  if S == "WA":
    if not d[p][0]:
      
      d[p][1] += 1
    else:
      
      pass
  elif S == "AC":
    if not d[p][0]:
      
      clear += 1
      d[p][0] = True
    else:
      
      pass
    
for i in d:
  tmp = d[i]
  
  if tmp[0]:
    
    wa += tmp[1]

print(clear,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):
from sys import stdin
n,m = map(int, stdin.readline().rstrip().split())

count = 0
penalty = 0
qb = [0]*n
was = [0]*n

for i in range(m):
    p,s = map(str,stdin.readline().rstrip().split())
    p = int(p)
    if s == "AC" and qb[p-1] != "AC":
        qb[p-1] = "AC"
        penalty += was[p-1]
        count += 1
    elif s == "WA":
        was[p-1] += 1
    else:
        pass

print(count, penalty)

Solution (Python):

import sys
N,M = map(int, input().split())
A = [tuple(input().split()) for _ in range(M)]
a_cnt = 0
p_cnt = 0
wa = [0] * N
flg = [0] * N

for i in range(M):
  no = int(A[i][0])-1
  if A[i][1] == "AC" and flg[no] == 0:
    a_cnt += 1
    p_cnt += wa[no]
    flg[no] = 1
    continue
  else:
    wa[no] += 1
print(a_cnt, p_cnt)

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

A = [0 for _ in range(N+1)]
ac, wa = 0, 0

for _ in range(M):
    p, S = input().split()
    p = int(p)
    if A[p] != None:
        if S == "AC":
            ac += 1
            wa += A[p]
            A[p] = None
        else:
            A[p] += 1
print(ac, wa)

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

a=[0]*n

for i in range(m):
  p,s=input().split()
  p=int(p)
  p-=1
  if a[p]==-1:
    continue
  if s=="AC":
    account+=1
    wacount+=a[p]
    a[p]=-1
  else:
    a[p]+=1

print(account, wacount)

Solution (Python):
from collections import defaultdict
N,M = map(int,input().split())
dic = defaultdict(list)
for i in range(M):
    p,s = input().split()
    dic[p].append(s)
nAC = 0
nWA = 0
for k in dic.keys():
    if 'AC' in dic[k]:
        for s in dic[k]:
            if s == 'AC':
                nAC += 1
                break
            nWA += 1
print(nAC,nWA)

Solution (Python):


n,m=map(int,input().split())
ac=[0]*n
wa=[0]*n
for i in range(m):
    pi,si=input().split()
    pi=int(pi)-1
    if ac[pi]==1:
        pass
    elif si=="AC":
        ac[pi]=1
    else:
        wa[pi]+=1
print(sum(ac),sum([wa[x] for x in range(n) if ac[x]==1]))

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

k = {}
l = {}
ok = 0
ng = 0
for i in range(m):
    p,s = input().split()
    if p in k and k[p] == 0 :
        continue
    elif p in k and s == 'AC':
        ok += 1
        k[p] = 0
    elif  s == 'WA':
        ng += 1 
        if p in k:
            k[p] += 1
        else:
            k[p] = 1
    elif  s == 'AC':
        ok+=1
        k[p] = 0

nng = 0
for v,vv in k.items():
    nng += vv

print(ok,ng- nng)