Problem: 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 `WA`s received before receiving an `AC` for the first time on that problem.  Find the numbers of Takahashi's correct answers and penalties.

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

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

N,M = map(int, input().split())
p = [0]*M
S = [0]*M
X = [0]*N
Y = [0]*N
A = 0
B = 0
for i in range(M):
    p[i],S[i] = input().split()
q = [int(s) for s in p]
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))      

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

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

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


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

N,M = map(int, input().split())
p = [0]*M
S = [0]*M
X = [0]*N
Y = [0]*N
A = 0
B = 0
for i in range(M):
    p[i],S[i] = input().split()
q = [int(s) for s in p]
for i in range(M):
    if Y[q[i]]==1:
        break
    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))      

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

N,M = map(int, input().split())
p = [0]*M
S = [0]*M
X = [0]*N
Y = [0]*N
X = [int(s) for s in X]
Y = [int(s) for s in Y]
A = 0
B = 0
for i in range(M):
    p[i],S[i] = input().split()
p = [int(s) for s in p]
for i in range(M):
    if S[i] == "AC":
        if Y[p[i]]==0:
            Y[p[i]]+=1
            A += 1
            B += X[p[i]]
    else:
        if Y[p[i]]==0:
            X[p[i]] += 1
print(str(A)+" "+str(B))      

N,M = map(int, input().split())
p = [0]*M
S = [0]*M
X = [0]*N
Y = [0]*N
X = [int(s) for s in X]
Y = [int(s) for s in Y]
A = 0
B = 0
for i in range(M):
    p[i],S[i] = input().split()
q = [int(s) for s in p]
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))      

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

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted