Problem:
 Score : 300 points    Problem Statement Takahashi participated in a contest on AtCoder.  The contest had N problems.  Takahashi made M submissions during the contest.  The i -th submission was made for the p_i -th problem and received the verdict S_i ( AC or WA ).  The number of Takahashi's correct answers is the number of problems on which he received an AC once or more.  The number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WA s received before receiving an AC for the first time on that problem.  Find the numbers of Takahashi's correct answers and penalties.      Constraints  N , M , and p_i are integers.  1 \leq N \leq 10^5  0 \leq M \leq 10^5  1 \leq p_i \leq N  S_i is AC or WA .         Input Input is given from Standard Input in the following format:  N  M  p_1  S_1  :  p_M  S_M       Output Print the number of Takahashi's correct answers and the number of Takahashi's penalties.        Sample Input 1 2 5
1 WA
1 AC
2 WA
2 AC
2 WA      Sample Output 1 2 2  In his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.  In his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.  Thus, he has two correct answers and two penalties.       Sample Input 2 100000 3
7777 AC
7777 AC
7777 AC      Sample Output 2 1 0  Note that it is pointless to get an AC more than once on the same problem.       Sample Input 3 6 0      Sample Output 3 0 0

Solution (Python):
n,m=map(int,input().split())
l=[0]*(n+1)
miss=[0]*(n+1)
for _ in range(m):
    p,s=input().split()
    p=int(p)
    if l[p]==0:
        if s=='AC':
            l[p]+=1
        else:
            miss[p]+=1
for i in range(1,n+1):
    if l[i]==0 and miss[i]!=0:
        miss[i]=0
a=l.count(1)
b=sum(miss)
print(a,b)

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

p_list = []
s_list = []
for i in range(M):
    p, s = input().split()
    p_list.append(int(p))
    s_list.append(s)

p_state = [0 for i in range(N)]
pena_list = [0 for i in range(N)]
ans = 0
pena = 0

for i in range(M):
    if p_state[p_list[i]-1] == 0 and s_list[i] == "WA":
        pena_list[p_list[i]-1] += 1
    elif p_state[p_list[i]-1] == 0 and s_list[i] == "AC":
        p_state[p_list[i]-1] = 1
        ans += 1
        pena += pena_list[p_list[i]-1]
    else:
        continue

print(ans, pena)

Solution (Python):
N,M = map(int,input().split())
ac_cnt = [0] * (N + 1)
wa_cnt = [0] * (N + 1)

for i in range(M):
  p,S = input().split()
  p = int(p)
  
  if ac_cnt[p] == 0:
    if S == "WA":
      wa_cnt[p] += 1
    else:
      ac_cnt[p] += 1
    
wa_cnt = [wa for i, wa in enumerate(wa_cnt) if ac_cnt[i] == 1]
print(sum(ac_cnt),sum(wa_cnt))

Solution (Python):
P,M = map(int,input().split())
dac = {}
dwa = {}
for _ in range(M):
  p,s = input().split()
  p = int(p)
  if s == "AC":
    if p not in dac:
      dac[p] = 1
  else:
    if p not in dac:
      if p not in dwa:
        dwa[p] = 1
      else:
        dwa[p] += 1

score = len(dac)
penalty = sum([val for k,val in dwa.items() if (k in dac)])
print(score,penalty)

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

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

print(ac.count(1), wa)

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

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

    if AC[p] == False:
        if s == 'WA':
            WA[p] += 1
        else:
            AC[p] = True

wa = 0

for i in range(n):
    if AC[i]:
        wa += WA[i]
        

print(AC.count(True),wa)

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

ok = [False]*N
wa = [0]*N

for i in range(M):
    p, S = input().split()
    p = int(p) - 1
    if ok[p] == False:
        if S == "WA":
            wa[p] += 1
        else:
            ok[p] = True
    else:
        pass
pena = 0
for i in range(N):
    if ok[i] == True:
        pena += wa[i]
print(sum(ok), pena)

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

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

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

ans_WA = 0
for i, j in zip(WA, AC):
  ans_WA += i * j
  
print(sum(AC), ans_WA)

Solution (Python):
n,m=map(int,input().split())
ac=[0]*(n+1)
wa=0
for i in range(m):
  p,c=input().split()
  if c=='WA' and ac[int(p)]!=1:
    ac[int(p)]-=1
  elif c=='AC' and ac[int(p)]!=1:
    wa+=abs(ac[int(p)])
    ac[int(p)]=1
print(ac.count(1),wa)

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




for i in range(M):    
  num = int(p_S[i][0])-1
  if AC[num] == 0 and p_S[i][1] == 'WA': WA[num] += 1
  elif AC[num] == 0 and p_S[i][1] == 'AC': AC[num] = True
  else: continue


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

Solution (Python):
n,m=map(int,input().split())
p=[0]*m
s=[0]*m
for i in range(m):
    pi,si=input().split()
    p[i]=int(pi)
    s[i]=si
judge=[0]*(n+1)
ac=0
wa=0
for i in range(m):
    if judge[p[i]]==-1:
        continue
    if judge[p[i]]!=-1:
        if s[i]=='WA':
            judge[p[i]]+=1
        else:
            wa+=judge[p[i]]
            judge[p[i]]=-1
            ac+=1
print(ac,wa)

Solution (Python):
n,m=map(int,input().split())
ansct=0
ansflag=[0]*n
miss=[0]*n
missct=0
for i in range(m):
    p,s=map(str,input().split())
    if (s=='AC')and(ansflag[int(p)-1]==0):
        ansflag[int(p)-1]=1
        ansct+=1
        missct+=miss[int(p)-1]
    elif ansflag[int(p)-1]==0:
        miss[int(p)-1]+=1
print(str(ansct)+' '+str(missct))

Solution (Python):
N, M = map(int, input().split())
pena= 0
ac = [0]*(10**5)
for _ in range(M):
  tmp = input().split()
  if ac[int(tmp[0])-1] < 1:
    if tmp[1] == "AC":
      pena -= ac[int(tmp[0])-1]
      ac[int(tmp[0])-1] = 1
    else: ac[int(tmp[0])-1] -= 1 
print(ac.count(1), pena)

Solution (Python):
n,m = map(int,input().split())
ans_list = [False for _ in range(n+1)]
pe_list = [0 for _ in range(n+1)]
ac=0
pe=0
for _ in range(m):
    p,s = input().split()
    if not ans_list[int(p)]:
        if s == 'AC':
            ac+=1
            pe+=pe_list[int(p)]
            ans_list[int(p)]=True
        else:
            pe_list[int(p)]+=1
            
print(ac,pe)

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

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

for i in range(M):
  j = li[i][0] - 1
  if li[i][1] == "WA":
    wa[j] += 1
  if ac[j] == 0 and li[i][1] == "AC":
    ac[j] = 1
    c1 += 1
    c2 += wa[j]

print(c1, c2)

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

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

for i in range(M):
  j = li[i][0] - 1
  if li[i][1] == "WA":
    wa[j] += 1
  if ac[j] == 0 and li[i][1] == "AC":
    ac[j] = 1
    c1 += 1
    c2 += wa[j]

print(c1, c2)

Solution (Python):
from collections import defaultdict
N,M = map(int,input().split())
AC_List = defaultdict(int)
WA_List = defaultdict(int)

for i in range(M):
    Num,Sta = map(str,input().split())
    if Num in AC_List:
        continue
    else:
        if Sta == "WA":
            WA_List[Num] += 1
        else:
            AC_List[Num] += 1

ansct = 0
for k,v in WA_List.items():
    if k in AC_List:
        ansct += v
            
print(str(len(AC_List))+" " +str(ansct))

Solution (Python):
def main():
    n, m = map(int, input().split())
    ac_list = [0 for _ in range(n + 1)] 
    wa_list = [0 for _ in range(n + 1)] 

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

        if ac_list[p] == 1: 
            continue
        
        if s == "AC":
            ac_list[p] = 1
        else:
            wa_list[p] += 1

    ac_count = 0
    wa_count = 0
    for i in range(1, n + 1):
        if ac_list[i] == 1:
            ac_count += 1
            wa_count += wa_list[i]

    print(ac_count, wa_count)


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    n, m = map(int, input().split())
    ans_dict = dict() 

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

        if p not in ans_dict: 
            if s == "AC": 
                ans_dict[p] = [1, 0]
            else: 
                ans_dict[p] = [0, 1]
        else: 
            if ans_dict[p][0] == 1: 
                continue
            else: 
                if s == "AC":
                    ans_dict[p][0] = 1
                else:
                    ans_dict[p][1] += 1

    ac_count = 0
    wa_count = 0
    for item in ans_dict.items():
        if item[1][0] == 1: 
            ac_count += 1
            wa_count += item[1][1]

    print(ac_count, wa_count)


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    n, m = map(int, input().split())
    ps_lst = [list(map(str, input().split())) for _ in range(m)]
    judge_lst = [0] * n
    penalty_lst = [0] * n
    correct = 0
    penalty = 0

    for i in range(m):
        problem = int(ps_lst[i][0]) - 1
        result = ps_lst[i][1]
        
        if judge_lst[problem] == 0:
            if result == 'AC':
                judge_lst[problem] = 1
            else:
                penalty_lst[problem] += 1

    for i in range(n):
        if judge_lst[i] == 1:
            correct += 1
            penalty += penalty_lst[i]
            
    print(correct, penalty)


if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())
WA = [0 for i in range(N+1)]
AC = [0 for i in range(N+1)]
for i in range(M):
  p, q = input().split()
  p = int(p)
  if q == "AC":
    AC[p] = 1
  else:
    if AC[p] == 0:
      WA[p] += 1
ans_WA = 0
for i, j in zip(WA, AC):
  ans_WA += i * j
print(sum(AC), ans_WA)

Solution (Python):

import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    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])

    AC = 0
    WA = 0
    l = [0] * N
    for i in range(M):
        if l[p[i] - 1] != 1:
            if S[i] == 'WA':
                l[p[i] - 1] -= 1
            elif S[i] == 'AC':
                WA += l[p[i] - 1] * (-1)
                l[p[i] - 1] = 1
                AC += 1
    print(AC, WA)

if __name__ == '__main__':
    main()

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, M = map(int, readline().split())
    AC = [False] * N
    cnt = [0] * N

    for _ in range(M):
        p, s = input().split()
        p = int(p)
        p -= 1
        if s == "AC":
            AC[p] = True
        else:
            if not AC[p]:
                cnt[p] += 1

    ans_a = 0
    ans_p = 0
    for i in range(N):
        if AC[i]:
            ans_a += 1
            ans_p += cnt[i]

    print(ans_a, ans_p)


if __name__ == '__main__':
    main()

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

dp = [[0 for _ in range(2)] for _ in range(n)] 

for i in range(m):
    if dp[int(lis[i][0])-1][0]==1:
        continue
    else:
        if lis[i][1]=='WA':
            dp[int(lis[i][0])-1][1] += 1
        if lis[i][1]=='AC':
            dp[int(lis[i][0])-1][0] = 1

ac = 0
wa = 0

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

print(ac,wa)

Solution (Python):

_INPUT = """\
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
2 AC
"""

def main():
    n, m = map(int, input().split())

    seikai = [False] * n
    matigai = [0] * n

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

        if q == "AC":
            seikai[p] = True
        else:
            if seikai[p] != True:
                matigai[p] += 1

    num = 0
    ac = 0
    for i in range(n):
        if seikai[i] == True:
            num += matigai[i]
            ac += 1
    print(ac,num)
            
if __name__ == '__main__':
    import io
    import sys
    import math
    import itertools
    from collections import deque

    
    main()

Solution (Python):

_INPUT = """\
2 5
1 WA
1 AC
2 WA
2 AC
2 WA
2 AC
"""

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

    str_l = ["WA"]*n
    int_l = [0]*n
    num = 0
    ac = 0

    for pp, s in ps:
        p = int(pp)-1
        if s == "AC":
            str_l[p] = "AC"
        else:
            if str_l[p] != "AC":
                int_l[p] += 1

    for i in range(n):
        if str_l[i] == "AC":
            num += int_l[i]
            ac += 1

    print(ac,num)
    

    
    

    
    
    

    
    
    
    
    


    
    
    
            
if __name__ == '__main__':
    import io
    import sys
    import math
    import itertools
    from collections import deque

    
    main()

Solution (Python):
import sys


def resolve(in_):
    N, M = map(int, next(in_).split())
    PS = tuple(line.strip().split() for line in in_)
    
    ac = set()
    wa = {}

    for p, s in PS:
        if s == 'AC':
            ac.add(p)
        if s == 'WA' and p not in ac:
            wa[p] = wa.setdefault(p, 0) + 1

    penalties = 0
    for k, v in wa.items():
        if k in ac:
            penalties += v
    
    return '{} {}'.format(len(ac), penalties)


def main():
    answer = resolve(sys.stdin)
    print(answer)


if __name__ == '__main__':
    main()

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

AC=[0]*n
WA=[0]*n

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

ac, wa=0,0

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

print(ac, wa)

Solution (Python):
from collections import Counter

N, M = [int(_) for _ in input().split()]

wa = Counter()

ac = set()

for i in range(M):
    p, s = input().split()
    p = int(p)
    if p in ac: continue
    if s == 'WA':
        wa[p] += 1
    else:
        ac.add(p)
wa_cnt = 0
for v in ac:
    wa_cnt += wa[v]

print(len(ac), wa_cnt)

Solution (Python):
from operator import itemgetter

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

for i in range(M) :
    PS[i][0] = int(PS[i][0])

submits = [["null"] for i in range(N)]
for i in range(M) :
    submits[PS[i][0]-1][0] = PS[i][0]-1
    submits[PS[i][0]-1].append(PS[i][1])

ac = 0
pena = 0
for i in range(len(submits)) :
    if submits[i][0] == "null" :
        continue

    flag = False
    wabuf1 = 0
    for j in range(1,len(submits[i])) :
        if submits[i][j] == "AC" :
            ac += 1
            flag = True
            break
        else :
            wabuf1 += 1
    if flag == True :
        pena += wabuf1

print(ac,pena)

Solution (Python):
import numpy as np

N, M = map(int,input().split())
AC = np.array([0 for i in range(N)])
WA = np.array([0 for i in range(N)])

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

Solution (Python):
N,M=map(int, input().split())
a=[0]*(N+1)
w=[0]*(N+1)

for _ in range(M):
  p,s=input().split()
  p=int(p)
  if s=='AC':
    a[p]=1
  else:
    if a[p]==0:
      w[p]+=1

a2=0
w2=0
for n in range(N+1):
  if a[n]==1:
    a2+=a[n]
    w2+=w[n]
      
print(a2, w2)

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

AC = [0] * (N+1)
pl = [0] * (N+1)
cole = 0
pena = 0
for target_list in range(M):
    ans = input().split()
    problem = int(ans[0])
    result = ans[1]

    if AC[problem] == 0 and result == 'WA':
        pl[problem] += 1
    elif AC[problem] == 0 and result == 'AC':
        pena += pl[problem]
        cole += 1
        AC[problem] = 1

print(cole, pena)

Solution (Python):
n, m = map(int, input().split())
Penalty = [0]*(n+1)
AC = [False]*(n+1)
correct = 0
penalty = 0
for i in range(m):
  ans = input().split()
  problem = int(ans[0])
  result = ans[1]
  if AC[problem] == False:
    if result == 'AC':
      AC[problem] = True
      correct += 1
      penalty += Penalty[problem]
    else:
      Penalty[problem] += 1
print(correct, penalty)

Solution (Python):
n, m = map(int, input().split())
P = [0]*n
AC = [False]*n
correct = 0
penalty = 0
for i in range(m):
  ans = input().split()
  problem = int(ans[0])
  result = ans[1]
  if AC[problem-1] == False:
    if result == 'AC':
      AC[problem-1] = True
      correct += 1
      penalty += P[problem-1]
    else:
      P[problem-1] += 1
print(correct, penalty)

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

P = [0] * (N + 1)           
ok = [False] * (N + 1)      

correct = 0                 
penalty = 0                 
for i in range(M):
    query = input().split()
    p = int(query[0])
    S = query[1]
    if ok[p] == False:
        if S == 'AC':
            ok[p] = True
            correct += 1
            penalty += P[p]
        else: 
            P[p] += 1

print(correct, end=' ')
print(penalty)

Solution (Python):
N, M = map(int, input().split())
flgs = [0] * N
penas = [0] * N
ac = 0
pena = 0
for _ in range(M):
    p, s = input().split()
    p = int(p)
    s = (s=='AC')
    if flgs[p - 1]:
        continue
    elif s:
        ac += 1
        flgs[p - 1] = 1
        pena += penas[p-1]
    else:
        penas[p - 1] += 1

print(ac, pena)

Solution (Python):
N,M = map(int, input().split())
scorebook = [[] for _ in range(N)]
for i in range(M):
    p,S = input().split()
    p = int(p)-1
    scorebook[p].append(S)
maru = 0
batu = 0
for score in scorebook:
    try:
        batu += score.index("AC")
        maru += 1
    except:
        pass
print(maru, batu)

Solution (Python):
N,M = map(int, input().split())
scorebook = [[] for _ in range(N)]
for i in range(M):
    p,S = input().split()
    p = int(p)-1
    scorebook[p].append(S)
maru = 0
batu = 0
for score in scorebook:
    try:
        batu += score.index("AC")
        maru += 1
    except:
        pass
print(maru, batu)

Solution (Python):
def abc151c_welcome_to_at_coder():
    n, m = map(int, input().split())
    penalty = [0] * n
    sum_penalty = 0
    ac = [0] * n
    for i in range(m):
        p, s = input().split()
        if ac[int(p) - 1] == 0:
            if s == 'WA':
                penalty[int(p) - 1] += 1
            else:
                ac[int(p) - 1] = 1
                sum_penalty += penalty[int(p) - 1]
    print(sum(ac), sum_penalty)


abc151c_welcome_to_at_coder()

Solution (Python):

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


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


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

    ac = [0] * N
    wa = [0] * N
    num_ac = 0
    num_pe = 0
    for i in range(M):
        P, S = input().split()
        P = int(P) - 1

        if S == "AC":
            if ac[P]:
                continue
            else:
                ac[P] = 1
                num_ac += 1
                num_pe += wa[P]
        else:
            if ac[P]:
                continue
            else:
                wa[P] += 1

    print(num_ac, num_pe)


def main():
    solve()


if __name__ == '__main__':
    main()

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

qq=[True]*n
for i in range(m):
    i,j=input().split()
    i=int(i)
    i-=1
    if j=="AC":
        if qq[i]:
            qq[i]=False
            res+=pp[i]
    else:
        pp[i]+=1

print(qq.count(False),res)

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

prob = {}


for i in range(m):
  x,y = input().split()
  if x not in prob:
    if y == 'AC':
      prob[x] = [1, 0]
    else:
      prob[x] = [0, 1]
  else:
    if prob[x][0] == 0:
      if y == 'AC':
        prob[x][0] += 1
        answered = True
      else:
        prob[x][1] += 1

ac = 0
wa = 0

for i in prob:
  if prob[i][0] == 1:
    ac += 1
    wa += prob[i][1]

print(ac, wa)

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

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

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

wa_n = sum(wa[i] if ac[i] else 0 for i in range(n))
print("{} {}".format(sum(ac), wa_n))

Solution (Python):
N,M=map(int,input().split())
results = [False]*N
penalties = [0]*N
for _ in range(M):
    p,S=input().split()
    p = int(p)
    if S == 'AC':
        results[p-1] = True
    else:
        if not results[p-1]:
            penalties[p-1] += 1

points1 = 0
points2 = 0

for i in range(N):
    if results[i]:
        points1 += 1
        points2 += penalties[i]

print('{} {}'.format(points1,points2))

Solution (Python):
N, M = map(int, input().split())
a = [[0, 0] for i in range(N)]
for i in range(M):
  IN = list(input().split())
  p = int(IN[0])
  S = IN[1]
  if S == "AC":
    a[p-1][1] = 1
  else:
    if a[p-1][1] == 0:
      a[p-1][0] += 1
m = 0
n = 0
for i in range(N):
  if a[i][1] == 1:
    m += 1
    n += a[i][0]
print(m)
print(n)

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

l=[0]*n
w=0
c=0
ac=set()

for i in range(m):
  p,s=map(str,input().split())
  p=int(p)
  if s=='WA':
    l[p-1]+=1
  else:
    if p not in ac:
      c+=1
      w+=l[p-1]
      ac.add(p)

print(c,w)

Solution (Python):
n,m=map(int,input().split())
li=[0]*n
ok=0
ng=0
pro=set()
for i in range(m):
    p,s=map(str,input().split())
    p=int(p)
    if s=="WA":
        li[p-1]+=1
    else:
        if not p in pro:
            ok+=1
            ng+=li[p-1]
            pro.add(p)
print(ok,ng)

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

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

Solution (Python):
n,m=map(int,input().split())
l=[0]*n
d=[0]*n
for i in range(m):
    s=input().split()
    x=int(s[0])
    if(s[1]=='AC'):
        l[x-1]=1
    else:
        if(l[x-1]==1):
            continue
        else:
            d[x-1]+=1
p=0
for i in range(n):
    if(l[i]==1):
        p+=d[i]
print(sum(l),p)

Solution (Python):
N, M = map(int, input().split())
a, w = 0, 0
P = set()
W = {}
for _ in range(M):
    p, S = map(str, input().split())
    if p in P:
        continue
    if S == 'WA':
        W.setdefault(p, 0)
        W[p] += 1
    if S == 'AC':
        a += 1
        P.add(p)
        if p in W:
            w += W[p]
print(a, w)

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

Solution (Python):
n, m = map(int, input().split())
ps = [list(input().split()) for _ in range(m)]
ac = [0]*n
wa = [0]*n
cnt = [0]*n
for i in range(m):
    x = int(ps[i][0]) - 1
    if ps[i][1] == "AC" and ac[x] == 0:
        ac[x] = 1
        wa[x] = cnt[x]
    elif ps[i][1] == "WA" and ac[x] == 0:
        cnt[x] += 1
print(sum(ac), sum(wa))

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

is_solved = [False] * N
wa_count = [0] * N
wa_total = 0

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

    if s == 'AC':
        if not is_solved[p]:
            is_solved[p] = True
            wa_total += wa_count[p]
    else:
        wa_count[p] += 1

print(sum(is_solved), wa_total)

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

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

is_ac = [False]*N
wa_cnt = [0]*N

for i in range(M):
    if S[i] == 'AC':
        is_ac[p[i]-1] = True
    else:
        if not is_ac[p[i]-1]:
            wa_cnt[p[i]-1] += 1

ac_cnt = 0
penalty = 0

for j in range(N):
    if is_ac[j]:
        ac_cnt += 1
        penalty += wa_cnt[j]

print("{} {}".format(ac_cnt, penalty))

Solution (Python):
N,M=map(int,input().split())
AC=[0]*N
WA=[0]*N
pts=0
pena=0
for i in range(M):
    a,b=map(str,input().split())
    if b=='AC':
        if AC[int(a)-1]==0:
            AC[int(a)-1]=1
            pts+=1
            pena+=WA[int(a)-1]
    else:
        WA[int(a)-1]+=1
print(pts,pena)

Solution (Python):
N, M, *PS = open(0).read().split()
N, M = [int(_) for _ in [N, M]]
cor = [0] * (N + 1)
pen = [0] * (N + 1)
for p, s in zip(PS[::2], PS[1::2]):
    p = int(p)
    if cor[p] == 1:
        continue
    if s == 'AC':
        cor[p] = 1
    else:
        pen[p] += 1
ans = [0, 0]
for i in range(1, N + 1):
    if cor[i] == 0:
        continue
    ans[0] += 1
    ans[1] += pen[i]
print(*ans)

Solution (Python):
n, m = map(int, input().split())
account, wacount = 0, 0
acdic = [0] * (n + 10)
for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == "AC" and acdic[p] <= 0:
        account += 1
        wacount += abs(acdic[p])
        acdic[p] = 1
    elif s == "WA" and acdic[p] <= 0:
        acdic[p] -= 1
print(account, wacount)

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

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

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

AC = 0
WA = 0
for i in ans:
    if i[0] == "AC":
        AC += 1
        WA += i[1]

print(AC,WA)

Solution (Python):
N, M = map(int, input().split())
count = [0]*N
ans = 0
ok = 0
for _ in range(M):
    p, s = input().split()
    if count[int(p)-1] >= 0 and s == "WA":
        count[int(p) - 1] += 1
    elif count[int(p)-1] >= 0 and s == "AC":
        ans += count[int(p)-1]
        count[int(p)-1] = -1
        ok += 1
print(ok, ans)

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

flagac=[False]*N
pnlt=[0]*N
for i in range(M):
    p=P[i]-1
    s=S[i]
    if s=='AC':
        flagac[p]=True
    else:
        pnlt[p]+=(flagac[p]+1)%2



ctac=0
ctwa=0
for i in range(N):
    if flagac[i]:
        ctac+=1
        ctwa+=pnlt[i]
print(ctac, ctwa)

Solution (Python):








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


d = {}

for i in range(m):
    key = p[i][0]
    val = p[i][1]
    if key in d:
        d[key].append(val)
    else:
        d[key] = [val]


acNum = 0

for v in d.values():
    if "AC" in v:
        acNum += 1


waNum = 0

for v in d.values():
    if "AC" in v:
        for i in range(len(v)):
            if v[i] == "AC":
                break
            else:
                waNum += 1
print(acNum, waNum)

Solution (Python):
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readlines

from collections import defaultdict

def main():

    ac_num = 0
    pt_num = 0

    C = defaultdict(lambda: {"status":False, "penaulty":0} )

    lines = input()
    N, M = list(map(int, lines[0].split()))
    for i in range(1, M+1):
        pi, si = lines[i].split()
        pi = int(pi)
        if C[pi]["status"]:
            continue
        else:
            if si == "AC":
                C[pi]["status"] = True
                ac_num += 1
            else:
                C[pi]["penaulty"] += 1

    for i in range(1, N+1):
        if C[i]["status"]:
            pt_num += C[i]["penaulty"]

    print(ac_num, pt_num)

main()

Solution (Python):
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
wa = 0
n,m = map(int,input().split())
data = [0]*(n+1)
ans = [0]*(n+1)
for i in range(m):
  p,s = input().split()
  p = int(p)
  if s == "WA":
    data[p] += 1
  else:
    if ans[p] == 0:
      wa += data[p]
      ans[p] = 1
print(sum(ans),wa)

Solution (Python):

N,M = map(int,input().split())
S_P_list = []
for _ in range(M):
    p,s = input().split()
    S_P_list.append((int(p),s))

S_P_list = sorted(S_P_list,key = lambda x:x[0],reverse = False)    

AC_list = list(set([i[0] for i in S_P_list if i[1] == 'AC']))
WA = 0
AC = 0
for i in range(M):
    if (S_P_list[i][0] in AC_list):
        if S_P_list[i][1] == 'AC':
            AC += 1
            AC_list.remove(S_P_list[i][0])
        else:
            WA += 1
print(AC,WA)

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

pena=[0]*(n+1)
seitou=[0]*(n+1)

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

pena_kazu=0

for i in range(1,n+1):
    if seitou[i]==1:
        pena_kazu+=pena[i]

seitou_kazu=sum(seitou)

print(str(seitou_kazu)+" "+str(pena_kazu))

Solution (Python):
n,m = map(int,input().split())
dic = {}
ac = 0
wa = 0
for _ in range(m):
    p,s = map(str,input().split())
    p = int(p)
    if p not in dic:
        if s =='AC':
            ac += 1
            dic[p] = s
        else:
            dic[p] = 1
    elif dic[p]=='AC':
        continue
    else:
        if s =='AC':
            ac += 1
            wa +=dic[p]
            dic[p] = s
        else:
            dic[p] += 1

print(str(ac) + ' ' + str(wa))

Solution (Python):
import collections

N, M = map(int, input().split())
WA_CNT = {}
CLEAR = {}
for i in range(M):
    P, S = input().split()
    if P in CLEAR:
        continue
    if S == "AC":
        CLEAR[P] = 1
        continue

    if not P in WA_CNT:
        WA_CNT[P] = 0
    WA_CNT[P] += 1


num = len(CLEAR)
try_num = 0
for i in CLEAR:
    if i in WA_CNT:
        try_num += WA_CNT[i]
print("{} {}".format(num, try_num))