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())
ansa=0
lip,lis=[],[]
if m==0:
    print(0,0)
else:
    for i in range(m):
        p,s=map(str,input().split())
        lip.append(p)
        lis.append(s)
        if s=="AC":
            if next!=p:
                ansa+=1
                next= p

    print(ansa,lis.count("WA"))

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

n,m=map(int,input().split())
ansa=0
lip,lis=[],[]
if m==0:
    print(0,0)
else:
    for i in range(m):
        p,s=map(str,input().split())
        lip.append(p)
        lis.append(s)
        if s=="AC":
            if next!=p:
                ansa+=1
                next= p

    print(ansa,lis.count("WA"))
print(lis)

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

n,m=map(int,input().split())
lip,lis=[],[]
old=0
ansa,ansb=0,0
wa=0
for i in range(m):
    p,s=input().split()
    if i==0:
        old=p
        if s=="AC": 
            ansa+=1
        else:
            wa+=1
    elif old!=p:
        if s=="AC":
            ansa+=1
            old=p 
            ansb=wa 
        else:
            wa+=1
    else:
        wa=0
print(ansa,ansb)


n,m=map(int,input().split())
ac,wa,wakoho=0,0,0
for i in range(m):
    p,s=input().split()
    p=int(p)
    if i==0:
        last="a"
        lastwa="a"
    if s=="AC" and p!=last:
        ac+=1
        wa+=wakoho
    elif s=="WA" and p==lastwa:
        wakoho+=1
        lastwa=p
    if s=="AC":
        last=p
        wakoho=0
print(ac,wa)

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 s=="AC":
        ac+=1
        before=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)

n,m=map(int,input().split())
acs=[0]*n
was=[0]*n
WA=0
for i in range(m):
    p,s=input().split()
    p=int(p)
    if acs[p-1]==0:
        if s=="AC":
            acs[p-1]=1
            WA+=was[p-1]
        else:
            was[p-1]+=1
print(sum(acs),WA)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted