Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
index=[]
ac=[]
pena=[]

for i in range(M):
    p,s = input().split()

    #もし初めてp問目が提出されたなら
    if not p in index:
        index.append(p)
        ac.append(0)
        pena.append(0)
    #もしp問目が未ACなら
    if ac[index.index(p)] == 0:
        if s == "AC" :
            ac[index.index(p)] += 1
        else:
            pena[index.index(p)] += 1
AC = 0
PENA = 0

for i in range(len(index)):
    if ac[i] == 1:
        AC += 1
        PENA = PENA+pena[i]
print(AC,PENA)

Fixed submission:
N,M=map(int,input().split())
ac=[0]*N
wa=[0]*N
pena=0
acsum=0
for i in range(M):
    p,S=input().split()
    p=int(p)-1
    if S == 'AC':
        if ac[p]==0:
            ac[p]=1
            pena+=wa[p]
            acsum+=1
    else:
        wa[p]+=1
print(acsum,pena)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
index=[]
ac=[]
pena=[]

for i in range(M):
    p,s = input().split()

    #もし初めてp問目が提出されたなら
    if not p in index:
        index.append(p)
        ac.append(0)
        pena.append(0)
    #もしp問目が未ACなら
    if ac[index.index(p)] == 0:
        if s == "AC" :
            ac[index.index(p)] += 1
        else:
            pena[index.index(p)] += 1
AC = 0
PENA = 0

for i in range(len(index)):
    if ac[i] == 1:
        AC += 1
        PENA = PENA+pena[i]
print(AC,PENA)

Fixed submission:
N,M=map(int,input().split())
ac=[0]*N
wa=[0]*N
pena=0
acsum=0
for i in range(M):
    p,S=input().split()
    p=int(p)-1
    if S == 'AC':
        if ac[p]==0:
            ac[p]=1
            pena+=wa[p]
            acsum+=1
    else:
        wa[p]+=1
print(acsum,pena)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split(" "))
p = []
S = []
flag_AC = []
flag_WA = []

for i in range(M):
    inp = input().split(" ")
    p.append(int(inp[0]))
    S.append(inp[1])

for i in range(N):
    flag_AC.append(0)
    flag_WA.append(0)

# n番目の提出ステータスを取得
def Anc(n):
    L = []
    L.append(p[n])
    L.append(S[n])
    return L

AC = 0
WA = 0

for i in range(M):
    data = Anc(i)
    if data[1] == "AC":
        if flag_AC[data[0]] == 0:
            flag_AC[data[0]] = 1
            AC = AC + 1

    if data[1] == "WA":
        if flag_AC[data[0]] == 0:
            flag_WA[data[0]] = flag_WA[data[0]] + 1

for i in range(M):
    data = Anc(i)
    if flag_AC[data[0]] == 0:
        flag_WA[data[0]] = 0
    else:
        flag_WA[data[0]] = flag_WA[data[0]] + 1

print(AC,WA)

Fixed submission:
N,M=map(int,input().split())
ac=[0]*N
wa=[0]*N
pena=0
acsum=0
for i in range(M):
    p,S=input().split()
    p=int(p)-1
    if S == 'AC':
        if ac[p]==0:
            ac[p]=1
            pena+=wa[p]
            acsum+=1
    else:
        wa[p]+=1
print(acsum,pena)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split(" "))
p = []
S = []
flag_AC = []
flag_WA = []

for i in range(M):
    inp = input().split(" ")
    p.append(int(inp[0]))
    S.append(inp[1])

for i in range(N):
    flag_AC.append(0)
    flag_WA.append(0)

# n番目の提出ステータスを取得
def Anc(n):
    L = []
    L.append(p[n])
    L.append(S[n])
    return L

AC = 0
WA = 0

for i in range(M):
    data = Anc(i)
    if data[1] == "AC":
        if flag_AC[data[0]] == 0:
            flag_AC[data[0]] = 1
            AC = AC + 1

    if data[1] == "WA":
        if flag_AC[data[0]] == 0:
            flag_WA[data[0]] = flag_WA[data[0]] + 1
            WA = WA+1

print(AC,WA)

Fixed submission:
N,M=map(int,input().split())
ac=[0]*N
wa=[0]*N
pena=0
acsum=0
for i in range(M):
    p,S=input().split()
    p=int(p)-1
    if S == 'AC':
        if ac[p]==0:
            ac[p]=1
            pena+=wa[p]
            acsum+=1
    else:
        wa[p]+=1
print(acsum,pena)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split(" "))
p = []
S = []
flag_AC = []
flag_WA = []

for i in range(M):
    inp = input().split(" ")
    p.append(int(inp[0]))
    S.append(inp[1])
    flag_AC.append(0)
    flag_WA.append(0)

# n番目の提出ステータスを取得
def Anc(n):
    L = []
    L.append(p[n])
    L.append(S[n])
    return L

AC = 0
WA = 0

for i in range(M):
    data = Anc(i)
    if data[1] == "AC":
        if flag_AC[data[0]] == 0:
            flag_AC[data[0]] = 1
            AC = AC + 1

    if data[1] == "WA" and flag_AC[data[0]] == 0:
        flag_WA[data[0]] = flag_WA[data[0]] + 1
        WA = WA+1

print(AC,WA)

Fixed submission:
N,M=map(int,input().split())
ac=[0]*N
wa=[0]*N
pena=0
acsum=0
for i in range(M):
    p,S=input().split()
    p=int(p)-1
    if S == 'AC':
        if ac[p]==0:
            ac[p]=1
            pena+=wa[p]
            acsum+=1
    else:
        wa[p]+=1
print(acsum,pena)