Buggy python submission (verdict: Runtime Error):
# coding UTF-8
# 
# problem C
# 

import pandas as pd

t = []
N, M = map(int, input().split())
for i in range(M):
    t.append(tuple(input().split(' ')))

df = pd.DataFrame(t, columns=['p', 'S'])
alist = df.groupby('p')['S'].apply(list)

#print(df)
#print(alist)

#print(alist[0])

#print(alist.apply(lambda d: d[:d.index('AC')))


c = 0
NG = 0
for i in range(len(alist)):
    #print(alist[i])
    try:
        k = alist[i].index('AC')
    except ValueError:
        NGtmp = alist[i].count('WA')
        NG = NG + NGtmp
    else:
        #print(k)
        #print(alist[:k])
        NGtmp = alist[i][:k].count('WA')
        c = c + 1
        NG = NG + NGtmp

#print(c)
#print(NG)

print('{} {}'.format(c, NG))
 

Fixed submission:
import sys

readline = sys.stdin.readline

def main():
    N, M = map(int, readline().split())
    aclist = [0] * N
    wrongcount = [0] * N
    for _ in range(M):
        p, S = readline().split()
        q = int(p)-1
        if aclist[q] == 0 and S == 'WA':
            wrongcount[q] += 1
        if S == 'AC':
            aclist[q] = 1

    pena = 0
    for i in range(N):
        if aclist[i] == 1:
            pena += wrongcount[i]
    ac = sum(aclist)

    print(ac, pena)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
# coding UTF-8
# 
# problem C
# 

import pandas as pd

t = []
N, M = map(int, input().split())
for i in range(M):
    t.append(tuple(input().split(' ')))

df = pd.DataFrame(t, columns=['p', 'S'])
alist = df.groupby('p')['S'].apply(list)

#print(df)
#print(alist)

#print(alist[0])

#print(alist.apply(lambda d: d[:d.index('AC')))

c = 0
NG = 0
for i in range(M):
    try:
        k = alist[i].index('AC')
    except:
        NGtmp = alist[i].count('WA')
        NG = NG + NGtmp
    else:
        NGtmp = alist[:k].count('WA')
        c = c + 1
        NG = NG + NGtmp

print('%s %s'%(c, NG))


Fixed submission:
import sys

readline = sys.stdin.readline

def main():
    N, M = map(int, readline().split())
    aclist = [0] * N
    wrongcount = [0] * N
    for _ in range(M):
        p, S = readline().split()
        q = int(p)-1
        if aclist[q] == 0 and S == 'WA':
            wrongcount[q] += 1
        if S == 'AC':
            aclist[q] = 1

    pena = 0
    for i in range(N):
        if aclist[i] == 1:
            pena += wrongcount[i]
    ac = sum(aclist)

    print(ac, pena)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
# coding UTF-8
# 
# problem C
# 

import pandas as pd

t = []
N, M = map(int, input().split())
for i in range(M):
    t.append(tuple(input().split(' ')))

df = pd.DataFrame(t, columns=['p', 'S'])
alist = df.groupby('p')['S'].apply(list)

print(df)
print(alist)

print(alist[0])

print(alist.apply(lambda d: d[:d.index('AC')))

c = 0
NG = 0
for i in range(M):
    try:
        k = alist[i].index('AC')
    except:
        NGtmp = alist[i].count('WA')
        NG = NG + NGtmp
    else:
        NGtmp = alist[:k].count('WA')
        c = c + 1
        NG = NG + NGtmp

print('%s %s'%(c, NG))
    



Fixed submission:
import sys

readline = sys.stdin.readline

def main():
    N, M = map(int, readline().split())
    aclist = [0] * N
    wrongcount = [0] * N
    for _ in range(M):
        p, S = readline().split()
        q = int(p)-1
        if aclist[q] == 0 and S == 'WA':
            wrongcount[q] += 1
        if S == 'AC':
            aclist[q] = 1

    pena = 0
    for i in range(N):
        if aclist[i] == 1:
            pena += wrongcount[i]
    ac = sum(aclist)

    print(ac, pena)


if __name__ == "__main__":
    main()