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

Submission status: Accepted

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

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
  else:
    if ac[p]==0:
      wa[p]+=1
a=0
b=0
for i in range(N):
  if ac[i]:
    a+=1
    b+=wa[i]
print(*[a,b])

Submission status: Accepted

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

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

print(right, wrong)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict

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

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

acCnt = 0
waCnt = 0

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict

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

Submission status: Accepted

Solution code:
from collections import defaultdict

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

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

correct = 0
penalty = 0

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

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

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

Submission status: Accepted

Solution code:
import sys

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

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

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

    return

 
if __name__ == "__main__":
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    
    tokens = iterate_tokens()
    N = int(next(tokens))
    M = int(next(tokens))
    p_list = []
    S_list = []
    for i in range(M):
        p_list.append(int(next(tokens)))
        S_list.append(next(tokens))

    solve(N, M, p_list, S_list)

Submission status: Accepted

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

penaltyCount = []

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

penalties = 0
points = 0

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

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


print(points, penalties)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
p = [0 for _ in range(n)]
pw = [0 for _ in range(n)]
# print(p)
ansWA = 0
ansAC = 0

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

# print(p)
print(ansAC,ansWA)

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import deque, defaultdict
from itertools import chain, combinations
import json


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

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
ac=[False]*N
wa=[0]*N
for _ in range(M):
  p,S=input().split()
  p=int(p)-1
  if S=='AC':
    ac[p]=True
  else:
    if not ac[p]:
      wa[p]+=1
a=0
b=0
for i in range(N):
  if ac[i]:
    a+=1
    b+=wa[i]
print(*[a,b])

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
inp = []
ans = [(0, False) for _ in range(n)]

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

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

Submission status: Accepted

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

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

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

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

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

print(correct, penalty)

Submission status: Accepted

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

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

print(len(ac),cnt)

Submission status: Accepted

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

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

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

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

print(oks, ngs)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

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

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

Submission status: Accepted

Solution code:
n,m = list(map(int,input().split()))
counter = 0
data = []
tmp = {}#問題番号をkeyとしてWAをカウント

wa = 0
#入力処理
for _ in range(m):
  a,b = input().split() #入力処理
  if b == "WA": #解答がWA→tmpに問題番号をkeyとしてカウント
    if int(a) not in tmp:
      tmp[int(a)] = 0
    if tmp[int(a)] != -1:
      tmp[int(a)] += 1
  if int(a) not in tmp: #WA無しのACの対応 
    tmp[int(a)] = 0
  if (( b == "AC") and (tmp[int(a)] != -1)):#解答がACでtmp[問題番号]が出力済みでない場合
    counter += 1
    #checkd.append(int(a))
    wa += tmp[int(a)] #問題番号aの値をWAの合計に加算
    tmp[int(a)] = -1 #問題番号aが加算済み


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

Submission status: Accepted

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

ans1 = 0
ans2 = 0

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


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



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

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


print(ans1, ans2)

Submission status: Accepted

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

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

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

print(ac,wa)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

submit = dict()
WA = 0
AC = 0

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

print(AC,WA)

Submission status: Accepted

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

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

for i in range(m):
    #初めてACを出した時、acにカウントを1足し、それまでにその問題で間違えた数をwaに足し、yetにACが出たことを記録
    if s[i] == "AC" and p[i] not in yet:
        ac +=1
        if p[i] in count.keys():
            wa +=count[p[i]]
        yet.add(p[i])
    elif s[i] == "WA" and p[i] not in yet:
        if p[i] in count.keys():
            count[p[i]] += 1
        else:
            count[p[i]] = 1
print(ac,wa)

Submission status: Accepted

Solution code:
# C - Welcome to AtCoder
from collections import defaultdict


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# C - Welcome to AtCoder
from collections import defaultdict


def main():
    N, M, *PS = open(0).read().split()
    is_correct = [0] * (int(N) + 1)
    wa_count = defaultdict(int)
    penalties = 0
    for p, s in zip(*[iter(PS)] * 2):
        p = int(p)
        if not is_correct[p]:
            if s == "AC":  # first AC -> count penalties on problem_p
                is_correct[p] = 1
                penalties += wa_count[p]
            else:  # not yet AC and get WA -> +1 penalty
                wa_count[p] += 1
    print(sum(is_correct), penalties)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# C - Welcome to AtCoder
from collections import defaultdict


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

def main():
    # 入力値の取得（１行目だけ）
    N, M = map(int, input().split())

    # 正解したかどうかを管理するリスト。
    # フラグとして使うので、中身は出力時に帳尻が合えばboolでもOK
    correct = [0] * N

    # 問題ごとのペナルティー数（WA）の数を数える
    penalty = [0] * N

    # ACした問題でのペナルティー数を保持する変数
    pena = 0

    # ２行目以降の入力を取得しながら処理していく。
    for _ in range(M):

        # 各行の p,s をとる
        pi, si = input().split()
        # piをintに型変換する
        pi = int(pi)

        # s が 'WA'で、その問題がまだ正解していなければ
        if si == 'WA' and correct[pi - 1] == 0:
            # その問題のペナルティを加算する
            penalty[pi - 1] += 1

        # s が'AC'で、その問題にまだ正解していなければ
        elif si == 'AC' and correct[pi - 1] == 0:
            # 正解したことを記録
            correct[pi - 1] = 1
            # その時点での、その問題のペナルティー数をpenaに加算
            pena += penalty[pi - 1]

    # 正解した問題数と、ペナルティー数の合計を表示
    print(sum(correct), pena)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
AC=[0] * (N + 1)
WA=[0] * (N + 1)
cnt_AC=0
cnt_WA=0

for _ in range(M):
  i,s=input().split()
  i=int(i)
  if AC[i]==0:
    if s=='WA':
      WA[i]+=1
    if s=='AC':
      AC[i]=1
      cnt_WA+=WA[i]
cnt_AC=sum(AC)
print(cnt_AC,cnt_WA)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
WA = [0] * (N + 1)
AC = [0] * (N + 1)
sum_WA = 0
for _ in range(M):
  i,s = input().split()
  i = int(i)
  if AC[i] == 0:
    if s == 'WA':
      WA[i] += 1
    elif s == 'AC':
      AC[i] = 1
      sum_WA += WA[i]

print(sum(AC),sum_WA)

Submission status: Accepted

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

submission = []
for i in range(n):
    submission.append([])

for i in range(m):
    pi, si = input().split()
    submission[int(pi) - 1].append(si)
    
n_ac = 0
n_penalty = 0
for i in range(n):
    if "AC" in submission[i]:
        n_ac += 1
        ac_index = submission[i].index('AC')
        n_penalty += ac_index
print(n_ac, n_penalty)

Submission status: Accepted

Solution code:
from collections import defaultdict

memo = dict()

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

for i in range(m):
    p, s = input().split()
    if p not in memo:
        memo[p] = [0, False]

    if memo[p][1]:
        continue

    v = memo[p]
    if s == 'AC':
        memo[p] = [v[0], True]
    else:
        memo[p] = [v[0]+1, False]        

ac, wa = 0, 0
for _,v in memo.items():
    w, a = v
    if a:
        ac += 1
        wa += w

print(ac, wa)

Submission status: Accepted

Solution code:
lst = []
n, m  = map(int, input().split())
for _ in range(m):
    i, h = input().split()
    lst.append([int(i), str(h)])

jdg_wa = [0] * n 
jdg_ac = [0] * n

penalty = 0
for _ in lst:
    idx = _[0] - 1
    if  jdg_ac[idx] != 1:
        if _[1] == 'WA':
            jdg_wa[idx] += 1
        elif _[1] == 'AC':
            jdg_ac[idx] = 1
            penalty +=  jdg_wa[idx]
print(sum(jdg_ac), penalty)

Submission status: Accepted

Solution code:
import sys
import math
import bisect
 
def main():
    n, m = map(int, input().split())
    wa = [0] * n
    ac = [0] * n
    penalty = 0
    for _ in range(m):
        p, s = input().split()
        p = int(p) - 1
        if s == 'WA':
            wa[p] += 1
        else:
            if ac[p] == 0:
                ac[p] = 1
                penalty += wa[p]
    print('%d %d' % (sum(ac), penalty))
 
if __name__ == "__main__":
    main()

Submission status: Accepted

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

try_flags = [True] * N  # まだacceptされてない=続けるフラグ
wa_list = [0] * N
ac_list = [0] * N

for _ in range(M):
    i, result = input().split()
    i = int(i) - 1
    if result == 'WA' and try_flags[i]:
        wa_list[i] += 1
    if result == 'AC' and try_flags[i]:
        ac_list[i] = 1
        try_flags[i] = False

ac_cnt = 0
wa_cnt = 0
for ac, wa in zip(ac_list, wa_list):
    if ac == 1:
        ac_cnt += ac
        wa_cnt += wa
print('{} {}'.format(ac_cnt, wa_cnt))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(M):
    a.append(map(str, input().split()))

p_sum = 0
s_sum = 0

s_dict = {}
p_dict = {}
for k in range(M):
    ps = list(a[k])

    if (ps[0] in p_dict) == True:
        if p_dict[ps[0]] == True:
            continue
    if ps[1] == "WA":  
        if (ps[0] in s_dict) == True:
            s_dict[ps[0]] += 1
        else:
            s_dict[ps[0]] = 1
    else:
        p_dict[ps[0]] = True
        p_sum += 1
        if (ps[0] in s_dict) == True:
            s_sum += s_dict[ps[0]]
        pre_s_sum = 0

print(str(p_sum) + " " + str(s_sum))

Submission status: Accepted

Solution code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
 
n,m=map(int,input().split())
AC=[0]*n
WA=[0]*n
WAc=0
for i in range(m):
	a,b=input().split()
	c=int(a)
	if AC[c-1]==0:
		if b=="AC":
			AC[c-1]+=1
		else:
			WA[c-1]+=1

for j in range(n):
	if AC[j]==1:
		WAc+=WA[j]

print(sum(AC),WAc)

Submission status: Accepted

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

check = [0 for i in range(N + 1)]
pAC = 0
pWA = 0
for p in Pn:
    x = int(p[0])
    if check[x] != -1:
        if p[1] == 'WA':
            check[x] += 1
        elif p[1] == 'AC':
            pWA += check[x]
            pAC += 1
            check[x] = -1

print(pAC, pWA)

Submission status: Accepted

Solution code:
# N問出題, M回提出
N, M = map(int, input().split())

p_S_list = []

WA = 'WA'
AC = 'AC'

question_list = [False] * N
WA_count_list = [0] * N

count_AC = 0
count_WA = 0

for i in range(M):
    p, S = input().split()
    int_p = int(p)
    
    if S == WA and question_list[int_p - 1] == False:
        WA_count_list[int_p - 1] += 1

    if S == AC and question_list[int_p - 1] == False:
        count_AC += 1
        count_WA += WA_count_list[int_p - 1]
        question_list[int_p - 1] = True

print(str(count_AC) + ' ' + str(count_WA))








'''
first_AC_index_list = []
AC_set = set([])

for j in range(M):
    p, S = input().split()
    int_p = int(p)
    p_S_list.append([int_p, S])

    if S == AC and (int_p not in AC_set):
        first_AC_index_list.append([j, int_p])
        AC_set.add(int_p)

count_AC = len(first_AC_index_list)
count_WA = 0
# for i in range(1, N + 1):
#     # i問目の問題について考える
#     if [i, AC] in p_S_list:
#         count_AC += 1

#         first_AC_index = p_S_list.index([i, AC])

#         count_WA += p_S_list[:first_AC_index].count([i, WA])

for i_list in first_AC_index_list:
    count_WA += p_S_list[:i_list[0]].count([i_list[1], WA])

ans = str(count_AC) + ' ' + str(count_WA)

print(ans)

'''

Submission status: Accepted

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

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


    else:
        if ac[p] != -1:
            ac[p] += 1

print(ac.count(-1), wa)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
problems = [False] * (N+1)
penalty = [0]*(N+1)

for i in range(M):
    p, S = input().split()
    if S == 'AC':
        problems[int(p)] = True
    if S == 'WA' and problems[int(p)] is False:
        penalty[int(p)] += 1

ans_AC, ans_pena = 0, 0
for i in range(1, N+1):
    if problems[i] is True:
        ans_AC += 1
        ans_pena += penalty[i]


print(ans_AC, ans_pena)

Submission status: Accepted

Solution code:
n,m=[int(i) for i in input().split()]
AC=[False]*n
WA=[0]*n
for i in range(m):
    p,s=[_ for _ in input().split()]
    p=int(p)-1
    if s=="WA" and not AC[p]:
        WA[p]+=1
    elif s=="AC":
        AC[p]=True
ans=[0,0]
for i in range(n):
    if AC[i]:
        ans[0]+=1
        ans[1]+=WA[i]
print(*ans,sep=" ")

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ac = [0] * (n+1)
pena = 0

for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == "AC":
        if ac[p] != -1:
            pena += ac[p]
            ac[p] = -1

    else:
        if ac[p] != -1:
            ac[p] += 1


print(ac.count(-1), pena)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
dic = {i: 0 for i in range(1, N+1)}
ac_count = 0
wa_count = 0
for i in range(M):
    p, S = input().split()
    p = int(p)
    if S == 'WA' and dic[p] >= 0:
        dic[p] += 1
    elif dic[p] >= 0:
        ac_count += 1
        wa_count += dic[p]
        dic[p] = -1
print(ac_count, wa_count)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
pr = {i: 0 for i in range(1, n+1)}
ac, wa = 0, 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'WA' and pr[p] >= 0:
        pr[p] += 1
    elif pr[p] >= 0:
        ac += 1
        wa += pr[p]
        pr[p] = -1
print(ac, wa)

Submission status: Accepted

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

prob = {i: 0 for i in range(1, n+1)}
ac, wa = 0, 0

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

print(ac, wa)

Submission status: Accepted

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

Qa,Qw = {}, {}
for _ in range(M):
    p, S = input().split()
    p = int(p)-1

    if p not in Qa:
        Qa[p] = 0

    if p not in Qw:
        Qw[p] = 0

    if S == 'AC':
        Qa[p] = 1
    elif S == 'WA':
        if Qa[p] <= 0:
            Qw[p] += 1

AC = sum([ac for ac in Qa.values()])
WA = sum([Qw[k] for k,v in Qa.items() if v > 0])
print( AC, WA)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
L1 = [0]*a
L2 = [0]*a
acc,wac = 0,0
for i in range(b):
    c,d = input().split()
    if d == "AC" and L2[int(c)-1] == 0:
        acc +=1
        L2[int(c)-1] = 1
        wac += L1[int(c)-1]
        continue
    
    else:
         L1[int(c)-1] += 1
print(acc,wac)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
passed = 0
failed = 0
dicto = {}

for i in range(1, n+1):
    dicto[i] = [False, 0]

for i in range(m):
    key, status = input().split()
    key = int(key)
    if status == 'WA' and not dicto[key][0]:
        dicto[key][1] += 1
    else:
        dicto[key][0] = True

for i in dicto:
    if dicto[i][0]:
        failed += dicto[i][1]
        passed += 1

print(passed, failed)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
Q = {i: 0 for i in range(1, 1 + N)}

correction = 0
penalty = 0

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

    # already answered correctly
    if Q[p] > 0:
        continue

    if s:
        correction += 1
        penalty -= Q[p]
        Q[p] = 1
    else:
        Q[p] -= 1

print(correction, penalty)

Submission status: Accepted

Solution code:
N, M=map(int,input().split())
if M==0:
	print("0 0")
else:
	ac=0
	pe=0
	ch=[0]*N
	Ch=[0]*N
	for i in range(M):
		a, b=input().split()
		a=int(a)-1
		if ch[a]==1:
			continue
		elif b=="WA":
			Ch[a]+=1
		else:
			ch[a]=1
			ac+=1
			pe+=Ch[a]
	print(ac,pe)