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())
AC =[0]*(N+1)
WA =[0]*(N+1)

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

for m in range(N+1):
    if AC[m]==0:
        WA[m]=0
print(sum(AC),sum(WA))

Solution (Python):
N,M = map(int,input().rstrip().split(" "))
ans = [False for _ in range(N + 1)]
wa = [0 for _ in range(N + 1)]
ansi = 0
penai = 0
for i in range(M):
  k = input().rstrip().split(" ")
  if ans[int(k[0])] == False:
    if k[1] == "AC":
      ans[int(k[0])] = True
      penai += wa[int(k[0])]
      ansi += 1
    else:
      wa[int(k[0])] += 1
print(str(ansi) + " " + str(penai))

Solution (Python):
N,M = map(int,input().rstrip().split(" "))
ans = [False for _ in range(N + 1)]
wa = [0 for _ in range(N + 1)]
ansi = 0
penai = 0
for i in range(M):
  k = input().rstrip().split(" ")
  if ans[int(k[0])] == False:
    if k[1] == "AC":
      ans[int(k[0])] = True
      penai += wa[int(k[0])]
      ansi += 1
    else:
      wa[int(k[0])] += 1
print(str(ansi) + " " + str(penai))

Solution (Python):
N,M = (int(x) for x in input().split())

cnt_ac = [0]*N
cnt_wa = [0]*N
for i in range(M):
  p_i,S_i = (x for x in input().split())
  p_i = int(p_i)
  
  if S_i == 'AC' and cnt_ac[p_i-1] == 0:
    cnt_ac[p_i-1] += 1
    
  elif S_i == 'WA' and cnt_ac[p_i-1] == 0:
    cnt_wa[p_i-1] += 1
    
for i in range(N):
  if cnt_ac[i] == 0:
    cnt_wa[i] = 0
    
print(sum(cnt_ac),sum(cnt_wa))

Solution (Python):
n,m = map(int, input().split())
 
arS = [False] * (n+1)
arP = [False] * (n+1)
 
score = 0
penalty = 0

for i in range(m):
	id, res = input().split()
	id = int(id)
	if (res == "AC") and (arS[id]==False):
		arS[id] = True
		score = score+1
		penalty = penalty + arP[id]
	if (res == "WA"): 
		arP[id] = arP[id] + 1
        
print(score, penalty)

Solution (Python):
n, m = map(int, input().split())
d = {}
res = [0, 0]
for i in range(m):
    a, b = map(str, input().split())
    d.setdefault(a, [0, 0])
    if b == "AC" and d[a][0] == 0:
        d[a][0] = 1
        res[0] += 1
        res[1] += d[a][1]
    else:
        d[a][1] += 1
print(res[0], res[1])

Solution (Python):
N,M=[int(i) for i in input().split(" ")]
plog={}
for i in range(M):
    p,S=input().split(" ")
    if p in plog:
        plog[p]+=[S]
    else:
        plog[p]=[S]

WA_Count=0
AC_Count=0
for pl in plog:
    _WA_Count=0
    for res in plog[pl]:
        if res=="WA":
            _WA_Count+=1
        elif res=="AC":
            AC_Count+=1
            WA_Count+=_WA_Count
            break
print("%d %d"%(AC_Count,WA_Count))

Solution (Python):
N,M=map(int,input().split())
ac=[False]*N
wa={}
for i in range(N):
    wa[i]=0

AC=0
WA=0
for _ in range(M):
    temp,S=input().split()
    p=int(temp)-1
    if ac[p]:
        continue
    elif S=="AC":
        ac[p]=True
        AC+=1
    else:
        wa[p]+=1

for i in range(N):
    if ac[i]:
        WA+=wa[i]
print(AC,WA)

Solution (Python):
from collections import defaultdict

N,M = map(int,input().split())
AC_dict = defaultdict(int)
ans_AC = 0
ans_WA = 0

for _ in range(M):
    p,s = input().split()
    p = int(p)
    if s == "AC":
        if AC_dict[p] == -1:
            continue
        else:
            ans_AC += 1
            ans_WA += AC_dict[p]
            AC_dict[p] = -1
    else:
        if AC_dict[p] == -1:
            continue
        else:
            AC_dict[p] += 1

print(ans_AC,ans_WA)

Solution (Python):
N, M = map(int, input().split())
submit = [list(input().split()) for _ in range(M)]
acflag = [False]*N
AC = 0
waflag = [0]*N
WA = 0

for i in range(M):
    if (not acflag[int(submit[i][0])-1]) and submit[i][1] == "AC":
        acflag[int(submit[i][0])-1] = True
        AC += 1
    elif (not acflag[int(submit[i][0])-1]) and submit[i][1] == "WA":
        waflag[int(submit[i][0])-1] += 1

for i in range(N):
    if acflag[i]:
        WA += waflag[i]
print(AC, WA)

Solution (Python):
N,M=map(int,input().split())
ac=[0]*N
wa=[0]*N
WA=0
for i in range(M):
  lst=list(map(str,input().split()))
  n=int(lst[0])-1
  if lst[1]=='WA':
    if ac[n]:
      pass
    else:
      wa[n]+=1
  else:
    if ac[n]:
      pass
    else:
      ac[n]=1
      WA+=wa[n]
print(' '.join([str(sum(ac)),str(WA)]))

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

for j in range(m):
    p,s = input().split()
    p = int(p)

    if s == 'AC':
        AC[p] = 1
    elif s == 'WA'and AC[p] != 1:
        WA[p] += 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=[0]*N
WA=[0]*N
wa=0
for i in range(M):
    p,s=input().split()
    p=int(p)-1
    if AC[p]==0 and s=="AC":
        AC[p]=1
        wa+=WA[p]
    WA[p]+=1
print(sum(AC),wa)

Solution (Python):
import numpy as np


def main():
    n, m = map(int, input().split())
    ac = np.array([0] * n)
    pena = np.array([0] * n)
    
    for _ in range(m):
        p, s = map(str, input().split())
        p = int(p) - 1
        if ac[p] == 0 and s == 'WA':
            pena[p] += 1
        else:
            ac[p] = 1
    print(sum(ac), sum(ac * pena))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
nm=input().rstrip().split(" ")
n=int(nm[0])
m=int(nm[1])
answers=[[] for i in range(n)]
for i in range(m):
    line=input().rstrip().split(" ")
    if line[1]=="AC":
        answers[int(line[0])-1].append(1)
    if line[1]=="WA":
        answers[int(line[0])-1].append(0)

ac=0
i=0
was=[]
while i<n:
    sums=0
    j=0
    while j<len(answers[i]):
        sums=sums+answers[i][j]
        if sums>0:
            ac+=1
            was.append(j)
            break
        j=j+1
    i=i+1
print(ac,end=" ")

wacount=0
for j in was:
    wacount=wacount+j
print(wacount)

Solution (Python):
n, m = map(int, input().split())
table = [[0, "None"] for i in range(n+10)]
for i in range(m):
    p, s = input().split()
    p = int(p)
    if table[p][1] == "None" or table[p][1] == "WA":
        if s == "WA":
            table[p][0] += 1
        table[p][1] = s
AC = 0
PEN = 0
for i in table:
    if i[1] == "AC":
        AC += 1
        PEN += i[0]
print(AC, PEN)

Solution (Python):


import numpy as np

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

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

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

Solution (Python):

n,m =list(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]: continue
    if s == "AC":
        ac[p] = 1

    elif s == "WA":
        wa[p]+=1
AC = 0
pena = 0

for i in range (n):
    AC += ac[i]
    if ac[i]: pena += wa[i]
print(str(AC)+" "+str(pena))

Solution (Python):
N,M=map(int,input().split())
L=[0]*N
A=0
W=0
tmp=[0]*N
for i in range(M):
	x,y=input().split()
	t=int(x)
	if L[t-1]==0:
		if y=="WA":
			tmp[t-1]+=1
		else:
			A+=1
			W+=tmp[t-1]
			L[t-1]=1
print(A,W)

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

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

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

A = [0]*N
B = [0]*N

for i in range(M):
  if d[i][1] == 'AC':
    A[int(d[i][0])-1] = 1
  elif A[int(d[i][0])-1] == 0:
    B[int(d[i][0])-1] += 1

c = 0

for i in range(N):
  c += A[i]*B[i]

print("{} {}".format(sum(A),c))

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

ac_set = set()

penalty_total = 0
penalty_map = {}

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

  if s == "AC":
    ac_set.add(p)
    penalty_total += penalty_map.get(p, 0)
  else:
    if p not in penalty_map:
      penalty_map[p] = 1
    else:
      penalty_map[p] += 1

print(len(ac_set), penalty_total)

Solution (Python):
n,m = map(int,input().split())
ps = [list(input().split()) for _ in range(m)]
d = {}
cl_cnt = 0
pl_cnt = 0
for i in ps:
  if int(i[0]) in d:
    if (d[int(i[0])] >= 0) and (i[1] == 'WA'):
      d[int(i[0])] += 1
    elif (d[int(i[0])] >= 0) and (i[1] == 'AC'):
      cl_cnt += 1
      d[int(i[0])] += 1
      pl_cnt += d[int(i[0])]
      d[int(i[0])] = -1
  else:
    if i[1] == 'WA':
      d[int(i[0])] = 0
    else:
      d[int(i[0])] = -1
      cl_cnt += 1
print(cl_cnt,pl_cnt)

Solution (Python):
N,M = [int(x) for x in input().split()]
s = []
for i in range(M):
    array = list(map(str,input().split()))
    s.append(array)

answer = 0
penalty = 0

WA = [0 for i in range(N)]

for i in range(M):
    if WA[int(s[i][0])-1] != "AC":
        if s[i][1] == "WA":
            WA[int(s[i][0])-1] += 1
        else:
            penalty += WA[int(s[i][0])-1]
            answer += 1
            WA[int(s[i][0])-1] = "AC"
    
print(answer,penalty)

Solution (Python):
N, M = map(int,input().split())
lst=[None]*M
for i in range(M):
    p, S=input().split()
    lst[i]=(int(p), S)

stop_set=set()

WA_count=0
AC_count=0
from collections import defaultdict
WA_dict = defaultdict(lambda: 0)

for el in lst:
    if not el[0] in stop_set:
        if el[1]=='AC':
            AC_count+=1
            stop_set.add(el[0])
        else:
            WA_dict[el[0]] +=1


new_set=set(WA_dict.keys())&stop_set

WA_count=sum([WA_dict[i] for i in new_set])
print(AC_count, WA_count)

Solution (Python):
N, M = map(int, input().split())
result = [0 for i in range(N)]
right = 0
penalty = 0
for i in range(M):
  p, s = map(str, input().split())
  p = int(p)
  if result[p - 1] != -1:
    if s == "WA":
      result[p - 1] += 1
    else:
      right += 1
      penalty += result[p - 1]
      result[p - 1] = -1
print("{} {}".format(str(right), str(penalty)))

Solution (Python):
import numpy as np
problem, answer = map(int, input().split())
ac_count = np.array([0]*problem)
wa_count = np.array([0]*problem)
for i in range(answer):
    a,b = input().split()
    if ac_count[int(a) - 1] == 0 and b == "WA":
        wa_count[int(a) - 1] += 1
    else:
        ac_count[int(a) - 1] = 1

print("{} {}".format(sum(ac_count), sum(ac_count * wa_count)))

Solution (Python):
from collections import defaultdict


def main():
    a = list(map(int, input().split()))
    inputs = [input().split() for i in range(a[1])]
    num_ac = 0
    results = defaultdict(int)
    results_wa = defaultdict(int)
    for i in inputs:
        if not results[i[0]]:
            if i[1] == "WA":
                results_wa[i[0]] += 1
            elif i[1] == "AC":
                num_ac += 1
                results[i[0]] = 1
    
    for k in results.keys():
        if results[k] == 0:
            results_wa[k] = 0
    
    num_wa = sum(results_wa.values())
    print(num_ac, num_wa)


if __name__ == "__main__":
    main()

Solution (Python):
n,m=map(int,input().split())
row=m
number=[]
judgment=[]
for p in range(row):
    a,b=input().split()
    number.append(int(a))
    judgment.append(b)

penalist = [0]*n
aclist = [0]*n
anscount=0
penacount=0

for i in range(0,m):
    if judgment[i] == 'WA':
        penalist[number[i]-1] += 1
    else:
        if aclist[number[i]-1] >= 1:
            pass
        else:
            aclist[number[i]-1] += 1
            anscount += 1
            penacount += penalist[number[i]-1]

print(anscount,penacount)

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

P = [0] * N
sum_WA = 0

for _ in range(M):
    p_i, s_i = list(input().split())
    p_i = int(p_i) - 1
    if P[p_i] != 'AC':
        if s_i == 'WA':
            P[p_i] += 1
        else:
            sum_WA += P[p_i]
            P[p_i] = 'AC'


sum_AC = P.count('AC')
print(sum_AC, sum_WA)

Solution (Python):


import sys


def input():
    return sys.stdin.readline()


def resolve():
    n, m = map(int, input().split())
    first_ac_dic = {}
    wa_count_dic = {}
    wa_num = 0
    for i in range(m):
        p, s = input().split()
        p = int(p)

        if s == "AC":
            if p in first_ac_dic:
                pass
            else:
                first_ac_dic[p] = i
                wa_num += wa_count_dic.get(p, 0)
        else:
            wa_count_dic[p] = wa_count_dic.get(p, 0) + 1

    ans_ac = len(first_ac_dic)

    print(ans_ac, wa_num)


if __name__ == "__main__":
    resolve()

Solution (Python):




def resolve():
    n, m = map(int, input().split())
    first_ac_dic = {}
    wa_count_dic = {}
    wa_num = 0
    for i in range(m):
        p, s = input().split()
        p = int(p)

        if s == "AC":
            if p in first_ac_dic:
                pass
            else:
                first_ac_dic[p] = i
                wa_num += wa_count_dic.get(p, 0)
        else:
            wa_count_dic[p] = wa_count_dic.get(p, 0) + 1

    ans_ac = len(first_ac_dic)

    print(ans_ac, wa_num)


if __name__ == "__main__":
    resolve()

Solution (Python):



import sys



def resolve():
    n, m = map(int, input().split())
    all_wa = 0
    all_ac = 0
    ac_list = []
    p_list, s_list = [], []
    first_ac_dic = {}

    wa_count_dic = {}
    wa_num = 0
    for i in range(m):
        p, s = input().split()
        p = int(p)
        p_list.append(p)
        s_list.append(s)

        if s == "AC":
            if p in first_ac_dic:
                pass
            else:
                first_ac_dic[p] = i
                wa_num += wa_count_dic.get(p, 0)
        else:
            wa_count_dic[p] = wa_count_dic.get(p, 0) + 1

    ans_ac = len(first_ac_dic)

    print(ans_ac, wa_num)


if __name__ == "__main__":
    resolve()

Solution (Python):
N, M = map(int, input().split())
ps = [[] for _ in range(N)]
for _ in range(M):
    p, s = input().split()
    ps[int(p)-1].append(s)

WAc = 0
ACc = 0
temp = 0
for i in range(N):
    for j in range(len(ps[i])):
        if ps[i][j] == "WA": 
            temp += 1
        else:
            ACc += 1
            WAc += temp
            temp = 0
            break
    else:
        temp = 0
print(ACc, WAc)

Solution (Python):
n , m = map(int,input().split(" "))
c = []
ans = 0
pen = 0
for i in range(n):
    c.append(0)

for i in range(m):
    x , s = input().split(" ")
    p = int(x)
    if s == "AC":
        if c[p-1] == 0:
            c[p-1] = 1
            ans += 1
        elif c[p-1] < 0:
            pen += -(c[p-1])
            c[p-1] = 1
            ans += 1
    elif s == "WA":
        if c[p-1] <= 0:
            c[p-1] -= 1
print(str(ans) + " " + str(pen))

Solution (Python):
N,M = list(map(int,input().split()))
A = ['a']*N
B = [0]*N
ans1 = 0
ans2 = 0
for i in range(M):
  C,D = input().split()
  C = int(C)-1
  if A[C] == D == 'WA':
    ans1 += 1
    B[C] += 1
  if A[C] == 'a' and D == 'WA':
    ans1 += 1
    B[C] += 1
  if A[C] == 'WA' and D == 'AC':
    ans2 += 1
    A[C] = 'AC'
  if A[C] == 'a' and D == 'AC':
    ans2 += 1
    A[C] = 'AC'
for i in range(N):
  if A[i] == 'a':
    ans1 -= B[i]
print('{0} {1}'.format(ans2,ans1))

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,m = map(int,input().split())
wa_cnt = [0]*n
pena = 0
solve = 0
for i in range(m):
  p,s = map(str,input().split())
  if s == "WA":
    wa_cnt[int(p)-1] += 1
  else:
    if wa_cnt[int(p)-1] >= 0:
      pena += wa_cnt[int(p)-1]
      solve += 1
      wa_cnt[int(p)-1] = -100010
print(solve,pena)

Solution (Python):
n,m = map(int,input().split())
ac = [0] * (n+1)
wa = [0] * (n+1)
lst = []
for _ in range(m):
    p,s = map(str,input().split())
    lst.append([p,s])
    
for i in range(m):
    result = lst[i][1]
    q = int(lst[i][0])
    if result == 'AC' and ac[q] == 0:
        ac[q] += 1
    elif result == 'WA' and ac[q] == 0:
        wa[q] += 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=[0]*N
WA=[0]*N
for i in range(M):
    p,s=input().split(' ')
    p=int(p)
    if s=='AC':
        AC[p-1]=1
    elif not AC[p-1]:
        WA[p-1]+=1
print(sum(AC),sum([i if j==1 else 0 for i,j in zip(WA,AC)]))

Solution (Python):
n,m=map(int,input().split())
hoge=[0 for i in range(n)]
huga=[0 for i in range(n)]
for i in range(m):
  a,b=map(str,input().split())
  if(hoge[int(a)-1]==0 and b=="AC"):
    hoge[int(a)-1]=1
  if(hoge[int(a)-1]==0 and b=="WA"):
    huga[int(a)-1]+=1
    
for i in range(n):
  if(hoge[i]==0):
    huga[i]=0
    
print(sum(hoge),sum(huga))

Solution (Python):
n,m = map(int, input().split())
a = [[0, 'WA'] for i in range(n)]
tmp_AC = 0
tmp_WA = 0
for i in range(m):
  l,s = map(str, input().split())
  l = int(l) - 1
  if a[l][1] == 'WA' and s == 'AC':
    a[l][1] = 'AC'
    tmp_AC += 1
    tmp_WA += a[l][0]
  elif a[l][1] == 'WA' and s == 'WA':
    a[l][0] += 1
print(tmp_AC, tmp_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 AC[p]==0:
        if s=='AC':
            AC[p]+=1
        else:
            WA[p]+=1

for i in range(N):
    if AC[i]==0:
        WA[i]=0
    
print(sum(AC),sum(WA))

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

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

d = {}

for i in range(m):
    p, s = map(str,input().split())
    if not p in d:
        d[p] = [0, 0]
    if s == 'WA' and d[p][1] == 0:
        d[p][0] += 1
    elif s == 'AC':
        d[p][1] = 1

ans = 0
pena = 0

for dict in d.values():
    if dict[1] == 1:
        ans += 1
        pena += dict[0]

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

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

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

Solution (Python):
N, M = map(int, input().split())
a = set()
d = {}
penalty = 0
for i in range(M):
    p, S = input().split()
    if S == 'AC' and int(p) not in a:
        a.add(int(p))
        if p in d:
            penalty += d.pop(p)
    else:
        if p in d:
            d[p] += 1
        else:
            d[p] = 1
print(len(a), penalty)

Solution (Python):
N, M = map(int, input().split())
Counted = [0 for _ in range(N)]
num1 = 0
num2 = 0
subnum2 = [0 for l in range(N)]
for j in range(M):
  p, S = input().split()
  p_ = int(p)
  if S == "AC" and Counted[p_ -1] == 0:
    num1 += 1
    num2 += subnum2[p_ - 1]
    Counted[p_ -1] = 1
  elif S == "WA" and Counted[p_-1] == 0:
    subnum2[p_ - 1] += 1
print("{} {}".format(num1, num2))

Solution (Python):
nm = input().split()
n = int(nm[0])
m = int(nm[1])

p = []
r = []

for i in range(m):
	pr = input().split()
	p.append(int(pr[0]))
	r.append(pr[1])

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

if m != 0:
	for l in range(m):
		if r[l] == 'AC' and flg[p[l]-1] !=  'ac':
			ac += 1
			wa += flg[p[l]-1]
			flg[p[l]-1] = 'ac'
		elif  flg[p[l]-1] != 'ac' :
			flg[p[l]-1] += 1

print(ac)
print(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 not ac[p]:
        if s == "AC":
            ac[p] = True
        else:
            wa[p] += 1
accnt = len([1 for x in ac if x])
wacnt = sum([wa[i] for i in range(N) if ac[i]])
print(accnt, wacnt)

Solution (Python):
n, m = map(int, input().split())
query = [tuple(input().split()) for _ in range(m)]
 
wa = [0] * n
ac = [0] * n
for p, result in query:
    p = int(p) - 1
    if result == 'AC':
        ac[p] = 1
    if result == 'WA' and ac[p] == 0:
        wa[p] += 1
 
accept = 0
penalty = 0
for i in range(n):
    if ac[i]:
        penalty += wa[i]
        accept += 1
 
print(accept, penalty)

Solution (Python):

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

AC = 0


AC_list = [0] * (n + 1)
WA = 0
WA_List = [0] * (n + 1)

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

    if S == "AC":
        
        if AC_list[p] == 0:
            AC += 1
            WA += WA_List[p]
            AC_list[p] = 1
        
    else:
        
        if AC_list[p] == 0:
            WA_List[p] += 1
        

print(AC,WA)

Solution (Python):
n, m=map(int, input().split())
a=set()
d={}
pena=0
for i in range(m):
    p, s=input().split()
    if s=="AC" and int(p) not in a:
        a.add(int(p))
        if p in d:
            pena+=d.pop(p)
    else:
        if p in d:
            d[p]+=1
        else:
            d[p]=1
print(len(a), pena)

Solution (Python):

n, m = map(int, input().split())
ac = [False for _ in range(n)]
wa = [0 for _ in range(n)]

ans = 0
for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC' and ac[p] == False:
        ans += wa[p]
        ac[p] = True
    else:
        wa[p] += 1
print(sum([ac[i] for i in range(n)]), ans)

Solution (Python):
N,M=map(int,input().split())
p=[0]*M
S=[0]*M
sei=[0]*N
pena=[0]*N
total=[0]*N

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

  if S[i]=="AC":
    if sei[p[i]-1]>=1:
      pass
    else:
      sei[p[i]-1] +=1
      
  else: 
    if sei[p[i]-1]>=1:
      pass
    else: 
      pena[p[i]-1] +=1

for j in range(N):
  total[j]=sei[j]*pena[j]
  
print(sum(sei),sum(total))

Solution (Python):
n,m = map(int,input().split())
ac=[0 for i in range (n)]
wa=[0 for i in range (n)]
grid = []
for i in range(m):
    a,b = input().split()
    if  ac[int(a)-1] == 1:
        continue
    if b == 'AC':
        ac[int(a)-1] = 1
    elif b == 'WA':
        wa[int(a)-1] += 1
ac_con,wa_con = 0,0
for i in range(n):
    if ac[i] == 0:
        continue
    else:
        ac_con+=1
        wa_con+=wa[i]
print(ac_con,wa_con)

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

pena=np.array([0]*N)
status=np.array([0]*N)


for i in range(M):
  p,s=tuple(input().split())
  p=int(p)
  if s=="WA":
    if status[p-1]!=1:
      pena[p-1]+=1
  if s=="AC":
    if status[p-1]!=1:
      status[p-1]=1
nac=sum(status)
npena=sum(pena*status)
print(nac, npena)

Solution (Python):
N,M=map(int,input().split())
ac=[0]*(N+1)
wa=[0]*(N+1)
for i in range(M):
    p,s=input().split()
    if ac[int(p)]==1:
        continue
    if s=='AC':
        ac[int(p)]=1
    elif s=='WA':
        wa[int(p)]+=1

ac_ans,wa_ans=0,0
for a,w in zip(ac,wa):
    if a==0:
        continue
    ac_ans+=a
    wa_ans+=w

print(ac_ans,wa_ans)

Solution (Python):
N,M=map(int,input().split())
ac=[False for _ in range(N+1)]
wa=[0 for _ in range(N+1)]
for i in range(M):
    p,S=input().split()
    p=int(p)
    if S=='AC':
        ac[p]=True
    elif ac[p]==False:
        wa[p]+=1
for i in range(N+1):
    if ac[i]==False:
        wa[i]=0
print(sum(ac),sum(wa))

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

l=list(input().split() for _ in range(m))

w=[0]*n
a=[0]*n
seitou=0
pena=0

for i in l:
    k=int(i[0])-1
    if a[k]==0:
        if i[1]=="AC":
            a[k]+=1
        else:
            w[k]+=1

seitou=sum(a)
for j in range(n):
    if int(a[j])==1:
        pena+=w[j]
        
print(seitou,pena)

Solution (Python):
import sys

input = sys.stdin.readline

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

p = []
S = []
ans = 0
pena = 0
count = [0] * N
check = set()
for _ in range(M):
    l = list(map(str, input().split()))
    p.append(int(l[0]))
    S.append(l[1])

for i in range(M):
    if p[i] not in check:
        if S[i] == 'AC':
            pena += count[p[i]-1]
            ans += 1
            check.add(p[i])
        elif S[i] == 'WA':
            count[p[i]-1] += 1

print(ans, pena)

Solution (Python):
import sys

input = sys.stdin.readline

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

p = []
S = []
ans = 0
pena = 0
count = [0] * N
check = set()
for _ in range(M):
    l = list(map(str, input().split()))
    p.append(int(l[0]))
    S.append(l[1])

for i in range(M):
    if p[i] not in check:
        if S[i] == 'AC':
            pena += count[p[i]-1]
            ans += 1
            check.add(p[i])
        elif S[i] == 'WA':
            count[p[i]-1] += 1

print(ans, pena)

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

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

for _ in range(M):
  p, s = input().split()
  p, s = int(p), str(s)
  if ac[p]: continue

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

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

print(ans1, ans2)

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

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


ans = [[0,0] for i in range(n)]

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

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

print(ac,pe)

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

wal=[0]*n
acl=[0]*n

for p,s in ps:
    p=int(p)-1
    if s=='AC' and acl[p] ==0:
        acl[p]+=1
    elif s=='WA' and acl[p] ==0:
        wal[p]+=1

wa=0
for i,ac in enumerate(acl):
    if ac == 1:
        wa+=wal[i]    
    
print(sum(acl),wa)

Solution (Python):
n,m = map(int,input().split())
ac_dir = {}
wa_dir = {}

for _ in range(m):
    p, s = input().split()
    if s == 'AC' and p not in ac_dir:
        ac_dir[p] = 1
    
    elif s == 'WA' and p not in wa_dir and p not in ac_dir:
        wa_dir[p] = 1
    
    elif s == 'WA' and p in wa_dir and p not in ac_dir:
        wa_dir[p] += 1

print(sum(ac_dir.values()), sum([k for j, k in wa_dir.items() if j in ac_dir]))

Solution (Python):
N, M = map(int, input().split(' '))
AC_dir = {}
WA_dir = {}
for i in range(M):
    p, S = input().split(' ')
    if S == 'AC' and p not in AC_dir:
        AC_dir[p] = 1
    elif S == 'WA' and p not in WA_dir and p not in AC_dir:
        WA_dir[p] = 1
    elif S == 'WA' and p in WA_dir and p not in AC_dir:
        WA_dir[p] += 1
print(sum(AC_dir.values()), sum([k for j, k in WA_dir.items() if j in AC_dir]), sep=' ')

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

q = [0]*n
t = [0]*n

for [p,s] in ps:
    p = int(p) - 1
    if s == "AC" and q[p] == 0:
        q[p] += 1
    elif s == "WA" and q[p]== 0:
        t[p] += 1


"""
for [u,r] in ps:
    u = int(u) -1
    if q[u] == 0 and t[u] != 0:
        t[u] == 0
"""

w = 0
for i, uc in enumerate(q):
    if uc == 1:
        w += t[i]
    


print(sum(q),w)

Solution (Python):

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


solved_dic={}
pena_dic={}
for i in range(n):
    solved_dic[i+1]=False
    pena_dic[i+1]=0

pena=0
solved=0

for i in range(m):
    p,s=map(str,input().split())
    p=int(p)
    if s=="WA":
        if not solved_dic[p]:
            pena_dic[p]=pena_dic[p]+1        
    else:
        if not solved_dic[p]:
            solved+=1
            solved_dic[p]=True

for p in range(n):
    if solved_dic[p+1]:
        pena+=pena_dic[p+1]
print("{} {}".format(solved,pena))

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

num_ac = 0
num_wa = 0
q_d = dict()
done = set()

for q_num, result in answers:
    q_num = int(q_num)
    if q_num in done:
        continue

    if result == "AC":
        num_ac += 1
        num_wa += q_d.get(q_num, 0)
        done.add(q_num)
    elif result == "WA":
        q_d[q_num] = q_d.get(q_num, 0) + 1

print(num_ac, num_wa)

Solution (Python):


n, m = map(int, input().split())
ps = list(list(input().split()) for _ in range(m))

wal = [0]*n
acl = [0]*n
for [p, s] in ps:
    p = int(p)-1
    if s == 'AC' and acl[p] == 0:
        acl[p] += 1
    elif s == 'WA'and acl[p] == 0:
        wal[p] += 1

wa = 0
for i, ac in enumerate(acl):
    if ac == 1:
        wa += wal[i]

print(sum(acl),wa)

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

Solution (Python):
N, M = map(int, input().split())
p = [None]*M
S = [None]*M
for i in range(M):
  p[i], S[i] = input().split()

ac_flag = [0]*N
wa_count = [0]*N

penalty = 0
for i in range(M):
  j = int(p[i])-1
  if S[i] == 'AC':
    if ac_flag[j]:
      pass
    else:
      ac_flag[j] = 1
      penalty += wa_count[j]
  else:
    wa_count[j] += 1
print(*[sum(ac_flag), penalty])

Solution (Python):
N, M = map(int, input().split())
p = [None]*M
S = [None]*M
for i in range(M):
  p[i], S[i] = input().split()

ac = [0]*N
penalty = [0]*N
for i in range(M):
  if S[i] == 'AC':
    ac[int(p[i])-1] = 1
  else:
    if ac[int(p[i])-1] == 0:
      penalty[int(p[i])-1] += 1
for j in range(N):
  if ac[j] == 0:
    penalty[j] = 0
print(*[sum(ac), sum(penalty)])

Solution (Python):
n,m = map(int,input().split())
ac = [0] * n
wrong = [0] * n
seitou = 0
pena = 0
for i in range(m):
         p,s = input().split()
         p = int(p)
         if ac[p-1] == 0:
                  if s == "AC":
                           ac[p-1] = 1
                  else:
                           wrong[p-1] += 1
seitou = sum(ac)
for i in range(n):
         if ac[i] == 1:
                  pena += wrong[i]
print(seitou,pena)