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):
params = input().split(' ')
n = eval(params[1])

AC = set()
WA = {}

penalties = 0
points = 0

for i in range(n):
    submission = input().split(' ')
    p = eval(submission[0])
    status = submission[1]
    
    if p in AC:
        continue
    
    if status == 'AC':
        AC.add(p)
        points += 1
        penalties += getPenalties(p)
    
    elif p in WA:
        WA[p] += 1

    else:
        WA[p] = 1

print(points, penalties)


def getPenalties(x):
    if x in WA:
        return WA[x]
    return 0


params = input().split(' ')
n = eval(params[1])

AC = set()
WA = {}

penalties = 0
points = 0

for i in range(n):
    submission = input().split(' ')
    p = eval(submission[0])
    status = submission[1]
    
    if p in AC:
        continue
    
    if status == 'AC':
        AC.add(p)
        points += 1
        penalties += getPenalties(p)
    
    elif p in WA:
        WA[p] += 1

    else:
        WA[p] = 1
    


def getPenalties(x):
    if x in WA:
        return WA[x]
    return 0

params = input().split(' ')
n = params[1]

acfoundfor = []

penalties = 0
points = 0

for i in range(n):
    submission = input().split(' ')
    p = eval(submission[0])
    status = submission[1]
    
    if p in acfoundfor:
        continue

    if status == 'AC':
        points += 1
        acfoundfor.append(p)
    else:
        penalties += 1


params = input().split(' ')
m = eval(params[0])
n = eval(params[1])

penaltyCount = []

for i in range(m):
    penaltyCount.append(0)

penalties = 0
points = 0

for i in range(n):
    submission = input().split(' ')
    p = eval(submission[0])
    status = submission[1]
    
    if penaltyCount[p] == -1:
        continue

    if status == 'AC':
        penalties += penaltyCount[p]
        penaltyCount[p] = -1
        points += 1
    else:
        penaltyCount[p] += 1


print(points, penalties)


params = input().split(' ')
n = eval(params[1])

acfoundfor = []

penalties = 0
points = 0

for i in range(n):
    submission = input().split(' ')
    p = eval(submission[0])
    status = submission[1]
    
    if p in acfoundfor:
        continue

    if status == 'AC':
        points += 1
        acfoundfor.append(p)
    else:
        penalties += 1

params = input().split(' ')
m = eval(params[0])
n = eval(params[1])

penaltyCount = []

for i in range(m):
    penaltyCount[i] = 0

penalties = 0
points = 0

for i in range(n):
    submission = input().split(' ')
    p = eval(submission[0])
    status = submission[1]
    
    if penaltyCount[p] == -1:
        continue

    if status == 'AC':
        penaltyCount += penaltyCount[p]
        penaltyCount[p] = -1
        points += 1
    else:
        penaltyCount[p] += 1


print(points, penalties)

params = input().split(' ')
n = eval(params[1])

penaltyCount = [0] * eval(params[0])

penalties = 0
points = 0

for i in range(n):
    submission = input().split(' ')
    p = eval(submission[0])
    status = submission[1]
    
    if penaltyCount[p] == -1:
        continue

    if status == 'AC':
        penaltyCount += penaltyCount[p]
        penaltyCount[p] = -1
        points += 1
    else:
        penaltyCount[p] += 1


print(points, penalties)


params = input().split(' ')
m = eval(params[0])
n = eval(params[1])

penaltyCount = []

for i in range(m):
    penaltyCount.append(0)

penalties = 0
points = 0

for i in range(n):
    submission = input().split(' ')
    p = eval(submission[0])-1
    status = submission[1]
    
    if penaltyCount[p] == -1:
        continue

    if status == 'AC':
        penalties += penaltyCount[p]
        penaltyCount[p] = -1
        points += 1
    else:
        penaltyCount[p] += 1


print(points, penalties)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Accepted