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):
x=input().split()
n=int(x[0])
m=int(x[1])
p=[]
ref=[]
for k in range(m):
  x=input().split()
  p.append(int(x[0]))
  ref.append(x[1])
first=[-1]*(n+1)
penal=[0]*(n+1)
for k in range(m):
  if first[p[k]]!=-1:
    continue
  prob=p[k]  
  if ref[k]=='AC':
    first[prob]=k
  else:
    penal[prob]+=1
pb=0
pen=0
for k in range(n+1):
  if first[k]!=-1:
    pb+=1
    pen+=penal[k]
print(pb,pen)

Solution (Python):
n,m=map(int,input().split())
submit=[]
ans_table={}
ans1=0
ans2=0
cnt1=0
cnt2=0
if m==0:
    print("0 0")
else:
    for i in range(m):
        submit.append(list(input().split()))
    submit.sort(key=lambda x:x[0])

    tmp=submit[0][0]
    for i in submit:
        if i[0]!=tmp:
           tmp = i[0]
           cnt2 = 0
        if i[1]=="WA":
            cnt2+=1
        else:
            if i[0] in ans_table:
                continue
            else:
                ans_table[i[0]]="AC"
                ans2+=cnt2
                ans1+=1
    print(ans1,ans2)

Solution (Python):
n, m = map(int, input().split())
L = ["WA" for i in range(n + 1)]
wa = [0 for i in range(n + 1)]

ac = 0
penalty = 0
for i in range(m):
    s, p = map(str, input().split())
    s = int(s)
    if L[s] == "AC":
        continue

    if L[s] == "WA" and p == "WA":
        wa[s] += 1
    elif L[s] == "WA" and p == "AC":
        L[s] = "AC"
        ac += 1
        penalty += wa[s]


print(ac, penalty)

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)
    if s == "AC" and ac[p-1] == False:
        ac[p-1] = True
    elif s == "WA" and ac[p-1] == False:
        wa[p-1] += 1
a = 0
w = 0
for i in range(n):
    if ac[i]:
        a += 1
        w += wa[i]
print(a, w)

Solution (Python):
n, m = map(int, input().split())
t = {}
W = [0 for i in range(0, n+1)]
A = [0 for i in range(0, n+1)]
w = 0
a = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if A[p] == 0 and s == "WA":
        W[p] += 1
    elif A[p] == 0 and s == "AC":
        a += 1
        A[p] = 1
        w += W[p]
print(a, w)

Solution (Python):
a,b = map(int,input().split())
AC = [0]*(a+1)
WA = [0]*(a+1)
ac = 0
wa = 0
wat = 0

for i in range(b):
  x,y = map(str,input().split())
  if y == "WA":
    WA[int(x)] += 1
  elif AC[int(x)] == 0 and y == "AC":
    wa += WA[int(x)]
    ac += 1
    AC[int(x)] = 1

print(ac,wa)

Solution (Python):
a,b = map(int,input().split())
AC = [0]*(a+1)
WA = [0]*(a+1)
ac = 0
wa = 0
wat = 0

for i in range(b):
  x,y = map(str,input().split())
  if y == "WA":
    WA[int(x)] += 1
  elif AC[int(x)] == 0 and y == "AC":
    wa += WA[int(x)]
    ac += 1
    AC[int(x)] = 1

print(ac,wa)

Solution (Python):
n, m = map(int, input().split())
q_list = [3] * n
p_count = 0
c_count = 0

for i in range(n):
    q_list[i] = [i, 0, False]

for j in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'WA':
        q_list[p][1] += 1
    elif s == 'AC' and q_list[p][2] == False:
        p_count += q_list[p][1]
        c_count += 1
        q_list[p][2] = True

print('{} {}'.format(c_count, p_count))

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

for i in range(m):
    p[i] = input().split()
AC=[[0,-1] for j in range(n)]
k=0
WA=0
for i in range(m):
    if p[i][1]=="AC" and AC[int(p[i][0])-1][0]==0 :
        AC[int(p[i][0])-1][0]=1
        AC[int(p[i][0])-1][1]=i
        k=k+1
for i in range(m):
    if p[i][1]=="WA" and AC[int(p[i][0])-1][0]==1 and AC[int(p[i][0])-1][1]>i:
        WA=WA+1

print(k,WA)

Solution (Python):
n, m = map(int, input().split())
d = {}
for i in range(m):
    p, s = input().split()
    d.setdefault(p, [])
    d[p].append(s)

cnt = 0; correct = 0
for v in d.values():
    if "AC" not in v:
        continue
    correct += 1
    cnt += v.index("AC") 

print(correct, cnt)

Solution (Python):
n, m = map(int, input().split())
d = {}
for i in range(m):
    p, s = input().split()
    d.setdefault(p, [])
    d[p].append(s)

cnt = 0; correct = 0
for v in d.values():
    if "AC" not in v:
        continue
    correct += 1
    cnt += v.index("AC") 

print(correct, cnt)

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

AnsN = [0] * N
WrongN = [0] * N
AnsSum = 0
WrongSum = 0

for i in range(M):
    if (input_list[i][1] == 'AC') and (AnsN[int(input_list[i][0])-1] == 0):
        AnsN[int(input_list[i][0]) - 1] = 1
        AnsSum += 1
        WrongSum += WrongN[int(input_list[i][0])-1]
    elif (input_list[i][1] == 'WA') and (AnsN[int(input_list[i][0])-1] == 1):
        continue
    elif (input_list[i][1] == 'WA') and (AnsN[int(input_list[i][0])-1] >= 0):
        WrongN[int(input_list[i][0])-1] += 1

print(AnsSum, WrongSum)

Solution (Python):
import sys
lines = sys.stdin.read().split("\n")
n, m = map(int, lines[0].split())

ac_flags = [0] * (n + 1)
wa_counter = [0] * (n + 1)

ac_count = 0
wa_count = 0
for line in lines[1:-1]:
    p, s = line.split()
    p = int(p)
    if ac_flags[p] == 0:
        if s == "AC":
            ac_flags[p] = 1
            ac_count += 1
            wa_count += wa_counter[p]
        else:
            wa_counter[p] += 1

print ac_count, wa_count

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

AC = [0] * 200000
WA = [0] * 200000

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

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

print(ac, wa)

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

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

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

Solution (Python):



n, m = input().split()
N = int(n)
M = int(m)
P = [input().split() for i in range(M)]


wa_arr=[0 for _ in range(N)]
ac_flag=[False for _ in range(N)]

for i in range(M):
    
    q_num=int(P[i][0]) - 1
    
    if ac_flag[q_num]:
        
        continue
    if P[i][1] == "AC":
        ac_flag[q_num]=True
    else:
        wa_arr[q_num] += 1

cntac=0
cntwa = 0

for j in range(N):
    
    if ac_flag[j]:
        cntac += 1
        cntwa += wa_arr[j]
print(cntac, cntwa)

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

num = [[0 for i in range(2)] for j in range(N)]
cntwa = 0
cntac = 0
for i in range(M):
    if num[int(P[i][0]) - 1][0] == 0:
        if P[i][1] == "AC":
            num[int(P[i][0]) - 1][0] = 1
            cntac += 1
        else:
            num[int(P[i][0]) - 1][1] += 1
            cntwa += 1

for j in range(N):
    if num[j][0] == 0:
        cntwa -= num[j][1]
print(cntac, cntwa)

Solution (Python):
n, m = [int(i) for i in input().split()]
p = [0] * m
s = [0] * m

ac = 0
wc = 0
wan = [0] * (n+1)
qj = [False] * (n+1)

for i in range(m):
    p[i], s[i] = input().split()
    p[i] = int(p[i])
    if not qj[p[i]]:
        if s[i] == 'AC':
            qj[p[i]] =  'True'
            ac += 1
            wc += wan[p[i]]
        else:
            wan[p[i]] += 1

print(ac, wc)

Solution (Python):
N,M=map(int,input().split())
d={} 
e={} 
f={} 
for _ in range(M):
    p,s=input().split()
    d.setdefault(p,0)
    e.setdefault(p,0)
    
    if s=="WA" and d[p]==0:
        e[p]+=1
    elif s=="AC":
        d[p]=1
        f[p]=e[p]

print(sum(d.values()),sum(f.values()))

Solution (Python):
N,M=map(int,input().split())
d={} 
e={} 
f={} 
for _ in range(M):
    p,s=input().split()
    d.setdefault(p,0)
    e.setdefault(p,0)
    f.setdefault(p,0)
    if s=="WA" and d[p]==0:
        e[p]+=1
    elif s=="AC":
        d[p]=1
        f[p]=e[p]

print(sum(d.values()),sum(f.values()))

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

p = [0] * m
s = [0] * m
ac = [0] * n
wa = [0] * n

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

p = [int(i) for i in p]
 
for i in range(m):
    if ac[p[i] - 1] == 0:
        if s[i] == 'AC':
            ac[p[i] - 1] = 1
        else:
            wa[p[i] - 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())
AC = [0] * n
WA = [0] * n

for i in range(m):
    x = input().split()
    num = int(x[0]) - 1
    if x[1]=='AC':
        AC[num]=1
    elif x[1]=='WA' and AC[num]==0:
        WA[num]+=1
        
print(sum(AC), sum([w for i, w in enumerate(WA) if AC[i]]))

Solution (Python):
from collections import Counter

n,m = map(lambda x: int(x), input().split())
x = [0 for i in range(100005)]
tot=0
ac=0
for i in range(m):
	p, s = input().split()
	p=int(p)
	if x[p] == -1:
		continue
	if s == 'AC':
		ac +=1
		tot+=x[p]
		x[p]=-1
	elif s == 'WA':
		x[p] += 1
print(ac, tot)

Solution (Python):
nm = list(map(int, input().split()))
N = nm[0]
M = nm[1]

p = [0] * M
s = [0] * M
for i in range(M):
    ps = list(map(str, input().split()))
    p[i] = int(ps[0])
    s[i] = ps[1]

acc = [0] * N
for i in range(M):
    if s[i] == "AC":
        acc[p[i]-1] = 1

point = 0
for i in range(N):
    point = point + acc[i]

penalty = 0
pnc =[ [0] * N for i in range(2)]
for i in range(M):
    if s[i] == "WA" and pnc[1][p[i]-1] == 0:
        pnc[0][p[i]-1] = pnc[0][p[i]-1] + 1
    elif s[i] == "AC":
        pnc[1][p[i]-1] = 1

for i in range(N):
    if pnc[1][i] == 1:
        penalty = penalty + pnc[0][i]

print(str(point)+" "+str(penalty))

Solution (Python):


n, m = map(int, input().split())
p = []
s = []
for i in range(m):
    t1, t2 = input().split()
    p.append(int(t1)-1)
    s.append(t2)


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

pena = [0 for _ in range(n)]


for i in range(m):
    if ac[p[i]] == 0:
        if s[i] == 'AC':
            ac[p[i]] = 1 
        else:
            pena[p[i]] += 1

AC=0
PENA=0
for i in range(n):
    AC += ac[i]
    if ac[i] == 1:
        PENA += pena[i]

print("%d %d" % (AC,PENA))

Solution (Python):


n, m = map(int, input().split())
p = []
s = []
for i in range(m):
    t1, t2 = input().split()
    p.append(int(t1)-1)
    s.append(t2)


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

pena = [0 for _ in range(n)]


for i in range(m):
    if ac[p[i]] == 1:
        continue 
    if s[i] == 'AC':
        ac[p[i]] = 1 
    else:
        pena[p[i]] += 1

AC=0
PENA=0
for i in range(n):
    AC += ac[i]
    if ac[i] == 1:
        PENA += pena[i]

print("%d %d" % (AC,PENA))

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

Solution (Python):
n,m=map(int,input().split())
AC=[0 for _ in range(n)]
WA=[0 for _ in range(n)]
pen=0
for _ in range(m):
    p,s=input().split()
    p=int(p)
    if s=="AC":
        if AC[p-1]==0:
            AC[p-1]=1
            pen += WA[p-1]
        else:
            pass
    else:
        if AC[p-1]==0:
            WA[p-1] +=1
        else:
            pass
print(AC.count(1),pen)

Solution (Python):
N, M = map(int, input().split())
correct = [0 for _ in range(N)]
missed = [0 for _ in range(N)]
penalty = 0
ans = 0
for _ in range(M):
    p, s = input().split()
    p = int(p)

    if s == "AC" and correct[p - 1] == 0:
        correct[p - 1] = 1
        penalty += missed[p - 1]
    elif s == "WA" and correct[p - 1] == 0:
        missed[p - 1] += 1

print(sum(correct), penalty)

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

count_ac = count_wa = 0
check_ac = [0] * n
wa_p_i = [0] * n

for i in range(m):
    p, s = input().split()
    now = int(p) - 1

    if s == "AC":
        if check_ac[now] == 0:
            count_ac += 1
            check_ac[now] = 1
            count_wa += wa_p_i[now]
    elif s == "WA":
        wa_p_i[now] += 1

print(count_ac, count_wa)

Solution (Python):
import math
n, m = map(int, input().split())
false_count = [1]*n
ans_false_count = [0]*n
ans_success_count = [0]*n

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

    if s=='WA':
        false_count[p-1] = int(false_count[p-1]*2)
    else:
        ans_false_count[p-1] += int(false_count[p-1])
        ans_success_count[p-1] = 1
        false_count[p-1] = 0

for j in range(n):
    if ans_false_count [j] != 0:
        ans_false_count[j] = math.log(ans_false_count[j],2)

new_ans_false_count = ans_false_count
print(sum(ans_success_count), int(sum(new_ans_false_count)))

Solution (Python):
import numpy as np

N, M = [int(i) for i in input().split()]
P = []
S = []
for _ in range(M):
    p, s = [x for x in input().split()]
    P.append(int(p)-1)
    S.append(str(s))

AC_list = [0]*N
WA_list = [0]*N
for i in range(M):
    if S[i] == "AC":
        AC_list[P[i]] = 1
    if S[i] == "WA" and AC_list[P[i]] == 0:
        WA_list[P[i]] += 1

correct = sum(AC_list)
penalty = sum(np.array(WA_list)*np.array(AC_list))
print(correct, penalty)

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())
box = [0]*N
cor = 0
fal = 0

for i in range(M):
  p,s = input().split()
  p = int(p)
  s = str(s)
  
  if s == "WA":
    if box[p-1] != -1:
      box[p-1] += 1
  else:
    if box[p-1] != -1:
      cor += 1
      fal += box[p-1]
      box[p-1] = -1

print(cor,fal)

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

import array; 
wacounts = array.array("l", [0] * (n+1))
acflags = array.array("b", [0] * (n+1))

for pi, si in pss:
    pi = int(pi)
    if acflags[pi] == 0:
        if si == "WA": wacounts[pi] += 1
        if si == "AC": acflags[pi] = 1
    

print(acflags.count(1), end=" ")
print(sum(x*y for x,y in zip(wacounts, acflags)))

Solution (Python):
n,m = map(int,input().split())
ps = [list(input().split()) for _ in range(m)]
aw = ["WA"] * n
wacnt = [0] * n
ac = 0
wa = 0
for i in ps:
    if aw[int(i[0])-1] == "WA":
        if i[1] == "AC":
            ac += 1
            wa += wacnt[int(i[0])-1]
            aw[int(i[0])-1] = "AC"
        else:
            wacnt[int(i[0])-1] += 1
    else:
        pass
print(ac,wa)

Solution (Python):
n,m = map(int,input().split())
box = [0] * n
ans = 0
fal = 0
for _ in range(m):
    p,s = input().split()
    p = int(p)
    s = str(s)
    if s == "WA":
        if box[p-1] != -1:
            box[p-1] += 1
        else:
            pass
    else:
        if box[p-1] != -1:
            ans += 1
            fal += box[p-1]
            box[p-1] = -1
        else:
            pass
print(ans,fal)

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

wa_count = [0] * n
is_accepted = [False] * n
ans_ac = 0
ans_wa = 0

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

    if s == 'AC':
        if not is_accepted[p]:
            is_accepted[p] = True
            ans_ac += 1
            ans_wa += wa_count[p]
    else:
        wa_count[p] += 1

print(ans_ac, ans_wa)

Solution (Python):
n,m=map(int,input().split())
ac=0
wa=0
boac=[0]*n
bowa=[0]*n
for i in range(m):
    p,s=map(str,input().split())
    p=int(p)-1

    if s=="WA":
        bowa[p]+=1

    if s=="AC" and boac[p]==0:
        boac[p]=1
        ac+=1
        wa+=bowa[p]

print(ac,wa)

Solution (Python):

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

chk = [False]*n
wa = [0]*n
c_ac = 0;
c_wa = 0;

for i in range(m):
    _p,_s=input().split()
    j=int(_p)-1
        
    if _s == "WA":
      if chk[j] == False:
        wa[j]+=1
    
    elif _s == "AC":
      if chk[j] == False:
        c_ac += 1
        c_wa += wa[j]
        chk[j] =True

print(c_ac,c_wa,sep= ' ')

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

result = ["WA"] * N
penalty = [0] * N

for i in range(M):
  I = int(pS[i][0]) - 1
  if result[I] == "WA" and pS[i][1] == "WA":
    penalty[I] += 1
  elif result[I] == "WA" and pS[i][1] == "AC":
    result[I] = "AC"

ans = [0] * 2
for j in range(N):
  if result[j] == "AC":
    ans[0] += 1
    ans[1] += penalty[j]

print(" ".join(map(str, ans)))

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

ac = [False]*n
c_ac = 0
c_wa = 0
wa = [0]*n
for _ in range(m):
    pi,si = input().split()
    pi = int(pi) - 1
    
    if ac[pi] == False:
        if si == 'WA':
            wa[pi] += 1
        elif si == 'AC':
            c_ac += 1
            c_wa += wa[pi]
            ac[pi] = True

print(c_ac, c_wa)

Solution (Python):
q,sub=map(int,input().split())
ac=[0 for i in range(q)]
sum_wa=[0 for i in range(q)]
waans=0
for i in range(sub):
    m,n=input().split()
    m=int(m)
    if n=='WA':
        if ac[m-1]==0:
            sum_wa[m-1]+=1
    elif n=='AC' and ac[m-1]==0:
        ac[m-1]+=1
        waans+=sum_wa[m-1]
print(sum(ac) ,waans)

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=set()
W=[0 for i in range(0,N)]
w=0
for i in range(0, M):
    if S[i]=='AC' and p[i]-1 not in A:
        w+=W[p[i]-1]
        A.add(p[i]-1)
    elif S[i]=='WA':
        if p[i]-1 not in A:
            W[p[i]-1]+=1
print(len(A), w)

Solution (Python):
N, M = map(int, input().split())
sub = [[0, 0] for _ in range(N)]  
ac, penalty = 0, 0
for _ in range(M):
    p, s = input().split()
    p = int(p)
    if s == 'WA':
        sub[p-1][0] += 1
    elif s == 'AC' and sub[p-1][1] == 0:
        sub[p-1][1] = 1
        ac += 1
        penalty += sub[p-1][0]
print(ac, penalty)

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

Solution (Python):
n,m=map(int,input().split())
p=[0]*m
temp=['a']*m
s=["qw"]*m
judge=[0]*n
wa=[0]*n
  
for i in range(0,m):
  temp[i],s[i]=input().split()
  p[i]=int(temp[i])
  
ac=0
wasum=0
for i in range(0,m):
  if s[i][0]=='W' and s[i][1]=='A':
    wa[p[i]-1]+=1
  elif s[i][0]=='A' and s[i][1]=='C' and judge[p[i]-1]==0:
    ac+=1
    judge[p[i]-1]=1
    wasum+=wa[p[i]-1]
print("%d %d"% (ac,wasum))

Solution (Python):
[N,M]=list(map(int, input().split()))
ac=[0 for i in range(N)]
wa=[0 for i in range(N)]
p=[]
S=[]
WA=0

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

for i in range (0,M):
    if S[i]=="WA":
        if ac[p[i]-1]==0:
            wa[p[i]-1]=wa[p[i]-1]+1
    else:
        if ac[p[i]-1]==0:
            ac[p[i]-1]=1

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

AC=ac.count(1)
print(str(AC)+" "+str(WA))

Solution (Python):

a,b=map(int,input().split())

c=[]
for i in range(b):
    d,e=map(str,input().split())
    c.append([int(d),e])

acans=0
waans=0
ac=[0]*(a+1)
wa=[0]*(a+1)
for i in range(b):
    if c[i][1]=="AC":
        if ac[c[i][0]-1]==0:
            acans+=1
            ac[c[i][0]-1]+=1
            waans+=wa[c[i][0]-1]
    else:
        wa[c[i][0]-1]+=1


print(acans,waans)

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):
def solve(string):
    n, m, *ps = string.split()
    n = int(n)
    ac = [0] * n
    wa = [0] * n
    for p, s in zip(*[iter(ps)] * 2):
        p = int(p) - 1
        if s ==  "AC":
            ac[p] = 1
        elif not ac[p]:
            wa[p] += 1
    return "{} {}".format(sum(ac),sum([w * a for a,w in zip(ac, wa)]))
    
    
if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Solution (Python):
N,M = map(int, input().split())
ans = {}
AC = 0
WA = 0

for i in range(M):
  num,stu = map(str, input().split())
  if num in ans:
    if ans[num][0] == 0:
      if stu == "AC":
        ans[num][0] = 1
      else:
        ans[num][1] += 1
  else:
      if stu == "AC":
        ans[num] = [1,0]
      else:
        ans[num] = [0,1]

  
for j in ans.values():
  if j[0] == 1:
    AC += 1
    WA += j[1]
    
print(str(AC)+" " +str(WA))

Solution (Python):
n, m = [int(i) for i in input().split(' ')]
wa = [0] * n
ac = [0] * n
for _ in range(m):
    problem, status = input().split(' ')
    problem = int(problem) - 1
    if status == 'WA':
        if ac[problem] == 0:
            wa[problem] += 1
        continue
    ac[problem] = 1

no_ac = 0
no_wa = 0

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

print(str(no_ac) + ' ' + str(no_wa))

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

P = {}
AC = 0
WA = 0
for i in range(m):
    num ,jud = map(str,input().split())
    if num in P:
        if P[num][0] == 0:
            if jud == "AC":
                P[num][0] = 1
            else:
                P[num][1] += 1
    else:
        if jud == "AC":
            P[num] = [1,0]
        else:
            P[num] = [0,1]

for j in P.values():
    if j[0] == 1:
        AC += 1
        WA += j[1]
    
print("{} {}".format(AC,WA))

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

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

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

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

for p, s in ps:
    if f[p]:
        if s == "AC":
            ac[p] += 1
            f[p] = False
        else:
            wa[p] += 1

ans = [0, 0]
for _f, _ac, _wa in zip(f, ac, wa):
    if not _f:
        ans[0] += _ac
        ans[1] += _wa

print(*ans)

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())
pS = []
for i in range(M):
    pS.append(tuple(map(str, input().split())))


countAC = 0

pS_set = set(pS)

for i in pS_set:
    if i[1] == 'AC':
        countAC += 1


countWA_dict = {}

countWA_final = {}

countWA = 0

for i in pS:
    
    if i[1] == 'WA':
        
        if i[0] not in countWA_dict.keys():
            countWA_dict[i[0]] = 1
        
        else:
            countWA_dict[i[0]] += 1
    
    else:
        
        if i[0] not in countWA_final.keys():
            countWA_final[i[0]] = 0
            if i[0] in countWA_dict.keys():
                
                countWA_final[i[0]] = countWA_dict[i[0]]
                
                countWA += countWA_dict[i[0]]

print(str(countAC) + ' ' + str(countWA))

Solution (Python):
N, M = map(int, input().split())
submit_list = []
for i in range(M):
  input_val = input().split()
  p = int(input_val[0])
  s = input_val[1]
  submit_list.append([p, s])

INDEX_ANS_NUM = 0
INDEX_ANS_RES = 1

data_list = [[False, 0] for _ in range(N)]
IDX_IS_AC_DONE = 0
IDX_COUNT_WA = 1

for submit_index, submit in enumerate(submit_list):
  submit_prob_num = submit[INDEX_ANS_NUM]
  submit_result = submit[INDEX_ANS_RES]
  data_index = submit_prob_num - 1
  if (data_list[data_index][IDX_IS_AC_DONE] == True):
    continue
  else:
    if (submit_result == 'AC'):
      data_list[data_index][IDX_IS_AC_DONE] = True
    else:
      data_list[data_index][IDX_COUNT_WA] += 1

count_AC = 0
sum_WA = 0
for _, data in enumerate(data_list):
  if (data[IDX_IS_AC_DONE] == True):
    count_AC += 1
    sum_WA += data[IDX_COUNT_WA]

print(count_AC, sum_WA)

Solution (Python):
import sys
N, M, *PS = sys.stdin.read().strip().split()
N = int(N)
ac = [0] * N
wa = [0] * N
for p, s in zip(*[iter(PS)] * 2):
  p = int(p) -1
  if s == "AC":
    ac[p] = 1
  elif ac[p] == 0:
    wa[p] += 1
penalties = sum([w if a > 0 else 0 for a, w in zip(ac, wa)])
print("{} {}".format(sum(ac), penalties))

Solution (Python):
import sys
N, M, *PS = sys.stdin.read().strip().split()
N = int(N)
ac = [0] * N
wa = [0] * N
for p, s in zip(*[iter(PS)] * 2):
  p = int(p) -1
  if s == "AC":
    ac[p] = 1
  elif ac[p] == 0:
    wa[p] += 1
penalties = sum([w * a for a, w in zip(ac, wa)])
print("{} {}".format(sum(ac), penalties))

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

apb = [[] for i in range(10 ** 5)]


for i in range(M):
    n, a = input().split()
    apb[int(n)] += [a]
    if a == 'AC':
      continue

apb_new = list(filter(lambda a: a != [], apb))


penalty = 0
correct_answer = 0
for words in apb_new:
  if 'AC' in words:
    correct_answer += 1
    for word in words:
      if word == 'WA':
        penalty += 1
      else:
        break


print(correct_answer, penalty)

Solution (Python):
def ACWA(p,j,p_list):
    if j=="AC":
        p_list[p][0]=1
    else:
        p_list[p][1]+=1
    return p_list
    
N,M = map(int,input().split(" "))
p_list = {}
wa_count = 0

for _ in range(M):
    In = input().split()
    if (In[0] in p_list) == False:
        p_list[In[0]]=[0,0]
        p_list = ACWA(In[0],In[1],p_list)
    else:
        if p_list[In[0]][0]==1:
            continue
        else:
            p_list = ACWA(In[0],In[1],p_list)
                
List = list(p_list.values())
a = 0
b = 0

for i in range(len(List)):
    if List[i][0]==1:
        a+=List[i][0]
        b+=List[i][1]

print("{} {}".format(a,b))

Solution (Python):
import sys
N, M, *PS = sys.stdin.read().strip().split()
N = int(N)
ac = [0] * N
wa = [0] * N
for p, s in zip(*[iter(PS)] * 2):
  p = int(p) - 1
  if s == "AC":
    ac[p] = 1
  elif ac[p] == 0:
    wa[p] += 1
penalties = sum([w * a for a, w in zip(ac, wa)])
print("{} {}".format(sum(ac), penalties))

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

question = [0]*(N+1)
wrong = [0]*(N+1)

for i in range(M):
    if PS[i][1] == 'AC':
        if question[int(PS[i][0])] == 0:
            question[int(PS[i][0])] = 1
    else:
        if question[int(PS[i][0])] == 0:
            wrong[int(PS[i][0])] += 1

WA = 0
for i in range(N+1):
    if question[i] == 1:
        WA += wrong[i]

print(sum(question), WA)

Solution (Python):
n,m=map(int,input().split())
AC=[0]*n
WA=[0]*n
ACs=set()
for _ in range(m):
    p,c=input().split(); p=int(p)
    if p in ACs:continue
    if c=='AC':
        AC[p-1]+=1
        ACs.add(p)
    else:
        WA[p-1]+=1
for i in range(n):
    if i+1 not in ACs:
        WA[i]=0
print(sum(AC),sum(WA))

Solution (Python):
n, m = map(int, input().split())
AC = [0 for _ in range(n)]
PENA = [0 for _ in range(n)]
ac = 0
pena = 0
for _ in range(m):
    p, s = input().split()
    p = int(p)-1
    if(AC[p]):
        continue
    if(s == "AC"):
        AC[p] = 1
    else:
        PENA[p] += 1

for i in range(n):
    ac += AC[i]
    if(AC[i]):
        pena += PENA[i]
print(ac, pena)

Solution (Python):
n, m = map(int, input().split())
AC = [0 for _ in range(n+1)]
PENA = [0 for _ in range(n+1)]
ac = 0
pena = 0
for _ in range(m):
    p, s = input().split()
    p = int(p)
    if(AC[p]):
        continue
    if(s == "AC"):
        AC[p] = 1
    else:
        PENA[p] += 1

for i in range(n+1):
    ac += AC[i]
    if(AC[i]):
        pena += PENA[i]
print(ac, pena)

Solution (Python):
n, m = map(int,input().split())
cor, war = 0,0
c = [[0,0] for k in range(n)] 
for i in range(m):
  p,s = list(input().split())
  p = int(p)-1
  if s == "AC" and c[p][0] == 0: 
    cor += 1
    c[p][0] = 1
    war += c[p][1]
  if s == "WA" and c[p][0] == 0: 
    c[p][1] += 1
print(cor,war)

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

ans_list = [[False, 0] for _ in range(N)]
for i, p in enumerate(P):
  current_prob_index = p[0] - 1
  if (ans_list[current_prob_index][0] == True):
    continue
  else:
    if (p[1] == 'WA'):
      ans_list[current_prob_index][1] += 1
    else:
      ans_list[current_prob_index][0] = True

AC_count = 0
WA_count = 0
for i, a in enumerate(ans_list):
  if (a[0] == True):
    AC_count += 1
    WA_count += a[1]

print(AC_count, WA_count)

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

right = 0
wrong = 0
question = [0 for i in range(N+1)]
wrong_count = [0 for i in range(N+1)]

for i in range(M):
    if list[i][1] == "AC" :
        if question[int(list[i][0])] != 1 :
            right += 1
            wrong += wrong_count[int(list[i][0])]
            question[int(list[i][0])] = 1
    else :
        if question[int(list[i][0])] != 1:
            wrong_count[int(list[i][0])] += 1

print("{} {}".format(right, wrong))