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(x) for x in input().split())
ac_dir = {n:False for n in range(1, N+1)}
wa_dir = {n:0 for n in range(1, N+1)}
ac_count = 0
wa_count = 0
for _ in range(M):
    data = input().split()
    p = int(data[0])
    S = data[1]
    if ac_dir[p]:
        continue
    else:
        if S == "AC":
            ac_dir[p] = True
            ac_count += 1
            wa_count += wa_dir[p]
        elif S == "WA":
            wa_dir[p] += 1
print(ac_count, wa_count)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ac=[[0,False] for i in range(n)]
for i in range(m):
    p=list(input().split(" "))
    x=p[0]
    y=p[1]
    if ac[int(x)-1][1]==True:
        pass
    else:
        if y=="WA":
            ac[int(x)-1][0]+=1
        elif y=="AC":
            ac[int(x)-1][1]=True
counter=0
acc=0
for i in range(n):
    if ac[i][1]:
        acc+=1
        counter+=ac[i][0]
print(acc,counter)

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split()))
correct = 0
incorrect = 0
Q = [0] * N
num_WA = [0] * N
for i in range(M):
    s, t = input().split()
    s = int(s)

    if t == 'AC':
        if Q[s-1] == 1:
            continue
        else:
            Q[s-1] = 1
            correct += 1
            incorrect += num_WA[s-1]
    else:
        num_WA[s-1] += 1
print(correct, incorrect)

Submission status: Accepted

Solution code:
N, M = list(map(int,input().split()))
a = [False for i in range(N)]
wa = [0 for i in range(N)]
for i in range(M):
  p, s = input().split()
  pi = int(p)-1
  if s=="AC":
      a[pi] = True
  elif not a[pi]:
      wa[pi] += 1
print(sum([1 for ai in a if ai]), sum([wa[i] for i in range(N) if a[i]]))

Submission status: Accepted

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

Ques = [0]*(N + 1)

correct = 0
incorrect = 0

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

print(correct, incorrect)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ERR = COR = 0
AC = [0]*N
WA = [0]*N

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

    if (t == 'AC' and AC[s] == -1):
        continue

    elif (t =='AC'):
        COR += 1
        AC[s] = -1
        ERR += WA[s]
    
    elif (t == 'WA'):
        WA[s] += 1

print(COR, ERR)

Submission status: Accepted

Solution code:
n, m = [int(x) for x in input().split()]
lst = [0]*(n+1)
a = 0
b = 0
for i in range(m):
  p, s = input().split()
  p = int(p)
  if s == 'AC' and lst[p] is not None:
    a += 1
    b += lst[p]
    lst[p] = None
  elif s == 'WA' and lst[p] is not None:
    lst[p] += 1
print(a,b)

Submission status: Accepted

Solution code:
## atcoder problem 3 ever
n, m = map(int, input().split())
solved = {}
penalty = {}
for case in range(m):
    p, s = input().split()
    p = int(p)

    if s=='AC':
        solved[p] = True
    else: ## s is WA
        if p in solved:
            continue ## ignore
        else:
            penalty[p] = penalty.get(p, 0) + 1

total_penalty = 0
for key in solved:
    total_penalty += penalty.get(key, 0)

print(len(solved), total_penalty)

Submission status: Accepted

Solution code:
n, m = list(map(int, input().split()))
ac = set()
wa = {}
for i in range(m):
  p, s = input().split()
  p = int(p)
  if p in ac:
    continue
  if s == 'WA':
    wa[p] = wa.get(p, 0) + 1
  else:
    ac.add(p)
pe = 0
for p in set(ac) & set(wa.keys()):
    pe += wa[p]
print("%d %d" % (len(ac), pe))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
from collections import defaultdict as dd
d_ac = dd(lambda:0)
d_wa = dd(lambda:0)
for i in range(m):
  p, sc = input().split()
  if sc == "AC":
    d_ac[p] = 1
  if sc == "WA":
    if d_ac[p] == 0:
      d_wa[p] += 1

total_ac = sum(d_ac.values())
total_wa = 0
for key in d_ac.keys():
  if d_ac[key] == 1:
    total_wa += d_wa[key]
print(total_ac, total_wa)

Submission status: Accepted

Solution code:
def getinput(_debug):
    N = 0
    M = 0
    p = []
    S = []
    
    if _debug == 0:
        N, M = map(int,input().split())
        lines = [input() for x in range(M)]

    elif _debug == 1:
        f = open("3_sample1.txt").readlines()
        f = [x.rstrip() for x in f]
        N, M = map(int,f[0].split())
        lines = f[1:]
    
    elif _debug == 2:
        f = open("3_sample2.txt").readlines()
        f = [x.rstrip() for x in f]
        N, M = map(int,f[0].split())
        lines = f[1:]
    
    elif _debug == 3:
        f = open("3_sample3.txt").readlines()
        f = [x.rstrip() for x in f]
        N, M = map(int,f[0].split())
        lines = f[1:]
    
    # データ取得
    for l in lines:
        ls = l.split(" ")
        p.append(int(ls[0]))
        S.append(ls[1])

    return N,M,p,S

N,M,p,S = getinput(0)

AC = [0] * N  # 実施した問題数は1,まだの場合0
WA = [0] * N  # ペナルティのカウント
wa = 0

#       
for i in range(M):
    q = int(p[i]) - 1
    if AC[q] == 0 and S[i] == "AC":
        AC[q] = 1
        wa += int(WA[q])
    WA[q] += 1        

print("%d %d"%(sum(AC),wa))

Submission status: Accepted

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

solved = [0]* 10**5
penalty = [0]* 10**5
penalty_sum = 0
for _ in range(m):
    q, result = input().split()
    q = int(q) - 1
    
    if result == 'AC':
        if solved[q] == 0:
            solved[q] = 1
            penalty_sum += penalty[q]
    else:
        if solved[q] == 0:
            penalty[q] += 1

print(str(sum(solved)) + " " + str(penalty_sum))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
dic={}
ans=0
pen=0
for i in range(m):
    p,s=input().split()
    if p not in dic.keys():
        dic[p]={}
    if s=='AC':
        dic[p][s]=1
    if 'AC' not in dic[p].keys():
        if 'WA' not in dic[p].keys():
            dic[p][s]=0
        dic[p][s]+=1

for key in dic.keys():
    if 'AC' in dic[key].keys():
        ans+=1
        if 'WA' in dic[key].keys():
            pen+=dic[key]['WA']

print(str(ans)+' '+str(pen))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
d = np.zeros(N+1, dtype = 'int32')
t = 0
f = 0

for i in range(M):
    tmp = input().split()
    p = int(tmp[0])
    S = tmp[1]
    dp = d[p]
    if S == 'AC':
        if dp != -1:
            f += dp
            d[p] = -1
            t += 1
    elif dp != -1:
        d[p] += 1
print(t, f)

Submission status: Accepted

Solution code:
import numpy as np
N, M = map(int, input().split())
d = np.zeros(N+1, dtype = 'int32')
t = 0
f = 0
for i in range(M):
    tmp = input().split()
    p = int(tmp[0])
    S = tmp[1]
    dp = d[p]
    if S == 'AC':
        if dp != -1:
            f += dp
            d[p] = -1
            t += 1
    elif dp != -1:
        d[p] += 1
print(t, f)

Submission status: Accepted

Solution code:
N,M=[int(i) for i in input().split()]
AC,WA=[False]*N,[0]*N
for i in range(M):
    p,s=input().split()
    p=int(p)-1
    if AC[p]==False:
        if s=="AC":
            AC[p]=True
        if s=="WA":
            WA[p]+=1
    else:
        continue

ans_AC=AC.count(True)
ans_WA=0
for i in range(N):
    if AC[i]:
        ans_WA+=WA[i]
print(ans_AC,ans_WA)

Submission status: Accepted

Solution code:
import numpy as np
N, M = map(int, input().split())
d = np.array([0]*(N+1), dtype = 'int32')
t = 0
f = 0
for i in range(M):
    tmp = input().split()
    p = int(tmp[0])
    S = tmp[1]
    if S == 'AC':
        if d[p] != -1:
            f += d[p]
            d[p] = -1
            t += 1
    elif d[p] != -1:
        d[p] += 1
print(t, f)

Submission status: Accepted

Solution code:
N,M=[int(i) for i in input().split()]
AC,WA=[False]*N,[0]*N
ans_WA=0
for i in range(M):
    p,s=input().split()
    p=int(p)-1
    if AC[p]==False:
        if s=="AC":
            AC[p]=True
            ans_WA+=WA[p]
        if s=="WA":
            WA[p]+=1
    else:
        continue

ans_AC=sum(AC)
print(ans_AC,ans_WA)

Submission status: Accepted

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

AC,WA=[False]*N,[0]*N
panel=0
for i in range(M):
    p,s=input().split()
    p=int(p)-1
    if AC[p]:
        continue
    if s=="WA":
        WA[p]+=1
    else:
        AC[p]=True
        panel+=WA[p]

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M = map(int,readline().split())
PS = [line.split() for line in readlines()]

AC = [False] * (N+1)
WA_cnt = [0] * (N+1)

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
WAlist = [[0,"WA"]  for i in range(N)]
AC = WA = 0
for i in range(M):
    p,S = input().split()
    p = int(p)
    if S=="WA"and WAlist[p-1][1]=="WA":
        WAlist[p-1][0] += 1
    elif S=="WA" and WAlist[p-1][1]=="AC" or S=="AC"and WAlist[p-1][1]=="AC":
        continue
    elif S=="AC" and WAlist[p-1][1]=="WA":
        WAlist[p-1][1] = "AC"
        AC += 1

for j in range(N):
    if WAlist[j][1]=="AC":
        WA += WAlist[j][0]

print(AC,WA)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
li = list()
for i in range(m):
    li.append(tuple(input().split()))
 
ac_cnt = 0
wa_cnt = 0
 
s_ac = set()
d_wa = dict()
for l in li:
    if l[1] == 'AC':
        if l[0] not in s_ac:
            s_ac.add(l[0])
            ac_cnt += 1
            wa_cnt += d_wa.get(l[0], 0)
        else:
            pass
    elif l[1] == 'WA':
        d_wa[l[0]] = d_wa.get(l[0], 0) + 1
 
print(ac_cnt, wa_cnt)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
answer = [[False, 0] for _ in range(n)]
for i in range(m):
    number, result = input().split()
    number = int(number)
    if result == 'AC':
        answer[number-1][0] = True
    elif answer[number-1][0] != True:
        answer[number-1][1] += 1

ret = [ans[1] for ans in answer if ans[0] == True]
print(len(ret), sum(ret))

Submission status: Accepted

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

for i in range(m):
    if fa[p[i]-1] == 0:
        if s[i] == 'AC':
            fa[p[i]-1] = 1
        else:
            fw[p[i]-1] += 1
for i in range(n):
    if fa[i] == 0:
        fw[i] = 0
print(sum(fa), sum(fw))

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
action = [list(input().split()) for _ in range(m)]
answer_dict = {}
score = 0
penalty = 0

for a in action:
    if a[1] == 'WA' and a[0] not in answer_dict:
        answer_dict[a[0]] = 1
    elif a[1] == 'WA' and answer_dict[a[0]] != 'Done':
        answer_dict[a[0]] += 1
    elif a[1] == 'AC':
        if a[0] in answer_dict and answer_dict[a[0]] != 'Done':
            score += 1
            penalty += answer_dict[a[0]]
            answer_dict[a[0]] = 'Done'
        elif a[0] not in answer_dict:
            score += 1
            answer_dict[a[0]] = 'Done'

print(score,penalty)

Submission status: Accepted

Solution code:
from collections import defaultdict
n, m = map(int, input().split())
correct = set()
penalty = 0
history = defaultdict(int)
for i in range(m):
    p, s = input().split()
    if s == "AC":
        correct.add(p)
        if history[p] != -1:
            penalty += history[p]
        history[p] = -1
    else:
        if history[p] != -1:
            history[p] += 1
print(len(correct), penalty)

Submission status: Accepted

Solution code:
from collections import OrderedDict
N, M = map(int, input().split())

correct = set()
wrong = OrderedDict()

for _ in range(M):
  p, s = input().split()
  pn = int(p)
  if pn not in wrong:
    wrong[pn] = 0
  if s == 'AC':
    if pn not in correct:
      correct.add(pn)
  elif s == 'WA':
    if pn not in correct:
      wrong[pn] += 1

print(len(correct), sum([wrong[pn] for pn in correct]))

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
l = [list(input().split()) for i in range(m)]
ac = [False] * n
count = [0] * n
sum_wa = 0
for i in range(len(l)):
    # print(l[i][0], l[i][1])
    if l[i][1] == "WA" and ac[int(l[i][0]) - 1] == False:
        count[int(l[i][0]) - 1] += 1
    elif l[i][1] == "AC":
        sum_wa += count[int(l[i][0]) - 1]
        count[int(l[i][0]) - 1] = 0
        ac[int(l[i][0]) - 1] = True
print(ac.count(True), sum_wa)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
ans = {}
for i in range(M):
    a,b = map(str, input().split() )
    if ans.get(a,0):
        ans[a].append(b)
    else:
        ans[a] = [b]
c = 0
p = 0
t = ans.values()
for line in t:
    k = 0
    for i in line:
        if i == "AC":
            c += 1
            p += k
            break
        else:
            k += 1
print(c,p)

Submission status: Accepted

Solution code:
n,m =map(int, input().split())
a =[list(input().split()) for i in range(m)]
ends = [0]*n
was = [0]*n
for num, kekka in a:
    num=int(num)-1
    if kekka=='AC':
        ends[num]=1
    else:
        if ends[num]!=1:
            was[num]+=1
for i in range(n):
    if ends[i]==0:
        was[i]=0
print(sum(ends), sum(was))

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n, m = list(map(int, input().split(' ')))
    ac_set = set([])
    num_list = []
    result_list = []
    counter = 0
    pena_dict = {}
    for i in range(m):
        num, result = input().split(' ')
        result_list.append(result)
        if result == 'AC':
            ac_set.add(num)
        elif (result == 'WA') and ((num in ac_set) is False):
            if (num in pena_dict) is False:
                pena_dict[num] = 1
            else:
                pena_dict[num] = pena_dict[num] + 1

    for i in ac_set:
        if i in pena_dict:
            counter = counter + pena_dict[i]

    print(len(ac_set), counter)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
li_q = list()
for i in range(m):
    li_q.append(tuple(input().split()))

ac_count = 0
wa_count = 0

s_ac = set()
d_wa = dict()
for l in li_q:
    if l[1] == 'AC':
        if l[0] not in s_ac:
            s_ac.add(l[0])
            ac_count += 1
            wa_count += d_wa.get(l[0], 0)
        else:
            pass
    elif l[1] == 'WA':
        d_wa[l[0]] = d_wa.get(l[0], 0) + 1

print(ac_count, wa_count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
iNum, iM = map(int, input().split())
naB = np.zeros(iNum, dtype = "bool")
naW = np.zeros(iNum, dtype = int)
iC = 0
iW = 0
for _ in range(iM):
  l = input().split()
  iP = int(l[0]) - 1
  if not(naB[iP]):
    if l[1][0] == "A":
      naB[iP] = True
      iC += 1
      iW += naW[iP]
    else:
      naW[iP] += 1
print(iC, iW)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
N,M=map(int,input().split())
result=[[0]*2 for _ in range(N)]
AC=0
pena=0
for _ in range(M):
    p,S=map(str,input().split())
    p=int(p)
    if S=='AC':
        if result[p-1][1]==0:
            AC+=1
            result[p-1][1]=1
    else:
        if result[p-1][1]==0:
            result[p-1][0]+=1
for i in range(N):
    if result[i][1]==1:
        pena+=result[i][0]
print(AC,pena)

Submission status: Accepted

Solution code:
#AtCoder
from collections import defaultdict
N, M = map(int, input().split())

d = defaultdict(list)
for i in range(M):
    p, S = input().split()
    d[int(p)].append(S)

a = 0
p = 0
for i in d.items():
    if 'AC' not in i[1]:
        continue

    ac_index = i[1].index('AC')
    a += 1

    if 'WA' in i[1]:
        wanum = i[1][:ac_index]
        p += len(wanum)

print(a, p)

Submission status: Accepted

Solution code:

n, m = map(int, input().split())
solved = {}
penalty = {}
for case in range(m):
    p, s = input().split()
    p = int(p)

    if s=='AC':
        solved[p] = True
    else: ## s is WA
        if p in solved:
            continue ## ignore
        else:
            penalty[p] = penalty.get(p, 0) + 1

total_penalty = 0
for key in solved:
    total_penalty += penalty.get(key, 0)

print(len(solved), total_penalty)

Submission status: Accepted

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

Submission status: Accepted

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

ac_list = [0] * 10**6
wa_list = [0] * 10**6
for i in range(M):
    p, s = input().split()

    if ac_list[int(p)]:
        continue

    if s == "AC":
        ac_list[int(p)] = 1
        ac += 1
        wa += wa_list[int(p)]
    else:
        wa_list[int(p)] += 1

print(ac, wa)

Submission status: Accepted

Solution code:
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
ans = 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":
        ans += int_l[i]
        num += 1

print(num,ans)

Submission status: Accepted

Solution code:

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

wacnt = [0]*(N+1)
is_ac = [False]*(N+1)
for pp,s in ps:
    p = int(pp)
    if s=='AC':
        is_ac[p] = True
    else:
        if not is_ac[p]:
            wacnt[p] += 1
num = 0
ans = 0
for l in range(N+1):
    if is_ac[l]:
       ans += wacnt[l]
       num += 1
       
print(num,ans)

Submission status: Accepted

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

problem_list = {}

for i in range(m):
    p, s = list(input().split())
    if p in problem_list.keys():
        if problem_list[p][1] == 1:
            continue
        else:
            if s == "AC":
                problem_list[p][1] += 1
            else:
                problem_list[p][0] += 1
    else:
        if s == "AC":
            problem_list[p] = [0, 1]
        else:
            problem_list[p] = [1, 0]
            
correct = 0
penalty = 0

for v in problem_list.values():
    p, c = v
    if c == 0:
        continue
    correct += c
    penalty += p
    
print(str(correct) + " " + str(penalty))

Submission status: Accepted

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

ac=[0 for i in range(n+1)]
ans=0
cle=0

for i in range(k):
    inp=input().split()
    p=int(inp[0])
    s=inp[1]
    if ac[p]>=0:
        if s=="AC":
            ans+=ac[p]
            ac[p]=-1
            cle+=1
        else:
            ac[p]+=1

print(cle,ans)

Submission status: Accepted

Solution code:
import itertools
n, m = map(int, input().split())
P = [input().split() for i in range(m)]
P = list(itertools.chain.from_iterable(P))
ac_list = [0] * n
wa_list = [0] * n
counta = 0
countb = 0
for i in range(1, m * 2, 2):
    if P[i] == "AC" and ac_list[int(P[i - 1])-1] == 0:
        counta += 1
        ac_list[int(P[i - 1])-1] = 1
        countb += wa_list[int(P[i - 1]) - 1]
    elif P[i] == "WA":
        wa_list[int(P[i - 1]) - 1] += 1
    else:
        continue

print(counta, countb)

Submission status: Accepted

Solution code:
n, m = map(int, input().split(' '))
a = {}
b = 0
c = 0
for q in range(m):
    p, s = map(str, input().split(' '))
    if p not in a:
        if s == 'AC':
            a[p] = [0, 1]
            b += 1
        else:
            a[p] = [1, 0]
    else:
        if a[p][1] == 1:
            continue
        else:
            if s == 'AC':
                a[p][1] = 1
                b += 1
                c += a[p][0]
            else:
                a[p][0] += 1
print(b, c)

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()
  
  if s == "AC":
    AC[int(p)-1] = 1
  elif s == "WA" and AC[int(p)-1] < 1:
    WA[int(p)-1] += 1

resWA = map(lambda x, y: x*y, AC, WA)    

print(sum(AC), sum(resWA))

Submission status: Accepted

Solution code:

n,m=list(map(int,input().split()))
wa=[0 for _ in range(n)]
ac=[False for _ in range(n)]
for _ in range(m):
    p,s=input().split()
    p=int(p)-1
    if ac[p]:
        continue
    if s=="AC":
        ac[p]=True
    else:
        wa[p]+=1
ans=0
for i in range(n):
    if ac[i]:
        ans+=wa[i]
print(sum(ac),ans)

Submission status: Accepted

Solution code:
#python3

class Problem:
    def __init__(self, status):
        self.status = status
        self.penalties = 0

n,m = map(int, input().split())
data = []
for _ in range(m):
    x, y = map(str, input().split())
    data.append((x, y))

problems = {str(i+1): Problem('-') for i in range(n)}


for number, isAC  in data:
    if problems[number].status == 'AC':
        continue
    else: 
        if isAC == 'AC':
            problems[number].status = 'AC'
        elif isAC == 'WA':
            problems[number].penalties += 1 

cntACproblems = 0
cntPenalties = 0

for problem in problems.values():
    if problem.status == 'AC': 
        cntACproblems += 1
        cntPenalties += problem.penalties

print(str(cntACproblems) + ' ' + str(cntPenalties))

Submission status: Accepted

Solution code:
N,M= [int(i) for i in input().split()]
tmp=[]
scr=[0]*2
rec=[0]*N
eec=[0]*N

ts=0
for i in range(M):
        tmp = ([x for x in input().split()])
        q=int(tmp[0])

        if rec[q-1] == 1:
                continue
        else:
                if tmp[1] == 'AC':
                        rec[q-1]=1
                        scr[0]+=1
                        scr[1]+=eec[q-1]
                elif tmp[1]=='WA':
                        eec[q-1]+=1
        
        
print(scr[0],scr[1])

Submission status: Accepted

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

flags = [False] * N
p_ary = [0] * N

penalty = 0
score = 0
for _ in range(M):
    p_num, result = input().split()
    p_num = int(p_num) - 1
    if result == 'AC':
        if flags[p_num] is False:
            score += 1
        flags[p_num] = True
    elif result == 'WA' and flags[p_num] is False:
        p_ary[p_num] += 1

for p, flag in zip(p_ary, flags):
    if flag is True:
        penalty += p

print(score, penalty)

Submission status: Accepted

Solution code:
def t(n, ps):
    ac = 0
    wa = 0
    a = [False]*(n + 1)
    b = [0]*(n+1)
    for p, s in ps:
        if a[int(p)]:
            continue
        if s == 'AC':
            ac += 1
            wa += b[int(p)]
            a[int(p)] = True
        else:
            b[int(p)] += 1
    return (ac, wa)


if __name__ == '__main__':
    n, m = map(int, input().split())
    ps = [input().split() for i in range(m)]
    print(' '.join(map(str, t(n, ps))))

Submission status: Accepted

Solution code:
ac={}
wa={}
ans1=0
ans2=0
N,M=input().split(" ")
for i in range(int(M)):
    num,sa=input().split(" ")
    if sa=='AC':
        if num in ac:
            continue
        else:
            ans1+=1
            ac[num]=1
            if num in wa:
                ans2+=wa[num]
    else:
        if num in wa:
            wa[num]+=1
        else:
            wa[num]=1
print(ans1,ans2)

Submission status: Accepted

Solution code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
    
    
N,M=map(int,input().split())
a=0
b=0
AC=[0]*(N+1)
pen=[0]*(N+1)
p=0
l=[]
for i in range(M):
	j,r=input().split()
	if AC[int(j)]==0:
		if r=="WA":
			pen[int(j)]+=1
		else:
			AC[int(j)]+=1
for k in range(N+1):
	if AC[k]==1:
		p+=pen[k]

print(sum(AC),p)

Submission status: Accepted

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

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

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

    if AC[j] == 0 and res == "AC":
            AC[j] = 1
            wa += WA[j]
    WA[j] += 1

print(sum(AC), wa)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline


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

SUBMISSIONS = {i:[] for i in range(1, n + 1)}
for _ in range(m):
    p, s = input().split()
    SUBMISSIONS[int(p)].append(s)

ac, penalty = 0, 0
for i in range(1, n + 1):
    wa = 0
    for result in SUBMISSIONS[i]:
        if result == "WA":
            wa += 1
        else:
            ac += 1
            penalty += wa
            break

print(ac, penalty)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ac=set()
from collections import Counter
w=Counter()
wa=0
for i in range(m):
    p,s=input().split()
    if s=="AC":
        if p not in ac:
            wa+=w[p]
        ac.add(p)
    else:
        if p not in ac:
            w[p]+=1
print(len(ac),wa)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc151/tasks/abc151_c

N,M = map(int, input().split()) # 複数数値入力
p = []
S = []
for i in range(M):
    a,b = input().split() # 複数数値入力
    p.append(int(a)-1)
    S.append(b)

# 正答数
flag = [False for e in range(N)]
corr = 0
# 各問題iについて
for i in range(M):
    # これまで一度でもACを出していればskip
    if flag[p[i]]:
        continue
    else:
        # ACなら1足してflagを立てる
        if S[i] == "AC":
            corr += 1
            flag[p[i]] = True

# 誤答数
flag = [False for e in range(N)]
error = 0
# 各問題のerror
errors = [0 for e in range(N)]
# 各問題iについて
for i in range(M):
    # これまで一度でもACを出していればskip
    if flag[p[i]]:
        continue
    else:
        # WAなら1足す
        if S[i] == "WA":
            errors[p[i]] += 1
        # ACなら集計してflagを立てる
        else:
            error += errors[p[i]]
            flag[p[i]] = True

print(corr,error)

Submission status: Accepted

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

answer = [0] * N
penalty = [0] * N
P = 0

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

    if(answer[p_tmp] == 0):
        # 正解
        if s_tmp == 'AC':
            answer[p_tmp] = 1
            P += penalty[p_tmp]
        else:
            penalty[p_tmp] += 1

print(sum(answer), P)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
p, s = [], []
for i in range(m):
    pi, si = input().split()
    p.append(int(pi))
    s.append(si)

lst_ac = [0 for i in range(n+1)]
for i in range(m):
    if s[i] == 'AC':
        lst_ac[p[i]] = 1
ans_ac = sum(lst_ac)

out = 0
for i in range(m):
    if s[i] == 'WA' and lst_ac[p[i]] == 1:
        out += 1
    if s[i] == 'AC' and lst_ac[p[i]] == 1:
        lst_ac[p[i]] = 2

print(ans_ac, out)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
if M == 0:
  print(0, 0)
else:
  pS = [list(input().split()) for i in range(M)]

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

  listWA = [0 for i in range(N)]
  listAC = [0 for i in range(N)]
  
  for j in range(M):
    if listAC[pS[j][0] - 1] < 1:
      if pS[j][1] == "AC":
        listAC[pS[j][0] - 1] = 1
      else:
        listWA[pS[j][0] - 1] += 1
  
  for i in range(N):
    if listAC[i] < 1:
      listWA[i] = 0
  
  
  print(sum(listAC), sum(listWA))

Submission status: Accepted

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

max_val = 10**5+1
# dictの初期化
ac_L = []
wa_L = []
for val in range(1,max_val):
    wa_L.append(0)
    ac_L.append(0)

ac_ans,wa_ans = 0,0


for i in range(m):
    p,s = map(str,input().split())
    p = int(p)
    # acの処理
    if ac_L[p] ==0 and s == "AC":
        ac_L[p] = 1
        wa_ans += wa_L[p]
    # waの処理
    wa_L[p] += 1


#print(ac_dic,wa_dic)
print(sum(ac_L),wa_ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

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

d = defaultdict(int)
res_ans = 0
res_pena = 0

for _ in range(m):
    p, s = input().split()
    if s == "AC":
        if d[p] == -1:
            continue
        else:
            res_ans += 1
            res_pena += d[p]
            d[p] = -1
    else:
        if d[p] == - 1:
            continue
        else:
            d[p] += 1

print(res_ans, res_pena)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
d = {}
for _ in range(M):
    p, s = input().split()
    a = d.get(p, [0, 0])
    if s == "AC" and a[0] == 0:
        a[0] = 1
    elif s == "WA" and a[0] == 0:
        a[1] += 1

    d[p] = a

ac = 0
wa = 0
for x in d.values():
    if x[0] == 1:
        ac += x[0]
        wa += x[1]

print("{0} {1}".format(ac, wa))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
PM = [stdin.readline().rstrip().split() for _ in range(M)]
AC = set()
WA = {}
wa = 0
for pm in PM:
    if pm[0] in AC:
        continue
    if pm[1] == "AC":
        AC.add(pm[0])
        if pm[0] in WA:
            wa += WA[pm[0]]
    elif pm[1] == "WA":
        if pm[0] not in WA:
            WA[pm[0]] = 0
        WA[pm[0]] += 1  
print(len(AC), wa)