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

def resolve():
    n,m=map(int, input().split())
    if m==0:
        print(0,0)
    else:
        ansl=[[] for i in range(n)]
        for i in range(m):
            p,s=input().split()
            p=int(p)
            if 'AC' not in ansl[p-1]:
                ansl[p-1].append(s)
        wacnt=0
        accnt=0
        for i in range(n):
            if 'AC' in ansl[i]:
                accnt+=1
                wacnt+=len(ansl[i])-1
        print(accnt,wacnt)
resolve()

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,m=map(int, input().split())
    if m==0:
        print(0,0)
    else:
        l=[list(input().split()) for i in range(m)]
        wacnt=[0]*n
        accheck=[False]*n
        pcnt=0
        for p,s in l:
            p=int(p)
            if accheck[p-1]:
                continue
            if s=='WA':
                wacnt[p-1]+=1
            elif s=='AC':
                accheck[p-1]=True
                pcnt+=wacnt[p-1]
        print(sum(accheck),pcnt)
resolve()

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

def resolve():
    n,m=map(int, input().split())
    if m==0:
        print(0,0)
    else:
        ansl=[[] for i in range(n)]
        for i in range(m):
            p,s=input().split()
            p=int(p)
            if 'AC' not in ansl[p-1]:
                ansl[p-1].append(s)
        wacnt=0
        accnt=0
        for i in range(n):
            if 'AC' in ansl[i]:
                accnt+=1
                wacnt+=len(ansl[i])-1
        print(accnt,wacnt)
resolve()

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,m=map(int, input().split())
    if m==0:
        print(0,0)
    else:
        l=[list(input().split()) for i in range(m)]
        wacnt=[0]*n
        accheck=[False]*n
        pcnt=0
        for p,s in l:
            p=int(p)
            if accheck[p-1]:
                continue
            if s=='WA':
                wacnt[p-1]+=1
            elif s=='AC':
                accheck[p-1]=True
                pcnt+=wacnt[p-1]
        print(sum(accheck),pcnt)
resolve()

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

def resolve():
    n,m=map(int, input().split())
    if m==0:
        print(0,0)
    else:
        ansl=[[] for i in range(n)]
        for i in range(m):
            p,s=input().split()
            p=int(p)
            if 'AC' not in ansl[p-1]:
                ansl[p-1].append(s)
        wacnt=0
        accnt=0
        for i in range(n):
            if 'AC' in ansl[i]:
                accnt+=1
                wacnt+=len(ansl[i])-1
        print(accnt,wacnt)

resolve()

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,m=map(int, input().split())
    if m==0:
        print(0,0)
    else:
        l=[list(input().split()) for i in range(m)]
        wacnt=[0]*n
        accheck=[False]*n
        pcnt=0
        for p,s in l:
            p=int(p)
            if accheck[p-1]:
                continue
            if s=='WA':
                wacnt[p-1]+=1
            elif s=='AC':
                accheck[p-1]=True
                pcnt+=wacnt[p-1]
        print(sum(accheck),pcnt)
resolve()