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):
from collections import defaultdict
N, M = map(int, input().split())
done = set()
ac = defaultdict(int)
wa = defaultdict(int)

for _ in range(M):
    p, s = map(str, input().split())
    if s == "WA":
        if p not in done:
            wa[p] += 1
    elif s == "AC":
        if p not in done:
            ac[p] += 1
            done.add(p)

a = len(ac)
w = 0
for k, v in wa.items():
    if k in done:
        w += v

print(a, w)

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

WAcounter = [0]*(n+1)
ans = 0
p = 0
for c in a:
    i = int(c[0])
    s = c[1]
    if s=="WA":
        WAcounter[i]+=1
    else:
        p += max(0,WAcounter[i])
        ans += 1 if WAcounter[i]>=0 else 0
        WAcounter[i]=-1000000
print(ans,p)

Solution (Python):
N, M = [int(x) for x in input().split(" ")]
submit = dict()

for _ in range(M):
    p, S = [x for x in input().split(" ")]
    p = int(p)
    if p in submit:
        submit[p].append(S)
    else:
        submit[p] = [S]


cor = 0
fail = 0

for _, res in submit.items():
    fail_one = 0
    cor_one = 0
    for pat in res:
        if pat == "AC":
            cor_one = 1
            break
        else:
            fail_one += 1
    cor += cor_one
    if cor_one == 1:
        fail += fail_one

print(cor, fail)

Solution (Python):
import numpy as np

N, M = map(int, input().split())
if M == 0:
  print(0,0)
  exit()

P = []
S = []
for _ in range(M):
  x, y = input().split()
  P.append(int(x))
  S.append(y)

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

for p, s in zip(P, S):
  if s == 'AC':
    AC[p] = 1
    block[p] = 1
  if s == 'WA':
    if block[p] == 0:
      WA[p] += 1

print(sum(AC), sum(np.array(WA) * np.array(AC)))

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

d={}
for i in range(m):
    p,s=map(str,input().split())
    p=int(p)
    if p in d:
        d[p].append(s)
    else:
        d[p]=[s]

a,b=0,0
for i in d:
    x=d[i]
    temp=0
    flag=1
    for j in range(len(x)):
        if x[j]=="WA":
            b+=1
            temp+=1
        else:
            a+=1
            flag=0
            break

    if flag:
        b-=temp
        
print(a,b)

Solution (Python):


n,m=map(int,input().split())
s=[]
for i in range(m):
    s.append(input().split())
    s[i][0]=int(s[i][0])
cnt=[0]*n
cnt1=[0]*n

for i in range(m):
    if s[i][1]=='WA':
        if cnt[s[i][0]-1]!=0:
            continue
        else:
            cnt1[s[i][0]-1]+=1
    if s[i][1]=='AC':
        if cnt[s[i][0]-1]!=0:
            continue
        else:
            cnt[s[i][0]-1]+=1
    
    
ans=0
ans1=0

for i in range(n):
    if cnt[i]==0:
        continue
    else:
        ans+=cnt[i]
        ans1+=cnt1[i]
print(ans,ans1)

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

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

d = {}
count_AC = 0
count_WA = 0
for m in range(M):
  p, S = input().split()
  if p in d:
    if d[p]['AC'] > 0:
      continue
    else:
      if S == 'AC':
        d[p]['AC'] = 1
        count_AC += 1
        count_WA += d[p]['WA']
      else:
        d[p]['WA'] += 1
  
  else:
    d[p] = {'AC' : 0, 'WA' : 0}
    if S == 'AC':
      d[p]['AC'] += 1
      count_AC += 1
    else:
      d[p]['WA'] += 1
    
print(count_AC, count_WA)

Solution (Python):
N, M = map(int, input().split())
ac = [False for _ in range(N)]
n_wa_list = [0 for _ in range(N)]
n_ac = 0
for _ in range(M):
    p, s = input().split()
    p = int(p) - 1
    if not ac[p]:
        if s == 'WA':
            n_wa_list[p] += 1
        else:
            n_ac += 1
            ac[p] = True

n_wa = 0
for c, n in zip(ac, n_wa_list):
    if c:
        n_wa += n
print(n_ac, n_wa)

Solution (Python):
from collections import defaultdict
N, M = map(int,input().split())
submit = defaultdict(list)
for i in range(M):
    problem_num, S = input().split()
    problem_num = int(problem_num)
    if S == "AC":
        S = 1
    else:
        S = 0
    submit[problem_num].append(S)


ac = 0
penalty = 0
for l in submit.values():
    if 1 in l:
        ac += 1
        for i in range(len(l)):
            if l[i] == 0:
                penalty +=1
            elif l[i] == 1:
                break
print(str(ac)+" "+str(penalty))

Solution (Python):
[N,M] = list(map(int,input().split()))
P = []
S = []
for i in range(M):
    [ptmp,stmp] = list(input().split())
    P.append(ptmp)
    S.append(stmp)
ans1 = [0]*N
ans2 = [0]*N
for i in range(M):
    prob = int(P[i])
    resu = S[i]
    if resu=="AC":
        ans1[prob-1]=1
    elif resu=="WA" and ans1[prob-1]!=1:
        ans2[prob-1]+=1

cnt1=0
cnt2=0
for i in range(N):
    if ans1[i]==1:
        cnt1+=ans1[i]
        cnt2+=ans2[i]

output = str(cnt1) + " " + str(cnt2)

print(output)

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

for i in range(M):
  p = int(PS[i][0])-1
  s = PS[i][1]
  
  if s =="AC":
    Flag[p]=1
  else:
    if Flag[p]==0:
      WA_count[p]+=1
a=0
for i in range(N):
  if Flag[i]==1:
    a+=WA_count[i]

print(sum(Flag),a)

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

Solution (Python):
def main():
    N, M = map(int, input().split())
    cnt = 0
    answer_list = [[] for _ in range(N)]
    for i in range(M):
        p, S = input().split()
        p = int(p) - 1
        answer_list[p].append(S)

    ac = 0
    wa = 0
    for answers in answer_list:
        tmp_wa = 0
        for a in answers:
            if a == 'AC':
                ac += 1
                wa += tmp_wa
                break
            else:
                tmp_wa += 1
    
    print(ac, wa)

    

if __name__ == "__main__":
    main()

Solution (Python):
N,M = map(int,input().split())
Nstate = {str(i):0 for i in range(1,N+1)}
WAstate = {str(i):0 for i in range(1,N+1)}
AC = 0
for _ in range(M):
    n,m = map(str,input().split())
    if Nstate[n] == 0:
        if m == 'AC':
            Nstate[n] = 1
            AC += 1
        elif m == 'WA':
            WAstate[n] += 1
WA = 0
for i in range(1,N+1):
    if Nstate[str(i)] == 1:
        WA += WAstate[str(i)]
print(AC,WA)

Solution (Python):
N, M = map(int, input().split())
pen = [0] * N
AC = [False] * N
for _ in range(M):
    p, s = input().split()
    if s == "AC": AC[int(p) - 1] = True
    else:
        if AC[int(p) - 1] == False : pen[int(p) - 1] += 1
ACcount = AC.count(True)
Pcount = 0
for i in range(N):
    if AC[i]: Pcount += pen[i]
print(ACcount, Pcount)

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

AC = 0
WA = 0

list_AC = [-1] * N

P = []
S = []

for m in range(M):
    p, s = input().split()
    p    = int(p) - 1
    P.append(p)
    S.append(s)
    if s == 'AC':
        if list_AC[p] == -1:
            AC += 1
            list_AC[p] = m

for m in range(M):
    p = P[m]
    s = S[m]
    if s == 'WA':
        if list_AC[p] != -1:
            if m < list_AC[p]:
                WA += 1
print(AC, WA)

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

ac_check = [0 for _ in range(n)]
wa_check = [0 for _ in range(n)]

for i in range(m):
    i, judge = input().split()
    i = int(i)-1
    if judge == 'AC':
        if ac_check[i] == 0:
            ac_check[i] = 1

    elif judge == 'WA':
        if ac_check[i] == 0:
            wa_check[i] += 1
wa = 0
for i in range(n):
    if ac_check[i] == 1 and wa_check != 0:
        wa += wa_check[i]

print(sum(ac_check), wa)

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

for i in range(N):
    if not cleared[i]:
        penalties[i] = 0

print(n_ac, sum(penalties))

Solution (Python):


def main():
    N,M = map(int, input().split())

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

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

        if S == 'AC':
            if ac[p] == 0:
                ac[p] = 1
        elif ac[p] == 0:
            wa[p] += 1

    sumOfWa = sum(w if a == 1 else 0 for (a,w) in zip(ac, wa))
    print(sum(ac), sumOfWa)
        


if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())
P, S = [], []
AC = [0 for n in range(N)]
WA = [0 for n in range(N)]
for m in range(M):
    p, s = input().split()
    p = int(p) - 1
    if AC[p] == 0 and s == 'WA':
        WA[p] += 1
    if s == 'AC':
        AC[p] = 1
AC_count = sum(AC)
WA_count = 0
for n in range(N):
    if AC[n] == 1:
        WA_count += WA[n]
print(AC_count, WA_count)

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

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

ans_ac = ac.count(True)
print("{} {}".format(ans_ac, ans_wa))

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

WAs = [0]*(N+1)
alreadyACed = set()
AC_num = 0

for i in range(M):
    p,S = list(input().split())
    if p in alreadyACed:
        continue
    else:
        if S == "WA":
            WAs[int(p)] += 1
        elif S == "AC":
            AC_num += 1
            alreadyACed.add(p)
WA_num = 0
for i in range(N+1):
    if str(i) in alreadyACed:
        WA_num += WAs[i]

print(AC_num,WA_num)

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def solve():
    n, m = LI()
    d = [0] * n
    wa = [0] * n
    for _ in range(m):
        p, s = input().rstrip().split()
        p = int(p) - 1
        if d[p]:
            continue
        if s == "AC":
            d[p] = 1
        else:
            wa[p] += 1
    ans = 0
    for i in range(n):
        if d[i]:
            ans += wa[i]
    print(sum(d), ans)

    return



if __name__ == '__main__':
    solve()

Solution (Python):
N, M = map(int, input().split())
result = []
ans = dict((s, False) for s in range(1, N+1))
pen = dict((s, 0) for s in range(1, N+1))

for _ in range(M):
    s, d = input().split()
    if d == "AC":
        ans[int(s)] = True
        continue

    if d == "WA" and not ans[int(s)]:
        pen[int(s)] += 1

ans_result = 0
for _, v in ans.items():
    if v:
        ans_result += 1

pen_result = 0
for k, v in pen.items():
    if ans[k]:
        pen_result += v

print(ans_result, pen_result)

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

ok = [0 for _ in range(n)]
ng = [0 for _ in range(n)]
for _ in range(m):
    p, s = input().split()
    index = int(p) - 1
    if s == "AC":
        ok[index] += 1
    else:
        if ok[index] == 0:
            ng[index] += 1

count_ok = 0
count_ng = 0
for i in range(n):
    if ok[i] > 0:
        count_ok += 1
        if ng[i] > 0:
            count_ng += ng[i]
print("{} {}".format(count_ok, count_ng))

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


def gcd(a: int, b: int):
    """ https://cocodrips.hateblo.jp/entry/2014/03/05/143623
    """
    while b: a, b = b, a%b
    return a

def lcm(a: int, b: int):
    return a * b // gcd(a, b)


def main():
    
    N,M = map(int, input().split())
    
    
    
    vS = [input().split() for _ in [0,]*M]
    vN = [False,]*(N+1)
    vW = [0,]*(N+1)

    x,p = 0,0
    for a,s in vS:
        i = int(a)
        v = s=="AC"
        if vN[i]==False:
            if v:
                x += 1
                vN[i] = True
                p += vW[i]
            else:
                vW[i] += 1

    print(x,p)

    
    
    
    
    
    
    
    


if __name__ == "__main__":
    main()

Solution (Python):
from collections import defaultdict


def solve():
    N, M = map(int, input().split())
    ac_dict = defaultdict(int)
    wa_dict = defaultdict(int)
    ac_p, wa_p = set(), set()
    for _ in range(M):
        p, s = map(str, input().split())
        p = int(p)
        if s == 'AC':
            ac_p.add(p)
            ac_dict[p] = 1
        else:
            if ac_dict[p] != 1:
                wa_p.add(p)
                wa_dict[p] += 1
    
    wa = 0
    for pi in ac_p:
        if pi in wa_p:
            wa += wa_dict[pi]
    
    print(sum(ac_dict.values()), wa)


if __name__ == '__main__':
    solve()

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

Solution (Python):
if __name__ == "__main__":
	N, M = map(int, input().split())
	ac_list = [0] * (N+1)
	wa_list = [0] * (N + 1)
	for i in range(M):
		p, s = input().split()
		p = int(p)
		if s == "AC":
			ac_list[p] = 1
		else:
			if ac_list[p] == 0:
				wa_list[p] += 1
		
	ac = 0
	wa = 0
	for i in range(N+1):
		ac += ac_list[i]
		if ac_list[i] == 1:
			wa += wa_list[i]
	print("{0} {1}".format(ac, wa))

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

aclist = [0] * n
penaltylist = [0] * n

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

  if aclist[p-1] != 0:
    continue

  if s == 'AC':
    aclist[p-1] += 1
  else:
    penaltylist[p-1] += 1

ac = 0
penalty = 0
for i in range(n):
  if aclist[i] == 0:
    continue

  ac += 1
  penalty += penaltylist[i]

print(ac, penalty)

Solution (Python):
n, m = list(map(int, input().split()))
p, s = [], []
for i in range(m):
    tp, ts = input().split()
    p.append(int(tp))
    s.append(ts)

wa_counts = [0 for i in range(n)]
acs = [False for i in range(n)]

for i in range(m):
    if s[i] == 'AC':
        acs[p[i]-1] = True
    elif not acs[p[i]-1]:
        wa_counts[p[i]-1] += 1

wa_count = 0
ac_count = 0

for i in range(n):
    if acs[i] == True:
        ac_count += 1
        wa_count += wa_counts[i]

print(ac_count, wa_count, sep=' ')

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

ps = []
for i in range(M):
    ps.append(input().split())

penalties = [0] * N
corrects = [0] * N

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

for i in range(N):
    penalties[i] = penalties[i] * corrects[i]
print(sum(corrects), sum(penalties))

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

ans_flg = {}
wa_time = {}
wa = 0
ans = 0
for i in range(m):
    num, name = info[i]
    num = int(num)
    if num not in ans_flg:
        if name == "AC":
            ans_flg[num] = 1
            ans += 1
        else:
            if num not in wa_time:
                wa_time[num] = 1
            else:
                wa_time[num] += 1
wa = 0
for i in ans_flg:
    if i in wa_time:
        wa += wa_time[i]

print(ans, wa)

Solution (Python):
import numpy as np

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

aced = np.zeros(N, dtype="bool")
waed = np.zeros(N, dtype="int")

AC = "AC"
WA = "WA"

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

    if s == AC:
        aced[p] = True
    else:
        if not aced[p]:
            waed[p] += 1

ac_count = 0
wa_count = 0

for i in range(N):
    if aced[i]:
        ac_count += 1
        wa_count += waed[i]

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

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

ans = set()
pre_wa = [0]*(N+1)
wa = 0
for p, s in ps:
    p = int(p)
    if s == 'AC':
        ans.add(p)
        wa += pre_wa[p]
        pre_wa[p] = 0
    if s == 'WA' and p not in ans:
        pre_wa[p] += 1

print(len(ans), wa)

Solution (Python):
n,m = map(int,input().split())
d = {}
f = {}
for i in range(1,n+1):
    d[i] = []
    f[i] = 0
    
correct = 0
wrong = 0
for i in range(m):
    p,s = input().split()
    p = int(p)
    
    if(s=="AC" and f[p]==0):
        correct += 1 
        wrong += len(d[p])
        f[p] = 1
        
    d[p].append(s)

print(correct,wrong)

Solution (Python):
N,M=map(int,input().split())
data=[[] for i in range(N+1)]
for i in range(M):
    p,S=input().split()
    data[int(p)].append(S)

ACcount=0
WAcount=0
for h in data:
    for i in range(len(h)):
        if h[i]=="WA":
            continue
        else:
            ACcount+=1
            WAcount+=i
            break
print(ACcount,WAcount)

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

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

n_wc = 0
n_ac = 0

for i in range(m):
    num,j = input().split()
    num = int(num)

    if j == 'AC' and ac[num-1] == 0:
        n_ac += 1
        ac[num-1] = 1
        n_wc += wc[num-1]
    else:
        wc[num-1] += 1

print(n_ac,n_wc)

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

Solution (Python):
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    ps = [list(map(str, readline().rstrip().decode('utf-8').split())) for _ in range(m)]
    ac = collections.defaultdict(int)
    wa = collections.defaultdict(int)
    for p, s in ps:
        if s == "WA":
            if p not in ac:
                wa[p] += 1
        if s == "AC":
            ac[p] += 1
    wac = 0
    for k, v in wa.items():
        if k in ac:
            wac += v
    print(len(ac), wac)


if __name__ == '__main__':
    solve()

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

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

for _ in range(m):
    p, s = input().split()
    p = int(p)
    
    if l[p] == -1:
        continue

    if s == "AC":
        res1 += 1
        res2 += l[p]
        l[p] = -1
    else:
        l[p] += 1

print(res1, res2)

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

ac = 0
wa = 0
for i in range(N):
    clear = False
    tmpwa = 0
    for s in q[i]:
        if not clear and s == 'AC':
            clear = True
            ac += 1
            break
        else:
            tmpwa += 1
    if clear:
        wa += tmpwa

print(ac, wa)

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

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

nwa = sum([ wa[i] for i in range(N) if ac[i] == 1])
print(sum(ac), nwa)

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

accepts = [False] * n
penalties = [0] * n

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

    if s == 'AC':
        accepts[p] = True
    elif not accepts[p]:
        penalties[p] += 1

num_accepts = 0
num_penalties = 0

for i in range(n):
    if accepts[i]:
        num_accepts += 1
        num_penalties += penalties[i]

print(num_accepts, num_penalties)

Solution (Python):
n, m = [ int(v) for v in input().split() ]
status = [ "WA" for i in range(n) ]
penarty = [0 for i in range(n)]
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if status[p] == "WA":
        if s == "WA":
            penarty[p] += 1
        elif s == "AC":
            status[p] = "AC"
total_penarty = sum([ penarty[i] for i in range(n) if status[i] == "AC" ])
print(status.count("AC"), total_penarty)

Solution (Python):
n,m = map(int,input().split())
l = []
for i in range(m):
    p,s = input().split()
    p = int(p)
    l.append([p,s])
pl = [0 for i in range(n+1)]
b = 0
key = 0
count = 0
ans = 0
penalty = 0
for i in range(m):
    if l[i][1] == "AC":
        if pl[l[i][0]] >= 0:
            ans += 1
            penalty += pl[l[i][0]]
            pl[l[i][0]] = -1
    else:
        if pl[l[i][0]] >= 0:
            pl[l[i][0]] += 1
        else:
            continue   
print(ans,penalty)

Solution (Python):
N,M=map(int,input().split())
PS=[list(input().split()) for i in range(M)]
chk=[0]*N
Pena=[0]*N
seito=0
pena=0
for p,s in PS:
  p=int(p)
  if chk[p-1]==0:
    if s=='WA':
      Pena[p-1]+=1
    elif s=='AC':
      seito+=1
      chk[p-1]=1
      pena+=Pena[p-1]
  else:
    pass
print(seito,pena)

Solution (Python):
n, m = map(int, input().split())
dic = {i: False for i in range(1,n+1)}
was = [0 for i in range(n+1)]
ac = 0
wa = 0
for i in range(m):
  p, s = input().split()
  p = int(p)
  if dic[p]==False:
    if s == 'AC':
      dic[p] = True
      ac += 1
    else:
      was[p] += 1
for i in range(1,n+1):
  if dic[i]:
    wa += was[i]
print('{} {}'.format(ac, wa))

Solution (Python):
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
ac=[0]*n
c=0
w=0
ps=[]
for _ in range(m):
    p,s=input().split()
    p=int(p)
    s=s.rstrip()
    ps.append((p,s))
    if s=='AC':
        if ac[p-1]==0:
            c+=1
            ac[p-1]=1
        else:
            pass
nac=[0]*n
for _ in range(m):
    p=ps[_][0]
    s=ps[_][1]
    if s=='AC':
        if nac[p-1]==0:
            nac[p-1]=1
        else:
            pass
    else:
        if nac[p-1]==0 and ac[p-1]==1:
            w+=1
print(c,w)

Solution (Python):
n,m=map(int,input().split())
s=[0]*n
t=[0]*n
for i in range(m):
    a,b=map(str,input().split())
    a,
    a=int(a)-1
    if not s[a]:
        if b=="WA":
            t[a]+=1
        else:
            s[a]=1
print(sum(s),sum(t[i] for i in range(n)if s[i]))

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

PM.sort(key=lambda x:x[0])



aw = []
for i in range(N+10):
    aw.append([0,0])

a_cnt = 0
w_cnt = 0
for p, m in PM:
    if aw[p][0] == 1:
        pass
    elif m == 'WA':
        aw[p][1] += 1
    elif m == 'AC':
        aw[p][0] = 1

for a, w in aw:
    if a == 1:
        a_cnt += 1
        w_cnt += w
print(a_cnt, w_cnt)

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

acs = [False] * (N + 1)
was = [0] * (N + 1)

for p, s in X:
    if s == "AC":
        acs[int(p)] = True
    elif not acs[int(p)]:
        was[int(p)] += 1

was_cnt = 0
for a, w in zip(acs, was):
    if a:
        was_cnt += w

print(sum(acs), was_cnt)

Solution (Python):
from collections import defaultdict

n, m = map(int, input().strip().split())
data = [input().strip().split() for _ in range(m)]

ac = defaultdict(int)
wa = defaultdict(int)

for p, s in data:
    if s == 'AC':
        ac[p] += 1
    else:
        if ac[p] == 0:
            wa[p] += 1

correct = 0
penalty = 0
for i in range(n + 1):
    p = str(i)
    if ac[p] > 0:
        correct += 1
        penalty += wa[p]

print(correct, penalty)

Solution (Python):


iim = lambda: map(int, input().rstrip().split())
liim = lambda: list(map(int, input().rstrip().split()))

def resolve():
    N, M = iim()
    wa = dict()
    ac = set()
    for i in range(M):
        p, s = input().split()

        if not p in wa:
            wa[p] = 0

        if s == "AC":
            ac.add(p)
        elif not p in ac:
            wa[p] += 1

    x = 0
    for p in ac:
        x += wa[p]
    print(len(ac), x)


if __name__ == "__main__":
    resolve()

Solution (Python):
import sys
from collections import defaultdict

N,M=map(int, sys.stdin.readline().split())

ac=set()
wa=defaultdict(lambda: 0) 

wa_cnt=0

for _ in range(M):
    p,s=sys.stdin.readline().split()
    if s=="AC":
        ac.add(p)
        if wa[p] != "Done":
            wa_cnt+=wa[p]
        wa[p]="Done"
    elif s=="WA":
        if wa[p] != "Done":
            wa[p]+=1

print len(ac),wa_cnt

Solution (Python):
N,M = map(int,input().split())
AC = [False]*N
wa_cnt = [0]*N
ac_ans = 0
wa_ans = 0
for _ in range(M):
    ps,s = input().split()
    p = int(ps)
    if s == 'WA':
        wa_cnt[p-1] += 1
    if s == 'AC' and AC[p-1] == False:
        wa_ans += wa_cnt[p-1]
        AC[p-1] = True
ac_ans = sum(AC)
print(ac_ans,wa_ans)

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

SC = [[0 for _ in range(2)] for _ in range(N)]
for p,s in PS:
  if s == 'AC':
    SC[p][0] = 1
  else:
    if SC[p][0] == 0:
      SC[p][1] += 1

sc = 0
pe = 0
for s,p in SC:
  sc += s
  if s != 0:
    pe += p
print(sc,pe)

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

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

for i in range(N+1):
    if prob[i] > 0:
        WA -= prob[i]

print(AC, WA)

Solution (Python):

import sys


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    ok = 0
    penalty = 0

    problem_dict = {}
    for i in range(M):
        if problem_dict.get(p[i]) == None:
            problem_dict[p[i]] = [S[i]]
        else:
            problem_dict[p[i]].append(S[i])


    for key,value in problem_dict.items():
        if "AC" not in value:
            continue

        for result in value:
            if result == "WA":
                penalty += 1
            else:
                ok += 1
                break
    
    print(ok,penalty)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    p = [int()] * (M)  
    S = [str()] * (M)  
    for i in range(M):
        p[i] = int(next(tokens))
        S[i] = next(tokens)
    solve(N, M, p, S)

if __name__ == '__main__':
    main()

Solution (Python):
N,M=map(int,input().split())
acs=[0]*N
was=[0]*N
for i in range(M):
    p,s=input().split()
    if s=='AC':
        acs[int(p)-1]=1
    else:
        was[int(p)-1]+=(acs[int(p)-1]!=1)
was=[was[i] for i in range(N) if acs[i]==1]
print(sum(acs),sum(was))

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

pena_prob = [0]*(10**5 + 10)
ac_prob = [0]*(10**5 + 10)
for i in range(M):
  p,S = input().split()
  p = int(p)
  if(S == 'AC'):
    ac_prob[p] = 1
  elif(S == 'WA'):
    if(ac_prob[p] == 0):
      pena_prob[p] += 1

pena = 0
for i in range(len(ac_prob)):
  if(ac_prob[i] == 1):
   pena += pena_prob[i]    
  
ac = sum(ac_prob)
print(ac, pena)

Solution (Python):
n, m = map(int, input().split())
ps_lis = []
for i in range(m):
    p, s = input().split()
    ps_lis.append([int(p), s])
ac_lis = [0] * (n + 1)
pe_lis = [0] * (n + 1)
for p, s in ps_lis:
    if s == 'WA' and ac_lis[p] == 0:
        pe_lis[p] += 1
    elif s == 'AC':
        ac_lis[p] = 1
for i, ac in enumerate(ac_lis):
    if ac == 0:
        pe_lis[i] = 0
print(sum(ac_lis), sum(pe_lis))

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

p = [0] * (n+1)
p_wa = [0] * (n+1)

num_ac = 0
num_wa = 0

for i in range(m):
    mondai = int(ps[i][0])
    if p[mondai] == 0:
        if ps[i][1] == 'WA':
            p_wa[mondai] += 1
        else:
            num_ac += 1
            num_wa += p_wa[mondai]
            p[mondai] = 1

print(num_ac,num_wa)