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())
ac = 0
wa = 0
aclist = {}
for i in range(n):
    aclist[i + 1] = 0

for i in range(m):
    a,b = input().split()
    a = int(a)
    if aclist[a] == 1:
        continue
    elif b == 'WA':
        wa += 1
    elif b == 'AC':
        aclist[a] += 1
        ac += 1
        
print(int(ac), int(wa), end="")


n,m = map(int,input().split())
ac = 0
wa = 0
aclist = {}
for i in range(100000):
    aclist[i + 1] = 0

for i in range(m):
    a,b = input().split()
    a = int(a)
    if aclist[a] == 0:
        if b == 'WA':
            wa += 1
        if b == 'AC':
            aclist[a] += 1
            ac += 1
print(ac, wa, end="")

n,m = map(int,input().split())
ac = 0
wa = 0
aclist = {}
for i in range(n):
    aclist[i + 1] = 0

for i in range(m):
    a,b = input().split()
    a = int(a)
    if aclist[a] == 1:
        continue
    elif b == 'WA':
        wa += 1
    else:
        aclist[a] += 1
        ac += 1
print(int(ac), int(wa), end="")


n,m = map(int,input().split())
ac = 0
wa = 0
aclist = {}
for i in range(n):
    aclist[i + 1] = 0

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

print(ac, wa, end=" ")

n,m = map(int,input().split())
ac = 0
wa = 0
aclist = {}
for i in range(n):
    aclist[i + 1] = 0

for i in range(m):
    a,b = input().split()
    a = int(a)
    if aclist[a] == 0:
        if b == 'WA':
            wa += 1
        if b == 'AC':
            aclist[a] += 1
            ac += 1
print(ac, wa, end=" ")

n,m = map(int,input().split())
ac = 0
wa = 0
aclist = {}
for i in range(100000):
    aclist[i + 1] = 0

for i in range(m):
    a,b = input().split()
    a = int(a)
    if aclist[a] == 0:
        if b == 'WA':
            wa += 1
        else:
            aclist[a] += 1
            ac += 1
print(int(ac), int(wa), end="")


n,m = map(int,input().split())
ac = 0
wa = 0
aclist = {}
for i in range(n):
    aclist[i + 1] = 0

for i in range(m):
    a,b = input().split()
    a = int(a)
    if aclist[a] == 0:
        if b == 'WA':
            wa += 1
        if b == 'AC':
            aclist[a] += 1
            ac += 1
print(ac, wa, end="")

n,m = map(int,input().split())
ac = 0
wa = 0
aclist = {}
walist = {}
for i in range(n):
    aclist[i + 1] = 0
    walist[i + 1] = 0

for i in range(m):
    a,b = input().split()
    a = int(a)
    if aclist[a] == 1:
        continue
    elif b == 'WA':
        walist[a] += 1
    elif b == 'AC':
        aclist[a] += 1
        ac += 1
        wa += walist[a]
        
print(ac, wa)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted