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: Runtime Error

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


c = 0
a = 0

t = [0]*(n+1)

temp = []


for i in range(m):
    s = input().split()
    x = s[0]
    y = s[1]
    if y == 'AC' x not in temp:
        a += 1
        c += t[int(x)]
        temp += [x]
    elif y == 'WA':
        t[int(x)] += 1

print(a, c)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
point = input().split()
thr = 0
good = 0
bad = 0
N = int(test[0])
M = int(test[1])

if M == 0:
    print("0 0")
else:
    for i in range(M - 1):
        if point[0] == str(thr):
            point = input().split()
            continue
        elif point[1] == "AC":
            good += 1
            thr = point[0]
            point = input().split()
            continue
        elif point[1] == "WA":
            bad += 1
            point = input().split()
            continue
    print(str(good), str(bad))

Submission status: Runtime Error

Solution code:
import sys

N, M = map(int, sys.stdin.readline().split())
P = [None]*M
S = [None]*M
for i in range(M):
    P[i], S[i] = sys.stdin.readline().split()

AC = [0]*N
WA = 0
"""
for i in range(M):
    if S[i] == "AC":
        if AC[int(P[i])-1] == 0:
            AC[int(P[i])-1] += 1
            for j in range(i):
                if P[j] == P[i] and S[j] == "WA":
                    WA += 1
"""


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

print(sum(AC), WA)

Submission status: Runtime Error

Solution code:
import sys
N,M = map(int,input().split())
if M == 0:
	print('0 0')
	sys.exit()


p = [0]*M#問題の番号
s = [0]*M#結果 AC,WA

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

cor_count = 0
pen_count = 0
AC_list = []

for i in range(M):
	if not p[i+1] in AC_list:
		if s[i+1] == 'AC':
			AC_list.append(p[i+1])
		else:
			pen_count += 1

#print(AC_list)
cor_count = len(set(AC_list))
if M != 0:
	print(cor_count,pen_count)

Submission status: Runtime Error

Solution code:
N,M = list(map(int,input().split()))
ps = []
for i in range(M):
    ps.append(list(map(str,input().split())))
    
ps_new = sorted(ps , key=lambda x: x[0])
toi = []

for i in range(M):
    toi.append(ps[i][0])
    
toi2 = toi[0]
toi3 = [toi2]

for i in range(M):
    if toi2 != toi[i]:
        toi3.append(toi[i])
        toi2 = toi[i]
toi3.append("0")

toi = ps_new[0][0]
j = 0
count1 = 0
count2 = 0
count3 = 0

for i in range(M):
    if toi == ps[i][0]:
        count2 += 1
        if count2 == 1:
            shokai = i
        if ps_new[i][1] == "AC":
            count1 += 1
            j += 1
            toi = toi3[j]
            count2 = 0
            count3 = count3 + (i-shokai)
            
print(count1,count3)

Submission status: Runtime Error

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 = input().split()
    p = int(p)

    if S == "AC":
        if ac[p-1] == 0:
            ac += 1
            
    else:
        if ac[N-1] == 0:
            wa += 1

print(ac, wa)

Submission status: Runtime Error

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

if m==0:
  print(0,0)
else:
  submitList = []
  for i in range(m):
    if i == 0:
      submitList.append(tuple(input().split()))
    else:
      t = tuple(input().split())
      if submitList[-1] == t :
        if submitList[-1][1] == "WA":
          submitList.append(t)
      else:
        submitList.append(t)

  while submitList[-1][1] != "AC":
    submitList.pop()

  reCount = peCount = 0
  tmI = 0
  tmStatus = ''
  for i in submitList:
    if i == 0:
      tmI = i[0]
      tmStatus = i[1]
      if tmStatus == "AC":
        reCount += 1
      else:
        peCount += 1
    else:
      if tmI == i[0] and tmStatus == i[1] == "AC":
        pass
      else:
        tmI = i[0]
        tmStatus = i[1]
        if tmStatus == "AC":
          reCount += 1
        else:
          peCount += 1

  print(reCount, peCount)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
AC = 0
WA = 0
lis_ac = []
dic_wa ={}
if M == 0:
  print(0,0)
else:
  A = [list(input().split()) for i in range(M)]
  for i in range(M):
    if A[i][0] not in lis_ac:
      if A[i][1] == 'AC':
        lis_ac.append(A[i][0])
        WA += dic_wa[A[i][0]]
      elif A[i][0] in dic_wa.keys():
        dic_wa[A[i][0]] += 1
      else:
        dic_wa[A[i][0]] = 1
  print(len(lis_ac), WA)

Submission status: Runtime Error

Solution code:
n = input()
m = n.split()
P = [int(i) for i in m]
if P[1] == 0:
    for i in range(P[1]): #因数注意！
        n = input()    
    print("0 0")
else:
    
    AC = [0] * P[0]
    WA = [0] * P[0]

    for i in range(P[1]): #因数注意！
        n = input()    
        m = n.split()
        p = [i for i in m] #1列の数列をリスト化
        if p[1] == "AC":
            AC[int(p[0])-1] = 1
        else:
            if AC[int(p[0])-1] == 0:
                WA[int(p[0])-1] = WA[int(p[0])-1] +1
            else:
                pass
A1 = 0
A2 = 0
for i in range(P[0]):
    if AC[i] == 1:
        A1 = A1+1
        A2 = A2 + WA[i]
print(str(A1)+" "+str(A2))

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split( ))
wa = [0] * (n + 1)
acsum = 0
wasum = 0
for i in range(m):
    no_s, res = map(str, input().split( ))
    no = int(no_s)
    if wa[no] != -1 and res == "AC":
      	acsum += 1
        wasum += wa[no]
        wa[no] = -1
    elif wa[no] != -1 and res == "WA":
        wa[no] += 1
print(str(acsum) + " " + str(wasum))

Submission status: Runtime Error

Solution code:

n,m = map(int,input().split())
ans = [0]*n
miss = [0]*n

for _ in range(m+1):
    p,s = map(str,input().split())
    p = int(p)
#    print(p,s)
    if ans[p-1] == 0 and s == "WA":
        miss[p-1] += 1
    elif ans[p-1] == 0 and s == "AC":
        ans[p-1] += 1
    else:
        pass

#print(ans)
#print(miss)
a = sum(ans)
b = sum(miss)

print(a,b)

Submission status: Runtime Error

Solution code:
N,M = map(int, input().split())
p = [0]*M
S = [0]*M
for i in range(M):
    p[i],S[i] = input().split()
import numpy as np
p = [int(s) for s in p]
p1 = np.array(p)
S1 = [1 if i=="AC" else 0 for i in S]
N1 = list(set(p1 * S1))
p2 = [1 if i in N1 else 0 for i in p1]
p2 = np.array(p2)
p3 = list(p1 * p2)
p4 = [i for i in p3 if i != 0]

A = 0
B = 0
j = 0
for i in p4:
    if i in N1:
        A += S1[j]
        B += (1-S1[j])
        j +=1
        if S1[i] ==1:
            N1.remove(i)
print(str(A)+" "+str(B))

Submission status: Runtime Error

Solution code:
import sys

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

try:
    p_ini, s_ini = map(str, input().split())
except ValueError:
    print(0, 0)
    sys.exit()

p_list = []
s_list = []

p_list.append(p_ini)
s_list.append(s_ini)

for i in range(M - 1):
    p, s = map(str, input().split())
    p_list.append(p)
    s_list.append(s)

index_list = [i for i in range(M)]

# 区切れ目の辞書配列
p_dict = dict([(p_list[j], index_list[j]) for j in range(M)])

p_unique = list(set(p_list))

AC_num = 0
WA_num = 0
index_start = 0
for j in p_unique:
    index_end = p_dict[j]
    j_list = s_list[index_start:index_end + 1]
    j_len = len(j_list)

    # ACがある場合、ACの数, WAの数をカウント
    if 'AC' in j_list:
        AC_num += 1
        span = j_list.index('AC')
        j_len = len(j_list[:span])
        WA_num += j_len

    else:
        WA_num += j_len

    index_start = index_end + 1

print(AC_num, WA_num)

Submission status: Runtime Error

Solution code:
import sys

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

if m==0:
    print(0,0)
    sys.exit()

p=[]
s=[]
for i in range(m):
    pp,ss=input().split()
    p.append(int(pp))
    s.append(ss)

p.append(max(p)+1)

sei=0
pena=0

print(len(p))

i=0

while(True):
    #print(i)
    #print("p[i],p[-1]:",p[i],p[-1])
    if p[i]==p[-1]: break
    if s[i]=='WA':
        pena+=1
    else:
        sei+=1
        #print("p[i]+1:",p[i]+1)
        i=p.index(p[i]+1)-1
        #print("i:",i)
    i+=1
            
print(sei,pena)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split(" "))
p = []
S = []
flag_AC = []
flag_WA = []

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

for i in range(N):
    flag_AC.append(0)
    flag_WA.append(0)

# n番目の提出ステータスを取得
def Anc(n):
    L = []
    L.append(p[n])
    L.append(S[n])
    return L

AC = 0
WA = 0

for i in range(M):
    data = Anc(i)
    if data[1] == "AC":
        if flag_AC[data[0]] == 0:
            flag_AC[data[0]] = 1
            AC = AC + 1

    if data[1] == "WA":
        if flag_AC[data[0]] == 0:
            flag_WA[data[0]] = flag_WA[data[0]] + 1

for i in range(M):
    data = Anc(i)
    if flag_AC[data[0]] == 0:
        flag_WA[data[0]] = 0
    else:
        flag_WA[data[0]] = flag_WA[data[0]] + 1

print(AC,WA)

Submission status: Runtime Error

Solution code:
# AC を 1回以上出した各問題において、初めて AC を出すまでに出した WA の数
n,m = map(int, input().split())
p = []
s = []
wacounter = 0
walist = []
for i in range(0, n):
  walist.append(0)
point = 0
point_to_num = [] #acをとった問題
for i in range(0, m):
  list = input().split()
  p.append(int(list[0]))
  s.append(list[1])
 
for i in range(0, m):
  if s[i] == "AC" and not p[i] in point_to_num: #もし正解で、今までにその問題に正解していなかったら
    point_to_num.append(p[i]) #正解リストにその問題を追加
    #point = point + 1 正解ポイントをあげる
  elif s[i] == "WA" and not p[i] in point_to_num: #不正解かつ今まで正解を出したことがない
      wacounter += 1
      walist[p[i]-1] += 1
for i in range(0, n):
  if not i + 1 in point_to_num:#もし正解してない番号があったら、walistからwacounterをとってきてひく
    wacounter = wacounter - walist[p[i]-1]
print(len(point_to_num), wacounter)

Submission status: Runtime Error

Solution code:
test = input().split()
point = input().split()
thr = 0
good = 0
bad = 0
N = int(test[0])
M = int(test[1])

if M == 0:
    print("0 0")
else:
    for i in range(M - 1):
        if point[0] == str(thr):
            point = input().split()
            continue
        elif point[1] == "AC":
            good += 1
            thr = point[0]
            point = input().split()
            continue
        elif point[1] == "WA":
            bad += 1
            point = input().split()
            continue
    print(str(good), str(bad))

Submission status: Runtime Error

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

for i in range(len(p)):
    p[i] = int(p[i])
    
c = 0
a = 0
b = 0
for i in range(len(S)):
    if S[i] == 'AC' and p[i] > c:
        a = a + 1
        c = p[i]
    elif S[i] == 'WA' and p[i] > c:
        b = b + 1
        
print(a, b)

Submission status: Runtime Error

Solution code:
N, M = map(int, stdin.readline().rstrip().split())
AC = 0
WA = 0
data = {}
for _ in range(M):
    tmp = stdin.readline().rstrip().split()
    p, S =  int(tmp[0]), tmp[1]
    if p not in data.keys():
        if S == 'AC':
            data[p] = {'AC': True, 'WA': 0}
            AC += 1
        elif S == 'WA':
            data[p] = {'AC': False, 'WA': 1}
    else:
        if S == 'AC':
            if data[p]['AC'] is True:
                continue
            elif data[p]['AC'] is False:
                data[p]['AC'] = True
                WA += data[p]['WA']
                AC += 1
        elif S == 'WA':
            if data[p]['AC'] is True:
                continue
            elif data[p]['AC'] is False:
                data[p]['WA'] += 1
print('{} {}'.format(AC, WA))

Submission status: Runtime Error

Solution code:
import sys
P = 0
N,M = map(int,input().strip().split())
if M == 0:
    print("{0} {1}".format(0,P))
    sys.exit()
ans_list = [list(input().strip().split()) for _ in range(M)]
result = [False] * N
for ans in ans_list:
    if result[int(ans[0])-1] != True
        if ans[1] == "WA":
            P += 1
        elif ans[1] == "AC":
            result[int(ans[0])-1] = True
print("{0} {1}".format(result.count(True),P))

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
AC = 0
WA = 0
lis_ac = []
dic_wa ={}
if M == 0:
  print(0,0)
else:
  for i in range(M):
    A = list(input().split())
    if A[0] not in lis_ac:
      if A[1] == 'AC':
        lis_ac.append(A[0])
        WA += dic_wa[A[0]]
      elif A[0] in dic_wa.keys():
        dic_wa[A[0]] += 1
      else:
        dic_wa[A[0]] = 1
  print(len(lis_ac), WA)

Submission status: Runtime Error

Solution code:
import sys

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

try:
    p_ini, s_ini = map(str, input().split())
except ValueError:
    print(0, '', 0)
    sys.exit()

p_list = []
s_list = []

p_list.append(p_ini)
s_list.append(s_ini)

for i in range(M - 1):
    p, s = map(str, input().split())
    p_list.append(p)
    s_list.append(s)

index_list = [i for i in range(M)]

p_dict = dict([(p_list[j], index_list[j]) for j in range(M)])

p_unique = list(set(p_list))

AC_num = 0
WA_num = 0
index_start = 0
for j in p_unique:
    index_end = p_dict[j]
    j_list = s_list[index_start:index_end + 1]
    j_len = len(j_list)

    if 'AC' in j_list:
        AC_num += 1
        span = j_list.index('AC')
        j_len = len(j_list[:span])
        WA_num += j_len

    else:
        WA_num += j_len

    index_start = index_end + 1

print(AC_num, '', WA_num)

Submission status: Runtime Error

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

list_correct = [0] * n
list_pena = [0] * n
for i in range(m):
  if s[i] == "AC":
    if list_correct[p[i]] == 0:
      list_correct[p[i]] = 1
  else:
    if list_correct[p[i]] == 0:
      list_pena[p[i]] = list_pena[p[i]] + 1
      
sum_correct = sum(list_correct)
combined = [x * y for (x, y) in zip(list_correct, list_pena)]
sum_pena = sum(combined)

print (sum_correct, sum_pena)

Submission status: Runtime Error

Solution code:
s=list(map(int,input().split()))
AC=[]
WA={}
w=0
for b in range(s[1]):
  t=input().split()
  a=t[0]
  if a not in AC:
    if t[1]=="AC":
      w+=WA.get(a)
      AC.append(a)
    else:
      if a in WA:
        WA[a]=WA.get(a)+1
      else:
        WA[a]=1
print(str(len(AC))+" "+str(w))

Submission status: Runtime Error

Solution code:
N, M = input().split()
point = input().split()
thr = 0
good = 0
bad = 0
N = int(N)
M = int(M)

if M == 0:
    print("0 0")
else:
    for i in range(M - 1):
        if point[0] == str(thr):
            point = input().split()
            continue
        elif point[1] == "AC":
            good += 1
            thr = point[0]
            point = input().split()
            continue
        elif point[1] == "WA":
            bad += 1
            point = input().split()
            continue
    print(str(good), str(bad))

Submission status: Runtime Error

Solution code:
s=list(map(int,input().split()))
AC=[]
WA={}
w=0
for b in range(s[1]):
  t=input().split()
  a=t[0]
  if a not in AC:
    if t[1]=="AC":
      w+=WA[a]
      AC.append(a)
    else:
      if a in WA:
        WA[a]=WA.get(a)+1
      else:
        WA[a]=1
print(str(len(AC))+" "+str(w))

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
ans_ac = 0
ans_wa = 0
dic = {}
for i in range(1, n):
  dic[i] = [False, 0]

for i in range(m):
  p, s = input().split()
  if dic[int(p)][0]:
    continue
  if s == 'WA':
    dic[int(p)][1] += 1
  else:
    ans_ac += 1
    ans_wa += dic[int(p)][1]
    dic[int(p)][0] = True
    
print(ans_ac, ans_wa)

Submission status: Runtime Error

Solution code:
N,M=map(int, input().split())
AC=[]
WA=[0]*N
ans=0
for _ in range(M):
  p,S=input().split()
  if S=="AC":
    AC.append(p)
  elif p not in AC:
    WA[int(p)]+=1
for i in AC:
  ans+=WA[int(i)]
print(len(set(AC)),ans)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
inf = [ int(a) for a in input().rstrip().split(' ')]
# results = [[a for a in input().rstrip().split(' ')] for i in range(inf[1])]

solved = []
pennalty = {}

for i in range(inf[1]):
    sub = [a for a in input().rstrip().split(' ')]
    if not(sub[0] in solved):
        if sub[1] == 'AC':
            solved.append(sub[0])
        else:
            if (sub[0] in pennalty):
                pennalty[sub[0]] += 1
            else:
                pennalty[sub[0]] = 1

pena = 0
for key in solved:
    pena += pennalty[key]
            
print('{} {}'.format(len(solved), pena))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
al = []
for i in range(M):
  al.append(tuple(input().split()))
al_a = [i[0] for i in al if i[1] == 'AC']
al_a = list(set(al_a))
r1 = len(al_a)
r2 = 0
for j in al:
  if j[1] == 'AC':
    al_a.remove(j[0])
  elif j[0] in al_a:
    r2 += 1
    
print(r1 ,r2)

Submission status: Runtime Error

Solution code:
# AC を 1回以上出した各問題において、初めて AC を出すまでに出した WA の数
n,m = map(int, input().split())
p = []
s = []
wacounter = 0
walist = []
for i in range(0, n):
  walist.append(0)
point = 0
point_to_num = [] #acをとった問題
for i in range(0, m):
  list = input().split()
  p.append(int(list[0]))
  s.append(list[1])
 
for i in range(0, m):
  if s[i] == "AC" and not p[i] in point_to_num: #もし正解で、今までにその問題に正解していなかったら
    point_to_num.append(p[i]) #正解リストにその問題を追加
    #point = point + 1 正解ポイントをあげる
  elif s[i] == "WA" and not p[i] in point_to_num: #不正解かつ今まで正解を出したことがない
      wacounter += 1
      walist[p[i]] += 1
for i in range(0, m):
  if not p[i] in point_to_num:#もし正解してない番号があったら、walistからwacounterをとってきてひく
    wacounter = wacounter - walist[p[i]-1]
print(len(point_to_num), wacounter)

Submission status: Runtime Error

Solution code:
s=list(map(int,input().split()))
AC=[]
WA={}
w=0
for b in range(s[1]):
  t=input().split()
  if t[0] not in AC:
    if t[1]=="AC":
      w+=WA[t[0]]
      AC.append(t[0])
    else:
      WA[t[0]]=WA.get(t[0])+1
print(str(len(AC))+" "+str(w))

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
for _ in range(M):
    p,S = map(input().split())

for i in range(len(p)):
    p[i] = int(p[i])
    
c = 0
a = 0
b = 0
for i in range(len(S)):
    if S[i] == 'AC' and p[i] > c:
        a = a + 1
        c = p[i]
    elif S[i] == 'WA' and p[i] > c:
        b = b + 1
        
print(a, b)

Submission status: Runtime Error

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


li = []

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

wa = 0

se = {i for i in li if i[1]=='AC'}
ac = len(se)

flag = True
for i in range(m-1):
    if li[i][0]!=li[i+1][0]:
        flag = True
    elif li[i][0]==li[i+1][0] and li[i][1]=='AC':
        flag = False
    elif li[i][0]==li[i+1][0] and li[i][1]=='WA' and flag:
        wa += 1
    elif li[len(li)-1]==li[len(li-2)] and li[i][1]=='WA' and flag:
        wa += 1

print(ac, wa)

Submission status: Runtime Error

Solution code:
import numpy as np

NM=np.array(input().split(" "),dtype=np.int32)

result={}
tmp=[]

for i in range(NM[1]):
    s=input().split(" ")
    result.setdefault(s[0],[]).append(s[1])

corrects=0
penalty=0
keys=result.keys()

for k in keys:
    L=result[k]
    idx=L.index('AC')
    if(idx==-1):
        continue
    else:
        penalty+=idx
        corrects+=1

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

Submission status: Runtime Error

Solution code:
from functools import reduce
N, M = list(map(int, input().split()))
ps_list = [input().split() for _ in range(M)]

result = {}
for row in ps_list:
  if not row[0] in result:
    result[row[0]] = {
        "AC": 0,
        "WA": 0
    }
  if result[row[0]]["AC"] > 0:
    continue
  else:
    result[row[0]][row[1]] = result[row[0]][row[1]] + 1

print(result)
ac = 0
wa = 0
for k,v in result.items():
  ac = ac + v["AC"]
  if v["AC"] = 0:
    continue
  wa = wa + v["WA"]
print(ac, wa)

Submission status: Runtime Error

Solution code:
N,M=map(int, input().split())
AC=[]
WA=[0]*M
ans=0
for _ in range(M):
  p,S=input().split()
  if S=="AC":
    AC.append(p)
  elif p not in AC:
    WA[int(p)]+=1
for i in AC:
  ans+=WA[int(i)]
print(len(set(AC)),ans)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
Alist = [[]]*M
for i in range(M):
  Alist[i] = list(map(str, input().split()))
collect = [False]*N
NP = 0
NAC = 0
results = [False]*N
for k in range(M):
  if Alist[k][1] == 'AC':
    results[int(Alist[k][0])] = True

for j in range(M):
  if Alist[j][1] == 'WA' and results[int(Alist[j][0])] == True:
    NP += 1
  elif collect[int(Alist[j][0])-1] == False and Alist[j][1] == 'AC':
    NAC += 1
    collect[int(Alist[j][0])-1] = True
print(NAC, " ", NP)

Submission status: Runtime Error

Solution code:
import numpy as np
N, M = map(int, input().split())
P = [input().split() for _ in range(M)]
X = np.zeros(M, np.int)
ac = 0
wa = 0
for pi in P:
    i = int(pi[0])
    s = pi[1]
    if X[i-1] == 0:
        if s == 'WA':
            wa += 1
        else:
            ac += 1
            X[i-1] = 1

print(ac, wa)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
s=[list(map(str,input().split())) for i in range(b)] 
for i in range(b):
    s[i][0]=int(s[i][0])
if b==0:
    print("0 0")
    exit()
aans=0
wans=0
c1=0
for i in range(b-1,-1,-1):
    if s[i][1]=="AC":
        count=i
        break
for i in range(count):
    if s[i][1]=="WA":
        wans+=1

s= list(map(list, set(map(tuple, s))))
for i in range(len(s)):
    if s[i][1]=="AC":
        aans+=1
print(aans,end=" ")
print(wans)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
li_AC = [0]*N
count_WA = [0]*N
count_WA_total = 0
for i in range(M):
    p, S = input().split()
    p = int(p)
    if li_AC[p-1] == 0:
        if S == "AC":
            li_AC[p-1] = 1
            count_WA_total += count_WA[p-1]
        if S == "WA":
            count_WA[p-1] += 1
print(counter(li_AC, 1), count_WA_total)

Submission status: Runtime Error

Solution code:
N, M = input().split()
N = int(N)
M = int(M)
p = []
S = []
for i in range(M):
    a, b = input().split()
    a = int(a)
    p.append(a)
    S.append(b)
right = []
wrong = []
for j in range(N):
    right.append(0)
    wrong.append(0)
for k in range(M):
    if S[k] == 'WA' and right[p[k] - 1] == 0:
        wrong[p[k] - 1] += 1
    else if S[k] == 'AC':
        if right[p[k] - 1] == 0:
            right[p[k] - 1] += 1
print(str(sum(right)) + ' ' + str(sum(wrong)))

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split(" "))
p = []
S = []
flag_AC = []
flag_WA = []

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

for i in range(N):
    flag_AC.append(0)
    flag_WA.append(0)

# n番目の提出ステータスを取得
def Anc(n):
    L = []
    L.append(p[n])
    L.append(S[n])
    return L

AC = 0
WA = 0

for i in range(M):
    data = Anc(i)
    if data[1] == "AC":
        if flag_AC[data[0]] == 0:
            flag_AC[data[0]] = 1
            AC = AC + 1

    if data[1] == "WA":
        if flag_AC[data[0]] == 0:
            flag_WA[data[0]] = flag_WA[data[0]] + 1
            WA = WA+1

print(AC,WA)

Submission status: Runtime Error

Solution code:
import numpy as np

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

counter = {}

for i in range(m):
    res = list(input().split())
    p, s = (int(res[0]), res[1])
    if p in counter.keys():
        if s == 'AC':
            counter[p][0] = 1
        elif s == 'WA' and (not counter[p][0]):
            counter[p][1] += 1
    else:
        if s == 'AC':
            counter[p] = np.array([1, 0])
        else:
            counter[p] = np.array([0, 1])

if len(counter):
    print(*sum(filter(lambda v: v[0] == 1, counter.values())))
else:
    print('0 0')

Submission status: Runtime Error

Solution code:
from itertools import groupby
N, M  =map(int, input().split())
ps = [[] for i in range(M)]
for i in range(M):
    ps[i] = list(input().split())
listnum = []
listAC = []
for i in range(M):
    listnum.append(int(ps[i][0]))
for i in range(M):
    listAC.append(ps[i][1])
newnumlist = list([list(g) for k, g in groupby(listnum)])
newlistAC = [[] for i in range(len(newnumlist))]
for i in range(len(newnumlist[0])):
    newlistAC[0].append(ps[i][1])
lenth = 0

for i in range(1,len(newnumlist)):
    lenth += len(newnumlist[i-1])
    for j in range(len(newnumlist[i])):
        newlistAC[i].append(ps[j+lenth][1])
countAC=0
counterror = 0
for i in range(len(newlistAC)):
    for j in range(len(newlistAC[i])):
        if newlistAC[i][j] == 'WA':
            counterror += 1
        else:
            countAC += 1
            break
    
print(countAC, counterror)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, p: "List[int]", S: "List[str]"):
    wa_flag = [0]*N
    num_penalty = 0
    for i in range(M):
        pi = p[i]
        si = S[i]
        if wa_flag[pi-1] == 0 and si == "WA":
            num_penalty += 1
        if si == "AC":
            wa_flag = -1
    num_ac = wa_flag.count(-1)
    print(num_ac, num_penalty)
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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: Runtime Error

Solution code:
N, M = map(int, input().split())
p = [0] * M
S = [''] * M
for i in range(M):
    p_i, S[i] = input().split()
    p[i] = int(p_i)




# penal_ct = 0
# ac_count = 0
# # prev_ac_num = -1

# ac_list = [False] * N

# for i in range(M):
#     if (not ac_list[p[i] - 1]) and S[i] == 'AC': # ACかつ今までにACしてない
#         ac_list[p[i] - 1] = True
#         ac_count += 1
#         if i == 0:
#             continue
#         for j in range(i)[::-1]:
#             if S[j] == 'WA' and p[j] == p[i]:
#                 penal_ct += 1

#     if all(ac_list):
#         break



# for i in range(1, M)[::-1]:
#     if S[i] == 'AC' and p[i] != prev_ac_num:
#         prob_num = prev_ac_num = p[i]
#         ac_count += 1
#         for j in range(i)[::-1]:
#             if p[j] == prob_num and S[j] == 'WA':
#                 penal_ct += 1
print(ac_count, penal_ct)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
A=[[] for i in range(N)]
for i in range(M):
    Pi,Si=map(str,input().split())
    Pi=int(Pi)
    A[Pi-1].append(Si)

nAC=0
nWA=0
for i in range(N):
    if len(A[i])==0:
        pass
    else:
        j=0 
        while A[i][j]=="WA":
            nWA+=1
            j+=1
            if j>len(A[i]):
                break
            else:
                pass
        if A[i][j]=="AC":
            nAC+=1
        else:
            pass
print("{:1}{:2}".format(nAC,nWA))

Submission status: Runtime Error

Solution code:

if __name__ == "__main__":
    H, W = [int(s) for s in input().split()]



    accepted = [False] * N
    penalties = [0] * N
    for _ in range(M):
        p, S = input().split()
        p = int(p)
        # S = 'AC' or 'WA'
        if S == "AC":
            accepted[p - 1] = True
        if S == "WA" and not accepted[p - 1]:
            penalties[p - 1] += 1

    N_accepted = len([a for a in accepted if a])
    sum_penalties = sum([p for p, a in zip(penalties, accepted) if a])
    print(N_accepted, sum_penalties)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
for _ in range(M):
    p = map(int, input().split())
    S = map(str, input().split())

c = 0
a = 0
b = 0
for i in range(len(S)):
    if S[i] == 'AC' and p[i] > c:
        a = a + 1
        c = p[i]
    elif S[i] == 'WA' and p[i] > c:
        b = b + 1
        
print(a, b)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
l=[input().split() for _ in range(m)]
arr=[]
ac,wa=0,0
acl=[False for _ in range(m)]
for r in l:
  p,s=int(r[0]),r[1]
  if s=='AC' and acl[p]==False:
    arr.append([p,s])
    acl[p]=True
  elif s=='WA' and acl[p]==False:
    arr.append([p,s])
    
for r in arr:
  p,s=r
  if s=='WA' and acl[p]:
    wa+=1
  elif s=='AC':
    ac+=1
    
print(ac,wa)

Submission status: Runtime Error

Solution code:
cin=input().split()
N=int(cin[0])
M=int(cin[1])


result={}
ac=0
was={}
for i in range(M):
    cin=input().split()
    p=int(cin[0])
    S=str(cin[1])

    log=result.get(p,None)
    if S == "AC" and log != "AC":
        ac+=1
        result[p]="AC"

    if S == "WA" and log != "AC":
        was[p]=was.get(p,0)+1

wa=0
for k,v in result.items():
    if v == "AC":
        wa+=was[k]
print(str(ac)+" "+str(wa))

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
for _ in range(M):
    p = map(int, input().split())
    S = map(str, input().split())

c = 0
a = 0
b = 0
for i in range(len(M)):
    if S[i] == 'AC' and p[i] > c:
        a = a + 1
        c = p[i]
    elif S[i] == 'WA' and p[i] > c:
        b = b + 1
        
print(a, b)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
p = [0]*m
s = [0]*m
c = [0]*m
j = 1
for i in range(m):
    p[i],s[i] = map(str,input().split())
    if i == 0:
        c[i] = str(p[i])
    elif c[j - 1] != p[i]:
        c[j] = str(p[i])
        j += 1
ac = 0
wa = 0
j = 0
for i in range(m):

    if p[i] == c[j] and s[i] == "AC":
        ac += 1
        j += 1
        if c[j] == 0:
            break
    else :
        wa += 1
        
print("{} {}".format(ac,wa))

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
A=[[] for i in range(N)]
for i in range(M):
    Pi,Si=map(str,input().split())
    Pi=int(Pi)
    A[Pi-1].append(Si)

nAC=0
nWA=0
for i in range(N):
    if len(A[i])==0:
        pass
    else:
        j=0 
        while A[i][j]=="WA":
            nWA+=1
            j+=1
            if j>len(A[i]):
                break
            else:
                pass
        if A[i][j]=="AC":
            nAC+=1
        else:
            pass
print("{:1},{:2}".format(nAC,nWA))