Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

N,M = map( int, input().split() )

#str_lines = [x.strip("\n") for x in sys.stdin.readlines()]

list_str_P_S = [input().split() for i in range(M)]

#-----
#-----

list_question_no=list(set(list(zip(*list_str_P_S))[0]))

#print("list_str_P_S=",list_str_P_S)
#print("list_question_no=",list_question_no)

count_AC=0
count_WA=0
list_temp=[]
list_next=[]
for str_i in list_question_no:

  for L in list_str_P_S:
    str_number = L[0]
    result = L[1]
    
    if str_number == str_i:
      list_temp.append(L)
    else:
      list_next.append(L)
  #print("list_temp",list_temp)
  #print("list_next",list_next)
  

  for L in list_temp:
    str_number = L[0]
    result = L[1]
    
    if str_number == str_i:
      if result == "WA":
        count_WA += 1
        #print("L",L,count_AC,count_WA)
      elif result == "AC":
        count_AC += 1
        #print("L",L,count_AC,count_WA)
        break
        
  list_str_P_S=list_next
  list_temp=[]
  list_next=[]
  #print("list_str_P_S next=",list_str_P_S)  
  #print("-----")

#print("ans=",count_AC,count_WA)
print(count_AC,count_WA)


Fixed submission:
# -*- coding: utf-8 -*-

N,M = list(map(int, input().rstrip().split()))
pS_list = []

for i in range(M):
    inp = input().rstrip().split()
    pS_list.append( [int(inp[0]), inp[1]] )

#-----
problem_AC_set = set()
problem_WA_dic = {}

for p,S in pS_list:
    if (S == "AC") and (p not in problem_AC_set):
        problem_AC_set.add(p)
    
    if (S == "WA") and (p not in problem_AC_set):
        problem_WA_dic.setdefault(p, 0)
        problem_WA_dic[p] += 1

cnt_AC = len(problem_AC_set)
cnt_WA = sum([v for k,v in problem_WA_dic.items() if k in problem_AC_set])

print(cnt_AC, cnt_WA)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

N,M = map( int, input().split() )

#str_lines = [x.strip("\n") for x in sys.stdin.readlines()]
str_lines = [input() for i in range(M)]

list_str_P_S=[]
for S in str_lines:
  list_str_P_S.append( list(S.split()) )

#-----
#-----

list_question_no=list(set(list(zip(*list_str_P_S))[0]))

#print("list_str_P_S=",list_str_P_S)
#print("list_question_no=",list_question_no)

count_AC=0
count_WA=0
for str_i in list_question_no:

  for L in list_str_P_S:
    str_number = L[0]
    result = L[1]
    
    if str_number == str_i:
      if result == "WA":
        count_WA += 1
        #print("L",L,count_AC,count_WA)
      elif result == "AC":
        count_AC += 1
        #print("L",L,count_AC,count_WA)
        break

#print("ans=",count_AC,count_WA)
print(count_AC,count_WA)


Fixed submission:
# -*- coding: utf-8 -*-

N,M = list(map(int, input().rstrip().split()))
pS_list = []

for i in range(M):
    inp = input().rstrip().split()
    pS_list.append( [int(inp[0]), inp[1]] )

#-----
problem_AC_set = set()
problem_WA_dic = {}

for p,S in pS_list:
    if (S == "AC") and (p not in problem_AC_set):
        problem_AC_set.add(p)
    
    if (S == "WA") and (p not in problem_AC_set):
        problem_WA_dic.setdefault(p, 0)
        problem_WA_dic[p] += 1

cnt_AC = len(problem_AC_set)
cnt_WA = sum([v for k,v in problem_WA_dic.items() if k in problem_AC_set])

print(cnt_AC, cnt_WA)