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] = map(str, input().split())
for i in range(m):
    p[i] = int(p[i])

ans1 = 0
ans2 = 0

aclis = [0] * (n+1)
walis = [0] * (n+1)


for i in range(m):
    if s[i] == 'AC':
        aclis[p[i]] = 1


    elif aclis[p[i]] == 0 and s[i] == 'WA':
        walis[p[i]] += 1
ans1 = aclis.count(1)

for i in range(n):
    if aclis[i] == 1:
        ans2 += walis[i]

print(ans1, ans2)

n,m = map(int,input().split())
if m == 0:
    print(0, 0)
else:
    p = [0] * m
    s = [0] * m
    for i in range(m):
        p[i], s[i] = map(str, input().split())
    for i in range(m):
        p[i] = int(p[i])
    p.append(int(ie9))

    probcnt = p[0]
    ACval = False
    ACcnt = 0
    wa = 0
    pena = 0
    for i in range(m):
        if probcnt == p[i]:
            if ACval == False:
                if s[i] == 'WA':
                    wa += 1
                    if p[i] !=p[i+1]:
                        wa = 0
                else:
                    ACval = True
                    ACcnt += 1
                    pena += wa
                    wa = 0

        else:
            ACval = False
            probcnt = p[i]
            if ACval == False:
                if s[i] == 'WA':
                    wa += 1
                    if p[i] !=p[i+1]:
                        wa = 0
                else:
                    ACval = True
                    ACcnt += 1
                    pena += wa


    print(ACcnt, pena)

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())
for i in range(m):
    p[i] = int(p[i])

probcnt = 1
ACval = False
ACcnt
wa = 0
for i in range(m):
    if probcnt == p[i]:
        if ACval == False:
            if s[i] == 'WA':
                wa += 1
            else:
                ACval = True
                ACcnt += 1
    else:
        ACval = False
        probcnt += 1
        if ACval == False:
            if s[i] == 'WA':
                wa += 1
            else:
                ACval = True
                ACcnt += 1

print(ACcnt, wa)

n,m = map(int,input().split())
if m == 0:
    print(0, 0)
else:
    p = [0] * m
    s = [0] * m
    for i in range(m):
        p[i], s[i] = map(str, input().split())
    for i in range(m):
        p[i] = int(p[i])

    probcnt = p[0]
    ACval = False
    ACcnt = 0
    wa = 0
    pena = 0
    for i in range(m):
        if probcnt == p[i]:
            if ACval == False:
                if s[i] == 'WA':
                    wa += 1
                else:
                    ACval = True
                    ACcnt += 1
                    pena += wa
            wa = 0
        else:
            ACval = False
            probcnt = p[i]
            if ACval == False:
                if s[i] == 'WA':
                    wa += 1
                else:
                    ACval = True
                    ACcnt += 1
                    pena += wa
            wa = 0

    print(ACcnt, pena)


n,m = map(int,input().split())
if m == 0:
    print(0, 0)
else:
    p = [0] * m
    s = [0] * m
    for i in range(m):
        p[i], s[i] = map(str, input().split())
    for i in range(m):
        p[i] = int(p[i])

    probcnt = p[0]
    ACval = False
    ACcnt = 0
    wa = 0
    pena = 0
    for i in range(m):
        if probcnt == p[i]:
            if ACval == False:
                if s[i] == 'WA':
                    wa += 1
                else:
                    ACval = True
                    ACcnt += 1
                    pena += wa
        wa = 0
        else:
            ACval = False
            probcnt = p[i]
            if ACval == False:
                if s[i] == 'WA':
                    wa += 1
                else:
                    ACval = True
                    ACcnt += 1
                    pena += wa
        wa = 0

    print(ACcnt, pena)


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())
for i in range(m):
    p[i] = int(p[i])

ans1 = 0
ans2 = 0

aclis = [0] * n
walis = [0] * n
ac = 1s


for i in range(m):
    if s[i] == 'AC':
        aclis[p[i]] = True
        

    if aclis[p[i]] == 0:
        walis[p[i]] += 1
ans1 = aclis.count('True')

for i in range(n):
    if aclis[i] == True:
        ans2 += walis[i]

print(ans1, ans2)

n,m = map(int,input().split())
if m == 0:
    print(0, 0)
else:
    p = [0] * m
    s = [0] * m
    for i in range(m):
        p[i], s[i] = map(str, input().split())
    for i in range(m):
        p[i] = int(p[i])

    probcnt = p[0]
    ACval = False
    ACcnt = 0
    wa = 0
    pena = 0
    for i in range(m):
        if probcnt == p[i]:
            if ACval == False:
                if s[i] == 'WA':
                    wa += 1
                else:
                    ACval = True
                    ACcnt += 1
                    pena += wa
                wa = 0
        else:
            ACval = False
            probcnt = p[i]
            if ACval == False:
                if s[i] == 'WA':
                    wa += 1
                else:
                    ACval = True
                    ACcnt += 1
                    pena += wa
                wa = 0

    print(ACcnt, pena)

n,m = map(int,input().split())
if m == 0:
    print(0, 0)
else:
    p = [0] * m
    s = [0] * m
    for i in range(m):
        p[i], s[i] = map(str, input().split())
    for i in range(m):
        p[i] = int(p[i])

    probcnt = p[0]
    ACval = False
    ACcnt = 0
    wa = 0
    pena = 0
    for i in range(m):
        if probcnt == p[i]:
            if ACval == False:
                if s[i] == 'WA':
                    wa += 1
                else:
                    ACval = True
                    ACcnt += 1
                    pena += wa
        
        else:
            ACval = False
            probcnt = p[i]
            if ACval == False:
                if s[i] == 'WA':
                    wa += 1
                else:
                    ACval = True
                    ACcnt += 1
                    pena += wa
        wa = 0

    print(ACcnt, pena)

n, m = map(int,input())
p = [0] * m
s = [0] * m
for i in range(m):
    p[i], s[i] = map(str, input().split())
for i in range(m):
    p[i] = int(p[i])

ans1 = 0
ans2 = 0

aclis = [0] * n
walis = [0] * n



for i in range(m):
    if s[i] == 'AC':
        aclis[p[i]] = True
        ac += 1

    if aclis[p[i]] == 0:
        walis[p[i]] += 1
ans1 = aclis.count('True')

for i in range(n):
    if aclis[i] == True:
        ans2 += walis[i]

print(ans1, ans2)

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())
for i in range(m):
    p[i] = int(p[i])

ans1 = 0
ans2 = 0

aclis = [0] * (n+1)
walis = [0] * (n+1)


for i in range(m):
    if s[i] == 'AC':
        aclis[p[i]] = 1



    elif aclis[p[i]] == 0 and s[i] == 'WA':
        walis[p[i]] += 1
ans1 = aclis.count(1)
#print(aclis)
#print(walis)

for i in range(n+1):
    if aclis[i] == 1:
        ans2 += walis[i]


print(ans1, ans2)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Accepted