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):
def main():
    N, M = list(map(int, input().split()))
    inputs = [input().split() for i in range(M)]
    
    inputs = inputs.split()
    inputs = [[inputs[i], inputs[i + 1]] for i in range(0, len(inputs), 2)]
    print(inputs)
    has_been_solved = set()

    penalty = 0
    correct = 0
    for i in inputs:
        num = int(i[0])
        if num not in has_been_solved and i[1] == 'AC':
            has_been_solved.add(num)
        elif num not in has_been_solved and i[1] != 'AC':
            penalty += 1
    correct = len(has_been_solved)
    
    print(correct, penalty)            
        

if __name__ == "__main__":
    main()


def main():
    # N, M = list(map(int, input().split()))
    
    with open('./abc151/test.txt', 'r') as f:
        inputs = f.read()
        f.close()
    inputs = inputs.split()
    inputs = [[inputs[i], inputs[i + 1]] for i in range(0, len(inputs), 2)]
    print(inputs)
    has_been_solved = set()

    penalty = 0
    correct = 0
    for i in inputs:
        num = int(i[0])
        if num not in has_been_solved and i[1] == 'AC':
            has_been_solved.add(num)
        elif num not in has_been_solved and i[1] != 'AC':
            penalty += 1
    correct = len(has_been_solved)
    
    print(correct, penalty)            
        

if __name__ == "__main__":
    main()


import sys

def main():
    N, M = list(map(int, input().split()))
    
    inputs = [input().split() for i in range(M)]
    has_been_solved = set()

    penalty = {}
    correct = 0

    for i in inputs:
        
        num = int(i[0])
        if num in has_been_solved:
            continue

        if i[1] == 'AC':
            correct += 1
            has_been_solved.add(num)
        else:
            if num not in penalty:
                penalty[num] = 1
            else:
                penalty[num] += 1
    print(correct, sum([penalty[p] for p in  already]))         
        

if __name__ == "__main__":
    main()


import sys

def main():
    N, M = list(map(int, input().split()))
    inputs = [input().split() for i in range(M)]
    
    has_been_solved = set()

    penalty = 0
    correct = 0
    for i in sys.stdin:
        num = int(i[0])
        if num in has_been_solved:
            continue

        if i[1] == 'AC':
            has_been_solved.add(num)
        else:
            penalty += 1
    correct = len(has_been_solved)
    
    print(correct, penalty)            
        

if __name__ == "__main__":
    main()


n,m=map(int,input().split())
a=[0]*n
w=[0]*n
ac=0
wc=0
for _ in range(m):
    p,s=input().split()
    p=int(p)-1
    if a[p]==0:
        if s=='AC':
            a[p]=1
            ac+=1
            wc+=w[p]
        else:
            w[p]+=1
print(ac,wc)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Accepted