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

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

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)

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)


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)

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)

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 and keep[j][1]=="AC":
        ac+=1
        lis.append(keep[j][0])
for j in range(M):
    if keep[j][0] in lis and keep[j][1]=="WA":
        wa+=1
    
print(ac,wa)

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 k in range(N):
    WA+=ac[k]*wa[k]
    
print(AC,WA)


Verdicts: Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Accepted