Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
lst=[None]*M
for i in range(M):
    p, S=input().split()
    lst[i]=(int(p), S)

#print(N, M, lst)
#count AC
AC_count = 0
WA_count = 0
AC_check={}
for i in range(M-1,-1,-1):
    #print(i)
    if lst[i][1]=='AC':
        AC_check[lst[i][0]-1]=i
#print(AC_check)

AC_count=len(AC_check)

for k, v in AC_check.items():
        #AC_count += 1
        WA_count+=lst[:v].count((k+1, 'WA'))

print(AC_count, WA_count)

Fixed submission:
N, M = map(int,input().split())
lst=[None]*M
for i in range(M):
    p, S=input().split()
    lst[i]=(int(p), S)

stop_set=set()

WA_count=0
AC_count=0
from collections import defaultdict
WA_dict = defaultdict(lambda: 0)

for el in lst:
    if not el[0] in stop_set:
        if el[1]=='AC':
            AC_count+=1
            stop_set.add(el[0])
        else:
            WA_dict[el[0]] +=1
#print(dict(WA_dict))

new_set=set(WA_dict.keys())&stop_set
#print(new_set)
WA_count=sum([WA_dict[i] for i in new_set])
print(AC_count, WA_count)

Buggy python submission (verdict: Runtime Error):
N, M = map(int,input().split())
lst=[None]*M
for i in range(M):
    p, S=input().split()
    lst[i]=(int(p), S)

#print(N, M, lst)
#count AC
AC_count = 0
WA_count = 0
AC_check={}
for i in range(M-1,-1,-1):
    #print(i)
    if lst[i][1]=='AC':
        AC_check[lst[i][0]-1]=i
#print(AC_check)

AC_count=len(AC_check)

for i in range(1, N+1):
    if AC_check[i-1]!=None:
        #AC_count += 1
        WA_count+=lst[:AC_check[i-1]].count((i, 'WA'))

print(AC_count, WA_count)

Fixed submission:
N, M = map(int,input().split())
lst=[None]*M
for i in range(M):
    p, S=input().split()
    lst[i]=(int(p), S)

stop_set=set()

WA_count=0
AC_count=0
from collections import defaultdict
WA_dict = defaultdict(lambda: 0)

for el in lst:
    if not el[0] in stop_set:
        if el[1]=='AC':
            AC_count+=1
            stop_set.add(el[0])
        else:
            WA_dict[el[0]] +=1
#print(dict(WA_dict))

new_set=set(WA_dict.keys())&stop_set
#print(new_set)
WA_count=sum([WA_dict[i] for i in new_set])
print(AC_count, WA_count)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
lst=[None]*M
for i in range(M):
    p, S=input().split()
    lst[i]=(int(p), S)

#print(N, M, lst)
#count AC
AC_count = 0
WA_count = 0
AC_check=[None]*N
for i in range(M-1,-1,-1):
    #print(i)
    if lst[i][1]=='AC':
        AC_check[lst[i][0]-1]=i
#print(AC_check)

AC_count=N-AC_check.count(None)

for i in range(1, N+1):
    if AC_check[i-1]!=None:
        #AC_count += 1
        WA_count+=lst[:AC_check[i-1]].count((i, 'WA'))

print(AC_count, WA_count)

Fixed submission:
N, M = map(int,input().split())
lst=[None]*M
for i in range(M):
    p, S=input().split()
    lst[i]=(int(p), S)

stop_set=set()

WA_count=0
AC_count=0
from collections import defaultdict
WA_dict = defaultdict(lambda: 0)

for el in lst:
    if not el[0] in stop_set:
        if el[1]=='AC':
            AC_count+=1
            stop_set.add(el[0])
        else:
            WA_dict[el[0]] +=1
#print(dict(WA_dict))

new_set=set(WA_dict.keys())&stop_set
#print(new_set)
WA_count=sum([WA_dict[i] for i in new_set])
print(AC_count, WA_count)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
lst=[None]*M
for i in range(M):
    p, S=input().split()
    lst[i]=(int(p), S)

#print(N, M, lst)
#count AC
AC_count = 0
WA_count = 0
AC_check=[None]*N
for i in range(M-1,-1,-1):
    #print(i)
    if lst[i][1]=='AC':
        AC_check[lst[i][0]-1]=i
#print(AC_check)


for i in range(1, N+1):
    if AC_check[i-1]!=None:
        AC_count += 1
        WA_count+=lst[:AC_check[i-1]].count((i, 'WA'))

print(AC_count, WA_count)

Fixed submission:
N, M = map(int,input().split())
lst=[None]*M
for i in range(M):
    p, S=input().split()
    lst[i]=(int(p), S)

stop_set=set()

WA_count=0
AC_count=0
from collections import defaultdict
WA_dict = defaultdict(lambda: 0)

for el in lst:
    if not el[0] in stop_set:
        if el[1]=='AC':
            AC_count+=1
            stop_set.add(el[0])
        else:
            WA_dict[el[0]] +=1
#print(dict(WA_dict))

new_set=set(WA_dict.keys())&stop_set
#print(new_set)
WA_count=sum([WA_dict[i] for i in new_set])
print(AC_count, WA_count)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
lst=[None]*M
for i in range(M):
    p, S=input().split()
    lst[i]=(int(p), S)

#print(N, M, lst)
#count AC
AC_count = 0
WA_count = 0
AC_check=[None]*N
for i in range(M-1,-1,-1):
    #print(i)
    if lst[i][1]=='AC':
        AC_check[lst[i][0]-1]=i
#print(AC_check)


for i in range(1, N+1):
    if AC_check[i-1]!=None:
        AC_count += 1
        WA_count+=lst[:AC_check[i-1]].count((i, 'WA'))

print(AC_count, WA_count)

Fixed submission:
N, M = map(int,input().split())
lst=[None]*M
for i in range(M):
    p, S=input().split()
    lst[i]=(int(p), S)

stop_set=set()

WA_count=0
AC_count=0
from collections import defaultdict
WA_dict = defaultdict(lambda: 0)

for el in lst:
    if not el[0] in stop_set:
        if el[1]=='AC':
            AC_count+=1
            stop_set.add(el[0])
        else:
            WA_dict[el[0]] +=1
#print(dict(WA_dict))

new_set=set(WA_dict.keys())&stop_set
#print(new_set)
WA_count=sum([WA_dict[i] for i in new_set])
print(AC_count, WA_count)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
lst=[None]*M
for i in range(M):
    p, S=input().split()
    lst[i]=(int(p), S)

#print(N, M, lst)
#count AC
AC_count = 0
WA_count = 0
for i in range(1, N+1):
    if (i, 'AC') in lst:
        AC_count += 1
        success = lst.index((i, 'AC'))
        WA_count+=lst[:success].count((i, 'WA'))

print(AC_count, WA_count)

Fixed submission:
N, M = map(int,input().split())
lst=[None]*M
for i in range(M):
    p, S=input().split()
    lst[i]=(int(p), S)

stop_set=set()

WA_count=0
AC_count=0
from collections import defaultdict
WA_dict = defaultdict(lambda: 0)

for el in lst:
    if not el[0] in stop_set:
        if el[1]=='AC':
            AC_count+=1
            stop_set.add(el[0])
        else:
            WA_dict[el[0]] +=1
#print(dict(WA_dict))

new_set=set(WA_dict.keys())&stop_set
#print(new_set)
WA_count=sum([WA_dict[i] for i in new_set])
print(AC_count, WA_count)