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):
def main():
    N, M = (int(i) for i in input().split())
    A = {str(i+1): ["?", 0] for i in range(N)}
    for m in range(M):
        p, s = (i for i in input().split())
        if A[p][0] == "WA" or A[p][0] == "?":
            A[p][0] = s
            if s == "WA":
                A[p][1] += 1

    ans = [0, 0]
    for a in A.values():
        if a[0] == "AC":
            ans[0] += 1
            ans[1] += a[1]
    print(*ans)


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np
n,m = map(int, input().split())
AC = np.array([0]*n)
WA = np.array([0]*n)

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

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

Solution (Python):
import sys

N, M = input().split(' ')
p_acwa_dict = {}
cnt_ac = 0
cnt_wa = 0
pre_p = 0
for line in sys.stdin:
  p, s = line.rstrip().split()
  p = int(p)
      
  pre_p = p
  acwa_cnt_dict = p_acwa_dict.setdefault(p, {'AC': 0, 'WA': 0})
  
  if acwa_cnt_dict['AC'] > 0:
    continue
    
  if s == 'AC':
    acwa_cnt_dict['AC'] += 1
    cnt_ac += 1
    cnt_wa += acwa_cnt_dict['WA']
  elif s == 'WA':
    acwa_cnt_dict['WA'] += 1

print("{} {}".format(cnt_ac, cnt_wa))

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

answered = [False] * N
will_wa = [0]*N
n_ac = 0
n_wa = 0

for _ in range(M):
  p, s = input().split()
  p = int(p)
  p -= 1
  if not answered[p]:
    if s == 'WA':
      will_wa[p] += 1
    else:
      answered[p] = True
      n_wa += will_wa[p]
      n_ac += 1

print(n_ac, n_wa)

Solution (Python):

N, M = map(int, input().split())
P = [0]*M
S = [0]*M

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


ac = [0]*N
wa = [0]*N

for i in range(M):
    if S[i] == "AC":
        ac[P[i]] = 1
    else:
        if ac[P[i]] == 0:
            wa[P[i]] += 1

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


print("{} {}".format(ac.count(1), wa_num))

Solution (Python):
def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_by_types(*value_types, delim=" "):
    return tuple(
        [t(x) for t, x in zip(value_types, input().rstrip("\n").split(delim))])


def main():
    n, m = get_next_ints()
    ac_count = 0
    wa_count = 0

    from collections import defaultdict
    ac_cache = defaultdict(int)
    wa_cache = defaultdict(int)
    ac_count = 0
    wa_count = 0
    wa = 0
    for i in range(m):

        p, result = get_next_by_types(int, str)

        if ac_cache[p] == 0:
            if result == 'AC':

                ac_cache[p] = 1
                ac_count += 1
                wa_count += wa_cache[p]
                wa = 0
            else:
                wa_cache[p] += 1
    print(ac_count, wa_count)


if __name__ == '__main__':
    main()
if __name__ == '__jupyter__':
    import doctest
    print(doctest.testmod())

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

if M <= 0:
    print("0 0")
    exit(0)

exactly = 0
penarty = 0
scores = {}

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

    if scores.get(p) is None:
        scores[p] = {"AC":0, "WA":0}
    elif scores[p]["AC"] > 0:
        continue

    if s == "AC":
        scores[p]["AC"] = 1
        exactly += 1
        penarty += scores[p]["WA"]

    elif s == "WA":
        scores[p]["WA"] += 1

print("{0} {1}".format(exactly, penarty))

Solution (Python):
num_of_probs, num_of_submission = [ int(i) for i in input().split(" ") ]

solution_table = {}

for i in range(0, num_of_submission):
  prob, result = [ i for i in input().split(" ") ]

  if solution_table.get(int(prob)) == None:
    solution_table[int(prob)] = {"WA": 0, "AC": 0}

  if result == "WA":
    if solution_table[int(prob)]["AC"] == 0:
      solution_table[int(prob)]["WA"] += 1
  else:
    if solution_table[int(prob)]["AC"] == 0:
      solution_table[int(prob)]["AC"] += 1

total_ac = 0
total_wa = 0
for value in solution_table.values():
  if value['AC'] > 0:
    total_wa += value['WA']
    total_ac += value['AC']

print( total_ac, total_wa )

Solution (Python):
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista 

def atcoder(): 
    N, M = wczytaj_liste()
    odpowiedzi_string = []
    for i in range(M): 
        odpowiedzi_string.append(input())
    odpowiedzi_lista = []
    for string in odpowiedzi_string: 
        zadanie, wynik = string.split()
        nr_zadania = int(zadanie)
        odpowiedzi_lista.append((nr_zadania, wynik))
    rozwiazane_zadania = set()
    zle_rozwiazania = {}
    for i in range(N+1): 
        zle_rozwiazania[i] = 0
    for nr_zadania, wynik in odpowiedzi_lista:
        if nr_zadania not in rozwiazane_zadania: 
            if wynik == 'WA':
                zle_rozwiazania[nr_zadania] += 1
            else: 
                rozwiazane_zadania.add(nr_zadania)
    kary = 0 
    poprawne = len(rozwiazane_zadania)
    for nr_zadania in rozwiazane_zadania: 
        kary += zle_rozwiazania[nr_zadania]
    print(poprawne, kary)

atcoder()

Solution (Python):
def solve(n, m, PS):
    d = {}
    scores = [0, 0]
    for p, s in PS:
        if p not in d:
            d[p] = {'wa': 0, 'ac': 0}
        if d[p]['ac'] > 0:
            continue
        if s == 'AC':
            d[p]['ac'] = 1
            scores[0] += 1
            scores[1] += d[p]['wa']
        if s == 'WA':
            d[p]['wa'] += 1
    return scores

_n, _m = map(int, input().split())
_PS = [input().split() for _ in range(_m)]
_scores = solve(_n, _m, _PS)
print(_scores[0], _scores[1])

Solution (Python):


N, M = map(int, input().split())
l = [[0] * 2 for i in range(N)] 
ok = 0
ng = 0

for i in range(M):
    p, s = input().split()
    p = int(p)-1
    if s == 'WA':
        l[p][0] += 1
    elif l[p][1] == 0:
        l[p][1] += 1
        ok += 1
        ng += l[p][0]
        
print('{} {}'.format(ok, ng))

Solution (Python):
'''C - Welcome to AtCoder
高橋君は AtCoder のコンテストに参加しています。

このコンテストでは、 N 問の問題が出題されます。
高橋君はコンテスト中に M回の提出を行いました。

i 回目の提出は pi番目の問題への提出であり、結果は Si (AC または WA) でした。
高橋君の正答数は、AC を 1回以上出した問題の数です。
高橋君のペナルティ数は、高橋君が AC を 1 回以上出した各問題において、初めて AC を出すまでに出した WA の数の総和です。
高橋君の正答数とペナルティ数を答えてください。

入力
入力は以下の形式で標準入力から与えられる。

N M
p1 S1
:
pM SM

2 5
1 WA
1 AC
2 WA
2 AC
2 WA
>
2 2

100000 3
7777 AC
7777 AC
7777 AC
>
1 0

6 0
>
0 0
'''
import numpy as np

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

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

for _ in range(M):
    p, S = input().split()
    
    if AC[int(p)-1] ==0 and S == "WA": 
        WA[int(p)-1] += 1              
    else:
        AC[int(p)-1] = 1               
    
print(sum(AC), sum(WA*AC))

Solution (Python):
import numpy as np
 
N,M = map(int,input().split()) 
 
AC = np.array([0]*N)
WA = np.array([0]*N)
 
for i in range(M):
    p,S = input().split()
    
    if AC[int(p)-1] ==0 and S == "WA":
       WA[int(p)-1] += 1
    else:
        AC[int(p)-1] = 1

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

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

wa_counter = [ 0 for i in range(N)]
ac_flag = [ 0 for i in range(N)]
penalty_sum = 0

for i in range(M):
  P, outcome = map(str, input().split())
  P = int(P) -1
  if ac_flag[P] == 0 and outcome == "AC":
    ac_flag[P] = 1
    penalty_sum += wa_counter[P]
  elif ac_flag[P] == 0 and outcome == "WA":
    wa_counter[P] += 1
  else:
    pass

print(sum(ac_flag), penalty_sum)

Solution (Python):
def run():
  N, M = map(int, input().split())
  s_li = [0]*(N+1)
  e_li = [0]*(N+1)
  for m in range(M):
    p, s = input().split()
    p = int(p)
    if s == 'WA':
      if s_li[p] == 0:
        e_li[p] += 1
    else:
      s_li[p] = 1
  print(sum(s_li), sum([s*e for s, e in zip(s_li, e_li)]))

if __name__ == '__main__':
  run()

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

li = [[0,0] for _ in range(N)]

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

penalty = 0
AC_count = 0
for i in range(N):
    penalty += li[i][0]*li[i][1]
    AC_count += li[i][1]

print(AC_count,penalty)

Solution (Python):
import numpy as np
n, m = map(int, input().split())
result = [[0, 0] for _ in range(n)]

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

    if b == "AC":
        result[a][0] = 1
    elif not result[a][0]:
        result[a][1] += 1
print(np.sum(result, axis=0)[0], np.prod(result, axis=-1).sum())

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

accurate = [0] * n
correct = 0
wrong = [0] * n
penalty = 0

for i in range(m):
    p,s = input().split()
    num = int(p) - 1 
    if s == 'AC' and accurate[num] == 0:
        accurate[num] += 1
        correct += 1
        penalty += wrong[num]
    elif s == 'WA':
        wrong[num] += 1 

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

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

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

ac_tf = [0] * n
wa_num = [0] * n

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == "AC":
        if ac_tf[p] == 0:
            ac += 1
            wa += wa_num[p]
            ac_tf[p] = 1
    else:
        wa_num[p] += 1
            
print(ac, wa)

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

er_c = 0
ac_c = 0

if M == 0:
    print(0, 0)
    exit(0)

flag = [0]*N

for i in reversed(range(M)):
    if ps[i][1] == 'AC':
        flag[int(ps[i][0])-1] = 1

for i in range(M):
    if flag[int(ps[i][0])-1] == 1:
        if i == 0:
            if ps[i][1] == 'WA':
                er_c += 1
            else:
                ac_c += 1
                flag[int(ps[i][0])-1] = -1
        elif ps[i][1] == 'WA':
            er_c += 1
        elif ps[i][1] == 'AC':
                ac_c += 1
                flag[int(ps[i][0])-1] = -1

print(ac_c, er_c)

Solution (Python):
import sys
import numpy as np
sys.setrecursionlimit(100000000)
from collections import defaultdict
import collections
d = defaultdict(int)
d_TF = defaultdict(bool)

n,m = map(int,input().split())
ps = []
for i in range(m):
    ps.append(list(map(str,input().split())))

    if ps[i][1] == 'AC':
        d_TF[ps[i][0]] = True

    if d_TF[ps[i][0]] == False and ps[i][1] == 'WA':
        d[ps[i][0]] += 1





ansAC = 0
ansWA = 0
for key in d_TF:
    if d_TF[key] == True:
        ansAC += 1
        ansWA += d[key]

print(ansAC,ansWA)

Solution (Python):
from sys import stdin


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

from collections import defaultdict

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

penalties = defaultdict(int)
p_count = 0

answered = dict()

for _ in range(m):
	q, ans = input().split()
	if int(q) not in answered:
		if ans=='AC':
			p_count += penalties[int(q)]
			answered[int(q)] = 1
		else:
			penalties[int(q)] += 1
print(len(answered), p_count)

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

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

for i in range(M):
    p, s = input().split(" ")
    p = int(p) - 1
    s = str(s)
    
    if s == "AC" and ans[p] == 0:
        ans[p] = 1
        pena += wc_c[p]
        
    elif s == "WA" and ans[p] == 0:
        wc_c[p] += 1
        
print(sum(ans), pena)

Solution (Python):
N,M = map(int, input().split())
P_S = [input().split() for _ in range(M)]
ac = [0]*(N)
wa = [0]*(N)
for i in range(M):
    no = int(P_S[i][0])
    result = P_S[i][1]
    if ac[no-1] ==0 and result == "AC":
        ac[no-1] =1    
    elif ac[no-1] ==0 and result =="WA":
        wa[no-1] += 1
for i in range(N):
    if ac[i] != 1:
        wa[i] = 0
print(sum(ac),sum(wa))

Solution (Python):


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


p = []
s = []
ans = [0]*N
c_wa = [0]*N
pena = 0

for i in range(M):
    temp1, temp2 = input().strip().split(" ")
    p.append(int(temp1))
    s.append(str(temp2))
  

for j in range(M):
    
    if s[j] == "WA":
        if ans[p[j]-1] == 0:
            c_wa[p[j]-1] += 1
        elif ans[p[j]-1] == 1:
            pass
        
                
            
    elif s[j] == "AC":
        if ans[p[j]-1] == 0:
            ans[p[j]-1] += 1
        elif ans[p[j]-1] == 1:
            pass
        
for k in range(N):
    if ans[k] == 1:
        pena += c_wa[k]
    

            
print(sum(ans), pena)

Solution (Python):

n, m = [int(x) for x in input().split()]
history = { i+1 : [0, False] for i in range(n)}

for _ in range(m):
  pi, result = input().split()
  translated_pi = int(pi)
  if result == 'WA' and not history[translated_pi][1]:
    history[translated_pi][0] += 1
  else:
    history[translated_pi][1] = True

ac_count = 0
penalty_count = 0
for result in history.values():
  if result[1]:
    ac_count += 1
    penalty_count += result[0]

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

Solution (Python):
N, M = map(int, input().split())
ans1 = 0
ans2 = 0
Q = [0] * N
wrong = [0] * N
for i in range(M):
  p, S = map(str, input().split())
  p = int(p) - 1
  if Q[p] == 0 and S == "AC":
    ans1 += 1
    ans2 += wrong[p]
    Q[p] = 1
  elif S == "WA":
    wrong[p] += 1
print(ans1,ans2)

Solution (Python):
N,M=map(int,input().split())
ACL=[0]*N
PL=[0]*N
AC=0
P=0
for i in range(M):
  p,S=input().split()
  p=int(p)
  p-=1
  if S =='AC':
    if ACL[p]==0:
      AC+=1
      P+=PL[p]
      ACL[p]=1
  else:
    PL[p]+=1
print(AC,P)

Solution (Python):
N,M=map(int,input().split())
ac=[0]*N
wa=[0]*N
for _ in range(M):
  p,S=input().split()
  p=int(p)-1
  if S=='AC':
    ac[p]=1
  else:
    if ac[p]==0:
      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())
dic = {}
 
for _ in range (M):
  p, s = input().split()
  if p not in dic and s == 'AC':
    dic[p] = [1,0]
  elif p not in dic and s == 'WA':
    dic[p] = [0,1]
  elif s == 'AC' and dic[p][0] == 0:
    dic[p][0] += 1
  elif s == 'WA' and dic[p][0] == 0:
    dic[p][1] += 1

right = 0
wrong = 0
 
for item in dic.values():
  right += item[0]
  if item[0]==1:
    wrong += item[1]

print(right, wrong)

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

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

for i in range(m):
    p,s=input().split()
    p=int(p)-1
    
    if s=="AC":
        if acl[p]==0:
            acl[p]=1
            wa+=wal[p]
            ac+=1
        
    else:
        wal[p]+=1
        
print(ac, wa)

Solution (Python):
def p_c():
    from collections import defaultdict
    d = defaultdict(int)
    ac_list = set()
    n, m = map(int, input().split())
    for _ in range(m):
        p, s = input().split()
        if s == "WA" and p not in ac_list:
            d[p] += 1
        if s == "AC":
            ac_list.add(p)
    wa = 0
    for key in d.keys():
        if key in ac_list:
            wa += d[key]
    print(len(ac_list), wa)
    
p_c()

Solution (Python):
from collections import defaultdict

n,m = list(map(int, input().split(" ")))
dic = defaultdict(lambda : [0,0])

for i in range(m):
    task,status = input().split(" ")
    if status == "AC":
        dic[task][0] += 1
    if dic[task][0] == 0 and status == "WA":
        dic[task][1] += 1

acCnt = 0
waCnt = 0

for _, v in dic.items():
    a,b = v
    if a > 0:
        acCnt += 1
        waCnt += b
print(str(acCnt) + " " + str(waCnt))

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

ac_tf = [0] * n
wa_num = [0] * n

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == "AC":
        if ac_tf[p] == 0:
            ac += 1
            wa += wa_num[p]
            ac_tf[p] = 1
    else:
        wa_num[p] += 1
            
print(ac, wa)

Solution (Python):
N,M=map(int, input().split())
C = [ [0,0] for _ in range(N) ]
for i in range(M):
    p, s = input().split()
    p = int(p) - 1
    if s == "AC":
        C[p][1] = 1
    else:
        if C[p][1] == 0:
            C[p][0] += 1
ans = 0
pena = 0
for i in range(N):
    if C[i][1] == 1:
        ans += 1
        pena += C[i][0]
print(ans,pena)

Solution (Python):
import sys
input = sys.stdin.readline
params = list(map(int, input().split()))
result_parse = lambda x:[int(x[0]),x[1]]
results = [result_parse(input().split()) for i in range(params[1])]
fails = [0]*params[0]
suceeds = [False]*params[0]
for result in results:
    index = result[0]-1
    if result[1] == 'AC':
        suceeds[index] = True
    elif suceeds[index] is False:
        fails[index] += 1
fails = sum(fails[i]*suceeds[i] for i in range(params[0]))
print(str(sum(suceeds)) + ' ' + str(fails))

Solution (Python):
import sys
from collections import defaultdict

n, m = map(int, input().split())
ac = 0
wa = defaultdict(lambda: 0)
already = set()
for line in sys.stdin:
    y, z = line.strip().split()
    y = int(y)
    if y in already:
        continue
    if z == 'AC':
        ac += 1
        already.add(y)
    else:
        wa[y] += 1
    
print(ac, sum(wa[i] for i in already))

Solution (Python):
from collections import defaultdict

params = input().split()
n = int(params[0])
m = int(params[1])

penaltyCount = dict()
penaltyCount = defaultdict(lambda: 0, penaltyCount)

correct = 0
penalty = 0

for i in range(m):
    submission = input().split()
    p = int(submission[0]) - 1
    status = submission[1]

    if penaltyCount[p] == -1:
        continue
    if status == "WA":
        penaltyCount[p] += 1
    else:
        penalty += penaltyCount[p]
        penaltyCount[p] = -1
        correct += 1

print(str(correct) + " " + str(penalty))

Solution (Python):
import sys

def solve(N: int, M:int, p_list:list, S_list:list):
    AC_count = [False for _ in range(N)]
    WA_count = [0 for _ in range(N)]
    point = 0
    pena = 0

    for i in range(M):
        if S_list[i] == 'AC':
            AC_count[p_list[i]-1] = True
        else:
            if AC_count[p_list[i]-1] == False:
                WA_count[p_list[i]-1] += 1
        
    for i in range(N):
        if AC_count[i]:
            point += 1
            pena += WA_count[i]

    print(str(point) + " " + str(pena))

    return

 
if __name__ == "__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_list = []
    S_list = []
    for i in range(M):
        p_list.append(int(next(tokens)))
        S_list.append(next(tokens))

    solve(N, M, p_list, S_list)

Solution (Python):
params = input().split(' ')
m = eval(params[0])
n = eval(params[1])

penaltyCount = []

for i in range(m):
    penaltyCount.append(0)

penalties = 0
points = 0

for i in range(n):
    submission = input().split(' ')
    p = eval(submission[0])-1
    status = submission[1]
    
    if penaltyCount[p] == -1:
        continue

    if status == 'AC':
        penalties += penaltyCount[p]
        penaltyCount[p] = -1
        points += 1
    else:
        penaltyCount[p] += 1


print(points, penalties)

Solution (Python):
n, m = map(int, input().split())
ac = "AC"
ac_dic= {}
wa_dic = {}
wa_num = 0
for _ in range(m):
  p, s = input().split()
  if s == ac:
    ac_dic[p] = 1
  elif not (p in ac_dic):
    if p in wa_dic:
      wa_dic[p]+=1
    else:
      wa_dic[p] = 1
for key, value in wa_dic.items():
  if key in ac_dic:
    wa_num += value
ans = len(ac_dic)
print(ans, wa_num)

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

ansWA = 0
ansAC = 0

for i in range(m):
    pi,ans=input().split()
    pi=int(pi)-1
    if p[pi] != -1:
        if ans == 'AC':
            p[pi] = -1
            ansAC += 1
            ansWA += pw[pi]
        else:
            pw[pi] += 1


print(ansAC,ansWA)

Solution (Python):
def main():
    N, M = map(int, input().split())
    ac = [False] * N
    penalties = [0] * N
    for _ in range(M):
        p, S = input().split()
        num = int(p) - 1
        if ac[num]:
            continue
        if S == "AC":
            ac[num] = True
        else:
            penalties[num] += 1
    ans = 0
    penalty = 0
    for i in range(N):
        if ac[i]:
            ans += 1
            penalty += penalties[i]
    print(ans, penalty)


if __name__ == "__main__":
    main()

Solution (Python):
from collections import deque, defaultdict
from itertools import chain, combinations
import json


def main():
    
    N, M = [int(a) for a in input().split()]
    
    pS = [
        [a for a in input().split()]
        for _ in range(M)
    ]

    seitou = 0
    pen = 0
    mem = [0] * (N + 1)

    for p, S in pS:
        p = int(p)
        if mem[p] < 0:  
            continue
        if S == 'AC':
            seitou += 1
            pen += mem[p]
            mem[p] = -1
        else:
            mem[p] = mem[p] + 1
    print(seitou, pen)


if __name__ == "__main__":
    main()

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

AC_flag = [0] * N
WA_count = [0] * N
total_WA = 0

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

print('%d %d' % (sum(AC_flag), total_WA))

Solution (Python):
N,M = map(int,input().split())
AC_list = [0]*N
Pena_list = [0]*N
for i in range(M):
    p,s = input().split()
    p = int(p)
    if s == "WA":
        if AC_list[p-1] == 1:
            continue
        else:
            Pena_list[p-1] += 1
    else:
        AC_list[p-1] = 1
for i in range(N):
    if AC_list[i] == 0:
        Pena_list[i] = 0
print(AC_list.count(1),end=" ")
print(sum(Pena_list))

Solution (Python):
from collections import *
r = set()
c = defaultdict(int)
n, m = map(int, input().split())
 
for _ in range(m):
  l = input().split()
  i = int(l[0])
  if l[1] == 'AC':
    r.add(i)
  elif i not in r:
    c[i] += 1
 
print(len(r), sum(v for k, v in c.items() if k in r))

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())
inp = []
ans = [(0, False) for _ in range(n)]

for _ in range(m):
    inp.append(input().split())

for i in inp:
    q, r = int(i[0]) - 1, i[1]
    count = ans[q][0]
    flag = ans[q][1]
    if r == 'WA' and not flag:
        ans[q] = (count+1, False)
    if r == 'AC':
        ans[q] = (count, True)
ac = list(filter(lambda x: x[1], ans))
print(len(ac), sum(map(lambda x: x[0], ac)))

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

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

lst_ans = [0] * N
lst_correct = [False]*N

correct = 0
penalty = 0
for _ in range(M):

	p, S = input().split()
	p = int(p)
	if (S == 'AC' and lst_correct[p-1]==False):
		penalty += lst_ans[p-1]
		lst_correct[p-1]=True
		correct += 1
	else :
		lst_ans[p-1]+=1

print(correct, penalty)

Solution (Python):
N, M  = map(int, input().split())
wa = [0] * (N+1)
ac = set()
for _ in range(M):
    p,S = input().split()
    p = int(p)
    if p in ac:
        continue
    if S == "AC":
        ac.add(p)
    else:
        wa[p] += 1

cnt = 0
for p in ac:
    cnt += wa[p]

print(len(ac),cnt)

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

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

ans = [[0, 0] for _ in range(n)]
for p, s in arr:
    if s == 'AC':
        ans[p - 1][0] = 1
    else:
        if ans[p - 1][0] == 0:
            ans[p - 1][1] += 1

oks = 0
ngs = 0
for ok, ng in ans:
    if ok == 1:
        oks += 1
        ngs += ng

print(oks, ngs)

Solution (Python):
N, M = map(int,input().split())
AC_Set = set()
WA_Dict = {}
WA_SUM = 0
for i in range(M):
    num,result = list(input().split())
    if num in AC_Set:
        continue
    else:
        if result == "AC":
            AC_Set.add(num)
            WA_SUM += WA_Dict.get(num,0)
        else:
            WA_Dict[num] = WA_Dict.get(num,0) + 1

print("{} {}".format(len(AC_Set),WA_SUM))

Solution (Python):

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

for i in range(M):
  p, s = input().split()
  p = int(p)-1
  if not memo[p]['ok']:
    if s == 'WA':
      memo[p]['wa'] += 1
    else:
      memo[p]['ac'] += 1
      memo[p]['ok'] = True

ac = 0
wa = 0
for i in memo:
  if i['ok']:
    ac += 1
    wa += i['wa']
    
print(ac, wa)

Solution (Python):
n,m = list(map(int,input().split()))
counter = 0
data = []
tmp = {}

wa = 0

for _ in range(m):
  a,b = input().split() 
  if b == "WA": 
    if int(a) not in tmp:
      tmp[int(a)] = 0
    if tmp[int(a)] != -1:
      tmp[int(a)] += 1
  if int(a) not in tmp: 
    tmp[int(a)] = 0
  if (( b == "AC") and (tmp[int(a)] != -1)):
    counter += 1
    
    wa += tmp[int(a)] 
    tmp[int(a)] = -1 


"""
for i in range(m):
  if data[i][1] == "WA":
    if int(data[i][0]) not in tmp:
      tmp[int(data[i][0])] = 0
    tmp[int(data[i][0])] += 1  
  elif ((data[i][1]) == "AC") and (int(data[i][0]) not in checkd):
    counter += 1
    checkd.append(int(data[i][0]))
    if int(data[i][0] ) not in tmp:
      tmp[int(data[i][0])] = 0  
    wa += tmp[int(data[i][0])]
"""    
print(counter,wa)

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

ans1 = 0
ans2 = 0

aclis = [0] * (n+1)
walis = [0] * (n+1)


for i in range(m):
    if s[i] == 'AC':
        aclis[p[i]] = 1



    elif aclis[p[i]] == 0 and s[i] == 'WA':
        walis[p[i]] += 1
ans1 = aclis.count(1)



for i in range(n+1):
    if aclis[i] == 1:
        ans2 += walis[i]


print(ans1, ans2)

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

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

for i in range(M):
    p,s=map(str,input().split())
    P=int(p)
    if s=="AC":
        if AC[P-1]!=P:
            AC[P-1]+=P
            ac+=1
            wa+=WA[P-1]
    else:
        if AC[P-1]!=P:
            WA[P-1]+=1

print(ac,wa)

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

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

for i in range(M):
  pi, S = map(str,input().split())
  p = int(pi)
  
  if S == "AC":
    if AC[p-1] != 1:
      AC[p-1] = 1
      ac += 1
      wa += WA[p-1]
  elif S == "WA":
    if AC[p-1] == 1:
      pass
    else:
      WA[p-1] += 1
else:
  print(ac, wa)

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

submit = dict()
WA = 0
AC = 0

for i in range(M):
  p,S = map(str, input().split())
  
  if p not in submit:
    if S == "AC":
      submit[p] = -1
      AC += 1
    elif S =="WA":
      submit[p] = 1
  else:
    if S == "AC":
      if submit[p] != -1:
        AC += 1
        WA += submit[p]
        submit[p] = -1
    elif S =="WA":
      if submit[p] != -1:
        submit[p] += 1    	

print(AC,WA)

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

ac = 0
wa = 0
yet =set()
count = {}
for i in range(m):
    tmp1,tmp2 = input().split()
    p.append(int(tmp1))
    s.append(tmp2)

for i in range(m):
    
    if s[i] == "AC" and p[i] not in yet:
        ac +=1
        if p[i] in count.keys():
            wa +=count[p[i]]
        yet.add(p[i])
    elif s[i] == "WA" and p[i] not in yet:
        if p[i] in count.keys():
            count[p[i]] += 1
        else:
            count[p[i]] = 1
print(ac,wa)

Solution (Python):

n, m = [int(x) for x in input().split()]
history = { i+1 : [0, False] for i in range(n)}

for _ in range(m):
  pi, result = input().split()
  translated_pi = int(pi)
  if result == 'WA' and not history[translated_pi][1]:
    history[translated_pi][0] += 1
  else:
    history[translated_pi][1] = True

ac_count = 0
penalty_count = 0
for result in history.values():
  if result[1]:
    ac_count += 1
    penalty_count += result[0]

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

Solution (Python):

from collections import defaultdict


def main():
    N, M, *PS = open(0).read().split()
    is_correct = [0] * (int(N) + 1)
    wa_count = defaultdict(int)
    for p, s in zip(*[iter(PS)] * 2):
        p = int(p)
        if not is_correct[p]:
            if s == "AC":  
                is_correct[p] = 1
            else:  
                wa_count[p] += 1
    penalties = sum(cnt for i, cnt in wa_count.items() if is_correct[i])
    print(sum(is_correct), penalties)


if __name__ == "__main__":
    main()

Solution (Python):

from collections import defaultdict


def main():
    N, M, *PS = open(0).read().split()
    is_correct = [0] * (int(N) + 1)
    wa_count = defaultdict(int)
    penalties = 0
    for p, s in zip(*[iter(PS)] * 2):
        p = int(p)
        if not is_correct[p]:
            if s == "AC":  
                is_correct[p] = 1
                penalties += wa_count[p]
            else:  
                wa_count[p] += 1
    print(sum(is_correct), penalties)


if __name__ == "__main__":
    main()

Solution (Python):

from collections import defaultdict


def main():
    N, M, *PS = open(0).read().split()
    is_correct = [0] * (int(N) + 1)
    wa_count = defaultdict(int)
    for p, s in zip(*[iter(PS)] * 2):
        p = int(p)
        if s == "AC":
            is_correct[p] = 1
        else:
            if not is_correct[p]:  
                wa_count[p] += 1
    penalties = sum(cnt for i, cnt in wa_count.items() if is_correct[i])
    print(sum(is_correct), penalties)


if __name__ == "__main__":
    main()