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 WAs 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



Sample input:
2 5
1 WA
1 AC
2 WA
2 AC
2 WA


Sample output:
2 2

Submission status: Accepted

Solution code:
N, M = [int(i) for i in input().split()]
dic = {}

for _ in range(M):
    p, s = input().split()
    if p not in dic:
        dic[p] = [False, 0]
    isAC, WC = dic[p]
    if isAC:
        continue
    if s == "AC":
        dic[p][0] = True
    elif s == "WA":
        dic[p][1] += 1

correct = 0
penalty = 0

for v in dic.values():
    if v[0]:
        correct += 1
        penalty += v[1]

print(correct, penalty)

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

N,M = m()

c = [0 for i in range(N)]
ca = [0 for i in range(N)]
cw = [0 for i in range(N)]


cc = 0
for i in range(M):
    p,s = input().split()
    if s == "WA":
        if ca[int(p)-1] == 0:
            cw[int(p)-1] += 1
    else:
        if ca[int(p)-1] == 0:
            ca[int(p)-1] = 1


for i in range(N):
    if ca[i] == 1:
        cc += cw[i]
print(sum(ca),cc)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
f = [False]*N
ac = 0
wa = [0]*N
for _ in range(M):
    p, s = list(input().split())
    p = int(p)
    if s == 'AC' and not f[p-1]:
        f[p-1] = True
        ac += 1
    elif not f[p-1]:
        wa[p-1] += 1
w = 0
for i in range(N):
    if f[i]:
        w += wa[i]
print(ac, w)

Submission status: Accepted

Solution code:
import sys
#import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, M = rl()
solve = [False] * (N+1)
count = [0] * (N+1)
penalty = 0
for i in range(M):
    p, s = input().split()
    p = int(p)
    if solve[p]:
        continue
    if s == 'WA':
        count[p] += 1
    else:
        solve[p] = True
        penalty += count[p]

print(sum(solve), penalty)

Submission status: Accepted

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

t=[0]*n
t1=[0]*n

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

ans=0
ans1=0

for i in range(n):
    if t[i]==1:
        ans+=t1[i]

ans1=sum(t)

print(str(ans1)+' '+str(ans))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

n,m = list(map(int,input().split()))
ps = [list(input().split()) for i in range(m)]
ps = [[int(v1),v2] for v1,v2 in ps]
pac = [0 for _ in range(n+1)]
pwa = [0 for _ in range(n+1)]
for p,s in ps:
    if pac[p]==1:
        continue
    if s=="AC":
        pac[p]=1
    else:
        pwa[p]+=1
ret_ac = sum(pac)
ret_penalty = 0
for i,v in zip(pac,pwa):
    if i==1:
        ret_penalty+=v
print("{} {}".format(ret_ac,ret_penalty))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
penalty = [0 for x in range(n+1)]
solved = [-1 for x in range(n+1)]
ans = 0
ans_penalty = 0
for i in range(m):
    p, s = map(str, input().split())
    p = int(p)
    if s == "WA":
        if solved[p] == -1:
            penalty[p] += 1
    else:
        if solved[p] == -1:
            ans += 1
            ans_penalty += penalty[p]
            solved[p] = 0
print(ans, ans_penalty)

Submission status: Accepted

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

ac = [False] * N
pe = [0] * N
cnt = 0

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

    if ac[p]:
        continue

    if s == 'AC':
        ac[p] = True
        cnt += pe[p]
    else:
        pe[p] += 1

print(sum(ac), cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# Submit as pypy2


from __future__ import print_function, division, unicode_literals

__metaclass__ = type

try:
    input = raw_input
    range = xrange
except NameError:
    pass


import sys


# Test code requires python3
# from hypothesis import given
# from hypothesis import strategies as st
#
#
# def debug(*args, **kwargs):
#     print(*args, *('{}={}'.format(k, v) for k, v in kwargs.items()),


from collections import Counter


def main():
    N, M = map(int, input().split())
    AC = set()
    WA = Counter()
    for i in range(M):
        p, S = input().split()
        p = int(p) - 1
        S = S == 'AC'
        if S:
            AC.add(p)
        elif p not in AC:
            WA[p] += 1
    print(len(AC), sum(v for k, v in WA.items() if k in AC))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict
from collections import deque
import numpy as np
import heapq
from heapq import heappush, heappop


#read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

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

acs = 0
wro = 0

PROB = [0] * N
WRON = [0] * N

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

    if PROB[p] == 1:
        continue

    if s == 'AC':
        PROB[p] = 1
        acs += 1
    elif s == 'WA':
        WRON[p] += 1

for i in range(N):
    if PROB[i] == 1:
        wro += WRON[i]

print(str(acs)+" "+str(wro))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def solve():
    N, M = map(int, input().split())
    WA = dict()
    AC = dict()
    for i in range(1, M+1):
        p, S = input().split()
        if S == 'WA' and p not in AC:
            WA[p] = WA.get(p,0)+1
        if S == 'AC':
            AC[p] = 1

    return str(len(AC)) + ' ' + str(sum(WA.get(p,0) for p in AC))

if __name__ == '__main__':
    print(solve())

Submission status: Accepted

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

total_ac = 0
total_wa = 0
results = {}
for _ in range(m):
  pi, si = input().split()
  if results.get(pi) == None:
    results[pi] = {
      "AC": False,
      "CumWA": 0
    }
  if not results[pi]["AC"] and si == "AC":
    results[pi]["AC"] = True
    total_ac += 1
    total_wa += results[pi]["CumWA"] 
  elif not results[pi]["AC"] and si == "WA":
    results[pi]["CumWA"] += 1

print(total_ac , total_wa )

Submission status: Accepted

Solution code:
def joint(i):
    cnt = 0
    for node in line_dict[i]:
        if cnt_list[node] == -1:
            cnt += joint(node)



if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

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

    wa = 0

    wa_cnt = [0]*n
    for _ in range(m):
        p, result = input().split()
        p = int(p)-1
        if wa_cnt[p] == -1:
            continue
        else:
            if result == 'AC':
                wa += wa_cnt[p]
                wa_cnt[p] = -1
            else:
                wa_cnt[p] += 1

    print(str(wa_cnt.count(-1)) + ' ' + str(wa))

Submission status: Accepted

Solution code:
nm=input().split(" ")
N=int(nm[0])
M=int(nm[1])
log=[0]*N
wacount=0
account=0
for i in range(M):
  ps=input().split(" ")
  p=int(ps[0])-1
  s=True if ps[1]=="AC" else False
  if log[p]!=-1:
    if s:
      account+=1
      wacount+=log[p]
      log[p]=-1
    else:
      log[p]+=1
print(str(account)+" "+str(wacount))

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
AC = [0 for _ in range(N)]
WC = [0 for _ in range(N)]

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

print(sum(AC), sum([wc if AC[i] == 1 else 0 for i, wc in enumerate(WC)]))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N,M=map(int,input().split())

l=[0]*N


ans=[0,0]
for _ in range(M):
    num,judge=input().split()
    num=int(num)
    num-=1
    if l[num]==-1:
        continue
    else:
        if judge=="AC":
            ans[0]+=1
            ans[1]+=l[num]
            l[num]=-1
        else:
            l[num]+=1
    

print(*ans)

Submission status: Accepted

Solution code:
import sys
from collections import Counter

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(N, M, inputs):
    answers = inputs
    n_solve = 0
    n_pena = 0
    solve_progress = set()
    num_answers = Counter({})

    for ans in answers:
        a = ans.split()
        number = int(a[0])
        result = a[1]

        if number in solve_progress:
            continue
        if result == "AC":
            solve_progress.add(number)
            n_solve += 1
        else:
            num_answers[number] += 1

    for s in solve_progress:
        n_pena += num_answers[s]
    return "{} {}".format(n_solve, n_pena)


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    [N, M] = string_to_int(input())
    ret = solve(N, M, inputs(M))
    print(ret)

Submission status: Accepted

Solution code:
N, M=map(int, input().split())
ACnum=[0]*(N+1)
WAnum=[0]*(N+1)
for i in range(M):
  p, s=input().split()
  p=int(p)
  
  if ACnum[p]==0:
    if s=='AC':
      ACnum[p]=1
    else:
      WAnum[p]+=1

WAsum=0
for i in range(1, N+1):
  if ACnum[i]>0:
    WAsum+=WAnum[i]
out=[sum(ACnum), WAsum]
print(*out)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[list(map(str,input().split())) for i in range(m)]
a=0
b=0
r=[0]*n
q=[0]*n
for i in range(m):
    l[i][0]=int(l[i][0])
for i in range(m):
    if q[l[i][0]-1]==0 and l[i][1]=='WA':
        r[l[i][0]-1]+=1
    elif q[l[i][0]-1]==0 and l[i][1]=='AC':
        a+=1
        b+=r[l[i][0]-1]
        q[l[i][0]-1]=1
print(a,b)

Submission status: Accepted

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

count = {}
for _ in range(m):
    p,s = input().split()
    if p not in count:
        count[p] = [0,0]
    if s == 'AC':
        count[p][0] = 1
    elif s == 'WA' and count[p][0] == 0:
        count[p][1] += 1

ac,pena = 0,0
for a,w in count.values():
    ac += a
    if a:
        pena += w
print(ac, pena)

Submission status: Accepted

Solution code:
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):
    p,s=input().split()
    #print(p,s)
    p=int(p)
    if s=="AC":
        AC[p]=1
    elif s=="WA":
        if AC[p]==0:
            WA[p]+=1
ac=0
wa=0
for i in range(1,N+1):
    if AC[i]==1:
        ac+=1
        wa+=WA[i]
print(ac,wa)

Submission status: Accepted

Solution code:
#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy


def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
def main():
    n,m=map(int,input().split())
    wa=[0]*n
    ac=[0]*n
    for i in range(m):
        a,b=input().split()
        a=int(a)
        if b=="WA" and ac[a-1]==0:
            wa[a-1]+=1
        elif b=="AC":
            ac[a-1]=1
    for i in range(n):
        if ac[i]==0:
            wa[i]=0
   # print(wa,ac)
    print(sum(ac),sum(wa))



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
li=[input().split() for i in range(m)]

l=[0]*n
cnt_ac=0
cnt_wa=0
for p,s in li:
 p=int(p)
 p-=1
 if l[p]=='AC':
  continue
 elif l[p]!='AC' and s=='AC':
  cnt_ac+=1
  cnt_wa+=l[p]
  l[p]='AC'
 elif l[p]!='AC' and s=='WA':
  l[p]+=1
print(cnt_ac,cnt_wa)

Submission status: Accepted

Solution code:
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 s=="AC":
        AC[p-1]=1
    else:
        if AC[p-1]==0:
            WA[p-1]+=1

for i in range(N):
    if AC[i]==0:
        WA[i]=0

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
flags = [False]*n
num_ac = 0
num_wa = 0
wa_list = [0]*n

for i in range(m):
    p, s = input().split()
    p = int(p)
    if flags[p-1]:
        continue
    else:
        if s=='WA':
            wa_list[p-1] += 1
        else:
            flags[p-1] = True
            num_ac += 1
            num_wa += wa_list[p-1]

print(num_ac, num_wa)

Submission status: Accepted

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

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

acc = 0
wac = 0

for i in range(M):
    p, S = input().split()
    p = int(p)-1
    if pr[p] == True:
        continue
    if S == "AC":
        pr[p] = True
    else:
        wa[p] += 1

for i in range(N):
    if pr[i]:
        acc += 1
        wac += wa[i]

print(acc, wac)

Submission status: Accepted

Solution code:
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
  elif AC[p] < 1:
    WA[p] += 1
WA = [w if AC[p] else 0 for p, w in enumerate(WA)]
print(sum(AC), sum(WA))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
WA_chk = [0] * (N+1)
AC_chk = [0] * (N+1)
result = [] * (M+1)
WA_ans = 0
AC_ans = 0
for i in range(M): 
    A = [str(i) for i in input().split()]
    if A[1] == "WA":
        WA_chk[int(A[0])] += 1
    else:
        if AC_chk[int(A[0])] ==0:
            AC_ans += 1
            WA_ans += WA_chk[int(A[0])]
            AC_chk[int(A[0])] = 1
print(str(AC_ans) + " " + str(WA_ans))

Submission status: Accepted

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

wa = [0 for i in range(N)]

ac = [0 for i in range(N)]

waans = 0
acans = 0

for i in range(M):
    if sub[i][1] == 'AC' and ac[int(sub[i][0])-1] == 0:
        acans += 1
        waans += wa[int(sub[i][0])-1]
        ac[int(sub[i][0])-1] = 1
    elif sub[i][1] == 'WA' and ac[int(sub[i][0])-1] == 0:
        wa[int(sub[i][0])-1] += 1

print(acans,waans)

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nas = lambda: stdin.readline().split()
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
aced = [0] * n
pens = [0] * n
for i in range(m):
    p, s = nas()
    p = int(p)
    if s == "AC":
        aced[p-1] = 1
    else:
        if not aced[p-1]:
            pens[p-1] += 1
print(sum(aced), sum(pens[_] for _ in range(n) if aced[_]))

Submission status: Accepted

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

A = []
for  i in range(M):
    x = [x for x in input().split()]
    x[0] = int(x[0])
    A.append(x)

p = [0]*N
a = [False]*N

for i in range(M):
    t = A[i][0]-1
    if a[t]==True:
        pass
    else:
        if A[i][1] =='AC':
            a[t] = True
        else:
            p[t] += 1

ans_p = 0
for i in range(N):
    if a[i]==True:
        ans_p += p[i]

print(sum(a), ans_p)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
d = [False for _ in range(n)]
x = [0 for _ in range(n)]
penalty = 0
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if d[p]:
        continue
    if s == 'AC':
        d[p] = True
        penalty += x[p]
    else:
        x[p] += 1

print(sum(d), penalty)

Submission status: Accepted

Solution code:
import numpy as np

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

result = [0] * N
wa = [0] * N



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

    if s == 'AC':
        result[p-1] = 1
    elif s == 'WA' and result[p-1] == 0:
        wa[p-1] += 1

ac = np.sum(np.array(result))
wa = np.sum(np.array(result)*np.array(wa))

print(int(ac), int(wa))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n,m = map(int, input().split())
ps = [input().split() for _ in range(m)]

wa = [0]*(n+1)
solve = [False for _ in range(n+1)]
for p,s in ps:
    p = int(p)
    if s=="AC":
        solve[p] = True
    else:
        if not solve[p]:
            wa[p] += 1

ra = 0
rw = 0
for i in range(1,n+1):
    if solve[i]:
        ra += 1
        rw += wa[i]
print(ra,rw)

Submission status: Accepted

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

for p, S in [tuple(input().split()) for _ in range(M)]:
    p = int(p) - 1
    if S == 'WA' and ac[p] != 1:
        wa[p] += 1
        continue
    if S == 'AC':
        ac[p] = 1
pena = 0
for i in range(N):
    if ac[i] == 1:
        pena += wa[i]
print(sum(ac), pena)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
data = []
dict_q = dict()
wa = 0
ac = 0
finished = set()
for i in range(m):
    p, s = input().split()
    if s == "WA":
        if p in dict_q:
            dict_q[p] += 1
        else:
            dict_q[p] = 1
    else:
        if p in finished:
            continue
        finished.add(p)
        if p in dict_q:
            wa += dict_q[p]
        ac += 1
print("{} {}".format(ac,wa))

Submission status: Accepted

Solution code:
n, m = map(int, raw_input().split())
l = []
ac = set()
wa = {}
for i in range(m):
	a, b = raw_input().split()
	a = int(a)
	
	if a not in ac:
		if b == 'WA':
			if a in wa:
				wa[a] += 1
			else:
				wa[a] = 1
		else:
			ac.add(a)
ans = 0
for i in list(ac):
	if i in wa:
		ans += wa[i]
print len(ac), ans

Submission status: Accepted

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

q = [0]*n
count = 0
wacount = 0

for i in range(m):
  if p[i][1] == "WA":
    q[int(p[i][0])-1] += 1
  elif p[i][1] =="AC":
    if q[int(p[i][0])-1] < 0:
      continue
    else:
      count += 1
      wacount += q[int(p[i][0])-1]
      q[int(p[i][0])-1] -= 10**6

print("{} {}".format(count,wacount))

Submission status: Accepted

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
N,M=map(int, input().split())
l=[0]*N
w=[0]*N
for i in range(M):
    p,S=input().split()
    p=int(p)
    if S=="AC":
        l[p-1]=1
    else:
        if not l[p-1]:
            w[p-1]+=1
W=0
for i in range(N):
    W+=l[i]*w[i]
print(sum(l),W)

Submission status: Accepted

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

ans = 0
flag = [0] * n

for _ in range(m):
    P, s = input().split(' ')
    p = int(P) - 1
    if s == 'AC':
        if flag[p] != -1:
            ans += flag[p]
            flag[p] = -1
    elif flag[p] != -1:
        flag[p] += 1

print(flag.count(-1), ans)

Submission status: Accepted

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

    cnt = [0] * n
    not_solved = [True] * n

    ac = 0
    wa = 0
    for _ in range(m):
        p, s = input().split()
        p = int(p) - 1
        if s == 'AC':
            if not_solved[p]:
                not_solved[p] = False
                ac += 1
                wa += cnt[p]
        else:
            if not_solved[p]:
                cnt[p] += 1

    print(ac, wa)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()

# int(input())
# map(int, input().split())

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
isAC = [False] * (N+1)
penalties = [0] * (N+1)
ac, penalty = (0, 0)
for _ in range(M):
  p, s = input().split()
  p = int(p)
  if s == "AC":
    if not isAC[p]:
      isAC[p] = True
      ac += 1
      penalty += penalties[p]
  else:
    penalties[p] += 1
print(ac, penalty)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

from collections import Counter
def ri():
    return int(input())

def rl():
    return list(input().split())

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

def main():
    n, m = rli()
    wa = [0 for _ in range(n)]
    ac = [0 for _ in range(n)]
    for i in range(m):
        p, s = rl()
        p = int(p)
        p -= 1
        if ac[p] > 0:
            continue
        if s == "WA":
            wa[p] += 1
        else:
            ac[p] = 1
    sac = sum(ac)
    swa = sum(wa[i] for i in range(len(wa)) if ac[i] > 0)
    print(sac, swa)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
AC_q = [0] * N
WA_num = [0] * N
for _ in range(M):
    p, S = input().split()
    p = int(p)
    if S == "AC":
        AC_q[p - 1] = 1
    else:
        if AC_q[p - 1] == 0:
            WA_num[p - 1] += 1
AC = 0
WA = 0
for i in range(N):
    if AC_q[i] == 1:
        AC += 1
        WA += WA_num[i]
print(AC, WA)

Submission status: Accepted

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

lst = []
solved = set()
for i in range(M):
    pstr, s = list(input().split())
    pnum = int(pstr)
    lst.append((pnum, s))
    if s == 'AC':
        solved.add(pnum)

seen = set()
wa = 0
for (p, s) in lst:
    if p in solved and p not in seen:
        if s == 'AC':
            seen.add(p)
        else:
            wa += 1
print("{} {}".format(len(solved), wa))

Submission status: Accepted

Solution code:
from collections import defaultdict

n, m = map(int, input().split())
AC = defaultdict(int)
WA = defaultdict(int)

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC':
        AC[p] = 1
    elif s == 'WA' and AC[p] == 0:
        WA[p] += 1
num_ac, num_wa = 0, 0
for p, c in AC.items():
    if c == 1:
        num_ac += 1
        num_wa += WA[p]
print(num_ac, num_wa)

Submission status: Accepted

Solution code:
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
    elif s == 'WA':
        if ac[p] == 0:
            wa[p] += 1

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

ac = sum([item>0 for item in ac])
wa = sum(wa)
print(ac, wa)

Submission status: Accepted

Solution code:
from heapq import heappush, heappop
from collections import deque
import re
import math
import functools
import itertools
import fractions

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


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


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29


def mk1d(n, val=INF):
    return [val for i in range(n)]

def mk2d(h, w, val=INF):
    return [[val for i in range(w)]for i in range(h)]

DIV = 998244353


def convolve(a, b):
    p, g = 1107296257, 5
    n0, n1 = len(a), len(b)
    n = 1 << (max(n0, n1) - 1).bit_length() + 1
    a = a + [0] * (n-n0)
    b = b + [0] * (n-n1)
    w = pow(g, (p - 1) // n, p)
    invw = pow(w, p-2, p)

    def fft(f):
        d = n // 2
        v = w
        while d >= 1:
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, u * (f[j] - f[j+d]) % p
                u = u * v % p
            v = v * v % p
            d //= 2

    def ifft(f):
        d = 1
        while d < n:
            v = pow(invw, n // (2 * d), p)
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j+d] *= u
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, (f[j] - f[j+d]) % p
                u = u * v % p
            d *= 2

    fft(a), fft(b)
    for i in range(n):
        a[i] = a[i] * b[i] % p
    ifft(a)
    invn = pow(n, p - 2, p)
    return [a[i] * invn % p for i in range(n0 + n1 - 1)]


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

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
    return functools.reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return functools.reduce(lcm_base, numbers, 1)

def main():
    N,M = isRaw()
    isAC = [False]*N
    pena = [0]*N
    for idx in range(M):
        p,S = ssRaw()
        p = int(p)
        if S=="AC":
            isAC[p-1]=True
        if S=="WA":
            if not isAC[p-1]:
                pena[p-1]+=1
    numPena = sum([pena[idx] for idx in range(N) if isAC[idx]])
    return str(sum(isAC))+" "+str(numPena)
        


if __name__ == "__main__":
    print(main())

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
WAN=[0]*(n+1)
flags=[0]*(n+1)
for i in range(m):
    p,s=input().split()
    p=int(p)
    if s=='AC':
        flags[p]=1
    if s=='WA' and flags[p]==0:
        WAN[p]+=1
ans=0
for i in range(1, n+1):
    if flags[i]==1:
        ans+=WAN[i]
print(sum(flags),ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


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

    AC = [False] * (N+1)
    WA = [0]*(N+1)
    for pp, ss in zip(p, S):
        if ss == "AC":
            if AC[pp] == False:
                AC[pp] = True
        else:
            if AC[pp] == False:
                WA[pp] += 1
    tot = 0
    for i in range(N+1):
        if AC[i]:
            tot += WA[i]
    print(sum(AC), tot)

    return


def main():

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

x = 0

for i in range(n):
    x += data[i] * count[i]

print(sum(data),x)

Submission status: Accepted

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

ac = [0]*N
wa = [0]*N
for i in range(M):
    p,s = input().split()
    p = int(p)-1
    if s == "AC":
        ac[p] = 1
    elif ac[p] == 0:
        wa[p] += 1
    
print(sum(ac),sum([[0,wa[x]][ac[x]] for x in range(N)]),sep=" ")

Submission status: Accepted

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

seikai = set()
pena_num = 0
pena = [0] * (n + 1)

for i in range(m):
    p, s = map(str, input().split())
    if s == 'WA':
        if p not in seikai:
            pena[int(p)] += 1
        else:
            continue
    else:
        if p not in seikai:
            pena_num += pena[int(p)]
            seikai.add(p)
        else:
            continue
print(len(seikai), pena_num)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    res = [[] for _ in range(N)]
    for _ in range(M):
        p, s = LS()
        p = int(p)
        p -= 1
        res[p].append(s)
    seito = 0
    pena = 0
    for re in res:
        ac = False
        re_pena = 0
        for s in re:
            if s == 'AC':
                seito += 1
                ac = True
                break
            else:
                re_pena += 1
        if ac:
            pena += re_pena
    print(seito, pena)

main()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = set([])

n = [0] * 10 ** 5
ac, wa = 0, 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if p not in a:
        if s == "WA":
            n[p] += 1
        else:
            a.add(p)
            ac += 1
            wa += n[p]
print(ac, wa)

Submission status: Accepted

Solution code:
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
w = 0
for i in range(n):
  w += ac[i] * wa[i]
print(sum(ac),w)