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())
ps = [list(input().split()) for _ in range(m)]

seito = 0
pena  = 0

for i in range(n):
    flg = False
    for j in range(m):
        if sp[j][0] == i and ps[j][1] == "AC":
            if flg == False:
                seito += 1
                flg = True
            elif ps[j][0] == i and ps[j][1] == "WA":
                if flg == False:
                    pena += 1
            else:
                pass

print(seito, pena)

n, m = map(int, input().split())
ps = [list(input().split()) for _ in range(m)]

seito = 0
pena  = 0

str_list = ["WA"] * n 
int_list = [0] * n　　
num = 0
ac = 0    

for p_, s in  ps: 
    p = int(p_) - 1
    if s == "AC":
        str_list[p] = "AC"  
    else: # s!= WA
        if str_list[p] !="AC": 
            int_list[p] += 1   

for i in range(n): #
    if str_list[i] == "AC": ペナルティはACできた問題のみ
        num += int_list[i] 
        ac += 1　　　　　　

print(ac, num)

n, m = map(int, input().split())
ps = [list(input().split()) for _ in range(m)]

seito = 0
pena  = 0

for i in range(1, n+1):
    flg = False
    for j in range(m):
        if ps[j][0] == i and ps[j][1] == "AC":
            if flg == False:
                seito += 1
                flg = True
        elif ps[j][0] == i and ps[j][1] == "WA":
            if flg == False:
                pena += 1
        else:
            pass

print(seito, pena)

from collections import defaultdict

n, m = map(int, input().split()) 

d = defaultdict(int)
ans = 0
pena = 0

for _ in range(m):
    p, s = input().split()
    if s == "AC":
        if d[p] == -1:
            continue
        else:
            ans += 1
            pena += d[p]
            d[p] = -1
    else:
        if d[p] == -1:
            continue
        else;
            d[p] += 1

print(ans, pena)

n, m = map(int, input().split())
ps = [list(input().split()) for _ in range(m)]

str_list = ["WA"] * n 
int_list = [0] * n    
num = 0
ac = 0    

for p_, s in  ps: 
    p = int(p_) - 1
    if s == "AC":
        str_list[p] = "AC" 
    else: # s!= WA
        if str_list[p] !="AC": 
            int_list[p] += 1   

for i in range(n): 
    if str_list[i] == "AC": ペナルティはACできた問題のみ
        num += int_list[i] 
        ac += 1            

print(ac, num)

n, m = map(int, input().split())
ps = [list(input().split()) for _ in range(m)]

str_list = ["WA"] * n 
int_list = [0] * n    
num = 0
ac = 0    

for p_, s in  ps: 
    p = int(p_) - 1
    if s == "AC":
        str_list[p] = "AC" 
    else: # s!= WA
        if str_list[p] !="AC": 
            int_list[p] += 1   

for i in range(n): 
    if str_list[i] == "AC": 
        num += int_list[i] 
        ac += 1            

print(ac, num)

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Accepted