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())
di = {}
pe = 0
ac = 0
for i in range(M):
    inp = input().split(" ")
    if inp[1] == "WA":
        if inp[0] in di:
            if di[inp[0]] >= 1:
                di[inp[0]] += 1
        else:
            di[inp[0]] = 1
            
            
    else:
        pe += di[inp[0]]
        di[inp[0]] = 0
for v in di.values():
    if v == 0:
        ac += 1
print(str(pe)+" "+str(ac))

Submission status: Runtime Error

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

ans_list = []

for i in range(M):
    ans_list.append(input().split())

wa = 0
wa_tmp = 0
ac = 0
ac_tmp = 0
flag = 0
counter = 0

for n in range(int(ans_list[0][0]), int(ans_list[-1][0])+1):
    if M == 0:
        break
    
    else:
        for t in range(counter, M):
            if ans_list[t][0] == str(n):
                if ans_list[t][1] == "AC":
                    ac_tmp += 1
                    counter += 1
                    break

                elif str(n) and ans_list[t][1] == "WA":
                    wa_tmp += 1
                    counter += 1

            elif ans_list[t][0] == str(n+1):
                    break
            

        if ac_tmp == 0:
            wa_tmp = 0
        
        wa += wa_tmp
        ac += ac_tmp

        wa_tmp = 0
        ac_tmp = 0


print(ac, wa)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
cnt = 0
wa = 0
ac = 0
sumi = []
b = [0] * n
table = [input().split() for x in range(m)]
for x in range(m):
    if table[x][1] == 'WA':
        b[int(table[x][0])] += 1

    if table[x][1] == 'AC' and not table[x][0] in sumi:
        sumi.append(table[x][0])
        ac += 1
        wa += b[int(table[x][0])]

print(ac, wa)

Submission status: Runtime Error

Solution code:
N, M = [int(num) for num in input().split()]
pro = {}
c_sum = 0
c = []
f_sum = 0
for i in range(M):
    p, S = input().split()
    if S == 'AC':
        if p not in c:
            if p in pro:
                f_sum += pro[p]
            c.append(p)
    else S == 'WA':
        if p in c:
            continue
        elif p not in pro:
            pro[p] = 1
        else:
            pro[p] += 1
print("{} {}".format(len(c), f_sum))

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
dp = [0]*(100010)
qp = [0]*(100010)
for i in range(b):
    ta,tb = map(str,input().split())
    ta = int(ta)
    if qp[ta] == 0 :
        if tb == 'WA':dp[ta]+=1
        else qp[ta]=1
print(sum(qp),sum(dp))

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
wa={i:0 for i in range(1,a+1)}
ac=wa
for i in range(b):
    c,d=input().split()
    if d=="WA" and ac[int(c)]==0:
        wa[int(c)]+=1
    else:
        ac[int(c)]=1
print(sum(wa.values())+" "+sum(ac.values()))

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
p=[]
s=[]
idx=0
AC=0
WA=0
for i in range(m):
    p_,s_=input().split()
    p.append(int(p_))
    s.append(s_)
for i in range(m):
    cp=p.count(p[idx])
    for i in range(idx,(cp+idx)):
        ##print(i)
        if s[i]=='WA':
            WA+=1
        elif s[i]=='AC':
            AC+=1
            break
    idx=cp+idx
    if idx==m:
        break
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 int(ans[0]) <= N and 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())
x = []
y = []
for i in range(M):
    x1,y1=[i for i in input().split()]
    x.append(int(x1))
    y.append(y1)

if not any(x):
  print('{} {}'.format(0, 0))
  exit()


countWC = 0
countAC = 0
index = 0

for i in range(N):
  while y[index] == 'WA':
    countWC += 1
    index += 1   
  if index > 0:
    if x[index] == x[index - 1]:
      if y[index] == 'AC' and y[index - 1] == 'AC':
        continue
      if y[index] == 'WA' and y[index - 1] == 'AC':
        continue
  countAC += 1 
  index += 1

	
print('{} {}'.format(countAC, countWC))

Submission status: Runtime Error

Solution code:
import numpy as np

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

result={}
pre_idx=""
tmp=[]
for i in range(NM[1]):
    s=input().split(" ")
    idx=s[0]
    if(pre_idx!=idx):
        result[idx]=[]
        result[idx].append(s[1])
    else:
        result[idx].append(s[1])
    pre_idx=idx

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:
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))

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

Submission status: Runtime Error

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

for i in range(m):
    ipt=input().split()
    p=int(ipt[0])
    s=ipt[1]
    if l==[]:
        l.append([p,[s]])
    else:
        if l[-1][0] != p:
            l.append([p,[s]])
        else:
            l[-1][1].append(s)

a=0
p=0
for i in range(len(l)):
    j=0
    k=len(l[i][1])
    while l[i][1][j] != "AC" and j<k:
        p+=1
        j+=1
    if j != k:
        a+=1
print(a,p)

Submission status: Runtime Error

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

ans_list = [0]*N+1
pen_num = 0
cor_num = 0

for i in range(M):
  p_i, S_i = input().split()
  p_i = int(p_i)
  
  if (ans_list[p_i] == 0):
    if(S_i == "WA"):
      pen_num += 1
    elif(S_i == "AC"):
      cor_num += 1
      ans_list[p_i] = 1
      
print("{} {}".format(cor_num,pen_num))

Submission status: Runtime Error

Solution code:
n, m = (int(i) for i in input().split())
p = [None] * m
s = [None] * m
for i in range(m):
    p[i], s[i] = (j for j in input().split())
    p[i] = int(p[i])
    
pena = [0] * m
ac   = [0] * m
for i in range(m):
    q_index = p[i]-1
    if s[i] == 'AC': 
        ac[q_index] = 1
    if s[i] == 'WA':
        if ac[q_index] == 0: pena[q_index] += 1
        
print(sum(ac), sum(pena))

Submission status: Runtime Error

Solution code:
n, m = [int(i) for i in input().split(" ")]
score_dict = {}

for i in range(m):
    p, s = input().split(" ")
    if p not in score_dict:
        score_dict[p] = []
    
    score_dict[p].append(s)

ac_count = 0
wa_count = 0

for i in score_dict.values():
    tmp = i[:i.index("AC")+1]
    if "AC" in tmp:
        ac_count += 1
    
    wa_count += tmp.count("WA")

print("{0} {1}".format(ac_count, wa_count))

Submission status: Runtime Error

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

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_flag = False

if s[0] == 'AC':
	AC_flag =True
	cor_count += 1
else:
	pen_count += 1

for i in range(M-1):
	if p[i] == p[i+1]:
		if AC_flag == False:
			if s[i+1] =='AC':
				cor_count += 1
				AC_flag =True
			else:
				pen_count += 1
	else:
		AC_flag = False
		if s[i+1] =='AC':
			cor_count += 1
			AC_flag =True
		else:
			pen_count += 1


print(cor_count,pen_count)

Submission status: Runtime Error

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

ans_list = [0]*N
pen_num = 0
cor_num = 0

for i in range(M):
  p_i, S_i = input().split()
  p_i = int(p_i)
  
  if (ans_list[p_i] == 0):
    if(S_i == "WA"):
      pen_num += 1
    elif(S_i == "AC"):
      cor_num += 1
      ans_list[p_i] = 1
      
print("{} {}".format(cor_num,pen_num))

Submission status: Runtime Error

Solution code:
A = list(map(int , input().split()))
x = []
for i in range(A[1]):
    X=list(input().split())
    x.append(X)
di = {}
for i in x:
    di[int(i[0])] = []
for i in x:
    di[int(i[0])].append(i[1])
sei = 0
go = 0
for k ,v in di.items():
    if 'AC' in v:
        sei += 1
    go += v.index('AC')
print('{} {}'.format(sei,go))

Submission status: Runtime Error

Solution code:
N,M = list(map(int,input().split()))
colect_quest = [0]*N
WA_quest = [0]*N
for i in range(M):
    pi,si = list(map(str,input().split()))
    pi = int(pi)
    if si == "AC":
        colect_quest[pi] = 1
    if si == "WA" and colect_quest[pi] != 1:
        WA_quest[pi] += 1
    
print(sum(colect_quest),sum(WA_quest))

Submission status: Runtime Error

Solution code:
import numpy as np
N,M=map(int,input().split())
string_list=[input() for i in range(M)]
checkAC=np.zeros((N,2),np.int16)
for i in string_list:
    Ni,Si = i.split()
    Ni = int(Ni)-1
    if checkAC[Ni,0]==0:
        if Si=='AC':
            checkAC[Ni,0]=1
        else:
            check[Ni,1]+=1
strlist = checkAC.sum(axis=0)
print(str(strlist[0])+' '+str(strlist[1]))

Submission status: Runtime Error

Solution code:
import numpy as np

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

result={}
pre_idx=""
tmp=[]
for i in range(NM[1]):
    s=input().split(" ")
    idx=s[0]
    if(pre_idx==idx):
        tmp.append(s[1])
        if(i==NM[1]-1):
            result[pre_idx]=tmp
    elif(pre_idx!=idx):
        tmp=[]
        result[idx]=tmp
        tmp.append(s[1])
        pre_idx=idx

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:
%%time
N,M=map(int, input().split())
P=[]
S=[]
for i in range(M):
    p,s=input().split()
    P.append(int(p))
    S.append(s)


import numpy as np
P=np.array(P)
S=np.array(S)

if M>0:
    ans=P[S=="AC"]

    wa=0
    ac=[]
    for i in range(M):
        if P[i] in ans and P[i] not in ac and S[i]=="WA":
            wa+=1
        else:
            ac.append(P[i])
    
    
    print(len(ans),wa)
else:
    print(0,0)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
a = 0
b = 0
sp = dict()
correct = []
wrong = dict()
for _ in range(M):
    s, p = input().split()
    if not s in sp.keys():
        if p == "AC":
            a +=1
            correct.append(s)
        else:
            wrong[s] = 1
        sp[s] = p
    else:
        if sp[s] == "AC":
            continue
        else:
            if p == "AC":
                a += 1
                correct.append(s)
            else:
                wrong[s] = 1
            sp[s] = p
for c in set(correct):
    b += wrong[c]
print(a, b)

Submission status: Runtime Error

Solution code:
coding: utf-8

import bisect
import math

N, M = (int(v) for v in input().split())

seen = {}
WA = {}

acs = 0
was = 0

for i in range(M):
    q, tmp = input().split()
    if tmp == "AC":
        if q not in seen:
            acs += 1
            if q not in WA:
                WA[q] = 0
            was += WA[q]
            seen[q] = 1
    else:
        if q not in WA:
            WA[q] = 1
        else:
            WA[q] += 1

print (acs, was)

Submission status: Runtime Error

Solution code:
N,M = [int(x) for x in input().split()]
s = []
for i in range(M):
    array = list(map(str,input().split()))
    s.append(array)
a = 0
b = 0
for i in range(M):
    if s[i][0] == s[i+1][0]:
        if s[i][1] == "WA":
            b = b + 1
        else:
            a = a + 1
            break
    else:
        if s[i][1] == "AC":
            a = a + 1
        else:
            b = b + 1
print(str(a) + " " + str(b))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
PS = []
for i in range(M):
    p, s = input().split()
    PS += [(int(p),s)]

CA = 0
PN = 0
l = [True]*M
for i in range(len(PS)):
    if l[PS[i][0]]:
        if PS[i][1] == "WA":
            PN += 1
        elif PS[i][1] == "AC":
            CA += 1
            l[PS[i][0]] = False

print(CA, PN)

Submission status: Runtime Error

Solution code:
n, m = [int(x) for x in input().split()]

answers = []
for x in range(m):
    answers.append(input().split())

correct_answers = [answer[0] for answer in answers if answer[1] == "AC"]

temp = {k[0]: [] for k in answers}
for x in answers:
    temp[x[0]].append(x[1])

penalties = 0
for x in temp:
    G = temp[x][:temp[x].index("AC")]
    penalties += len(G)


print(len(set(correct_answers)), penalties)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
ans = []
ans_0 = []
for i in range(m):
    ans_0 = list(map(str, input().split()))
    ans.append(ans_0)
list0 = []
for j in range(n):
    list0.append(0)
sei = 0
pen = 0
for lis in ans:
    if list0[int(lis[0])] == 0:
        if lis[1] == "AC":
            sei += 1
            list0[int(lis[0])] = 1
        else:
            pen += 1
    else:
        if lis[1] == "AC":
            pass
        else:
            pen += 1
print(str(sei)+" "+str(pen))

Submission status: Runtime Error

Solution code:
from sys import stdin as s
n,m=map(int,s.readline().split())
l=[0]*n
wa=[0]*n
cor,pen=0
for i in range(m):
  x,y=s.readline().split()
  x=int(x)-1
  if y=="AC":
    l[x]=1
  elif not l[x]:
    wa[x]+=1
for i in range(n):
  if l[i]:
    cor+=1
    pen+=wa[i]
print(cor,pen)

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


if p ==[]:
    print("0 0")
else:
    A = 0
    B = 0
    for i in range(M):
        if p1[i] in N1:
            A += S1[i]
            B += (a-S1[i])
            if S1[i] ==1:
                N1.remove(p1[i])
    print(str(A)+" "+str(B))

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
lst = []
for i in range(m):
  lst.append(input().split())
  
task = 1
taskLst = [lst[0][0]]
temp = lst[0][0]
for i in lst:
  if i[0] == temp:
    continue
  else:
    task += 1
    taskLst.append(i[0])
    temp = i[0]
    
resLst = []
for i in range(len(taskLst)):
  tempLst = []
  for j in range(len(lst)):
    if lst[j][0] == taskLst[i]:
      if lst[j][1] == 'WA':
      	tempLst.append(lst[j][1])
      else:
        tempLst.append(lst[j][1])
        break
  resLst.append(tempLst)

finalLst = []
for i in range(len(resLst)):
  for j in range(len(resLst[i])):
    finalLst.append(resLst[i][j])
    
print(str(finalLst.count('AC')) + ' ' + str(finalLst.count('WA')))

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
for j in range(M):
  if collect[int(Alist[j][0])] == False and Alist[j][1] == 'WA':
    NP += 1
  elif collect[int(Alist[j][0])] == False and Alist[j][1] == 'AC':
    NAC += 1
    collect[int(Alist[j][0])] = True

print(NAC, " ", NP)

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])
    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" and 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:
N, M = map(int, input().split())
PS = []
for i in range(M):
    p, s = input().split()
    PS += [(int(p),s)]

CA = 0
PN = 0
l = [True]*N
for i in range(len(PS)):
    if l[PS[i][0]]:
        if PS[i][1] == "WA":
            PN += 1
        elif PS[i][1] == "AC":
            CA += 1
            l[PS[i][0]] = False

print(CA, PN)

Submission status: Runtime Error

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

RES = []

for i in range(M):
    RES.append(list(input().split()))

WA = [0]*(M+3) ##WAするのは提出数
ACed = [0]*(N+3) ##ACするのは問題数

for i in range(M):
    num = int(RES[i][0])
    if RES[i][1] == "WA" and not ACed[num]:
        WA[num] += 1
    elif RES[i][1] == "AC":
        ACed[num] = 1

print(sum(ACed),end=" ")
print(sum(WA))

Submission status: Runtime Error

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

cnt_wa = 0
cnt_ac = 0
pfin = 0
for i in range(m):
	if pfin < p[i]:
      	if s[i]=="WA":  
        	cnt_wa += 1
        else:
          	cnt_ac += 1
          	pfin = p[i]
          	if pfin==n:
            	break

print("{} {}".format(cnt_ac, cnt_wa))

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
List = [0]*N
correct , penalties = 0,0
for i in range(M):
    p,s = input().split()
    pro = int(p)-1
    if p > len(List):
        penalties+=1
        continue
    if List[pro]=="AC":
        continue
    if s == "WA":
        penalties+=1
        List[pro]=s
    else:
        List[pro]=s
        correct+=1
print("%d %d"%(List.count("AC"),penalties),List)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a_list = []
b_list = ["f"] * (10**5+1)
count_ac = 0
count_wa = 0
for i in range(m):
    a,b = map(str, input().split())
    a_list.append((int(a),b))
for i in range(m):
    if a_list[i][1] == "WA" and b_list[a_list[i][0]] == "f":
        count_wa += 1
    if a_list[i][1] == "AC":
        if b_list[a_list[i][0]] == "f":
            count_ac += 1
        b_list[a_list[i][0]] = "t"
for i in range(m):
    if b_list[a_list[i][0]] == "f" and b_list[a_list[i][1]] == "WA":
        count_wa -= 1
print(count_ac,count_wa)

Submission status: Runtime Error

Solution code:
# coding: utf-8
n, m = [int(x) for x in input().split(" ")]
ans = 0
pen = 0
prbstate = {}
fins = {}
A = []
for i in range(m):
    A.append(input().split(" "))

for a in A:
    if a[1] == "AC":
        fins.setdefault(a[0], "AC")

for i in range(m):
    p, s = A[i]
    prbstate.setdefault(p, 0)
    if s == "AC":
        prbstate[p] = 1
    if s == "WA" and prbstate[p] == 0 and fins[p] == "AC":
        pen += 1
for x in prbstate.values():
    ans += x
print(ans, pen)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
P = []
S = []
total = []


for i in range(M):
    a,b = map(str,input().split())
    P.append(a)
    S.append(b)
ok = 0
pena = 0

for (i,j) in zip(P,S):
    if not i in total:
        if j=='WA':
            pena+=1
        elif j=='AC'
            ok+=1
            total.append(i)
print(str(ok)+' '+str(pena))

Submission status: Runtime Error

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


for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    d[p].append(s)

ac_cnt, w_cnt = 0, 0
for l in d:
    if len(l) != 0:
        w_cnt += l.index("AC")

    if "AC" in l:
        ac_cnt += 1

print(ac_cnt, w_cnt)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
q_re = set()
ac = 0
wa = 0
dic_wa = {}
for i in range(m):
    q, re = input().split()
    if(re == "WA" and q not in q_re): 
        if(q not in dic_wa): dic_wa[q] = 1
        else: dic_wa[q] += 1
    if(re == "AC" and q not in q_re): 
        ac += 1
        q_re.add(q)
        wa += dic_wa[q]
print(ac, wa)

Submission status: Runtime Error

Solution code:
N, M = [int(x) for x in input().split()]
p = []; S = []
for _ in range(M):
    p_tmp, S_tmp = input().split()
    p.append(int(p_tmp))
    S.append(str(S_tmp))

AC = [0] * N
WA = [0] * M
for i in range(M):
    if AC[p[i] - 1] == 1:
        continue
    if S[i] == 'AC':
        AC[p[i] - 1] = 1
    else:
        WA[p[i] - 1] += 1
AC_count = sum(AC)
WA_count = sum(WA)
print(AC_count, WA_count)

Submission status: Runtime Error

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

for _ in range(M):
  p_str, s = map(str, input().split())
  p = int(p_str)
  if p in ac:
    continue
  if s == 'AC':
    ac.append(p)
    p.sort
  if s == 'WA':
    wa += 1

print(len(ac), wa)

Submission status: Runtime Error

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

a=[]
for i in range(M):
  a.append(input().rstrip().split())

pen =0
AClist =[]
ACflag= [0]*N
#print(a,len(a))

for i in range(len(a)):
  if a[i][1] == "AC" and ACflag[int(a[i][0])] == 0:
    AClist.append(a[i])
    ACflag[int(a[i][0])] = 1
  if a[i][1] == "WA" and ACflag[int(a[i][0])] == 0:
    pen += 1

print(len(AClist),pen)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np

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

    if M == 0:
        print('0 0')
        sys.exit()


    p_S = []
    for i in range(M):
        p_S.append(input().split())

    uniq_ps = np.unique(p_S, axis=0)
    


    ac = 0
    wa = 0
    for arr in uniq_ps:
        if arr[1] == 'AC':
            ac += 1
        else:
            wa += 1

    print(ac, wa)

main()

Submission status: Runtime Error

Solution code:
ls_ac = [0] * n
ls_ng = [0] * n
ac = 0
ng = 0


for i in range(m):
    p = int(ls[i][0])
    if ls[i][1] == "AC":
        if ls_ac[p - 1] == 0:
            ac += 1
            ng += ls_ng[p - 1]
            ls_ac[p - 1] = 1
    elif ls[i][1] == "WA":
        if ls_ac[p - 1] == 0:
            ls_ng[p - 1] += 1

print(ac, ng)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
pS = {}
for i in range(N):
    pS[i] = [0, 0, 0]  # is_ac, penatly, AC

for i in range(M):
    p, S = input().split()
    p = int(p) - 1
    if pS[p][0] == 0 and S == 'WA':
        pS[p][1] += 1
    elif pS[p][0] == 0 and S == 'AC':
        pS[p][0] = 1
        pS[p][2] = 1

AC = 0
penatly = 0
for i in range(N):
    if pS[p][0] == 1:
        penatly += pS[int(i)][1]
        AC += pS[int(i)][2]
print(AC, penatly)

Submission status: Runtime Error

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

t = 0
f = 0
for i in range(n):
  q = [l[j][1] for j in range(m) if l[j][0] == str(i+1)]
  if q.count("AC") != 0:
    t = t + 1
  a = q.index("AC")
  f = f + q[0:a].count("WA")
print(t,f)

Submission status: Runtime Error

Solution code:
cat atcorder_151_C.py
N, M = map(int, raw_input().split())
#print N, M

state = [-1 for i in range(N)]
pena = [0 for i in range(N)]
WA = [0 for i in range(N)]

for i in range(M):
    s = raw_input().split()
    p = int(s[0])
    sc = s[1]
    #print p, sc
    p -= 1
    if (state[p] == 0):
        continue
    if sc == 'WA':
        pena[p] += 1
    else:
        state[p] = 0

ok = 0
pn = 0
for i in range(N):
    if state[i] == 0:
        ok += 1
        pn += pena[i]

print ok, pn

Submission status: Runtime Error

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

flag_p = p[0]
flag_ac = 0
AC_sum = 0
WA_sum = 0

for i in range(M):
  if flag_p == p[i]:
    if S[i] == 'WA':
      WA += 1
    elif S[i] == 'AC' and flag_ac == 0:
      AC_sum += 1
      WA_sum += WA
      flag_ac = 1
      
  else:
    WA = 0
    flag = p[i]
    if S[i] == 'WA':
      WA += 1
    elif S[i] == 'AC' and flag_ac == 0:
      AC_sum += 1
      WA_sum += WA
      flag_ac = 1
    
print(AC_sum. WA_sum)

Submission status: Runtime Error

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


result={}
ac=0
wa=0
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":
        wa+=1

print(f"{ac} {wa}")

Submission status: Runtime Error

Solution code:
n, m = [int(x) for x in input().split()]
nac = 0
nwa = 0
past_ac = {}
for i in range(m):
    p, s = [x for x in input().split()]
    d = p + s
    if (p + 'AC') in past_ac:
        next
    else:
        if s == 'WA':
            past_ac[d] = 1 if d not in past_ac else past_ac[d] + 1
        else:
            past_ac[d] = 1
            nac += 1
            nwa += past_ac[p + 'WA']
print(nac, nwa)

Submission status: Runtime Error

Solution code:
import math
n,m = map(int,input().split())
ps_ls = [list(input().split()) for i in range(m)]
ans_wa = 0
ans_ac = 0
strk_wa = 0
frag = 1
for i in range(m):
    ps_ls[i][0] = int(ps_ls[i][0])
ps_ls.sort(key=lambda x: x[0])

for i in range(m-1):
    if ps_ls[i][1] == "WA" and frag == 1:
        strk_wa += 1

    if ps_ls[i][1] == "AC":
        if frag == 1:
            ans_ac += 1
        frag = 0
        ans_wa += strk_wa
    if ps_ls[i][0] != ps_ls[i+1][0]:
        strk_wa = 0
        frag = 1
if ps_ls[-1][1] == "AC":
    if frag == 1:
            ans_ac += 1
    ans_wa += strk_wa

print(ans_ac,ans_wa)

Submission status: Runtime Error

Solution code:
# import itertools
# import math

# N = int(input())
# S = input()
N, M = map(int, input().split())
# A = list(map(int, input().split()))

ans_p = [0] * N
ans_s = [0] * N

for i in range(M):
    input_sp = input().split()
    P = int(input_sp[0]) - 1
    S = input_sp[1]

    if S == 'AC':
        ans_s[P] = 1
    elif S == 'WA' and ans_s[P] == 0:
        ans_p[P] += 1

for i in ans_p:
    if ans_s[i] == 0 and ans_p[i] != 0:
        ans_p[i] = 0


print(str(sum(ans_s)) + " " + str(sum(ans_p)))

Submission status: Runtime Error

Solution code:
N, M = [int(x) for x in input().split(" ")]
P = []
correct = 0
penalty = 0
for x in range(M):
    temp = [x for x in input().split(" ")]
    if temp[1] == "AC" and temp not in P:
        correct += 1
    elif temp[1] == "WA" and temp not in P:
        penalty += 1
    P.append(temp)

print(f"{correct} {penalty}")

Submission status: Runtime Error

Solution code:
import numpy as np
N,M=map(int, input().split())
A = np.array([input().split() for i in range(M)])


P=A[:,0]
S=A[:,1]

if M>0:
    ans=np.unique(P[S=="AC"])

    wa=0
    for j in ans:
        for i in S[P==j]:
            if i=="WA":
                wa+=1
            else:
                break

    print(len(ans),wa)
else:
    print(0,0)

Submission status: Runtime Error

Solution code:
N, M = list(map(int, input().split(' ')))
result_list = [input().split(' ') for i in range(M)]
AC_total = 0
WA_total = 0
ac_list = []
wa_dict = {}
for p, s in result_list:
    if p not in ac_list:
        if s == 'WA':
            if p in wa_dict:
                wa_dict[p] += 1
            else:
                wa_dict[p] = 1
        else:
            AC_total += 1
            WA_total += wa_dict[p]
            ac_list.append(p)
print('{} {}'.format(AC_total, WA_total))

Submission status: Runtime Error

Solution code:
N, M = [int(num) for num in input().split()]
pro = {}
c_sum = 0
c = []
f_sum = 0
for i in range(M):
    p, S = input().split()
    if S == 'WA' and  p in pro and p not in c:
        pro[p] += 1
    elif S == 'WA' and p not in c:
        pro[p] = 1
    elif S == 'AC' and p not in c:
        f_sum += pro[p]
        c.append(p)
print("{} {}".format(len(c), f_sum))

Submission status: Runtime Error

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

for i in range(0, m):
    pi, si = map(str, input().split())
    p.append( int(pi) )
    s.append( si )


done = []
for i in range(0,n):
    done.append(False)

wa = 0
ac = 0
for i in range(0, m):
    if not done[p[i]]:
        if s[i] == 'WA':
            wa += 1
        else: # 'AC':
            ac += 1
            done[p[i]] = True

print(ac, wa)

Submission status: Runtime Error

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

    if S[i] == 'AC':
        if count_AC[p[i]] == 0:
            count_AC[p[i]] = 1
            
    if S[i] == 'WA':
        if count_AC[p[i]] == 0:
            count_WA[p[i]] += 1
            
print(sum(count_AC) , sum(count_WA))

Submission status: Runtime Error

Solution code:
n,m=[int(x) for x in input().split()]
a=[0 for _ in range(n)]
b=[0 for _ in range(n)]
for _ in range(m):
  p,q=input().split()
  if q=="AC": a[int(p)-1]=1+b[int(p)-1]
    else : b[int(p)-1]+=1
xg=0
for x in a:
  if x>0: xg+=1
print(xg,sum(a))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
pS = [tuple(map(str, input().split())) for _ in range(M)]

if M == 0:
    print(0, 0)
    exit()

ac = 0
wa = 0

x = 1
i = 0
while x <= N:
    if pS[i][0] != str(x):
        x += 1
        continue
    if pS[i][1] == 'WA':
        wa += 1
        i += 1
    if pS[i][1] == 'AC':
        ac += 1
        x += 1
        i += 1

print(ac, wa)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
li = []
seitou = 0
penalty = 0

if m == 0:
    print(0, 0)
else:
    for x in range(5):
        i, j = map(str, input().split())
        if i in li:
            pass
        else:
            if j == "WA":
                penalty += 1
            if j == "AC":
                li.append(i)
                seitou += 1

    print(seitou, penalty)