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 numpy import *

N, M = map(int, input().split())
p = zeros(M, dtype=int)
S = []
for i in range(M):
    x, y = input().split()
    p[i] = int(x) - 1
    S.append(y)

ac = zeros(N, dtype=int)
wa = zeros(N, dtype=int)
s_ac = 0
s_wa = 0
for i in range(M):
    if ac[p[i]] == 0:
        if S[i] == 'AC':
            ac[p[i]] += 1
            s_ac += 1
            s_wa += wa[p[i]]
        elif S[i] == 'WA':
            wa[p[i]] += 1
    else:
        pass

print('{} {}'.format(s_ac, s_wa))

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

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

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

answer_list = {}
for i in range(N):
    answer_list[str(i+1)] = 0

for i in range(M):
    p, S = input().split()
    if answer_list[p] == "AC":
        pass
    else:
        if S == "AC":
            AC += 1
            WA += answer_list[p]
            answer_list[p] = "AC"
        else:
            answer_list[p] += 1

print(AC, WA)

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

acCount = 0
waCount = 0

for i in range(m):
    p, s = input().split()
    p = int(p)
    if(ac[p] == False):
        if (s == "AC"):
            ac[p] = True
        else:
            wa[p] += 1

for i in range(n+1):
    if(ac[i] == True):
        acCount += 1
        waCount += wa[i]

print(acCount, waCount)

Solution (Python):
def main():
    N,M=map(int,input().split())
    pS=[list(input().split()) for i in range(0,M)]
    atcoderresult=[[0,0] for i in range(0,N+1)]
    for i in range(0,M):
        if pS[i][1]=='WA' and atcoderresult[int(pS[i][0])][0]==0:
            atcoderresult[int(pS[i][0])][1]=atcoderresult[int(pS[i][0])][1]+1
        if pS[i][1]=='AC':
            atcoderresult[int(pS[i][0])][0]=1
    ac=0
    penalty=0
    for i in range(1,N+1):
        if atcoderresult[i][0]==1:
            ac=ac+1
            penalty=penalty+atcoderresult[i][1]
    print(ac,penalty)

if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np

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

Q = np.zeros((N,2),dtype=int)
for i in range(M):
  p,S = input().split()
  p = int(p)-1
  if Q[p,0] == 0 and S == "AC":
    Q[p,0] = 1
  elif Q[p,0] == 0 and S == "WA":
    Q[p,1] += 1
  else:
    pass

Q[:,1] *= Q[:,0]
ret = Q.sum(axis=0)
print(ret[0],ret[1])

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

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

Solution (Python):
k, n = list(map(int, input().split()))
AC, WA = [0] * k, [0] * k
for i in range(n):
  x = input().split()
  number = int(x[0]) - 1
  if x[1] == "AC":
    AC[number] = 1
  elif x[1] == "WA" and AC[number] == 0:
    WA[number] += 1
print(sum(AC), sum([w for i, w in enumerate(WA) if AC[i]]))

Solution (Python):
n,m = map(int,input().split())
A = []
for _ in range(m):
    a,b = input().split()
    tmp = [int(a),b]
    A.append(tmp)
dict = {}
for a in A:
    dict.update({a[0]:[False,0]})
for a in A:
    if dict[a[0]][0] == False:
        if a[1] == "WA":
            dict[a[0]][1] += 1
        else:
            dict[a[0]][0] = True
wa = 0
ac = 0
for i in dict:
    if dict[i][0]:
        ac += 1
        wa += dict[i][1]
print("{} {}".format(ac,wa))

Solution (Python):
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys






read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 9

N, M = map(int, readline().split())
PS = [line.split() for line in readlines()]
AC = [False] * (N + 1)
WA = [0] * (N + 1)

penal = 0
for p, s in PS:
    p = int(p)
    if AC[p]:
        continue
    if s == b'WA':
        WA[p] += 1
    else:
        AC[p] = True
        penal += WA[p]

ac = sum(AC)
print(ac, penal)

Solution (Python):
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys






read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 9

N, M = map(int, readline().split())
PS = [line.split() for line in readlines()]
AC = [False] * (N + 1)
WA = [0] * (N + 1)

penal = 0
for p, s in PS:
    p = int(p)
    if AC[p]:
        continue
    if s == b'WA':
        WA[p] += 1
    else:
        AC[p] = True
        penal += WA[p]

ac = sum(AC)
print(ac, penal)

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

wa_stock = [0] * N
ac = 0
wa = 0
stat = ['NA'] * N

for _ in range(M):
    p, S = input().split()
    key = int(p) - 1
    if S == 'WA':
        wa_stock[key] += 1
    elif stat[key] != 'AC' and S == 'AC':
        stat[key] = 'AC'
        ac += 1
        wa += wa_stock[key]

print(ac, wa)

Solution (Python):
from collections import defaultdict
wa_dict = defaultdict(lambda: 0)
n, m = map(int, input().split())
ac_set = set([])
ac = 0
wa = 0
for _ in range(m):
    p, s = input().split()
    if s == 'AC':
        if p not in ac_set:
            wa += wa_dict[p]
            ac_set.add(p)
    else:
        if p not in ac_set:
            wa_dict[p] += 1
print(len(ac_set), wa)

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

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

for i in range(n):
    if ac[i] == 1:
        continue
    elif ac[i] == 0:
        wa[i] = 0
        
print(sum(ac),sum(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())
    p[i] = int(p[i])

ac = [0] * (n+1)
wa = [0] * (n+1)
for i in range(m):
    if s[i] == 'WA':
        if ac[p[i]] == 0:
            wa[p[i]] += 1
        else:
            pass
    if s[i] == 'AC':
        ac[p[i]] = 1

ac_num = 0
for i in range(len(ac)):
    if ac[i] != 0:
        ac_num += 1
ng = 0
for i in range(len(wa)):
    if ac[i] != 0:
        ng += wa[i]
            
print(ac_num,ng)

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

c = [0]*N
w = [0]*N

ac = 0
wa = 0

for i, v in A:
    if c[int(i)-1] == 0:
        if v == 'WA':
            w[int(i)-1] += 1
        elif v == 'AC':
            ac += 1
            wa += w[int(i)-1]
            c[int(i)-1] = 1

print(ac, wa)

Solution (Python):
n, m = (int(x) for x in input().split())
ps = []
for _ in range(m):
    p, s = (x for x in input().split())
    ps.append([int(p), s])
ans = [0] * n
pen = 0
tmp = [0] * n
for p, s in ps:
    if ans[p - 1] == 1:
        continue
    if s == 'WA':
        tmp[p - 1] += 1
    else:
        ans[p - 1] = 1
        pen += tmp[p - 1]
print(sum(ans), pen)

Solution (Python):
n, m = (int(x) for x in input().split())
ps = []
for _ in range(m):
    p, s = (x for x in input().split())
    ps.append([int(p), s])
ans = [0] * n
pen = 0
tmp = [0] * n
for p, s in ps:
    if s == 'WA' and ans[p - 1] == 0:
        tmp[p - 1] += 1
        continue
    else:
        ans[p - 1] = 1
        pen += tmp[p - 1]
        tmp[p - 1] = 0 
print(sum(ans), pen)

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

    penalties = 0
    wa_counts = [0] * n
    ac_flags = [0] * n

    for _ in range(m):
        line = input().split()
        q = int(line[0])
        r = line[1]

        if ac_flags[q-1] == 0:
            if r == 'WA':
                wa_counts[q-1] += 1

            else:
                ac_flags[q-1] = 1
                penalties += wa_counts[q-1]

    print(sum(ac_flags), penalties)
    
resolve()

Solution (Python):
def main(n,m,r):
    ac = [0]*n
    wa = [0]*n
    for i in range(len(r)):
        seq = int(r[i][0])
        judge = r[i][1]
        if ac[seq-1] == 1:
            continue
        if judge == "WA":
            wa[seq-1] += 1
        else:
            ac[seq-1] = 1
    for i in range(len(ac)):
        if ac[i] == 0:
            wa[i] = 0
    return "{0} {1}".format(sum(ac), sum(wa))

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

Solution (Python):
import numpy as np
N, M = map(int, raw_input().split())
Trial = np.zeros(N, int)
Penalty = 0
Accept  = 0
Finish = np.zeros(N, bool)
for i in xrange(M):
    a, b = raw_input().split()
    A = int(a) - 1
    if not Finish[A]:
        if b == 'AC':
            Penalty += Trial[A]
            Finish[A] = True
            Accept += 1
        else:
            Trial[A] += 1
    else:
        pass
    
print Accept, Penalty

Solution (Python):
import numpy as np
N, M = map(int, raw_input().split())
Trial = np.zeros(N, int)
Penalty = 0
Finish = np.zeros(N, bool)
for i in xrange(M):
    a, b = raw_input().split()
    A = int(a) - 1
    if not Finish[A]:
        if b == 'AC':
            Penalty += Trial[A]
            Finish[A] = True
        else:
            Trial[A] += 1
    else:
        pass
    
Accept = Finish.sum()
print Accept, Penalty

Solution (Python):
def main():
    N, M = map(int, input().split(' '))
    wc_cnt = [0 for _ in range(N + 1)]
    ac, wc = 0, 0
    for i in range(M):
        num, result = input().split(' ')
        num = int(num)
        if wc_cnt[num] is None:
            continue
        if result == 'AC':
            wc += wc_cnt[num]
            wc_cnt[num] = None
            ac += 1
        else:
            wc_cnt[num] += 1
    print(ac, wc)


if __name__ == '__main__':
    main()

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

is_solved = [0]*N
penalties = [0] * N
solutions = 0

for i in range(M):
    p_idx, verdict = input().split()
    p_idx = int(p_idx)

    if verdict == "WA" and (not is_solved[p_idx-1]):
        penalties[p_idx - 1] += 1
    elif verdict == "AC" and (not is_solved[p_idx-1]):
        is_solved[p_idx-1] = 1
        solutions += 1
penalty = 0

for i in range(N):
    if is_solved[i]:
        penalty += penalties[i]

print(solutions, penalty)

Solution (Python):
n,m=map(int,input().split())
l=[0]*(n+1)
p=0
for _ in range(m):
  a,b=list(input().split())
  if str(b)=="AC" and l[int(a)]!=-1:
    p+=l[int(a)]
    l[int(a)]=-1
  elif str(b)=="WA" and l[int(a)]!=-1:
    l[int(a)]+=1
print(l.count(-1),p)

Solution (Python):
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    N, M = read_int_list()
    p = [0] * M
    S = [''] * M
    for i in range(M):
      l = read_str_list()
      p[i] = int(l[0])
      S[i] = l[1]
      
    r = set()
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in r:
          r.add(p[i])

    correct, penalties = 0, 0
    f = set()  
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in f:
          f.add(p[i])
          correct += 1
      
      
      if S[i] == 'WA':
        if p[i] not in f and p[i] in r:
          penalties += 1

    print(correct, penalties)


def main0():
    N, M = read_int_list()
    p = [0] * M
    S = [''] * M
    for i in range(M):
      l = read_str_list()
      p[i] = int(l[0])
      S[i] = l[1]
      
    r = set()
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in r:
          r.add(p[i])

    correct = len(r)
    penalties = 0
    f = set()  
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in f:
          f.add(p[i])
      
      if S[i] == 'WA':
        if p[i] not in f and p[i] in r:
          penalties += 1

    print(correct, penalties)


def main1():
    N, M = read_int_list()
    correct = 0
    penalties = 0
    WA = [0] * (N + 1)
    AC = [0] * (N + 1)
    for i in range(M):
      l = read_str_list()
      p = int(l[0])
      S = l[1]

      if S == 'AC':
        AC[p] += 1
      if S == 'WA':
        WA[p] += 1

      if S == 'AC' and AC[p] == 1:
        correct += 1
        penalties += WA[p]
      
      

    print(correct, penalties)

main1()

Solution (Python):
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    N, M = read_int_list()
    p = [0] * M
    S = [''] * M
    for i in range(M):
      l = read_str_list()
      p[i] = int(l[0])
      S[i] = l[1]
      
    r = set()
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in r:
          r.add(p[i])

    correct, penalties = 0, 0
    f = set()  
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in f:
          f.add(p[i])
          correct += 1
      
      
      if S[i] == 'WA':
        if p[i] not in f and p[i] in r:
          penalties += 1

    print(correct, penalties)


def main0():
    N, M = read_int_list()
    p = [0] * M
    S = [''] * M
    for i in range(M):
      l = read_str_list()
      p[i] = int(l[0])
      S[i] = l[1]
      
    r = set()
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in r:
          r.add(p[i])

    correct = len(r)
    penalties = 0
    f = set()  
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in f:
          f.add(p[i])
      
      if S[i] == 'WA':
        if p[i] not in f and p[i] in r:
          penalties += 1

    print(correct, penalties)

main0()

Solution (Python):
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    N, M = read_int_list()
    p = [0] * M
    S = [''] * M
    for i in range(M):
      l = read_str_list()
      p[i] = int(l[0])
      S[i] = l[1]
      
    r = set()
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in r:
          r.add(p[i])

    correct, penalties = 0, 0
    f = set()  
    for i in range(M):
      if S[i] == 'AC':
        if p[i] not in f:
          f.add(p[i])
          correct += 1
      
      
      if S[i] == 'WA':
        if p[i] not in f and p[i] in r:
          penalties += 1

    print(correct, penalties)

main()

Solution (Python):
def InS(): return input()


def InL(): return list(map(int, input().split()))


def InI(): return int(input())


N, M = (int(x) for x in input().split(" "))

i = 0
WAcnt = [0] * N
stack = [False] * N
WAcnt


data_list = [list(map(str, input().split(" "))) for i in range(M)]

if M == 0:
    print(0, 0)
else:
    while M > i:
        if stack[int(data_list[i][0]) - 1] == False:
            if data_list[i][1] == "AC":
                stack[int(data_list[i][0]) - 1] = True
            else:
                WAcnt[int(data_list[i][0]) - 1] += 1
        i += 1
    res = 0
    for i in range(N):
        if stack[i]:
            res += WAcnt[i]

    print(sum(stack), res)

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

ls = [0 for _ in range(n+1)]

ans = 0
pen = 0

for _ in range(m):
  p,s = input().split()
  p = int(p)
  
  if ls[p] == None:
    pass
  elif s == "WA":
    ls[p] += 1
  else:
    pen += ls[p]
    ls[p] = None
    ans +=1
print(ans,pen)

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

lac = [0]*(N+1)
lpcnt = [0]*(N+1)

for i in range(M):
  s = input().split()
  n = int(s[0])
  if s[1] == "AC":
    lac[n] =1
    continue
  if s[1] == "WA" and lac[n] == 0:
    lpcnt[n] += 1

cnt = 0
for i in range(N+1):
  if lac[i] == 1:
    cnt += lpcnt[i]
  
print(sum(lac), end=" ")
print(cnt)

Solution (Python):
from sys import stdin
n,m = map(int,stdin.readline().split())
prob = dict()
AC,WA = 0,0
for _ in range(m):
	p,s = stdin.readline().split()
	p = int(p)
	if p in prob:
		if s == "AC":
			if prob[p] > 0:
				AC += 1
				WA += prob[p]
				prob[p] = 0
		else:
			if prob[p] > 0: prob[p] += 1
	else:
		if s == "AC":
			prob[p] = 0
			AC += 1
		else:
			prob[p] = 1
print(AC,WA)

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

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

for b in a:
  p = int(b[0]) - 1
  if ac[p] == 1:
    next
  else:
    if b[1] == 'AC':
      ac[p] = 1
    else:
      wa[p] += 1
wa = [ac[i]*wa[i] for i in range(n)]
print('{} {}'.format(sum(ac),sum(wa)))

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

lac = [0]*(N+1)
lpcnt = [0]*(N+1)

for i in range(M):
  s = input().split()
  n = int(s[0])
  if s[1] == "AC":
    lac[n] =1
    continue
  if s[1] == "WA" and lac[n] == 0:
    lpcnt[n] += 1

cnt = 0
for i in range(N+1):
  if lac[i] == 1:
    cnt += lpcnt[i]
  
print(sum(lac), end=" ")
print(cnt)

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

    dict = {}
    for _ in range(M):
        p, s = input().split()
        if not p in dict:
            if s == "AC":
                dict[p] = [1, 0]
            elif s == "WA":
                dict[p] = [0, 1]
        else:
            if dict[p][0] == 0:
                if s == "AC":
                    dict[p][0] = 1
                elif s == "WA":
                    dict[p][1] += 1

    ac = 0
    wa = 0
    for k, v in dict.items():
        if v[0] == 1:
            ac += v[0]
            wa += v[1]

    print(ac, wa)

if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())
p, S = [0]*M, [0]*M
for i in range(0,M):
    p[i], S[i] = input().split()
    p[i] = int(p[i])
s, t = 0, 0
res = []
for i in range(0,N):
    res.append([i,0])
for i in range(0,M):
    if S[i] == "WA":
        res[p[i]-1][1] = res[p[i]-1][1]+1
    elif res[p[i]-1][0] != -1:
        s, t = s+1, t+res[p[i]-1][1]
        res[p[i]-1][0] = -1
print(s, t)

Solution (Python):
import copy

N,M=map(int,input().split())
L=[list(map(str,input().split())) for i in range(M)]

for x in range(M):
    L[x][0]=int(L[x][0])




S=[]
component=[0,0]
for j in range(N):
    S.append(copy.deepcopy(component))



for k in range(1,M+1):
    if L[k-1][1]=='AC':
        if S[L[k-1][0]-1][0]==0:
            S[L[k-1][0]-1][0]=1
    else:
        if S[L[k-1][0]-1][0]==0:
            S[L[k-1][0]-1][1]+=1
    

ansAC=0
ansWA=0

for l in range(N):
    ansAC+=S[l][0]
    if S[l][0]==1:
        ansWA+=S[l][1]

print(ansAC,ansWA)

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

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

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

Solution (Python):
N, M = map(int, input().split())
results = [input().split() for _ in range(M)]
solved = set()
missed = dict()
penalty = 0

for p, S in results:
    if p in solved:
        continue

    if S == 'AC':
        solved.add(p)
        penalty += missed[p] if p in missed else 0
    else:
        missed[p] = missed[p] + 1 if p in missed else 1

print(len(solved), penalty)

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

Solution (Python):
from sys import stdin

def main():
    n,m = map(int,stdin.readline().split())
    arr= [0 for _ in range(n+1)]
    p=0;a= 0
    for _ in range(m):
        x,y = stdin.readline().split()
        x = int(x)
        if  arr[x] != -1:
            if y == "WA":
                arr[x]+=1
            else:
                a+=1
                p+=arr[x]
                arr[x] = -1
    print(a,p)
main()

Solution (Python):
from sys import stdin

def main():
    N,M=[int(x) for x in stdin.readline().split()]
    D=dict()
    AC=0
    WA=0
    for _ in range(M):
        p,a=stdin.readline().split()
        p=int(p)
        if not p in D:
            D[p]=0
        if a=='WA' and D[p]!=-1:
            D[p]+=1
        if a=='AC' and D[p]!=-1:
            WA+=D[p]
            AC+=1
            D[p]=-1
    print(AC,WA)
main()

Solution (Python):
n,m = map(int,input().split())
L = [0]*n
penalty = [0]*n
ans = 0
out = 0
for i in range(m):
  p,q = input().split()
  if q == 'AC':
    if L[int(p)-1] == 0:
      L[int(p)-1] = 1
      ans += 1
  else:
    if L[int(p)-1] == 0:
      penalty[int(p)-1] += 1
for i in range(n):
  if L[i] == 1:
    out += penalty[i]
print(ans,out)

Solution (Python):
n, m = map(int, input().split())
P = []
S = []
for i in range(m):
    p, s = input().split()
    P.append(p)
    S.append(s)
V = [[0] * 2 for i in range(n)]
for i in range(m):
    j = int(P[i]) - 1
    if V[j][0] != 1:
        if S[i] == 'AC':
            V[j][0] = 1
        else:
            V[j][1] += 1
a = 0
w = 0
for i in range(n):
    if V[i][0] == 1:
        a += 1
        w += V[i][1]
print(a, w)

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

ans,pen = 0,0
for _ in range(M):
    p,s = input().rstrip().split(' ')
    p = int(p) - 1
    if P[p] == -1:
        continue
    if s == "WA":
        P[p] += 1
    else:
        ans += 1
        pen += P[p]
        P[p] = -1
print(ans,pen)

Solution (Python):
N,M = [int(i) for i in input().split()]
P = [0 for _ in range(N)]
ans,pen = 0,0
for _ in range(M):
    p,s = input().split()
    p = int(p) - 1
    if P[p] == -1:
        continue
    if s == "WA":
        P[p] += 1
    else:
        ans += 1
        pen += P[p]
        P[p] = -1
print(ans,pen)

Solution (Python):
N,M = [int(i) for i in input().rstrip().split(' ')]
P = [0 for _ in range(N)]
ans,pen = 0,0
for _ in range(M):
    p,s = input().rstrip().split(' ')
    p = int(p) - 1
    if P[p] == -1:
        continue
    if s == "WA":
        P[p] += 1
    else:
        ans += 1
        pen += P[p]
        P[p] = -1
print(ans,pen)

Solution (Python):
import numpy as np

if __name__ == "__main__":
  _n, _m = map(int, input().split())
  results = []
  flag = set()
  ans_ac = 0
  ans_wa = 0
  for i in range(_m):
    _p, _s = input().split()
    _p = int(_p)
    if _s == 'AC':
      flag.add(_p)
    results.append((_p, _s))

  ans_ac = int(len(flag))

  for p, s in results:
    if s == 'WA' and p in flag:
      ans_wa += 1
    else:
      flag.discard(p)

  print(ans_ac, int(ans_wa))

Solution (Python):
n,m = map(int,input().split())
ac = [0 for _ in range(n)]
wa = [0 for _ in range(n)]
for _ in range(m):
  a,b = input().split()
  a = int(a) - 1
  if b == 'AC':
    ac[a] = 1
  elif ac[a] == 0:
    wa[a] += 1
for i in range(n):
  wa[i] *= ac[i]
print(sum(ac),sum(wa))

Solution (Python):



import numpy

def main():
  n, m = map(int, input().strip().split())
  counts = numpy.zeros(n).astype(numpy.int)
  flags = numpy.zeros(n).astype(numpy.int)
  for _ in range(m):
    p, s = input().strip().split()
    p = int(p)
    if s == 'WA' and flags[p-1] != 1:
      counts[p-1] += 1
    if s == 'AC':
      flags[p-1] = 1
  print(numpy.sum(flags), numpy.sum(counts * flags))

if __name__=='__main__':
  main()

Solution (Python):
[N, M] = map(int, input().rstrip().split(' '))
ps = []
ss = []

result = {}
ac = 0
wa = 0

was = [0 for i in range(N+1)]

for i in range(M):
    [p, s] = input().rstrip().split(' ')
    
    if result.get(p) == None:
        result[p] = s
        if s == "WA":
            was[int(p)] += 1
        elif s == "AC":
            ac += 1
    
    elif result[p] == "AC":
        continue
    
    else:
        
        if s == "AC":
            result[p] = s
            wa += was[int(p)]
            ac += 1
        
        else:
            was[int(p)] += 1

print(" ".join(map(str, [ac, wa])))

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

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

ac = 0
wa = 0

penaltyTemp = [0] * (N + 1)
Correct  = [0] * (N + 1)

for i in range(M):
    tp, S = input().split()
    P = int(tp)
    if Correct[P] == 1:
        continue
    if S == "WA":
        penaltyTemp[P] += 1
    else:
        ac += 1
        wa += penaltyTemp[P]
        Correct[P] += 1

print(ac, wa)

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

ac = 0
wa = 0

l = [0] * (N + 1)

for num in range(M):
    p, s =  input().split()
    p = int(p)
    if s == "AC":
        if l[p] <= 0:
            ac += 1
            wa += -l[p]
            l[p] = 1
        
         
    else:
        if l[p] <= 0:
            l[p] -= 1
        
print(*[ac, wa])

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    
    N, M = Scanner.map_int()
    P, S = [str] * M, [str] * M
    for i in range(M):
        P[i], S[i] = Scanner.string().split()
    ac, wa = 0, 0
    acs = defaultdict(bool)
    was = defaultdict(int)
    for i in range(M):
        if S[i] == "AC":
            if not acs[P[i]]:
                ac += 1
                wa += was[P[i]]
                acs[P[i]] = True
        else:
            was[P[i]] += 1
    print(ac, wa)
    return


if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np

def main():
    N, M = map(int, input().split())
    acc = [False] * (N+1)
    pen = [0] * (N+1)
    for _ in range(M):
        p, S = input().split()
        p = int(p)
        if S[0] == 'A':
            acc[p] = True
        else:
            if not acc[p]:
                pen[p] += 1
    n_pen = 0
    for i in range(1, N+1):
        if acc[i]:
            n_pen += pen[i]
    print('{} {}'.format(sum(acc), n_pen))

    

if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np

def main():
    
    
    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    

    N, M = map(int, input().split())
    accepted = [False] * N
    penalties = [0] * N
    for _ in range(M):
        q, res = input().split()
        q = int(q) - 1
        if res[0] == 'A':
            accepted[q] = True
        elif res[0] == 'W' and not accepted[q]:
            penalties[q] += 1

    s_acc = 0
    s_pen = 0
    for i in range(N):
        if accepted[i]:
            s_acc += 1
            s_pen += penalties[i]

    print('{} {}'.format(s_acc, s_pen))
    

if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict

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

"""考え方
普通にやる
"""

ans_ac = 0
ac_p_set = set()
wa_dict = defaultdict(int)

for m in range(M):
  p,s = input().split()
  
  
  if p in ac_p_set:
    continue
  
  
  if s == 'AC':
    ac_p_set.add(p)
    ans_ac += 1
  
  else:
    wa_dict[p] += 1
    

ans_wa = sum(wa_dict[i] for i in ac_p_set)
print(ans_ac,ans_wa)