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

#print(N,M)

num=[]
answer=[]
correct=[False] * N
correctCount = 0
wrongCount = 0
wrong=[0] * N
for k in range(M):
    n,a=input().split()
    num.append(int(n))
    answer.append(a)
    if a == "AC":
        if correct[n] == False:
            correct[n] = True
            correctCount += 1
            wrongCount += wrong[n]
    else:
        if correct[n] == False:
            wrong[n] += 1



    
#print(num)
#print(answer)
    
'''
preCorrect = False
correctCount=0
wrongCount = 0
temp_wrongCount = 0


for i in range(M):
    if i > 0 and num[i] != num[i-1]:
        if preCorrect == True:
            preCorrect = False
            temp_wrongCount = 0
        else:
            temp_wrongCount = 0
    
    
    if preCorrect == True:
        continue

    if answer[i] == "AC":
        correctCount += 1
        preCorrect = True
        wrongCount += temp_wrongCount
    if answer[i] == "WA":
        temp_wrongCount += 1
'''
print(correctCount, wrongCount)

Submission status: Runtime Error

Solution code:

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

#print(N,M)

num=[]
answer=[]
correct=[False] * N
correctCount = 0
wrongCount = 0
wrong=[False] * N
for k in range(M):
    n,a=input().split()
    num.append(int(n))
    answer.append(a)
    if a == "AC":
        if correct[n] == False:
            correct[n] = True
            correctCount += 1
            wrongCount += wrong[n]
    else:
        if correct[n] == False:
            wrong[n] += 1



    
#print(num)
#print(answer)
    
'''
preCorrect = False
correctCount=0
wrongCount = 0
temp_wrongCount = 0


for i in range(M):
    if i > 0 and num[i] != num[i-1]:
        if preCorrect == True:
            preCorrect = False
            temp_wrongCount = 0
        else:
            temp_wrongCount = 0
    
    
    if preCorrect == True:
        continue

    if answer[i] == "AC":
        correctCount += 1
        preCorrect = True
        wrongCount += temp_wrongCount
    if answer[i] == "WA":
        temp_wrongCount += 1
'''
print(correctCount, wrongCount)

Submission status: Runtime Error

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

#print(N,M)

num=[]
answer=[]
correct=[False] * N
correctCount = 0
wrongCount = 0
wrong[False] * N
for k in range(M):
    n,a=input().split()
    num.append(int(n))
    answer.append(a)
    if a == "AC":
        if correct[n] == False:
            correct[n] = True
            correctCount += 1
            wrongCount += wrong[n]
    else:
        if correct[n] == False:
            wrong[n] += 1



    
#print(num)
#print(answer)
    
'''
preCorrect = False
correctCount=0
wrongCount = 0
temp_wrongCount = 0


for i in range(M):
    if i > 0 and num[i] != num[i-1]:
        if preCorrect == True:
            preCorrect = False
            temp_wrongCount = 0
        else:
            temp_wrongCount = 0
    
    
    if preCorrect == True:
        continue

    if answer[i] == "AC":
        correctCount += 1
        preCorrect = True
        wrongCount += temp_wrongCount
    if answer[i] == "WA":
        temp_wrongCount += 1
'''
print(correctCount, wrongCount)

Submission status: Runtime Error

Solution code:
N , M = map(int , input().split(" "))
#N = 100000
#M = 100000
solve_problem = [0] * N 
wa = [0] * N
ans = 0

for i in range(0,M):
    ps = input().split(" ")
    if ps[1] == "AC":
        if solve_problem[ int(ps[0]) -1] == 0:
            solve_problem[int(ps[0]) -1] = 1
            ans += 1
    elif ps[1] == "WA":
        if solve_problem[ int(ps[0])-1] == 0:
            wa[int(ps[0]) -1 ] += 1

print(ans,sum(wa[i] for i in range(0,N) if solve_problem[1] == 1))

Submission status: Runtime Error

Solution code:
N , M = map(int , input().split(" "))
#N = 100000
#M = 100000
solve_problem = [0] * N 
wa = [0] * N
ans = 0

for i in range(0,M):
    ps = input().split(" ")
    if ps[1] == "AC":
        if solve_problem[ int(ps[0]) -1] == 0:
            solve_problem[int(ps[0]) -1] = 1
            ans += 1
    elif ps[1] == "WA":
        if solve_problem[ int(ps[0])-1] == 0:
            wa[int(ps[0]) -1 ] += 1



print(ans,sum(wa[i] for i in range(0,N) if solve_problem[1] == 1))

Submission status: Runtime Error

Solution code:
n,m = map(int, input().split())
num_ac = 0
num_wa = 0
tmp_num_wa = 0
answerd = []

for i in range(m):
  p,s = input().split()
  if p in answerd:
    continue
  if s == 'WA':
    tmp_num_wa += 1
  if s == 'AC':
    num_ac += 1
    num_wa += tmp_num_wa
    tmp_num_wa = 0
    answerd.append(_p)
    
print(num_ac, num_wa)

Submission status: Runtime Error

Solution code:
N, M = [int(i) for i in input().split()]
l = max(N, M)
WA, AC = [0] * l, [False] * l
wa, ac = 0, 0
for i in range(M):
    inp = input().split()
    P, S = int(inp[0]), inp[1]
    if not AC[P] and S == "AC":
        AC[P] = True
        ac += 1
        wa += WA[P]
    elif S == "WA":
        WA[P] += 1
print(ac, wa)

Submission status: Runtime Error

Solution code:
N, M = [int(i) for i in input().split()]
WA, AC = [0] * M, [False] * M
wa, ac = 0, 0
for i in range(M):
    inp = input().split()
    P, S = int(inp[0]), inp[1]
    if S == "AC":
        AC[P] = True
        ac += 1
        wa += WA[P]
    elif S == "WA":
        WA[P] += 1
print(ac, wa)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(1000000)

N,M=map(int,input().split())
    
ACCNT=[False]*N
Asum=0
WACNT=[0]*N

for i in range(M):
    PI,SI=input().split()
    iii=int(PI)-1
    if ACCNT[iii]==False:
        if SI=="WA" :
            WACNT[iii]=WACNT[iii]+1
        elif SI=="AC" :
            ACCNT[iii]=True
            Asum=Asum+1

Wsum=0
for i in range(N):
    if ACCNT[iii]==True:
        Wsum=Wsum+WACNT[iii]

print(Asum,Wsum)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(100000)

N,M=map(int,input().split())
    
ACCNT=[False]*N
Asum=0
WACNT=[0]*N

for i in range(M):
    PI,SI=input().split()
    iii=int(PI)-1
    if ACCNT[iii]==False:
        if SI=="WA" :
            WACNT[iii]=WACNT[iii]+1
        elif SI=="AC" :
            ACCNT[iii]=True
            Asum=Asum+1

Wsum=0
for i in range(N):
    if ACCNT[iii]==True:
        Wsum=Wsum+WACNT[iii]

print(Asum,Wsum)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
    
ACCNT=[False]*N
Asum=0
WACNT=[0]*N

for i in range(M):
    PI,SI=input().split()
    iii=int(PI)-1
    if ACCNT[iii]==False:
        if SI=="WA" :
            WACNT[iii]=WACNT[iii]+1
        elif SI=="AC" :
            ACCNT[iii]=True
            Asum=Asum+1

Wsum=0
for i in range(N):
    if ACCNT[iii]==True:
        Wsum=Wsum+WACNT[iii]

print(Asum,Wsum)

Submission status: Runtime Error

Solution code:
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        string[] arr = Console.ReadLine().Split(' ');
        int N = int.Parse(arr[0]);
        int M = int.Parse(arr[1]);
        int ac = 0;
        int wa = 0;

        bool[] arrAC = new bool[N];
        int[] arrWA = new int[N];

        for (int i = 0; i < M; i++)
        {
            string[] ps = Console.ReadLine().Split(' ');
            int qNo = int.Parse(ps[0]);
            if (N < qNo || qNo < 1)
            {
                continue;
            }

            if (arrAC[qNo - 1])
            {
                wa += arrWA[qNo - 1];
                continue;
            }


            if (ps[1] == "AC")
            {
                arrAC[qNo - 1] = true;
                ac++;
            }
            else
            {
                arrWA[qNo - 1]++;
                wa++;
            }
        }

        Console.WriteLine(ac.ToString() + " " + wa.ToString());
    }
}

Submission status: Runtime Error

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

for i in range(m):
    p,s = map(str,input().split())
    p = int(p)-1 
    if s == "WA" and ac[p] == 0:
        wa[p] += 1
    elif s == "AC" and ac[p] == 0:
        ac[p] = 1
        pena += wa[p]   #waのみの問題はペナルティカウントされないため、acして初めてwaの回数を加算する
    elif ac[p] == 1:
        continue

print(str(sum(ac)) + " " + str(pena)

Submission status: Runtime Error

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

ac_list = [0] * (N + 1)
wa_list = [0] * (M + 1)
a = 0
w = 0
for i in range(M):
    l = input().split()
    if ac_list[int(l[0])]!='AC':
        if l[1] == 'AC':
            ac_list[int(l[0])] = 'AC'
            a += 1
            w += wa_list[int(l[0])]
        else:
            wa_list[int(l[0])] += 1

print('{} {}'.format(a, w))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys

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

#str_lines = [x.strip("\n") for x in sys.stdin.readlines()]

list_str_P_S = [input().split() for i in range(M)]

#-----
#-----

list_question_no=list(set(list(zip(*list_str_P_S))[0]))

#print("list_str_P_S=",list_str_P_S)
#print("list_question_no=",list_question_no)

count_AC=0
count_WA=0
list_temp=[]
list_next=[]
for str_i in list_question_no:

  for L in list_str_P_S:
    str_number = L[0]
    result = L[1]
    
    if str_number == str_i:
      list_temp.append(L)
    else:
      list_next.append(L)
  #print("list_temp",list_temp)
  #print("list_next",list_next)
  

  for L in list_temp:
    str_number = L[0]
    result = L[1]
    
    if str_number == str_i:
      if result == "WA":
        count_WA += 1
        #print("L",L,count_AC,count_WA)
      elif result == "AC":
        count_AC += 1
        #print("L",L,count_AC,count_WA)
        break
        
  list_str_P_S=list_next
  list_temp=[]
  list_next=[]
  #print("list_str_P_S next=",list_str_P_S)  
  #print("-----")

#print("ans=",count_AC,count_WA)
print(count_AC,count_WA)

Submission status: Runtime Error

Solution code:
import numpy as np

n, m = [int(i) for i in input().split()]
ans = [input().split() for _ in range(m)]
ans = np.array(ans)

ps = ans[:, 0]
ss = ans[:, 1]
sub_ps = np.unique(ps)

cnt_c, cnt_w = 0, 0
for sp in sub_ps:
  indices = np.where(ps==sp)[0]
  s_sp = ss[indices]
  if np.all(s_sp == 'WA'):
    continue
  num_ws = np.where(s_sp == 'AC')[0][0]
  cnt_w += num_ws
  cnt_c += 1

print(cnt_c, cnt_w)

Submission status: Runtime Error

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

ac = 0
wa = 0

x = 1
i = 0
while x <= N:
    if i >= M:
        break
    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())
ac = [0]*m
wa = [0]*m
for i in range(m):
    p,s = input().split()
    p = int(p)
    if ac[p-1]:
        continue
    if s == 'AC':
        ac[p-1] = 1
    else:
        wa[p-1] += 1
count_ac = 0
count_wa = 0
for i in range(n):
    count_ac += ac[i]
    if ac[i]:
        count_wa += wa[i]
print(str(count_ac) + " " + str(count_wa))

Submission status: Runtime Error

Solution code:
ABC151 C
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(str, input().split())
nl = lambda: list(map(int, input().split()))
from collections import defaultdict
n,m=map(int, input().split())
ac=set()
ac_cnt=0
wa_cnt=0
d_ac=defaultdict(int)
d_wa=defaultdict(int)
for i in range(m):
    p,s=nm()
    if s=='AC':
        if int(p) in ac:
            continue
        ac.add(int(p))
        ac_cnt+=1
    elif s=='WA':
        if int(p) in ac:
            continue
        d_wa[p]+=1
 
for a in ac:
    wa_cnt+=d_wa[str(a)]
 
print(ac_cnt,wa_cnt)

Submission status: Runtime Error

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

penalty = 0

corrected = {}
wa = {}

for i in range(m):
  pi, si = input().split()
  if (si == 'AC' and not corrected.get(pi)):
    corrected[pi] = True
  elif (si == 'WA' and not corrected.get(pi)):
    wa[pi] = wa[pi] + 1 if wa.get(pi) else 1

correct = len(corrected.keys())
for i in corrected.keys()
	penalty += wa[i] if  wa.get(i) else 0

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

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
l = [list(input().split()) for i in range(m)]
wa = [0]*(10**5)
ac = [0]*(10**5)
WA = 0
for i in range(m):
    p, s = input().split()
    P = int(p)
    if ac[P] != 1:
        if s == "WA":
            wa[P] += 1
        else:
            ac[P] += 1
            WA += wa[P]
print(sum(ac), WA)

Submission status: Runtime Error

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

penalty = 0

corrected = {}
wa = {}

for i in range(m):
  pi, si = input().split()
  if (si == 'AC' and not corrected.get(pi)):
    corrected[pi] = True
  elif (si == 'WA' and not corrected.get(pi)):
    wa[pi] += wa[pi]

correct = len(corrected.keys())
for i in corrected.keys()
	penalty += wa[i]

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

Submission status: Runtime Error

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

tmp_dict = {} # 作業辞書
result_dict = {} # 結果辞書
for i in range(M):
  quiz, res = input().split()	
  
  if quiz not in tmp_dict: # 作業辞書になければ作成
    if quiz not in result_dict: # 結果辞書にもなければ作成
      tmp_dict[quiz] = 0
    
  if res == "AC": # 正解
    wa_count = tmp_dict.pop(quiz)
    result_dict[quiz] = wa_count
    tmp_dict[quiz] = "ok"

  if res == "WA": # 間違い
    if tmp_dict[quiz] != "ok":
      tmp_dict[quiz] += 1


print(len(result_dict), sum(result_dict.values()))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
S=[[0, ""] for j in range(M)]
ACcheck=[False for j in range(N)]
AC=0
WA=[0 for j in range(N)]
WA2 = 0
for i in range(M):
  ps = input().split()
  S[i][0]=int(ps[0])
  S[i][1]=ps[1]
for i in range(M):
  if S[i][1]=="AC":
    if ACcheck[S[i][0]-1]==False:
      AC+=1
      ACcheck[S[i][0]-1]=True
      WA2+=WA[S[i][0]]
  else:
    if ACcheck[S[i][0]-1]==False:
      WA[S[i][0]]+=1

print(AC, WA2)

Submission status: Runtime Error

Solution code:
import numpy as np

n, m = map(int,input().split())
ac = [0]*(n+1)
ac = np.array(ac)
wa = [0]*(n+1)
wa = np.array(wa)

for i in range(m):
    p, s = map(str, input().split())
    p= int(p)
    if s == 'AC':
        ac[p] = 1
    elif ac[p] == 0:
        wa[p] += 1

wa= wa*ac
print(sum(ac), sum(wa))

Submission status: Runtime Error

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

Num = []
St = []

toi=set() #重複無しのset型で用意，リストの重複がないやつ
for i in range(m):
    p, s = input().split()
    #Num.append(int(p))
    #St.append(s)
#print(Num[0])
#print(St)
    p=int(p)

    if p in toi:
        continue #以降はスキップ
    
    if s=='AC':
        maru+=1
        toi.add(p) #そのpの時のとい番号を保存
    else: 
        pena[p]+=1
print(maru, sum(pena[i] for i in toi)) #各pの時のWAをたす

Submission status: Runtime Error

Solution code:
n, m = list(map(int, input().split(" ")))
a= 0 
w = 0
if n == 0 or m == 0:
  print("{} {}".format(a,w))
else:
  t = []
  for i in range(m):
    s, g = list(input().split(" "))
    t.append(s)
    t.append(g)
  j = t[0]
  wc = 0
  ac = 0
  for i in range(0,m,2):
    if str(i) == j:
      if t[i+1] == 'WC':
        wc += 1
      else:
        ac += 1
      	if t[i+2] != j:
          j = t[i+2]
    else:
      if t[i+2] != j:
        j = t[i+2]
        
  print("{} {}".format(ac,wc))

Submission status: Runtime Error

Solution code:
n, m = list(map(int, input().split(" ")))
a= 0 
w = 0
if n == 0 or m == 0:
  print("{} {}".format(a,w))
else:
  t = []
  for i in range(m):
    s, g = list(input().split(" "))
    t.append(s)
    t.append(g)
  j = t[0]
  wc = 0
  ac = 0
  for i in range(0,m,2):
    if i == j:
      if t[i+1] == 'WC':
        wc += 1
      else:
        ac += 1
      	if t[i+2] != j:
          j = t[i+2]
    else:
      if t[i+2] != j:
        j = t[i+2]
        
  print("{} {}".format(ac,wc))

Submission status: Runtime Error

Solution code:
n, m = list(map(int, input().split(" ")))
a= 0 
w = 0
if n == 0 or m == 0:
  print("{} {}".format(a,w))
else:
  t = []
  for i in range(m):
    s, t = list(input().split(" "))
    t.append(s)
    t.append(t)
  j = t[0]
  wc = 0
  ac = 0
  for i in range(0,m,2):
    if i == j:
      if t[i+1] == 'WC':
        wc += 1
      else:
        ac += 1
      	if t[i+2] != j:
          j = t[i+2]
    else:
      if t[i+2] != j:
        j = t[i+2]
        
  print("{} {}".format(ac,wc))

Submission status: Runtime Error

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

aclist = []
ac = 0
wac = 0
count = [0 for x in range(n+1)]

for i in range(m):
  a , b = input().split()
  int(a)
  if n >= 0:
    if n == "AC":
      ac += 1
      wac += count[a]
      count[a] = -1
    else:
      count[a] += 1

print(ac, wac)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n, m = list(map(int, input().split(" ")))
a= 0 
w = 0
if n == 0 or m == 0:
  print("{} {}".format(a,w))
else:
  t = []
  for i in range(m):
    s, t = list(map(int, input().split(" ")))
    t.append(s)
    t.append(t)
  j = t[0]
  wc = 0
  ac = 0
  for i in range(0,m,2):
    if i == j:
      if t[i+1] == 'WC':
        wc += 1
      else:
      	if t[i+2] != j:
          j = t[i+2]
    else:
      if t[i+2] != j:
        j = t[i+2]
        
  print("{} {}".format(ac,wc))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys

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

#str_lines = [x.strip("\n") for x in sys.stdin.readlines()]
str_lines = [input() for i in range(M)]

list_str_P_S=[]
for S in str_lines:
  list_str_P_S.append( list(S.split()) )

#-----
#-----

list_question_no=list(set(list(zip(*list_str_P_S))[0]))

#print("list_str_P_S=",list_str_P_S)
#print("list_question_no=",list_question_no)

count_AC=0
count_WA=0
for str_i in list_question_no:

  for L in list_str_P_S:
    str_number = L[0]
    result = L[1]
    
    if str_number == str_i:
      if result == "WA":
        count_WA += 1
        #print("L",L,count_AC,count_WA)
      elif result == "AC":
        count_AC += 1
        #print("L",L,count_AC,count_WA)
        break

#print("ans=",count_AC,count_WA)
print(count_AC,count_WA)

Submission status: Runtime Error

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


correct = [0] * (n+1)
wrong = [0] * (n+1)



for _ in range(m):
    problem,result_text = input().split()
    problem = int(problem)
    
    if result_text == "AC":
        correct[problem]=1
        
    
    if result_text == "WA":
        if correct[problem] == 0:
            wrong[problem] += 1
    

for _ in range(len(wrong)):
    if correct[problem] == 0:
        wrong[problem] = 0



print ( sum(correct), sum(wrong) )

Submission status: Runtime Error

Solution code:
import sys
import os
f = open('input.txt', 'r')
sys.stdin = f

N, M = list(map(int, input().split()))
list_WA = [0] * N
list_Flag = [0] * N
for i in range(M):
  a, b = list(map(str, input().split()))
  a=int(a)
  if list_Flag[a-1] == 1:
      pass
  else:
    if b=='WA':
      list_WA[a-1]=list_WA[a-1]+1
    elif b=='AC':
      list_Flag[a-1]=1
    else:
      pass
WA=sum(list_WA)
AC=sum(list_Flag)
ans=[AC,WA]
print(' '.join(map(str, ans)))

Submission status: Runtime Error

Solution code:
import numpy as np

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

numAC = [0]*N
numWA = [0]*N
flgAC = [0]*N

#print(num)

for ii in range(M):
  pi,Si = input().split()
  pi = int(pi)
  
  if flgAC[pi] == 0:
    if Si == "AC":
      numAC[pi] = 1
      flgAC[pi] = 1
    elif Si == "WA":
      numWA[pi] += 1

print(np.sum(numAC),np.sum(numWA))

Submission status: Runtime Error

Solution code:


N, M = map(int,input().split())
A = [list(map(str,input().split())) for _ in range(M)]
A = sorted(A, key=lambda x: x[0])

all_failure = 0
all_AC = 0
scan = 0
for j in range(N):
    while M <= scan:
        #print(j,i,int(A[scan][0]), A[scan][1])
        if int(A[scan][0]) == j+1 and A[scan][1] == "WA":
            all_failure += 1
            scan+=1
        elif int(A[scan][0]) == j+1 and A[scan][1] ==  "AC":
            all_AC+=1
            scan+=1
            break
        elif int(A[scan][0]) < j:
            scan += 1
        else:
            break
        
print(all_AC, all_failure)

Submission status: Runtime Error

Solution code:
n,m=map(int, input().split())
ac,wa=0,0
if m==0:
    print(ac,wa)
else: #一度飛ばして新たな問題を解いたうえで戻ってくる場合があるのか？
    l=[0]*n #正解処理の配列
    r=[0]*n #誤答カウンター
    for i in range(m):
        pa,s=map(str, input().split())
        p=int(pa)
        if l[p-1]==0 and s=='AC': #初正解時の処理
            l[p-1]=1
            ac+=1
        elif s=='WA': #誤答時の処理
            r[p-1]+=1
        else:
            continue
    for i in range(n):
        if l[i]==1:
            wa+=w[i]
        else:
            continue
    print(ac,wa)

Submission status: Runtime Error

Solution code:
all_failure = 0
all_AC = 0
scan = 0
for j in range(N):
    while M < scan:
        #print(j,i,int(A[scan][0]), A[scan][1])
        if int(A[scan][0]) == j+1 and A[scan][1] == "WA":
            all_failure += 1
            scan+=1
        elif int(A[scan][0]) == j+1 and A[scan][1] ==  "AC":
            all_AC+=1
            scan+=1
            break
        elif int(A[scan][0]) < j:
            scan += 1
        else:
            break
        
print(all_AC, all_failure)

Submission status: Runtime Error

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

AC = []
WC = []
ansAC
ansRC

for i in range(0, M):
    AC[i] = False
    WA[i] = 0

for m in range(0, M):
    p, s = input().split()
    # 正解
    if s == "AC" and int(p) <= N:
        AC[p] = True
        ansAC +=1
        ansWC += WA[p]
    # WAかつ未正解
    elif s == "WA" and (p not in ans):
        WA[p] +=1
    else:
        continue

print(len(set(ans)), pena)

Submission status: Runtime Error

Solution code:
[n,m] = [int(x) for x in input().split()]
ac=[0]*(n+1)
wa=[0]*(n+1)
cnt_ac=0
cnt_wa=0
for i in range(m):
	p,s=input().split()
	p=int(p)
	if s=="AC":
		if	fac[p]==0:
			cnt_ac+=1
			cnt_wa+=wa[p]
			ac[p]=1
		
	else: 
		wa[p]+=1

print(int(cnt_ac),int(cnt_wa))

Submission status: Runtime Error

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

# 最大公約数 
def gcd(a, b):
  if a < b:
      a, b = b, a
  while a % b != 0:
      a, b = b, a % b
  return b

# 最小公倍数
def lcm(a, b):
  y = a*b / gcd(a, b)
  return int(y)

n, m = MAP()


L = []
for i in range(m):
  l = S_LIST()
  L.append(l)

# wa

wa = [0] * n
ac = [0] * n


for i in range(m):
  p = int(L[i][0])-1
  ans = L[i][1]
  if ans == "WA":
    # まだacない
    if ac[p] == 0:
      wa[p] = wa[p] + 1
  # acあった
  if ans == "AC":
    ac[p] = 1

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


print(sum(ac), sum(wa))


# for p in range(1, n+1):
#   if L[i][0] == str(p):
#     for i in range(m):
#       if L[i][1] == "WA":
#         wa += 1

#     for i in range(m):
#       if L[i][1] == "AC":
#         ac += 1
#   print(wa)
#   print(ac)

Submission status: Runtime Error

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

pn_num=0
AC_list=[0]*N

for _ in range(M):
    pi,Si=input().split()
    pi=int(pi-1)
        
    if Si=='AC':
        AC_list[pi]=1
    
    else:
        if AC_list[pi]==0:
            pn_num+=1
    
print(sum(AC_list),pn_num)

Submission status: Runtime Error

Solution code:

def solve(N, M, A):

    Unsolve = [0]*(N+1)
    Solved = []
    ac = 0
    wa = 0
    for i in range(M):
        if A[i][0] not in Solved:
            if A[i][1] == 'WA':
                Unsolve[A[i][0]] += 1
            elif A[i][1] == 'AC':
                Solved.append(A[i][0])
                wa += Unsolve[A[i][0]]
                ac += 1
    return ac, wa

def main():
    N, M = map(int, input().split())
    A = [list(x for x in input().split()) for _ in range(M)]
    ans = solve(N, M, A)
    print(*ans)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
ans1 = 0
ans2 = 0
preans2 = 0
check = 0
t = []
pret = []

for i in range(m):
  pret = list(map(str, input().split()))
  t.append(pret)
  
for i in range(m):
  if t[i][1] == "WA":
    if check = 0:
      preans2 += 1
  else:
    if check = 0:
      ans1 += 1
      ans2 += preans2
      preans2 = 0
      check += 1
    else:
      ans1 += 1
      check += 1
  if i > 0:
    if t[i][0] != t[i-1][0]:
      check = 0
      
print(ans1, ans2)

Submission status: Runtime Error

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

n,m=map(int,input().split())
l=[list(input().split()) for _ in range(m)]
 
p=[0]*m
wa=0

for i in range(m):
  if l[i][1]=="AC":
    wa += p[int(l[i][0])]
    p[int(l[i][0])]= -1
  elif l[i][1]=="WA":
    if p[int(l[i][0])] != -1:
      p[int(l[i][0])] += 1
      
print(p.count(-1),wa)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
flag=[0]*N
wa_count=[0]*N
WA=0
AC=0
for i in range(m):
  index,res=input().split()
  index=int(index)-1
  if res[0]=="A" and flag[index]==0:
    flag[index]=1
    AC+=1
    WA+=wa_count[index]
  elif res[0]=="W":wa_count[index]+=1
print(AC,WA)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
li = []
for i in range(m):
  li.append(list(input().split()))
li_a = [0 for i in range(n)]
li_b = [0 for i in range(n)]
a = 0
b = 0
for j in range(m):
  if li[j][1] == "WA":
    li_b[int(li[j][0])] += 1
  elif li[j][1] == "AC" and li_a[int(li[j][0])] == 0:
    a += 1
    b += li_b[int(li[j][0])]
    li_a[int(li[j][0])] += 1
print(a, b)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
flag=[0]*n
wa_count=[0]*n
WA=0
AC=0
for i in range(m):
  index,res=input().split()
  index=int(index)-1
  if res[0]=="A" and flag[index]==0:
    flag[index]=1
    AC+=1
    WA+=wa_count[index]
  elif res[0]=="W":wa_count[index]+=1
print(AC,WA)

Submission status: Runtime Error

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

aclist = [0]*n
walist = [0]*n
acflag = [False]*n

for i in range(m):
  pp, s = input().split()
  p = int(pp)
  if s == 'AC':
    if acflag[p]:
      pass
    else:
      aclist[p] += 1
      acflag[p] = True
  else:
    if acflag[p]:
      pass
    else:
      walist[p] += 1
  

print(sum(aclist), sum(walist))

Submission status: Runtime Error

Solution code:
n=int(n)
m=int(m)
x=[false for i in range(n)]
count=[0 for i in range(n)]
for i in range(m):
  p,s=input().split()
  p=int(p)
  if(not x[p-1]):
    if(s=="AC"):
      x[p-1]=true
    else:
      count[p-1]=count[p-1]+1
ans=0
ans2=0
for i in range(ansn):
  if(x[i]):
    ans+=1
    ans2+=count[i]
print(ans,ans2)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
AC = 0
WA = 0
lis = [0] * N
for i in range(M):
  a,b = map(input().split())
  if lis[int(a)-1] < 0:
    pass
  elif b == 'AC':
    WA += lis[int(a)-1]
    AC += 1
    lis[int(a)-1] = -1
  else:
    lis[int(a)-1] += 1
print(AC, WA)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
li = []
for i in range(m):
  li.append(list(input().split()))
li_a = [0 for i in range(m)]
li_b = [0 for i in range(m)]
a = 0
b = 0
for j in range(m):
  if li[j][1] == "WA":
    li_b[int(li[j][0])] += 1
  elif li[j][1] == "AC" and li_a[int(li[j][0])] == 0:
    a += 1
    b += li_b[int(li[j][0])]
    li_a[int(li[j][0])] += 1
print(a, b)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
flag=[0]*n
wa_count=[0]*n
WA=0
AC=0
for i in range(m):
  index,res=input().split()
  index=int(index)-1
  if res[0]=="A" and flag[index]==0:
    flag[index]=1
    AC+=1
    WA+=wa_count[index]
  elif res[0]=="W":wc_count[index]+=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.append([int(p), s])
flag = [False for _ in range(n)]
ac = [0 for _ in range(n)]
wa = [0 for _ in range(n)]
i = 0
sumac = 0
sumwa = 0

for i in range(m):
    p = ps[i][0]
    s = ps[i][1]
    if s == "WA" and ac[p - 1] == 0:
        wa[p - 1] += 1
    elif s == "AC" and ac[p - 1] == 0:
        ac[p - 1] += 1
        sumac += 1
        sumwa += wa[p - 1]

print(str(int(ac)) + " " + str(int(wa)))

Submission status: Runtime Error

Solution code:
import sys

def main():
    N, M = list(map(int, input().split()))
    
    inputs = [input().split() for i in range(M)]
    has_been_solved = set()

    penalty = {}
    correct = 0

    for i in inputs:
        
        num = int(i[0])
        if num in has_been_solved:
            continue

        if i[1] == 'AC':
            correct += 1
            has_been_solved.add(num)
        else:
            if num not in penalty:
                penalty[num] = 1
            else:
                penalty[num] += 1
    print(correct, sum([penalty[p] for p in has_been_solved]))         
        

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
AC = 0
WA = 0
lis = [0] * N
for i in range(M):
  a,b = map(input().split())
  if lis[int(a)-1] < 0:
    pass
  elif b == 'AC'
    WA += lis[int(a)-1]
    AC += 1
    lis[int(a)-1] = -1
  else:
    lis[int(a)-1] += 1
print(AC, WA)