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

if __name__ == "__main__":
    main()

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[j] == 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:
# coding UTF-8
# 
# problem C
# 

import pandas as pd

t = []
N, M = map(int, input().split())
for i in range(M):
    t.append(tuple(input().split(' ')))

df = pd.DataFrame(t, columns=['p', 'S'])
alist = df.groupby('p')['S'].apply(list)

#print(df)
#print(alist)

#print(alist[0])

#print(alist.apply(lambda d: d[:d.index('AC')))


c = 0
NG = 0
for i in range(len(alist)):
    #print(alist[i])
    try:
        k = alist[i].index('AC')
    except ValueError:
        NGtmp = alist[i].count('WA')
        NG = NG + NGtmp
    else:
        #print(k)
        #print(alist[:k])
        NGtmp = alist[i][:k].count('WA')
        c = c + 1
        NG = NG + NGtmp

#print(c)
#print(NG)

print('{} {}'.format(c, NG))

Submission status: Runtime Error

Solution code:
F_str = input().split()
F = [int(f) for f in F_str]
N = F[0]
M = F[1]

WA_list = [0 for _ in range(N)]
AC_list = []

for i in range(M):
    S_str = input().split()
    S = [str(s) for s in S_str]
    if(S[1] == "AC"):
        AC_list.append(S[0])
        AC_list = list(set(AC_list))
    elif(not(S[0] in AC_list)):
        WA_list[int(S[0])-1] += 1
        
WA_count = 0

for item in AC_list:
    WA_count += WA_list[int(item)-1]

print(str(len(AC_list)) + " " + str(sum(WA_count)))

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[j] == 0:
    a += 1
    b += li_b[int(li[j][0])]
    li_a[j] += 1
print(a, b)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
P=[]
S=[]

N,M = map(int, input().split(' '))
for i in range(M):
    p,s=map(str,input().split(' '))
    P+=p
    S+=[s]    
P=[int(p) for p in P]

Q=[]
for i in range(N):
    Q+=[[]]

for i in range(M):
    for j in  range(N):
        if P[i] == j+1 :
            Q[j]+=[S[i]]
            
        
A=0
B=0
b=0

for  i in range(len(Q):
    for j in range(len(Q[i])):
        b=0
        if Q[i][j]==[]:
            break
        elif Q[i][j]=='WA':
            b +=1
        elif Q[i][j]=='AC':
            A +=1
            B+=b
            break
            
print(A,B)

Submission status: Runtime Error

Solution code:
N, M = list(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])

dp = [[0] * 2 for i in range(N)]  # x問目の、score, 正答までのwrong_ans                                               #dp = [[0] * 2 for i in range(100005)]  # x問目の、score, penalty

for i in range(M):
    num = p[i] - 1
    # 未得点のときだけ影響
    if(dp[num][0] == 0):
         if(S[i] == 'WA'):
             dp[num][1] += 1
             continue

         elif(S[i] == 'AC'):
             dp[num][0] += 1
             continue
         else:
             print("S is ??")

score = 0
penalty = 0
for i in range(len(dp)):
    score += dp[i][0]
    penalty += dp[i][1]

print(score, penalty)
~

Submission status: Runtime Error

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


ac = 0
wa = 0
aclist = {}
walist = {}

count_WA=0
for i in range(n):
    aclist[i + 1] = 0
    walist[i + 1] = 0

for i in range(M):
    a,b=input().split()
    a=int(a)
    if aclist[a] == 1:
        continue
    elif b == 'WA':
        walist[a] += 1
    elif b == 'AC':
        aclist[a] += 1
        ac += 1
        wa += walist[a]




print(ac,wa,sep=" ")

Submission status: Runtime Error

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

pn_num=0
WA_list=[0]*N
AC_list=[0]*N

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

Submission status: Runtime Error

Solution code:
F_str = input().split()
F = [int(f) for f in F_str]
N = F[0]
M = F[1]

WA_list = [0 for _ in range(N)]
AC_list = []

for i in range(M):
    S_str = input().split()
    S = [str(s) for s in S_str]
    if(S[1] == "AC"):
        AC_list.append(S[0])
    elif(not(S[0] in AC_list)):
        WA_list[int(S[0])-1] += 1

AC_set = list(set(AC_list))

WA_count = 0

for item in AC_set:
    WA_count += WA_list[int(item)-1]

print(str(len(AC_set)) + " " + str(sum(WA_count)))

Submission status: Runtime Error

Solution code:
N,M= map(int,input().split())
L = [list(map(str,input().split())) for i in range(M)]
AC =0
WA =0
list =  [[] for i in range(N)]

for id,res in L:
    list[id-1].append(res)

for j in list:
    for i in j:
        if i =='AC':
            AC += 1
            WA += WC
            WC = 0
            break
        else:
            WC += 1

print(str(AC)+ ' '+str(WA))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
p = []
S = []
for i in range(M):
    pp, SS = map(str, input().split())
    p.append(pp)
    S.append(SS)

a = []
for i in range(M):
    a.append(int(p[i]))

AC = 0
P = 0

Q = []
R = []
for i in range(N):
    Q.append(0)
    R.append(0)

for i in range(M):
    index = a[i] - 1
    if Q[index] == 0 and S[i] == 'AC':
        AC = AC + 1
        Q[index] = 1
    elif Q[index] == 0 and S[i] == 'WA':
        R[i - 1] = R[i - 1] + 1

for i in range(N):
    if Q[i] == 0:
        P = 0
    else: P = P + R[i]

print(AC, P)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
p = []
S = []
for i in range(M):
    pp, SS = map(str, input().split())
    p.append(pp)
    S.append(SS)

a = []
for i in range(M):
    a.append(int(p[i]))

AC = 0
P = 0

Q = []
R = []
for i in range(N):
    Q.append(0)
    R.append(0)

for i in range(M):
    index = a[i] - 1
    if Q[index] == 0 and S[i] == 'AC':
        AC = AC + 1
        Q[index] = 1
    elif Q[index] == 0 and S[i] == 'WA':
        R[i] = R[i] + 1

for i in range(N):
    if Q[i] == 0:
        P = 0
    else: P = P + R[i]

print(AC, P)

Submission status: Runtime Error

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


def f(s):
  lst = s.split()
  return int(lst[0]),lst[1]

for i in range(M):
  p, s = f(input())
  P.append(p)
  S.append(s)

correct = 0
penalty = 0
q = []
p = []

for i, j in enumerate(S):
  if 'AC' in j:
    if P[i] not in q:
      q.append(P[i])
      correct += 1
    else:
      continue
  if 'WA' in j:
    p.append(P[i])
    if P[i] not in q:
        penalty += 1
    else:
      continue
    if S(P.index(P[i])) == 'AC':
      prenalty -= 1

'''
for i in range(len(p)):
  if p[i] not in q:
    penalty -= 1
'''

print(correct, penalty)

Submission status: Runtime Error

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

ac = 0
wa = []
ansed = []
for psn in ps:
    if psn[1] == 'AC':
        if psn[0] not in ansed:
            ac += 1
            ansed.append(psn[0])
    else:
        if psn[0] not in ansed:
            wa[int(psn[0])-1] += 1
for i in range(N):
    if str(i+1) not in ansed:
        wa[i] = 0

print(ac, sum(wa))

Submission status: Runtime Error

Solution code:
def main():
    N, M= map(int, input().split())
    
    acList = [False] * N
    waList = [0] * N
    waCount = 0

    for _ in range(M):
        p, s = map(str, input().split())
        p = int(p) - 1
        if atList[p]:
            continue
        if s == "WA":
            waList[p] += 1
            continue
        waCount += waList[p]
        acList[p] = True

    print(sum(acList), waCount)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N, M = list(map(int, input().split()))
list_WA = [0] * N
list_Flag = [0] * N
for i in range(M):
  a, b = list(map(int, input().split()))
  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)
print(AC,WA)

Submission status: Runtime Error

Solution code:
import sys
s = sys.stdin.readlines()

c = res.append
a = 0
b = 0
c = 0
N, M = map(int, s[0].split())
for e in s[1:M + 1]:
  p, S = e.split()
  if p not in c:
    if S == 'AC':
        c(p)
        a += 1
        c = b
    else:
        b += 1

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

Submission status: Runtime Error

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

    
for i in range(M):
    p,s=input().split()
    if p not in ac:
        if p not in key:
            key.append(p)
            wa[P[i]]=0

        if s=="WA":
            wa[p]+=1
        else:
            ac.append(p)
ans=0
for i in key:
    if i in ac:
        ans+=wa[i]
print(len(ac),ans)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
p = [0]*M
s = [a]*M
for i in range(M):
    p[i],s[i] = map(str,input().split())
pans = 0
sans = 0

for j in range(N):
    for k,val in enumerate(p):
        if val == str(j+1) and s[k] == "WA":
            sans += 1
        elif val == str(j+1) and s[k] == "AC":
            pans += 1
            break
print(pans,sans)

Submission status: Runtime Error

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

ac = [0 for i in range(N)]
wa = [0 for i in range(N)]

for i in range(M):
    s = int(ps[i][0])-1
    if ps[i][1] == "WA" and ac[s] == 0:
        wa[s] += 1

    if ps[i][1] == "AC" and ac[s] == 0:
        ac[s] = 1

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

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

Submission status: Runtime Error

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

ac = [0 for i in range(N)]
wa = [0 for i in range(N)]

for i in range(M):
    s = int(ps[i][0])-1
    if ps[i][1] == "WA" and ac[s] == 0:
        wa[s] += 1

    if ps[i][1] == "AC" and ac[s] == 0:
        ac[s] = 1

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

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

Submission status: Runtime Error

Solution code:
def main():
    N, M = list(map(int, input().split()))
    inputs = [input().split() for i in range(M)]
    
    inputs = inputs.split()
    inputs = [[inputs[i], inputs[i + 1]] for i in range(0, len(inputs), 2)]
    print(inputs)
    has_been_solved = set()

    penalty = 0
    correct = 0
    for i in inputs:
        num = int(i[0])
        if num not in has_been_solved and i[1] == 'AC':
            has_been_solved.add(num)
        elif num not in has_been_solved and i[1] != 'AC':
            penalty += 1
    correct = len(has_been_solved)
    
    print(correct, penalty)            
        

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def main():
    # N, M = list(map(int, input().split()))
    # inputs = [input().split() for i in range(M)]
    with open('./abc151/test.txt', 'r') as f:
        inputs = f.read()
        f.close()
    inputs = inputs.split()
    inputs = [[inputs[i], inputs[i + 1]] for i in range(0, len(inputs), 2)]
    print(inputs)
    has_been_solved = set()

    penalty = 0
    correct = 0
    for i in inputs:
        num = int(i[0])
        if num not in has_been_solved and i[1] == 'AC':
            has_been_solved.add(num)
        elif num not in has_been_solved and i[1] != 'AC':
            penalty += 1
    correct = len(has_been_solved)
    
    print(correct, penalty)            
        

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
nm = [int(i) for i in input().split()]
ac = 0
wa = 0
sub = []
for i in range(0, nm[1]):
    seen = set()
    seen_add = seen.add
    sub.append([i for i in input().split() if not (i in seen or seen_add)])
sub = list(set(map(tuple, sub)))
for i in range(0, len(sub)):
    if sub[i][1] == "AC":
        ac += 1
    elif sub[i][1] == "WA":
        wa += 1
    else:
        continue

print(ac, end=" ")
print(wa)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
ans = [input().split() for _ in range(m)]
ac = ()
wn = ()
acn,wan = 0,0
for i in ans:
  if i[0] not in ac:
    if i[1] == 'AC' :
      wan += wn.count(i[0])
      ac += (i[0])
      acn += 1
    else :
      wn += (i[0])
print(acn,wan)

Submission status: Runtime Error

Solution code:
N, M = list(map(int, input().split()))
lst = [input().split() for lst in range(M)]
lst.sort(key=lambda x: x[0])
pn = 0
temp_pn = [] 
for _ in range(M):
  temp_pn.append(0)
cr = 0
plbnum = 0
for i in lst:
  a = int(i[0])
  if N >=  a > plbnum:
    if i[1] == "WA":
      temp_pn[a-1] += 1
    elif i[1] == "AC":
      cr += 1
      pn += temp_pn[a-1]
      plbnum = a
print(cr, pn)

Submission status: Runtime Error

Solution code:
nm = list(map(int, (input().split())))
if nm[1] == 0:
    print(0, 0)

else:    
    ans_dict = {}
    ans_list = [input().split() for i in range(nm[1])]
    for i in range(len(ans_list)):
        key_val = ans_list[i][0]

        try:
            ans_dict[key_val].append(ans_list[i][1])
        except:
            ans_dict[key_val] = [ans_list[i][1]]
    ans_cnt = 0
    wa_cnt = 0
    for key_val in ans_dict.keys():
        check_list = ans_dict[key_val]

        if "AC" in check_list:
            ans_cnt += 1
        else:
            pass
        try:
            wa_cnt += len(check_list[:check_list.index("AC")])
        except:
            pass
print(ans_cnt, wa_cnt)

Submission status: Runtime Error

Solution code:
# coding UTF-8
# 
# problem C
# 

import pandas as pd

t = []
N, M = map(int, input().split())
for i in range(M):
    t.append(tuple(input().split(' ')))

df = pd.DataFrame(t, columns=['p', 'S'])
alist = df.groupby('p')['S'].apply(list)

#print(df)
#print(alist)

#print(alist[0])

#print(alist.apply(lambda d: d[:d.index('AC')))

c = 0
NG = 0
for i in range(M):
    try:
        k = alist[i].index('AC')
    except:
        NGtmp = alist[i].count('WA')
        NG = NG + NGtmp
    else:
        NGtmp = alist[:k].count('WA')
        c = c + 1
        NG = NG + NGtmp

print('%s %s'%(c, NG))

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
wa=0
ac=0
Q=list(range(N))
for i in range(N):
    Q[i]=True

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

print(ac,wa)

Submission status: Runtime Error

Solution code:
N, M = list(map(int, input().split()))
lst = [input().split() for lst in range(M)]
lst.sort(key=lambda x: x[0])
pn = 0
temp_pn = [] 
for _ in range(M):
  temp_pn.append(0)
cr = 0
plbnum = 0
for i in lst:
  a = int(i[0])
  if N >=  a > plbnum:
    if i[1] == "WA":
      temp_pn[a] += 1
    elif i[1] == "AC":
      cr += 1
      pn += temp_pn[a-1]
      plbnum = a
print(cr, pn)

Submission status: Runtime Error

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

for x in range(M):
    pS[x][0] = int(pS[x][0])
    
Ans, Pen = 0, 0
for x in range(M):
    if (pS[x][0] != pS[x-1][0]):
        pS_temp = 0
        Ans_temp = 0
    if (pS[x][1] == 'AC') and (pS_temp == 0):
        Ans += 1
        Ans_temp += 1
        pS_temp += 1
    elif (pS[x][1] == 'WA') and (pS_temp == 0) and (Ans_temp == 0):
        Pen += 1
print(Ans, Pen)

Submission status: Runtime Error

Solution code:
# coding UTF-8
# 
# problem C
# 

import pandas as pd

t = []
N, M = map(int, input().split())
for i in range(M):
    t.append(tuple(input().split(' ')))

df = pd.DataFrame(t, columns=['p', 'S'])
alist = df.groupby('p')['S'].apply(list)

print(df)
print(alist)

print(alist[0])

print(alist.apply(lambda d: d[:d.index('AC')))

c = 0
NG = 0
for i in range(M):
    try:
        k = alist[i].index('AC')
    except:
        NGtmp = alist[i].count('WA')
        NG = NG + NGtmp
    else:
        NGtmp = alist[:k].count('WA')
        c = c + 1
        NG = NG + NGtmp

print('%s %s'%(c, NG))

Submission status: Runtime Error

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

for i in range(m):
  p, s = input().split()
  if a.get(p) == None:
    a[p] = list()
  a[p].append(s)

for k, v in a.items():
  sum += a.find('AC')

print(sum)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
if m==0:
    print(0,0)
    exit()
l=[]
for i in range(m):
    x,y=input().split()
    l.append([int(x),y])
l=sorted(l,key=lambda x:x[0])
ac=0
wa=0
tmp=0
t=[0]*(n+1)

for i in range(m):
    if tmp==l[i][0]:
        continue
    if l[i][1]=="WA":
        wa+=1
    elif l[i][1]=="AC":
        ac+=1
        tmp=l[i][0]
print(ac,wa)

Submission status: Runtime Error

Solution code:
import itertools
n, m = map(int, input().split())
P = [input().split() for i in range(m)]
P = list(itertools.chain.from_iterable(P))
ac_list = []
wa_list = [0] * n

counta = 0
countb = 0
for i in range(1, m * 2, 2):
    if P[i] == "AC" and:
        if int(P[i - 1]) not in ac_list:
            counta += 1
            ac_list.append(int(P[i - 1]))
            countb += wa_list[int(P[i - 1]) - 1]
    else:
        wa_list[int(P[i - 1]) - 1] += 1
print(counta, countb)

Submission status: Runtime Error

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

AC = 0
WA = 0
x = 0
ACs = []
y = 0
for i in range(0, N):
    if P[i][1] == 'WA':
        x += 1
    elif P[i][1] == 'AC':
        for s in ACs:
            if s == P[i][0]:
                y = 1
        if y == 0:
            AC += 1
            WA += x
            x = 0
            ACs.append(P[i][0])
        y = 0

print(AC, WA)

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]=map(str,input().split())
    p[i]=int(p[i])
a=0
w=0
k=p[0]
x=0
y=0
for i in range(m):
    if p[i]!=k:
        
        k=p[i]
        x=0
        y=0
    if s[i]=="AC":
        x+=1
        if x==1:
            a+=1
    if s[i]=="WA" and x==0:
        w+=1
print(a,w)

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

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

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)
    elif toi != ps[i][0] and ps_new[i][1] == "AC":
        count+=1
print(count1,count3)

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 [j for j in al if j[0] in al_a]:
  if j[1] == 'AC':
    al_a.remove(j[0])
  else:
    r2 += 1
    
print(r1 ,r2)

Submission status: Runtime Error

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

WA_count, AC_count = 0, 0
P_set = list(set(P))
for i in range(len(P_set)):
  Pi_index = [j for j, x in enumerate(P) if x == P_set[i]]
  S_P_list = []
  for k in Pi_index :
    S_P_list.append(S[k])
  WA_counter = len(S_P_list[:S_P_list.index('AC')])
  
  WA_count += WA_counter
  AC_count += 1
      
print(AC_count, WA_count)

Submission status: Runtime Error

Solution code:
ACcnt = 0
WAcnt = 0

N, M = map(int,input().split())
P = ""
result = []

for i in range(M):
  result.append(input().split())
  if i == 0:
    P = result[i][0]
  if i > 0 and P != result[i][0]
     P = result[i][0]
  if P == result[i][0]:
    if result[i][1] == "AC":
      P = result[i][0]
      ACcnt += 1
    elif result[i][1] == "WA":
      WAcnt += 1
  else:
    pass

print(str(ACcnt) + " " + str(WAcnt))

Submission status: Runtime Error

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

for x in range(M):
    pS[x][0] = int(pS[x][0])
    
Ans, Pen = 0, 0
for x in range(M):
    if (pS[x][0] != pS[x-1][0]):
        pS_temp = 0
        Ans_temp = 0
    if (pS[x][1] == 'AC') and (pS_temp == 0):
        Ans += 1
        Ans_temp += 1
        pS_temp += 1
    elif (pS[y][1] == 'WA') and (pS_temp == 0) and (Ans_temp == 0):
        Pen += 1
print(Ans, Pen)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
p=[]
s=[]
start=0
idx=0
AC=0
WA=0
count=0
for i in range(m):
    p_,s_=input().split()
    p.append(int(p_))
    s.append(s_)
for i in range(m):
    count=p.count(p[idx])
    if s[start:start+count].count('AC')>=1:
        AC+=1
        WA+=s[start:s[start:start+count].index('AC')+start].count('WA')
    else:
        WA+=s[start:start+count].count('WA')
    start=start+count
    idx=start
    if start==m:
        break
print("{} {}".format(AC,WA))

Submission status: Runtime Error

Solution code:
N, M = list(map(int, input().split()))
lst = [input().split() for lst in range(M)]
lst.sort(key=lambda x: x[0])
pn = 0
temp_pn = [] 
for _ in range(M):
  temp_pn.append(0)
cr = 0
plbnum = 0
for i in lst:
  a = int(i[0])
  if N >=  a > plbnum:
    if i[1] == "WA":
      temp_pn[a] += 1
    elif i[1] == "AC":
      cr += 1
      pn += temp_pn[a]
      plbnum = a
print(cr, pn)

Submission status: Runtime Error

Solution code:
P=[]
S=[]

N,M = map(int, input().split(' '))
for i in range(M):
    p,s=map(str,input().split(' '))
    P+=p
    S+=[s]    
P=[int(p) for p in P]

Q=[]
for i in range(N):
    Q+=[[]]

for i in range(M):
    for j in  range(N):
        if P[i] == j+1 :
            Q[j]+=[S[i]]
            
print(Q)
        
A=0
B=0

for  i in range(N):
    for j in range(len(Q)):
        if Q[i][j]=='WA':
            B +=1
        elif Q[i][j]=='AC':
            A +=1
            break
            
print(A,B)

Submission status: Runtime Error

Solution code:
N, M = list(map(int, input().split()))
list_WA = [0]*N
list_Flag = [0]*N
for i in range(M):
  a, b = list(map(int, input().split()))
  if list_Flag[a-1] == 1:
	pass
  else:
    if b=='WA':
      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(*ans)

Submission status: Runtime Error

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

y = ['WA' if (x[i][1]=='WA' and i<x.index([x[i][0], 'AC'])) else 'AC' if (x[i][1]=='AC' and i==x.index(x[i])) else 'None' for i in range(m)]
print(y.count('AC'), y.count('WA'))

Submission status: Runtime Error

Solution code:
nm = list(map(int, (input().split())))
if nm[1] == 0:
    print(0, 0)

else:    
    ans_dict = {}
    ans_list = [input().split() for i in range(nm[1])]
    for i in range(len(ans_list)):
        key_val = ans_list[i][0]

        try:
            ans_dict[key_val].append(ans_list[i][1])
        except:
            ans_dict[key_val] = [ans_list[i][1]]
    ans_cnt = 0
    wa_cnt = 0
    for key_val in ans_dict.keys():
        check_list = ans_dict[key_val]

        if "AC" in check_list:
            ans_cnt += 1
        else:
            pass
        try:
            check_list.index("AC")
            wa_cnt += len(check_list[:check_list.index("AC")])
        except:
            pass
print(ans_cnt, wa_cnt)

Submission status: Runtime Error

Solution code:
A = list(map(int,input().split()))
B = []
for i in range(A[1]):
    a,b=input().split()
    B.append((int(a), b))

C = [0] * A[0]
X = [0] * A[0]

D = []
for j in range(A[1]):
    for l in range(A[0]):
        if B[j][0]==l+1:
            if X[l] = 1:
                pass
            elif B[j][1] == 'WA':
                C[l] = C[l] +1
            elif B[j][1] == 'AC' and X[l] == 0:
                X[l] = 1
                D.append(C[l])
print(len(D),sum(D))

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split(" "))
nac = 0
npe = 0
cp = 0
is_ac = [False]*n
np_list = [0]*n
for i in range(m):
  p_s, s = input().split(" ")
  p = int(p_s)-1
  cis_ac = is_ac[p]
  
  if cis_ac:
    continue
  if s == "AC":
    nac += 1
    is_ac[p]=True
  else:
    np_list[p] += 1

for a in is_ac:
  if a:
    npe += np_list[a]
print(str(nac)+" "+str(npe))

Submission status: Runtime Error

Solution code:
import sys
N,M = map(int,input().split())
if M == 0:
    print('%d %d' % (0,0))
    sys.exit(0)
Liste = dict()
Question = [0] * M
ACorWE = [0] * M
Z = 0
correct = 0
pena = 0
for i in range(M):
    Question[i], ACorWE[i]= map(str, input().split())
Question = [int(element) for element in Question]
for _ in range(max((max(Question)+1),len(ACorWE))): #range(max(Question)+1) before
    Liste[_] = [0] 
#Liste[4].append(0) 
#print(Liste)
#print(Question) #[1, 1, 2, 2, 2]
#print(ACorWE) #['WA', 'AC', 'WA', 'AC', 'WA']
for i in range(M): ###for i in range(M) before 
    Liste[Question[i]].append(ACorWE[i])
    #print(Liste)
    Liste[i].remove(0)
#print(Liste)
#{0: [], 1: ['WA', 'AC'], 2: ['WA', 'AC', 'WA'], 3: [], 4: []}

for i in range(1,len(Liste)): #range(1,max(Question)+1) before
    if 'AC' in Liste[i] and Z == 0:
        correct += 1
        Z = 1
    Z = 0
for i in range(1,len(Liste)): #range(1,max(Question)+1) before
    for j in range(len(Liste[i])):
        if j <= len(Liste[i]) -2:
            if Liste[i][j] == 'WA' and Liste[i][j+1] == 'AC' and　(i == max(Question)):
                pena += 1
                print('%d %d' % (correct,pena))
                sys.exit(0)
            elif Liste[i][j] == 'WA' and Liste[i][j+1] == 'AC':
                pena += 1
                break
            elif Liste[i][j] == 'WA' and Liste[i][j+1] == 'WA':
                pena += 1
#高橋君が AC を 1 回以上出した各問題において、初めて AC を出すまでに出した WA の数の総和です。
print('%d %d' % (correct,pena))

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
sekai = 0
wrong = [0]*(10**5)
ans = 0
problem = []

for i in range(M):
  p,S = map(str,input().split())
  if (S == 'AC') and (p not in problem):
    problem.append(p)
    sekai += 1
  elif(S=='WA') and (p not in problem):
    wrong[p] += 1

for j in problem:
  ans += wrong[int(j)]
print(sekai, ans)

Submission status: Runtime Error

Solution code:
import ita
qus = list(map(int, input().split()))
data  = ita.array.make1d(qus[0])
ch = []
sum = 0
pe = 0
for i in range(0, qus[1]):
  int_data = list(map(str, input().split()))
  n = int(int_data[0])-1
  if int_data[1] == 'WA':
      data[n] += 1
  else:
      if n in ch:
          None
      else:
          ch.append(n)
          sum += 1
          pe += data[n]
print(sum,' ',pe)

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 scan <= M:
        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
        else:
            break
        
print(all_AC, all_failure)

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()
q = [int(s) for s in p]
X = [0]*N
Y = [0]*N
A = 0
B = 0
for i in range(M):
    if S[i] == "AC":
        if Y[q[i]]==0:
            Y[q[i]]+=1
            A += 1
            B += X[q[i]]
    else:
        if Y[q[i]]==0:
            X[q[i]] += 1
print(str(A)+" "+str(B))

Submission status: Runtime Error

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

account = 0
wacount = 0
frag = 0

for j in range(n):
    frag = 0
    for k in range(m):
        a, s = map(str, input().split())
        p = int(a)

        if p == j+1 and s == "WA" and frag == 0:
            wacount += 1
        elif p == j+1 and s == "AC" and frag == 0:
            account += 1
            frag = 1

print("{} {}".format(account, wacount))