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 = input().split()
l = [0]*int(N) #flg
m = [0]*int(N) #counter
c =0

for i in range(int(M)+1):
    p,s = input().split()
    if s =="AC":
        if l[int(p)-1]==1:
            pass
        else:
            l[int(p)-1] = 1
            c += m[int(p)-1]
    elif s == "WA":
        m[int(p)-1] += 1



print(l.count(1),c)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python

def main():
    N, M = map(int, input().split())
    # [AC, WA]
    cnt = [[0, 0] for _ in range(2)]
    for _ in range(M):
        num, status = input().split()
        num = int(num) -1
        if status == "AC":
            if cnt[num][0] == 0:
                cnt[num][0] += 1
        if status == "WA":
            if cnt[num][0] == 0:
                cnt[num][1] += 1

    ac_cnt, wa_cnt = 0, 0
    for i in range(N):
        ac_cnt += cnt[i][0]
        wa_cnt += cnt[i][1]

    print(ac_cnt, wa_cnt, sep=" ")

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC' and a[p] == 0:
        AC[p] += 1
        w += W[p]
    elif s == 'WA' and a[p] == 0:
        WA[p] += 1

print(sum(a), w)

Submission status: Runtime Error

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

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC': and a[p] == 0:
        AC[p] += 1
        w += W[p]
    elif s == 'WA' and a[p] == 0:
        WA[p] += 1

print(sum(a), w)

Submission status: Runtime Error

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

for m in range(m):
  p,s = input().split()
  p = int(p) - 1
  if number[p]!=1:
    if s == "WA":
      number[p]+=1
    elif s == "AC":
      ac+=1
      wa+=number[p]
      number[p]=-1
print(ac,wa)

Submission status: Runtime Error

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

ac = [0]*(n+1)
wa = [0]*(n+1)

for _ in range(m):
    a, b = input().split()
    a = int(a)
    if b == 'AC':
        ac[a] = 1
    else: 
        if ac[a] == 0:
            wa[a] = wa[a] + 1

for i in range(n+1):
    wa[a] = wa[a] * ac[a]

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

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
L = list()
for m in range(M):
    l = input().split()
    L.append(l)
AC = 0
WA = 0
cnt = 0
for m in range(M):
    res = False
    if L[m][1] == 'AC':
        AC += 1
        res = True
        if res:
            cnt += 1
    elif L[m][1] == 'WA':
        WA += 1
    if int(L[m][0]) == N and res == True:
        break
print('{} {}'.format(AC // cnt, WA))

Submission status: Runtime Error

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

List = []
ans = [0  for i in range(N+1)]
WA = [0  for i in range(N+1)]

for i in range(M):
  p,S = map,input().split()
  
  if ans[p] != 0:
    if S == "AC":
      ans[p] = 1
    else:
      WA[p] += 1
      
A = sum(ans)
W = sum(WA)

print(A,W)

Submission status: Runtime Error

Solution code:
# C - Welcome to AtCoder
# https://atcoder.jp/contests/abc151/tasks/abc151_c

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

# 問題数分配列を作成 -> 正解判定用の関数
ac = [False] * n
wa = [0] * n

# まずはテーブルを作成する
for i in range(m):
    p, s = input().split()
    p = int(p)

    if p == "AC":
        # 正解したことのある問題か確認
        ac[i] = True
    else:
        if ac[i] == False:
            wa[i] += 1

ac_cnt = 0
wa_cnt = 0

for i in range(n):
    if ac[i] == True:
        ac_cnt += 1
        wa_cnt += wa[i]

print(ac_cnt,wa_cnt)

Submission status: Runtime Error

Solution code:
# C - Welcome to AtCoder
# https://atcoder.jp/contests/abc151/tasks/abc151_c

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

# 問題数分配列を作成 -> 正解判定用の関数
ac = [False] * N
wa = [0] * N

# まずはテーブルを作成する
for i in range(m):
    p, s = input().split()
    p = int(p)

    if p == "AC":
        # 正解したことのある問題か確認
        ac[i] = True
    else:
        if ac[i] == False:
            wa[i] += 1

ac_cnt = 0
wa_cnt = 0

for i in range(n):
    if ac[i] == True:
        ac_cnt += 1
        wa_cnt += wa[i]

print(ac_cnt,wa_cnt)

Submission status: Runtime Error

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

ps=[]
pena=[[0,False] for _ in range(n)]
for i in range(m):
    ps.append(input().split())
 
for i in range(m):
    if pena[int(ps[i][0])][1]==False and ps[i][1]=="WA":
        pena[int(ps[i][0])][0]+=1
    else:
        pena[int(ps[i][0])][1]=True

p=[pena[i][0] for i in range(len(pena))]
t=[pena[i][1] for i in range(len(pena))]
print(t.count(True),sum(p))

Submission status: Runtime Error

Solution code:
# C - Welcome to AtCoder
# https://atcoder.jp/contests/abc151/tasks/abc151_c

n,m = map(int,input().split())
submits = [list(input().split()) for i in range(0,m)]

ac = 0
wa = 0

AC = "AC"
WA = "WA"

tmp_wa = 0
tmp_ac = 0


for i in range(len(submits)):
    # ACなら正解数をカウントアップ
    if submits[i][1] == AC:
        # 同じ問題に正解してないかチェック
        if submits[i][0] == tmp_ac:
            continue
        ac += 1
        # WAの数をカウント
        wa += tmp_wa
        # WAを初期化
        tmp_wa = 0
        tmp_ac = submits[i][0]
    else:
        # WAならwa+1
        tmp_wa += 1

print(ac + " " + wa)

Submission status: Runtime Error

Solution code:
# C - Welcome to AtCoder
# https://atcoder.jp/contests/abc151/tasks/abc151_c

n,m = map(int,input().split())
submits = [list(input().split()) for i in range(0,m)]

ac = 0
wa = 0

AC = "AC"
WA = "WA"

tmp_wa = 0
tmp_ac = 0


for i in range(len(submits)):
    # ACなら正解数をカウントアップ
    if submits[i][1] == AC:
        # 同じ問題に正解してないかチェック
        if submits[i][0] == tmp_ac:
            continue
        ac += 1
        # WAの数をカウント
        wa += tmp_wa
        # WAを初期化
        tmp_wa = 0
        tmp_ac = submits[i][0]
    else:
        # WAならwa+1
        tmp_wa += 1

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

Submission status: Runtime Error

Solution code:
# C - Welcome to AtCoder
# https://atcoder.jp/contests/abc151/tasks/abc151_c

n,m = map(int,input().split())
submits = [list(input().split()) for i in range(0,m)]
print(submits)
ac = 0
wa = 0

AC = "AC"
WA = "WA"

tmp_wa = 0
tmp_ac = ""


for i in range(len(submits)):
    # ACなら正解数をカウントアップ
    if submits[i][1] == AC:
        # 同じ問題に正解してないかチェック
        if submits[i][0] == tmp_ac:
            continue
        ac += 1
        # WAの数をカウント
        wa += tmp_wa
        # WAを初期化
        tmp_wa = 0
        tmp_ac = submits[i][0]
    else:
        # WAならwa+1
        tmp_wa += 1

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

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
P,S=[],[]
ans,pen=0,0
task=[0]*N
for _ in range(M):
    A,B=map(str,input().split())
    P.append(int(A))
    S.append(B)

for j in range(M):
    if task[A[M]-1]!=-1 and S[j]=="WA":
        pen+=1
    elif task[A[M]-1]!=-1 and S[j]=="AC":
        ans+=1
        task[A[M]]=-1
        break
print(ans,pen)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
P,S=[],[]
ans,pen=0,0
task=[0]*N
for _ in range(M):
    A,B=map(str,input().split())
    P.append(int(A))
    S.append(B)

for j in range(M):
    if task[A[M]]!=-1 and S[j]=="WA":
        pen+=1
    elif task[A[M]]!=-1 and S[j]=="AC":
        ans+=1
        task[A[M]]=-1
        break
print(ans,pen)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
num = [1]*(n + 1)
AC_cnt = 0
WA_cnt = 0
for i in range(m):
    p,s=input().split()
    if s == 'AC'
        if num[int(p)]:
            num[int(p)] = 0
            AC_cnt += 1
else:
    WA_cnt += 1
print(AC_cnt,WA_cnt)

Submission status: Runtime Error

Solution code:
n,m= list(map(int, input().split()))
ans_box=[0]*n
wa=[0]*m
ac=0
wa_cnt=0
for j in range(m):
    k,l=input().split()
    h=int(k)-1
    if ans_box[h]==0:
        if l=="AC":
            ac+=1
            ans_box[h]+=1
            wa_cnt+=wa[h]
        else:
            wa[h]+=1
print(ac,wa_cnt)

Submission status: Runtime Error

Solution code:
n,m= list(map(int, input().split()))
ans_box=[0]*n
wa=[0]*m
ac=0
wa_cnt=0
for j in range(m):
    k,l=input().split()
    h=int(k)-1
    if ans_box[h]==0:
        if l=="AC":
            ac+=1
            ans_box[h]+=1
            wa_cnt+=wa[h]
        else:
            wa[h]+=1
print(ac,wa_cnt)

Submission status: Runtime Error

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

for i in range(m):
    p, s = map(str, input().split())
    p = int(p) - 1
    if s == "AC":
        AC[p] = 1
    elif s == "WA" and AC[p] == 0:
        WA[p] += 1

WA = [WA[i] for i in range(m) if AC[i] >= 1]

print(sum(AC), sum(WA))

Submission status: Runtime Error

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

# check
AC_questions = {}
for i in range(M):
    P, S = map(str, input().split())

    if P not in AC_questions:
        AC_questions[P] = {
            "wa_cnt": 0,
            "ac": False
        }

    if AC_questions[P]["wa_cnt"] is True:
        continue
    elif S == "AC":
        AC_questions[P]["ac"] = True
    # S == "WA"
    else:
        AC_questions[P]["wa_cnt"] += 1
        
AC_cnt = sum([1 for a in AC_questions if a['ac'] is True])
WA_cnt = sum([a["wa_cnt"] for a in AC_questions if a["ac"] is True])

print(AC_cnt, WA_cnt)

Submission status: Runtime Error

Solution code:
n,m=map(int, input().split())
h = [list(map(str,input().split())) for _ in range(m)]
# print(h)
for i in range(m):
    h[i][0] = int(h[i][0])
l=[]
penalty = 0
import numpy as np
p = np.zeros(n)
for i in range(m):
    if h[i][0] not in l:
        if h[i][1] == 'AC':
            l.append(h[i][0])
            penalty += p[i-1]
        else:
            p[h[i][0]-1] += 1
ansnum = len(l)

# for i in l:
#     penalty += p[i-1]

print(ansnum,int(penalty))

Submission status: Runtime Error

Solution code:
x = int(input())

ans = 0

def prime(x):
    y = x//2+1
    cnt = 0
    for i in range(2,y+1):
        if x%i==0:
            cnt += 1
            
    if cnt == 0:
        return x
    else:
        return 0
        
while ans == 0:
    ans = prime(x)
    x += 1
    
if x == 2:
    print(2)
else:
    print(ans)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
pS_list = [list(input().split()) 
           for nesya in range(m)]
ac = 0
wa = 0
q_list = [0]*n
for ps in ps_list:
  p = int(ps[0])-1
  s = ps[1]
  if q_list[p] == 1:
    continue
  if s == 'WA':
    q_list[p] -= 1
  else:
    a = q_list[p]
    wa -= a
    ac += 1
    q_list[p] = 1
print(ac,wa)

Submission status: Runtime Error

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

from itertools import accumulate
A1 = list(accumulate(A1))
A2 = list(accumulate(A2))

ans = 0
for i in range(N):
    ans = max(ans, A1[i] + A2[-1] - A2[i-1]) 
print(ans)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
cor = set()
pens = {}
for i in range(m):
  p,s = input().split()
  if s=="AC":
    cor.add(p)
  else:
    if not p in cor:
      if p in pens:
        pens[p] += 1
      else:
        pens[p] = 1
pen = 0
for x in cor:
  if x in pens:  
    pen += pens(x)
print(str(len(cor))+" "+str(pen))

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
li = [[0,0] for _ in range(n)]
t1,t2 = 0,0
for i in range(m):
    a,b = input().split()
    if li[int(a)-1][0] != 1:
        if b == "WA":
            li[int(a)-1][1] += 1
        else b == "AC":
            li[int(a)-1][0] += 1
for i in range(n):
    t1 += li[i][0]
    t2 += li[i][1]
print(t1,t2)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
w,l=0,[0]*n
for i in range(m):
    p,s=input().split()
    p,f=int(p)-1,l[p]>=0
    if s=='AC':
        w+=l[p]*f
        l[p]=-1
    else:
        l[p]+=f
print(l.count(-1),w)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
sub = []
ansac=0
answa=0
for i in range(n):
  sub.append(0)
for i in range(m):
  p,s = input().split()
  if(s == "AC"):
    sub[p-1]=1
    ansac+=1
  else:
    if(sub[p-1]==0):
      answa+=1
print(ansac,answa)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
sub = []
ansac=0
answa=0
for i in range(n):
  sub.append(0)
for i in range(m):
  p,s = map(int,input().split())
  if(s == "AC"):
    sub[p-1]=1
    ansac+=1
  else:
    if(sub[p-1]==0):
      answa+=1
print(ansac,answa)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
accepted = [0] * N
penalties = [0] * N
for _ in range(M):
    p, ac = input().split()
    p, ac = int(p), ac == "AC"
    accepted[p] |= ac
    penalties[p] += not accepted[p]
print(sum(accepted), sum(p for ac, p in zip(accepted, penalties) if ac))

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
ac,wa = 0,0
d = {}
for i in range(m):
  p,s = input().split()
  if p in d:
    if s=="WA":
      if d[p]:
        pass
      else:
        WA+=1
    elif s=="AC":
      if d[p]:
        pass
      else:
        d[p]=True
        ac+=1
  else:
    if s=="WA":
      d[p]=False
      wa+=1
    else:
      d[p]=True
      ac+=1
print(ac,wa)

Submission status: Runtime Error

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

scores = [[0, False] for _ in range(n)]

for _ in range(m):
    p, S = input().split()
    p = int(p)

    if scores[p][1]:
        continue

    if S == "AC":
        scores[p][1] = True
        continue

    if S == "WA":
        scores[p][0] += 1

score = pena = 0
for count, ac in scores:
    if ac:
        score += 1
        pena += count

print(score, pena)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
ps=[list(input().split()) for x in range(m)]
 
cnt=0
for p,s in ps:
  if s=='AC':
    cnt+=1
lp,ls=zip(*ps)
ans=0
for llpp in lp:
  if not [llpp,'AC'] in ps:
    ans+=1
print(cnt,ans)

Submission status: Runtime Error

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

cnt=0
for p,s in ps:
  if s=='AC':
    cnt+=1
lp,ls=zip(*ps)
ans=0
for llpp in lp:
  if not [llpp,'AC'] in ps:
    ans+=1
print(cnt,ans)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
WA,wa,ac=0,0,0
for i in range(m):
    p,s=input().split()
    p=int(p)
    if i>0 and p!=before:
        wa=0
    if s=="WA":
        wa+=1
    elif s=="AC" and p==before:
        WA+=wa
        ac+=1
    before=p
print(ac,WA)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
ps = [0] * m
p = [0] * m
s = [0] * m
for i in range(m):
    ps[i] = list(map(str,input().split()))
if m = 0:
    print(0,0)
    exit()
cp=int(ps[0][0])
countA = [0] * n
countW = 0
cn = 0
for item in ps:
    if item[1] == 'AC':
        countA[int(item[0])-1] = 1
        countW += cn
        cp += 1
        cn = 0
    else:
        cn+=1
print(sum(countA),countW)

Submission status: Runtime Error

Solution code:
n,m = map(int, input().split())
ac_list = [False]*(n+1)
pena_count = [0]*(n+1)
for i in range(m):
  p, s = map(int, input().split())
  if not ac_list[p]:
    if s == "AC":
      ac_list[p] = True
    else:
      pena_count[p] += 1
ac_count = 0
pena_c = 0
for i in range(1, n+1):
  if ac_list[i]:
    ac_count += 1
    pena_c += pena_count[i]
print(ac_count, pena_c)

Submission status: Runtime Error

Solution code:
n,m = (int(x) for x in input().split())
memo = [0]*n
pena = [0]*n
ans2 = 0
for i in range(m):
    p,s = (str(x) for x in input().split())
    p = int(p)
    if s=="AC":
        memo[p-1] = 1
    elif s=="WA":
        if memo[p-1]==0:
            pena[p-1] += 1

for j in range(p):
    if memo[j]==1:
        ans2 += pena[j]

print("{} {}".format(sum(memo),ans2))

Submission status: Runtime Error

Solution code:
N , M = map(int,input().split())
p = [''] * M
S = [''] * M
A = [0] * N
W = [0] * N
for i in range(M):
    p[i],S[i] = map(str,input().split())
    p[i] = int(p[i])
    if A[p[i]-1] == 0:
        if S[i] == 'WA':
            W[p[i]-1] += 1
        else:
            A[p[i]-1] += 1

for j in range(N):
    if A[j] == 0:
        W[j] =0
 print(sum(A),sum(W))

Submission status: Runtime Error

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

result = [[0] * 2 for i in range(n)]

for _ in range(m):
    tmp_i, s = input().split()
    i = int(tmp_i)
    if result[i][0] == 1:
        continue
    if s == 'AC':
        result[i][0] += 1
    else:
        result[i][1] += 1

print(sum([result[i][0] for i in range(n)]),
      sum([result[i][1] for i in range(n)]))

Submission status: Runtime Error

Solution code:
result = dict()
AC, WA = 0, 0
for p,s in PS:
    p = int(p)
    if not (p in result):
        result [p] = s
        if s == "WA":
            WA += 1
        elif s == "AC":
            AC += 1
    elif result[p] == "AC":
        continue
    else:
        result[p] = s
        if s == "WA":
            WA += 1
        elif s == "AC":
            AC += 1
print(AC, WA)

Submission status: Runtime Error

Solution code:
from collections import defaultdict
N, M = map(int, input().split())
d = defaultdict(lambda : "WA")
correct = 0
incorrect = 0
for _ in range(M):
    p, S = input().split()
    if d[p] == "WA":
        if S == "WA":
            incorrect += 1
            print(p, "WA", d)
        else:
            correct += 1
            d[p] = "AC"
            print(p, "AC", d)
print(correct, incorrect)

Submission status: Runtime Error

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

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

flag = [0 for _ in range(n)]
wa_num_list = [0 for _ in range(n)]

for i in range(m):
    p, s = list(map(str, input().split()))
    p = int(p)
    if flag[p-1] == 0:
        if s == "WA":
            wa_num_list[p-1] += 1
        else:
            flag[p-1] = 1

pen = 0
for i in range(m):
    if flag[i] == 1:
        pen += wa_num_list[i]

print(sum(flag), pen)

Submission status: Runtime Error

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

for i in range(M):
    p, S = input().split()
    p = int(p) 

    if S == "AC":
        AC[p-1] = 1
    elif S == "WA":
        if not AC[p-1]:
            WA[p-1] = 1

for j in range(N):
    if AC[p-1]==0:
        WA[p-1]==0
            
print(sum(AC), sum(WA))

Submission status: Runtime Error

Solution code:
n, m = map(int,input().split())
q = [0 for i in range(n)]
alist = []
ac = 0
pe = 0
be = be
for i in range(m):
    a,b=input().split()
    alist.append((int(a), b))
for i in range(m):
    if q[alist[i][0]-1] == 0:
        if alist[i][1] == 'AC':
            ac += 1
            be = be + pe
            q[alist[i][0]-1] = 1
        else:
            pe += 1
    else:
        continue
print(ac,be)

Submission status: Runtime Error

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

for i in range(m):
    p, s = input().split()
    p = int(p-1)
    if s == "WA" and a[p][1] == 0:
        a[p][0] += 1
    elif s == "AC" and a[p][1] == 0:
        ac += 1
        a[p][1] = 1

for i in a:
    if i[1] == 1:
        wa += i[0]

print(ac,wa)

Submission status: Runtime Error

Solution code:
import sys
n, m = map(int, sys.stdin.readline().split())
li = [[] for _ in range(m)]
for _ in range(m):
  i, k = map(str, sys.stdin.readline().split())
  i = int(i)
  li[i-1].append(k)
wa = 0
ac = 0
for i in li:
  for k in i:
    if k == 'WA':
      wa += 1
    if k == 'AC':
      ac += 1
      break
print(ac, wa)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
a=[-1]*(10**5)
for i in range(n):
	p,s=input().split()
	p=int(p)
	if s=="AC" and a[p]<0:
		a[p] = a[p]*(-1)
	if s=="WA" and a[p]<0:
		a[p] -= 1
ac=0
wa=0
for i in range(n):
	if a[i] > 0:
		ac += 1
		wa += a[i] - 1

print(ac,wa)

Submission status: Runtime Error

Solution code:
import sys
import math

n,m = map(int,input().split())
ps = [input().split() for i in range(m)]
import numpy as np
flag = np.zeros(n,dtype=np.int16)
count = 0
wa = 0
for i in range(m):
  if ps[i][1]=='AC' and flag[int(ps[i][0])-1]==0:
    flag[int(ps[i][0])-1]=1
    count+=1
  elif ps[i][1]=='WA' and flag[int(ps[i][0])-1]==0:
  	wa+=1
  else:
    count=count
    wa=wa
  if count==n:
    print(count,wa)
    sys.exit()
print(flag.count('1'),wa)

Submission status: Runtime Error

Solution code:
import numpy as np
def main():
  N,M=map(int,input().split())
  str_list = [list(input().split()) for _ in range(M)]
  np_str_list=np.array(str_list)
  wacount=0
  account=0
  if(len(str_list)==0):
    print(0,0)
  else:
    for i in range(1,N+1):
      tgtarray=np_str_list[np.where(np_str_list[:,0]==str(i)),1][0]
      if(len(tgtarray)!=0):
        ac_index=np.where(tgtarray=='AC')[0][0]
        account=account+1
        wacount=wacount+tgtarray[0:ac_index].shape[0]
    print(account,wacount)

if __name__=='__main__':
  main()

Submission status: Runtime Error

Solution code:
import numpy as np
def main():
  N,M=map(int,input().split())
  str_list = [list(input().split()) for _ in range(M)]
  np_str_list=np.array(str_list)
  wacount=0
  for i in range(1,N+1):
    tgtarray=np_str_list[np.where(np_str_list[:,0]==str(i)),1][0]
    ac_index=np.where(tgtarray=='AC')[0][0]
    wacount=wacount+tgtarray[0:ac_index].shape[0]
  account=len(np_str_list[np_str_list[:,1]=='AC',0])
  print(wacount,account)

if __name__=='__main__':
  main()

Submission status: Runtime Error

Solution code:
import numpy as np
def main():
  N,M=map(int,input().split())
  str_list = [list(input().split()) for _ in range(M)]
  np_str_list=np.array(str_list)
  wacount=0
  for i in range(1,N+1):
    tgtarray=np_str_list[np.where(np_str_list[:,0]==str(i)),1][0]
    ac_index=np.where(tgtarray=='AC')[0][0]
    wacount=wacount+tgtarray[0:ac_index].shape[0]
  account=len(np_str_list[np_str_list[:,1]=='AC',0])
print(wacount,account)

if __name__=='__main__':
  main()

Submission status: Runtime Error

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

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

for i in range(m):
    question_number, result = input().split()
    num = int(question_number) - 1
    if result == 'AC' and ans[num]:
        ans[num] = False
        ac += 1
    elif result == 'WA' and ans[num]:
        wa[num] += 1

wa_sum = 0

for wa_num in wa:
    if not ans[num]:
        wa_sum += wa_num 

print(ac, wa_sum)

Submission status: Runtime Error

Solution code:
# acするまでのwaをそれぞれの問題でカウントする
cnts = [0] * n

# key：acした問題番号、value：waした回数の辞書を作成する
at_dict = {}

for i in range(m):
    question, result = map(str, input().split())
    if result == 'AC':
        # ACした時点で上記で作成した辞書に、key：問題番号、value:wa回数を記入
        at_dict[question] = cnts[int(question)-1]
    elif result == 'WA':
        # WAなら上記のwa回数のリストにカウント
        cnts[int(question)-1] += 1
    
ac = len(at_dict)
wa = sum(v for v in at_dict.values())

print(ac, wa)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
keep=[]
lis=[]
ac=[0]*N
wa=[0]*N
WA=0
for i in range(M):
    ps=input().split()
    keep.append(ps)
    
for j in range(M):
    if keep[j][1]=="AC":
        ac[int(keep[j][0])-1]=1
    elif ac[int(keep[j][0])-1]==0:
        wa[int(keep[j][0])-1]+=1
AC=sum(ac)
for j in range(M):
    WA+=ac[j]*wa[j]
    
print(AC,WA)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
keep=[]
lis=[]
ac=[0]*N
wa=[0]*N
WA=0
for i in range(M):
    ps=input().split()
    keep.append(ps)
    
for j in range(M):
    if keep[j][1]=="AC":
        print(int(keep[j][0]-1))
        ac[int(keep[j][0]-1)]=1
    elif ac[int(keep[j][0]-1)]==0:
        wa[int(keep[j][0]-1)]+=1
AC=sum(ac)
for j in range(M):
    WA+=ac[j]*wa[j]
    
print(AC,WA)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
keep=[]
lis=[]
ac=[0]*N
wa=[0]*N
WA=0
for i in range(M):
    ps=input().split()
    keep.append(ps)
    
for j in range(M):
    if keep[j][1]=="AC":
        print(int(keep[j][0]))
        ac[int(keep[j][0])]=1
    elif ac[int(keep[j][0])]==0:
        wa[int(keep[j][0])]+=1
AC=sum(ac)
for j in range(M):
    WA+=ac[j]*wa[j]
    
print(AC,WA)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
keep=[]
lis=[]
ac=[0]*N
wa=[0]*N
WA=0
for i in range(M):
    ps=input().split()
    keep.append(ps)
    
for j in range(M):
    if keep[j][1]=="AC":
        ac[int(keep[j][0])]=1
    elif ac[int(keep[j][0])]==0:
        wa[int(keep[j][0])]+=1
AC=sum(ac)
for j in range(M):
    WA+=ac[j]*wa[j]
    
print(AC,WA)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
keep=[]
lis=[]
ac=[0]*M
wa=[0]*M
WA=0
for i in range(M):
    ps=input().split()
    keep.append(ps)
    
for j in range(M):
    if keep[j][1]=="AC":
        ac[int(keep[j][0])]=1
    elif ac[int(keep[j][0])]==0:
        wa[int(keep[j][0])]+=1
AC=sum(ac)
for j in range(M):
    WA+=ac[j]*wa[j]
    
print(AC,WA)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
keep=[]
lis=[]
ac=0
wa=0
for i in range(M):
    ps=input().split()
    keep.append(ps)
for j in range(M):
    if not keep[j][0] in lis:
        if keep[j][1]=="AC":
            ac+=1
            lis.append(keep[j][0])
        else:
            wa+=1
print(ans,wa)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
PS = [list(map(str,input().split())) for i in range(M)]
A_num = [0]*N
W_num = [0]*N
w=0
#print(PS)
for j in range(M):
    #print(A_num)
    if PS[j][1] == 'WA'and A_num[int(PS[j][0])-1]==0:
        W_num[int(PS[j][0]-1)]=1 
    if PS[j][1]== 'AC' and A_num[int(PS[j][0])-1]==0:
        A_num[int(PS[j][0])-1]=1
s = sum(A_num)
for k in range(N):
    if A_num[k] == 0:
        W_num[k]=0
w = sum(W_num)
print(s,w)

Submission status: Runtime Error

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

S=list(dict.fromkeys(s))

for i in range(len(S)):
    S[i]=S[i].split()

x=0
y=0
for i in range(len(S)-1,-1,-1):
    if S[i][1]=="AC":
        a=S[i][0]
        x+=1
    elif S[i][0]==a and S[i][1]=="WA":
        y+=1

print(x,y)

Submission status: Runtime Error

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

num = 0
pena = 0

lis=[0]*(n+1)
lis2=[0]*n
lis3=[0]*n
sw = [0]*n

for i in range(m):
    if y[i] == 'WA' and sw[int(x[i])]== 0:
        lis[int(x[i])] += 1
    else:
        lis2[int(x[i])] = 1
        sw[int(x[i])] = 1
        
pena = sum(lis)
num = sum(lis2)

print(num,pena)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
AC_counter = 0
Error_counter = 0
finish_list = []
for i in range(M):
  pS = input().split()
  if 'AC' == pS[1]:
    if pS[0] not in finish_list:
      AC_counter += 1
      finish_list.append(pS[i][0])
  elif 'WA' == pS[1]:
    if pS[0] not in finish_list:
      Error_counter += 1
print(AC_counter,Error_counter)

Submission status: Runtime Error

Solution code:
# 初期入力
N,M = (int(x) for x in input().split(" "))
S = []

#　問題種類をキー、ac,waを値の辞書
mondai_acwa ={i:list() for i in range(1,N+1) }
q_id =0
result =""
for i in range(M):
    q_id_str,result = (x for x in input().split())
    mondai_acwa[int(q_id_str)].append(result)

# ACのindexを検索（各問題）
count_wa=0
ac_index =[]
ac_sum=0
for i,v_wa in mondai_acwa.items():
    if 0 < len(v_wa):
        ac_i =v_wa.index("AC")
        ac_index.append(ac_i)
        ac_sum +=1
print(ac_sum,sum(ac_index))

Submission status: Runtime Error

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

penalty = [0] * n
isAC = [False] * n

for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == "WA":
        if not isAC[p]:
            penalty[p] += 1
    else:
        isAC[p] = True
for i in range(n)
    if not isAC[i]:
        penalty[i] = 0
print(sum(isAC), sum(penalty))

Submission status: Runtime Error

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

ans_list = [[[0] for i in range(2)] for j in range(n)]
#print(ans_list[0])
for i in range(m):
    p_num = int(p_list[i][0])
    if p_list[i][1] == "WA":
        ans_list[p_num-1][1]  = 1
    else:
        ans_list[p_num-1][0]  = 1
count1 = 0
count2 = 0
for i in range(n):
    if ans_list[i][0] == 1:
        count += 1
        if ans_list[i][1] == 1:
            count2 += 1
print(count1,count2)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
A=[0]*M
pen=0
for i in range(M):
  p,S=input().split()
  if S=="AC":
    A[int(p)-1]=1
  elif S=="WA" and A[int(p)-1]==0:
    pen += 1
print(sum(A),pen)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
N=[[0,0]]*(N+1)
L=list(list(map(input().split())) for j in range(M))
win=0
penalty=0
if M==0:
  print(0,0)
else:
  for i in range(M):
    m=int(L[i][0])
    eff=str(L[i][1])
    if eff=="WA":
      if N[m][0]!=1:
        N[m][1]+=1
      else:
        continue
    else:
      if N[m][0]!=1:
        N[m][0]=1
        win+=1
        penalty+=N[m][1]
      else:
        continue
  print(win,penalty)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
N=[[0,0]]*(N+1)
L=list(list(map(str,input().split())) for j in range(M))
win=0
peanalty=0
if M==0:
  print(0,0)
else:
  for i in range(M):
    m=int(L[i][0])
    eff=L[i][1]
    if eff=="WA":
      if N[m][0]!=1:
        N[m][1]+=1
      else:
        continue
    else:
      if N[m][0]!=1:
        N[m][0]=1
        win+=1
        penalty+=N[m][1]
      else:
        continue
  print(win,penalty)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
N=[[0,0]]*(N+1)
if M==0:
  print(0,0)
else:
  penalty=0
  win=0
  for j in range(M):
    L=list(map(str,input().split()))
    m=int(L[0])
    if L[1]=="WA":
      if N[m][1]!=1:
        penalty+=1
      else:
        continue
    else:
      if N[m][1]!=1:
        N[m][1]=1
        win+=1
      else:
        continue
print(win,penalty)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
N=[[0,0]]*(N+1)
if M==0:
  print(0,0)
else:
  penalty=0
  win=0
  for j in range(M):
    L=list(map(str,input().split()))
    m=int(L[0])
    if L[1]=="WA":
      if N[m]!=1:
        penalty+=1
      else:
        continue
    else:
      if N[m]!=1:
        N[m]=1
        win+=1
      else:
        continue
print(win,penalty)