Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ac = []
ac_append = ac.append
wa = {}
ok = 0
ng = 0

for _ in range(m):
    p, s = input().split()
    if p not in ac:
        if s == "AC":
            ac_append(p)
            ok += 1
            if p in wa.keys():
                ng += wa[p]
        else:
            if p in wa.keys():
                wa[p] += 1
            else:
                wa[p] = 1

print(ok, ng)


Fixed submission:
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ac = {str(i): 0 for i in range(n+1)}
wa = {str(i): 0 for i in range(n+1)}
ok = 0
ng = 0

for _ in range(m):
    p, s = input().split()
    if ac[p] == 0:
        if s == "AC":
            ac[p] += 1
            ok += 1
            if wa[p] > 0:
                ng += wa[p]
        else:
            wa[p] += 1

print(ok, ng)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ac = []
ac_append = ac.append
wa = {}
ok = 0
ng = 0

inp = [input().split() for _ in range(m)]
for p, s in inp:
    if p not in ac:
        if s == "AC":
            ac_append(p)
            ok += 1
        else:
            if p in wa.keys():
                wa[p] += 1
            else:
                wa[p] = 1

for i in ac:
    if i in wa.keys():
        ng += wa[i]

print(ok, ng)


Fixed submission:
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ac = {str(i): 0 for i in range(n+1)}
wa = {str(i): 0 for i in range(n+1)}
ok = 0
ng = 0

for _ in range(m):
    p, s = input().split()
    if ac[p] == 0:
        if s == "AC":
            ac[p] += 1
            ok += 1
            if wa[p] > 0:
                ng += wa[p]
        else:
            wa[p] += 1

print(ok, ng)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ac = []
wa = {}
ok = 0
ng = 0

for _ in range(m):
    p, s = input().split()
    if p not in ac:
        if s == "AC":
            ac.append(p)
            ok += 1
        else:
            if p in wa.keys():
                wa[p] += 1
            else:
                wa[p] = 1

for i in ac:
    if i in wa.keys():
        ng += wa[i]

print(ok, ng)


Fixed submission:
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ac = {str(i): 0 for i in range(n+1)}
wa = {str(i): 0 for i in range(n+1)}
ok = 0
ng = 0

for _ in range(m):
    p, s = input().split()
    if ac[p] == 0:
        if s == "AC":
            ac[p] += 1
            ok += 1
            if wa[p] > 0:
                ng += wa[p]
        else:
            wa[p] += 1

print(ok, ng)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ac = []
wa = {}
ok = 0
ng = 0

for _ in range(m):
    p, s = input().split()
    if p not in ac:
        if s == "AC":
            ac.append(p)
            ok += 1
        else:
            if p in wa.keys():
                wa[p] += 1
            else:
                wa[p] = 1

for i in ac:
    if i in wa.keys():
        ng += wa[i]

print(ok, ng)


Fixed submission:
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ac = {str(i): 0 for i in range(n+1)}
wa = {str(i): 0 for i in range(n+1)}
ok = 0
ng = 0

for _ in range(m):
    p, s = input().split()
    if ac[p] == 0:
        if s == "AC":
            ac[p] += 1
            ok += 1
            if wa[p] > 0:
                ng += wa[p]
        else:
            wa[p] += 1

print(ok, ng)