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())
import collections
d=collections.defaultdict(list)
for i in range(m):
    x,a=input().split()
    x=int(x)
    d[x].append(a)

ac=0
wa=0
for i in d:
    cnt=0
    for j in d[i]:
        if j=="WA":
            cnt+=1
        else:
            ac+=1
            wa+=cnt
            break
print(ac,wa)

Solution (Python):
from sys import stdin,setrecursionlimit
setrecursionlimit(10 ** 6)
input = stdin.readline
N, M = map(int, input().split())
ac = [False] * N 
wa = [0] * N 
wa_cnt = 0
for i in range(M):
  p, s = input().split()
  p = int(p) - 1 
  if ac[p] is False and s == "AC":
    wa_cnt += wa[p]
    ac[p] = True
  elif s == "WA":
    wa[p] += 1
print(ac.count(True), wa_cnt)

Solution (Python):
n,m = map(int,input().split())
a = [input().split() for i in range(m)]
p = [int(i[0]) for i in a]
q = [j[1] for j in a]

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

for t in range(m):
    if ac_c[p[t]-1]:
        continue
    if q[t] == "AC":
        ac += 1
        ac_c[p[t]-1] = True
        wa += wa_c[p[t]-1]
    else:
        wa_c[p[t]-1] += 1
print(ac,wa)

Solution (Python):
N, M = map(int, input().split())
ac = [False] * N 
wa = [0] * N 
wa_cnt = 0
for i in range(M):
  p, s = map(str, input().split())
  p = int(p) - 1 
  if ac[p] is False and s == "AC":
    wa_cnt += wa[p]
    ac[p] = True
  elif s == "WA":
    wa[p] += 1
print(ac.count(True), wa_cnt)

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

p = [0] * M
S = [''] * M


for i in range(M):
    p[i], S[i] = input().split()
    p[i] = int(p[i])

WAnum = 0
ACnum = 0

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

for i in range(M):
    num = p[i] - 1
    
    if(AC[num] >= 1):
        continue

    if(S[i] == 'WA'):
        WA[num] += 1

    elif(S[i] == 'AC'):
        AC[num] = 1
        ACnum += 1
        WAnum += WA[num]

print(ACnum, WAnum)

Solution (Python):
N, M = map(int, input().split())
PS = [list(map(str, input().split())) for _ in range(M)]
ac = [False] * N 
wa = [0] * N 
wa_cnt = 0
for ps in PS:
  p = int(ps[0]) - 1 
  s = ps[1]
  if not ac[p] and s == "AC":
    wa_cnt += wa[p]
    ac[p] = True
  elif s == "WA":
    wa[p] += 1
print(ac.count(True), wa_cnt)

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

Solution (Python):
def main():
    N, M = map(int, input().split())
    l = []
    for _ in range(M):
        p, s = input().split()
        l.append((int(p), s))
    da = {}
    dp = {}
    p = 0
    a = 0
    for i in range(M):
        if l[i][0] in da:
            continue
        elif l[i][1] == 'AC':
            a += 1
            da[l[i][0]] = True
            if l[i][0] in dp:
                p += dp[l[i][0]]
        else:
            if l[i][0] in dp:
                dp[l[i][0]] += 1
            else:
                dp[l[i][0]] = 1
    print(a, p)
main()

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

acc = [ False ] * N
pena = [ 0 ] * N 
for p, S in results:
  p = int(p) - 1
  if acc[p] is False:
    acc[p] = True if S == 'AC' else False 
    pena[p] = pena[p] + 1 if S == 'WA' else pena[p] 

wa = 0
for i in range(N):
  wa += pena[i] if acc[i] is True else 0
    
print(sum(acc), wa)

Solution (Python):
def main():
    N, M = map(int, input().split())
    AC = [False] * N
    WA = [0] * N
    w = 0
    for _ in range(M):
        p, s = input().split()
        p = int(p) - 1
        if s == 'AC' and not AC[p]:
            w += WA[p]
            AC[p] = True
        if s == 'WA':
            WA[p] += 1
    print(AC.count(True), w)

main()

Solution (Python):


n,m = map(int,input().split(" "))
ac_list = [0] * n
wa_list = [0] * n


wa = 0

for i in range(m):
    a,b = input().split(" ")
    if ac_list[int(a) - 1]:
        continue
    if b == "AC":
        ac_list[int(a) - 1] = 1
        wa += wa_list[int(a)-1]
    else:
        wa_list[int(a)-1] += 1
        
print(sum(ac_list),wa)

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

AC = [False for _ in range(N)]
n_WA = [0 for _ in range(N)]
n_penalties = 0

for _ in range(M):
    p, S = input().split()
    p = int(p) - 1
    if not AC[p]:
        if S == "AC":
            AC[p] = True
            n_penalties += n_WA[p]
        elif S == "WA":
            n_WA[p] += 1
        else:
            raise ValueError

print(sum(AC), n_penalties)

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

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

Solution (Python):
n,m=map(int,input().split())
P=[]
S=[]
for i in range(m):
    p,s=input().split()
    P.append(int(p))
    S.append(s)
A=[0]*n 
W=[0]*n 
for i in range(m):
    if A[P[i]-1]==0:
        if S[i]=="WA":
            W[P[i]-1]+=1
        else:
            A[P[i]-1]=1
for i in range(n):
    if A[i]==0:
        W[i]=0
print(sum(A),sum(W))

Solution (Python):

n, m = map(int, input().split())
ac = [0] * n
wa = [0] * n
pena = 0


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

    if ac[int(p)-1]:
        
        continue
    if s == 'AC':
        ac[int(p)-1] = 1
        
        pena += wa[int(p)-1]
    elif s == 'WA':
        wa[int(p)-1] += 1


print(sum(ac), pena)

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):
import numpy as np

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

AC = np.array([0]*N)
WA = np.array([0]*N)

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

    if AC[int(p)-1] ==0 and S == "WA":
       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())
corrects = [0] * n
penalties = [0] * n
penalties_sum = 0
for i in range(m):
    p, S = input().split()
    p = int(p) - 1
    if corrects[p]:
        continue
    if S == 'AC':
        corrects[p] = 1
        penalties_sum += penalties[p]
    elif S == 'WA':
        penalties[p] += 1

print("{} {}".format(sum(corrects), penalties_sum))

Solution (Python):
N, M = tuple(map(int, input().split()))
P, S = [], []
for _ in range(M):
    p, s = input().split()
    P.append(int(p))
    S.append(s)

accepted = [False] * N
wrong = [0] * N
AC, WA = 0, 0
for p, s in zip(P, S):
    if s == "WA":
        if not accepted[p-1]:
            wrong[p-1] += 1
    elif s == "AC" and accepted[p-1] is False:
        accepted[p-1] = True
        AC += 1
        WA += wrong[p-1]
print(AC, WA)

Solution (Python):
from operator import itemgetter
N, M, *pS = open(0).read().split()
p = pS[::2]
S = pS[1::2]
lst = []
for pi, Si in zip(p, S):
    lst.append((pi, Si))
lst.sort(key=itemgetter(0))
AC = [0] * int(N)
WA = [0] * int(N)
acpre = ""
pre = ""
cnt = 0
for li in lst:
    if li[0] == acpre:
        continue
    if li[0] != pre:
        cnt = 0
    if li[1] == "AC":
        AC[int(li[0]) - 1] += 1
        WA[int(li[0]) - 1] += cnt
        cnt = 0
        acpre = li[0]
    else:
        cnt += 1
    pre = li[0]
print(sum(AC), sum(WA))

Solution (Python):
N,M = map(int,input().split())
dict = {}
for i in range(M):
    a,b = input().split()
    if a not in dict:
        dict[a] = [0, 0]

    if b == "AC" :
        if dict[a][0] != 1 :
            dict[a][0] += 1
        else :
            pass
    else:
        if dict[a][0] == 1 :
            pass
        else:
            dict[a][1] += 1
ans1 = 0
ans2 = 0
for i , j in dict.items() :
    if j[0] == 1 :
        ans1 += 1
        ans2 += j[1]
    else:
        pass
print(ans1,ans2)

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

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

	if right.get(p) == None :
		right[p] = 0
		wrong[p]= 0


	if s == 'WA' :
		wrong[p]+=1
	else :
		if right[p] == 0  :
			if wrong[p] == 0 :
				ac+=1
				right[p] = 1
			else :
				ac+=1
				wa+=wrong[p]
				right[p] = 1
		else :
			continue



print(ac,wa)

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

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

problems = [False for _ in range(n)]
problems_end = [True for _ in range(n)]
wa_count = 0

for i in range(m):
    s = list(input().split(' '))
    if s[1] == 'AC':
        problems[int(s[0])-1] = True
    result.append(s)



for i, j in result:
    if j == 'AC':
        problems_end[int(i)-1] = False
    if problems[int(i)-1] == True and j == 'WA' and problems_end[int(i)-1] == True:
        wa_count += 1

ac_count = problems.count(True)
print(ac_count, wa_count)

Solution (Python):



import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  
  sys.stderr.write(_s+"\n")

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

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

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

for i,ac in enumerate(AC):
	if ac==0: WA[i]=0

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

Solution (Python):
N, M = map(int,input().split())
p = []
S = []
AC_cnt = [0 for i in range(N)]
WA_cnt = [0 for i in range(N)]
for i in range(M):
    tmp_p, tmp_S = input().split()
    tmp_p = int(tmp_p)
    p.append(tmp_p)
    S.append(tmp_S)
p_cnt = [0 for i in range(N)]
for i in range(M):
    if p_cnt[p[i]-1]==1:
        continue
    if S[i]=="AC":
        AC_cnt[p[i]-1]+=1
        p_cnt[p[i]-1]=1
    elif S[i]=="WA":
        WA_cnt[p[i]-1]+=1

ac_cnt = sum(AC_cnt)
wa_cnt = 0
for i in range(N):
    if AC_cnt[i]==1:
        wa_cnt+=WA_cnt[i]
print(ac_cnt,wa_cnt)

Solution (Python):
N,M = map(int,input().split())
ac = [False]*N
pe = [0]*N
acnum,penanum = [0]*2
for i in range(M) :
  p,s = input().split()
  p = int(p)-1
  if ac[p] :
    continue
  if s=="AC" :
    ac[p] = True
    acnum += 1
    penanum += pe[p]
  elif s=="WA" :
    pe[p] += 1   
print(acnum,penanum)

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

flag = [False] * N
count = [0] * N
ans = [0, 0]

for i in range(M):
    line = input().split()
    p = int(line[0]) - 1
    S = line[1]
    
    if flag[p]:
        pass
    else:
        if S == 'AC':
            ans[0] += 1
            ans[1] += count[p]
            flag[p] = True
        else:
            count[p] += 1
print('{} {}'.format(ans[0], ans[1]))

Solution (Python):
from collections import defaultdict


def main():
    """
    acのあとにwaもあるということ。
    初めてacになるまでのwaが問題。一度acになったらもうその問題はおしまい。
    正答数: ACを出した問題の数
    ペナルティ数: 最初のACに至るまでのWA数
    一度もacを出してない問題ではwaは0。
    """

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

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

    submits_iter = iter(submits)
    submit = next(submits_iter, None)
    done = set()
    passed = 0
    penalties = 0
    penalty_stock = defaultdict(int)
    while submit:
        p, s = submit
        if p not in done:
            if s == 'AC':
                passed += 1
                done.add(p)
                penalties += penalty_stock[p]
            else:
                penalty_stock[p] += 1
        submit = next(submits_iter, None)
    print('%s %s' % (passed, penalties))


main()

Solution (Python):
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil, floor
from collections import defaultdict
import itertools
sys.setrecursionlimit(200000)
input = sys.stdin.readline









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

a = [[False, 0, 0] for _ in range(N)]
for x, y in L:
    x = int(x) - 1
    if y == "WA" and a[x][0] == False:
        a[x][1] += 1
    elif y == "AC" and a[x][0] == False:
        a[x][0] = True
        a[x][2] += 1

ac = 0
wa = 0
for a, b, c in a:
    if a:
        wa += b
        ac += c

print(ac, wa)

Solution (Python):
n,m = map(int ,input().split())
s = [0] * n
cnt = [0] * n
pe = [0] * n
for i in range(m):
    P, S = input().split()
    p = int(P)
    p -= 1
    if(S == "AC" and s[p] == 0):
        s[p] = 1
        cnt[p] = pe[p]
    elif(S == "WA" and s[p] == 0):
        pe[p] += 1
print(sum(s), sum(cnt))

Solution (Python):


n, m = map(int, input().split())
p = ["" for _ in range(m)]
s = ["" for _ in range(m)]
for i in range(m):
    tmp = input().split()
    p[i] = int(tmp[0])
    s[i] = tmp[1]

isACed = [[0,0] for _ in range(n)]

n_correct = 0
n_penalty = 0
for i in range(m):
    if isACed[p[i]-1][1] != 1:
        if s[i] == "WA": 
            isACed[p[i]-1][0] += 1
        else: 
            n_correct += 1
            isACed[p[i]-1][1] = 1
            n_penalty += isACed[p[i]-1][0]

print(n_correct, n_penalty)

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

for i in range(M):
  p,S=input().split()
  x=int(p)-1
  if C[x][0]==0:
    if S=="WA":
      C[x][1]+=1
    else:
      C[x][0]=1

print(sum([C[i][0] for i in range(N)]),sum([C[i][1] for i in range(N) if C[i][0]==1]))

Solution (Python):
hoge = input().split()
N = int(hoge[0])
M = int(hoge[1])

WA = [0] * 105000
AC = [False] * 105000

WAnum = 0
ACnum = 0

for i in range(M):
    hoge = input().split()
    if AC[int(hoge[0])]:
      continue
    if hoge[1] == "AC":
      AC[int(hoge[0])] = True;
      ACnum += 1
      WAnum += WA[int(hoge[0])]
    elif hoge[1] == "WA":
      WA[int(hoge[0])] += 1
      
print(ACnum, WAnum)

Solution (Python):
tmp = []

tmp = list(map(int, input().split()))

m = tmp.pop()
n = tmp.pop()

tmp.clear

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

correct = 0
penalty = 0

for i in range(m):
    tmp = input().split()
    status = tmp.pop()
    num = int(tmp.pop())
    if flag[num-1] == False:
        if status == "WA":
            pena[num-1] = pena[num-1] + 1
        elif status == "AC":
            correct = correct + 1
            penalty = penalty + pena[num-1]
            flag[num-1] = True


print("{} {}".format(correct, penalty))

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

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

for i in range(m):
	q,r=input().split()
	q=int(q)-1
	if ac_[q]==0:
		if r=='WA':
			wa_[q]+=1
		if r=='AC':
			ac+=1
			wa+=wa_[q]
			ac_[q]=1

print(ac,wa)

Solution (Python):
N,M=map(int,input().split())
p=[]
S=[]
for i in range(M):
    x,y=input().split()
    p.append(int(x)-1)
    S.append(y)
WA=[0 for i in range(N)]
AC=[0 for i in range(N)]
for i in range(M):
    if S[i]=="AC":
        AC[p[i]]=1
    else:
        if AC[p[i]]==0:
            WA[p[i]]+=1
ans1=sum(AC)
ans2=0
for i in range(N):
    if AC[i]==1:
        ans2+=WA[i]
print(ans1,ans2)

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

for i in range(m):
    p, s = input().split()
    if correct_list[int(p)] == 0 and s == "WA":
        wrong_list[int(p)] += 1
    if s == "AC":
        correct_list[int(p)] = 1

for i in range(n + 1):
    if correct_list[i] == 0:
        wrong_list[i] = 0

print(str(sum(correct_list[1:])) + " " + str(sum(wrong_list[1:])))

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

Solution (Python):
(n, m) = list(map(int,input().split()))
ac = {}
pe = {}
for i in range(m):
    (p, s) = input().split()
    if(s=='AC'):
        ac[p] = True
    elif(p not in ac):
        if(p not in pe):
            pe[p] = 1
        else:
            pe[p] += 1
ac_num = 0
pe_num = 0
for k in ac.keys():
    ac_num += 1
    if k in pe:
        pe_num += pe[k]
print("%s %s" % (ac_num, pe_num))

Solution (Python):


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

AC = [False for _ in range(N)]
WA = [0 for _ in range(N)]
total_WA = 0

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

print(sum(AC), total_WA)

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

for i in range(m):
  [p, s] = input().split()
  if s == "AC":
    ac[int(p)-1] = 1
  elif ac[int(p)-1] != 1:
    wa[int(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())

err_list = [0] * N
score_list = ['WA'] * N
sum_error = 0
sum_ac = 0

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

  
  if score_list[idx - 1] == 'WA':
    
    if s == 'WA':
      err_list[idx - 1] += 1
    else:
      score_list[idx - 1] = 'AC'
      sum_ac += 1
      sum_error += err_list[idx - 1]

print(sum_ac, sum_error)

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,k=LI()
  l=[False for _ in range(n)]
  l2=[0 for _ in range(n)]

  ans1=ans2=0
  for _ in range(k):
    a,b=LS()
    a=int(a)

    if b=='WA':
      if l[a-1]==False:
        l2[a-1]+=1
    else:
      if l[a-1]==False:
        l[a-1]=True
        ans1+=1
        ans2+=l2[a-1]

  return str(ans1)+' '+str(ans2)


print(main())

Solution (Python):


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

a_dict = {}

for _ in range(0, M):
    p, s = map(str, input().split())
    if p in a_dict:
        a_dict[p].append(s)
    else:
        a_dict[p] = [s]

ans = 0
pena = 0

for k, v in a_dict.items():
    if 'AC' in v:
        ans += 1

        for b in v:
            if b == 'AC':
                break
            else:
                pena += 1

print('{} {}'.format(ans, pena))

Solution (Python):
N,M = map(int,input().split())
errors = 0
ans = 0
error_arr = [0]*(N+1)
s_arr = ['WA']*(N+1)
for i in range(M):
  idx,s = input().split()
  idx = int(idx)
  if s_arr[idx]!='AC':
    if s=='WA':
      error_arr[idx] += 1
    else:
      s_arr[idx]='AC'
      ans += 1
      errors += error_arr[idx]
      s_arr[idx] = 'AC'

print(ans,errors)

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

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

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

AC = is_AC.count(True)
WA = 0

for i in range(N):
    if is_AC[i]:
        WA += WA_cnt[i]

print(AC, 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):
    p,s = input().split()
    p = int(p)
    if s == 'AC':
        ac[p-1] = 1
    else:
        if ac[p-1]==1:continue
        wa[p-1] += 1

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

print(ans1,ans2)

Solution (Python):
import math
import numpy as np
from fractions import gcd
import fractions
import statistics
import collections
from functools import reduce
import itertools
from collections import defaultdict

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

ans = defaultdict(int)
wa = defaultdict(int)
for i in range(M):
    P,S = map(str, input().split())
    if (S == 'AC'):
        ans[P] = 1
    else:
        if (ans[P] != 1):
            wa[P] +=1

wa_cnt = 0
for k, v in wa.items():
    if ans[k] == 1:
        wa_cnt += v
val = ans.values()
print(list(val).count(1),wa_cnt)

Solution (Python):
N,M=map(int,input().split())
p=[]
S=[]
for i in range(M):
    x,y=input().split()
    p.append(int(x)-1)
    S.append(y)
WA=[0 for i in range(N)]
AC=[0 for i in range(N)]
for i in range(M):
    if S[i]=="AC":
        AC[p[i]]=1
    else:
        if AC[p[i]]==0:
            WA[p[i]]+=1
ans1=sum(AC)
ans2=0
for i in range(N):
    if AC[i]==1:
        ans2+=WA[i]
print(ans1,ans2)

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

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


AC=0
WA=0

for i in range(M):
    if ac[PS[i][0]-1]:
        continue
    else:
        if PS[i][1]=="AC":
            ac[PS[i][0]-1]=True
            WA+=wa[PS[i][0]-1]
            AC+=1
        else:
            wa[PS[i][0]-1]+=1
            
print("{} {}".format(AC,WA))

Solution (Python):
from collections import defaultdict
n, m = map(int, input().split())

penalties = defaultdict(int)
solved = set()

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

    if p in solved:
        continue
    if S == 'WA':
        penalties[p] += 1
    else:
        solved.add(p)

print(len(solved), sum([penalties[i] for i in solved]))

Solution (Python):


import collections

def main():
    N,M = map(int,input().split())
    ans = [False for _ in range(N)]
    pe = [0 for _ in range(N)]
    count = 0
    for i in range(M):
        pro,judge = map(str,input().split())
        pro = int(pro)-1
        if ans[pro]:
            continue
        else:
            if judge == "AC":
                ans[pro] = True
                count += pe[pro]
            else:
                pe[pro] += 1
                
    ans = collections.Counter(ans)
                
    print(ans[True],count)
        
if __name__ == "__main__":
    main()

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

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

for i in range(n):
    if ac[i] == "AC":
        pen_count += pen[i]

print(ac.count("AC"), pen_count)

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

n,m = inpl()
sc = [input().split() for i in range(m)]
ac = 0
pena = 0
stpe = [0] * (n+1)
prob = [False] * (n+1)
for s,c in sc:
    s = int(s)
    if prob[s]:
        continue
    else:
        if c == 'AC':
            prob[s] = True
            ac += 1
            pena += stpe[s]
            stpe[s] = 0
        else:
            stpe[s] += 1
print(ac,pena)

Solution (Python):
N, M = map(int, input().split())
WAC = [0 for i in range(N)]
TF = [0 for i in range(N)]
for i in range(M):
    p, S = input().split()
    p = int(p)-1
    if S == 'AC':
        TF[p] = 1
    if TF[p] == 0 and S == 'WA':
        WAC[p] += 1
count = 0
for i in range(N):
    count += TF[i] * WAC[i]
print(sum(TF), count)

Solution (Python):

N, M = map(int, input().split())
AC, WA = [], []
AC = [False for _ in range(10**5)]
WA = [0 for _ in range(10**5)]
ac, wa = 0, 0
for i in range(M):
    tmp = input().split()
    p = int(tmp[0]) - 1
    s = tmp[1]
    if AC[p]:
        continue
    else:
        if s == "AC":
            AC[p] = True
        else:
            WA[p] += 1
for i in range(N):
    if AC[i]:
        ac += 1
        wa += WA[i]
print(ac, wa)

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

cnt=[0]*N
ans=[0]*N

ac=0
wa=0

for i in range(M):
    p, s = input().split()
    p=int(p)-1
    
    if ans[p] == 1:
        continue
    elif s == 'AC':
        ans[p]=1
        ac+=1
        wa+=cnt[p]
    else:
        cnt[p]+=1
    
print(ac, wa)

Solution (Python):

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



num=[]
answer=[]
correct=[False] * (N+1)
correctCount = 0
wrongCount = 0
wrong=[0] * (N+1)
for k in range(M):
    n,a=input().split()
    num.append(int(n))
    answer.append(a)
    if a == "AC":
        if correct[int(n)] == False:
            correct[int(n)] = True
            correctCount += 1
            wrongCount += wrong[int(n)]
    else:
        if correct[int(n)] == False:
            wrong[int(n)] += 1



    


    
'''
preCorrect = False
correctCount=0
wrongCount = 0
temp_wrongCount = 0


for i in range(M):
    if i > 0 and num[i] != num[i-1]:
        if preCorrect == True:
            preCorrect = False
            temp_wrongCount = 0
        else:
            temp_wrongCount = 0
    
    
    if preCorrect == True:
        continue

    if answer[i] == "AC":
        correctCount += 1
        preCorrect = True
        wrongCount += temp_wrongCount
    if answer[i] == "WA":
        temp_wrongCount += 1
'''
print(correctCount, wrongCount)

Solution (Python):
from collections import defaultdict

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

results = defaultdict(list)
for _ in range(M):
    p, s = input().split()
    results[p].append(s)

acCnt = 0
waCnt = 0
for result in results.values():
    cnt = 0
    for s in result:
        if s == 'AC':
            acCnt += 1
            break
        cnt += 1
    else:
        continue
    waCnt += cnt

print(acCnt, waCnt)

Solution (Python):
n, m = map(int,input().split())
a = [input().split() for i in range(m)]
p = [int(i[0]) for i in a]
q = [j[1] for j in a]

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

for t in range(m):
    if ac_c[p[t]-1]:
        continue
    if q[t] == 'AC':
        ac += 1
        ac_c[p[t]-1] = True
        wa += wa_c[p[t]-1]
    else:
        wa_c[p[t]-1] += 1
print(ac,wa)

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

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

a = 0
b = 0
for i in range(N):
    if ac[i]:
        a += 1
        b += wa[i]
print(*[a, b])

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

solve_problem = [0] * N 
wa = [0] * N
ans = 0

for i in range(0,M):
    ps = input().split(" ")
    if ps[1] == "AC":
        if solve_problem[ int(ps[0]) -1] == 0:
            solve_problem[int(ps[0]) -1] = 1
            ans += 1
    elif ps[1] == "WA":
        if solve_problem[ int(ps[0])-1] == 0:
            wa[int(ps[0]) -1 ] += 1

print(ans,sum(wa[i] for i in range(0,N) if solve_problem[i] == 1))

Solution (Python):


n, m = map(int, input().split())
AC, WA = 0, 0
nWA = [0]*(n+1)
nAC = [0]*(n+1)

for i in range(m):
    cp, cS = input().split()
    cp = int(cp)
    if cS == 'AC':
        if nAC[cp] == 0:
            AC += 1
            WA += nWA[cp]
            nAC[cp] = 1
    else:
        nWA[cp] += 1
print(AC, WA)

Solution (Python):
n, m = map(int, input().split())
ps = [input().split() for _ in range(m)]
res = [[0,0] for _ in range(n)]
for p,s in ps:
    if s =="WA":
        if res[int(p)-1][0] != int(1):
            res[int(p)-1][1] += 1
    else:
        res[int(p)-1][0] = 1
ans = 0
pen = 0
for f,w in res:
    if f==1:
        ans+=1
        pen += w
print(str(ans) +" "+str(pen))

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

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

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

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

for i in range(m):
  p,s = input().split()
  p = int(p)-1
  if s == 'AC':
     ac[p] = 1
  elif s == 'WA':
    if ac[p] == 0:
      wa[p] += 1

num_ac = 0
num_wc = 0

for a, w in zip(ac,wa):
  num_ac += a
  if a > 0:
    num_wc += w  
print(num_ac,num_wc)

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

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

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

    if ac[p-1]:
        continue
    else:
        if s == 'AC':
            ac[p-1] = 1
        else:
            wa[p-1] += 1

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

print(AC, WA)

Solution (Python):
N,M = map(int,input().split())
lst = [0 for _ in range(N+1)]
lst2 = [0 for _ in range(N+1)]
count1=0
count2=0
for i in range (M):
    a,b = input().split()
    a = int(a) -1
    if lst[a] == 0:
        if b=="WA":
            lst2[a] =lst2[a] + 1
        elif b=="AC":
            lst[a]=1
            count2=count2+1
for i in range (N+1):
    if lst[i]==1:
        count1=count1+lst2[i]
print(str(count2)+" "+str(count1))

Solution (Python):
N, M = list(map(int, input().split(" ")))
list_p = [0 for i in range(N)]
list_penalty = [0 for i in range(N)]
while(True) :
  try :
    temp = input()
    p, S = temp.split(" ")
    p = int(p)
    if(S == "AC") :
      list_p[p-1] = 1
    else :
      if(list_p[p-1] == 0) :
        list_penalty[p-1] += 1
  except EOFError :
    break

penalty=0
for i in range(N) :
  if(list_p[i] == 1) :
    penalty += list_penalty[i]
print(sum(list_p), penalty)