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

n, m = map(int, input().split(' '))

WAs = [0] * n
ACs = []
ac_append = ACs.append
penalty = 0
for i in range(m):
    p, s = input().strip().split(' ')
    p = int(p) - 1
    if p in ACs:
        continue
    if s == 'AC':
        penalty += WAs[p]
        ac_append(p)
    else:
        WAs[p] += 1

print(len(ACs), penalty)


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

n, m = map(int, input().split(' '))

WAs = [0] * n
correct = 0
penalty = 0
for i in range(m):
    p, s = input().strip().split(' ')
    p = int(p) - 1
    if WAs[p] == -1:
        continue
    if s == 'AC':
        penalty += WAs[p]
        correct += 1
        WAs[p] = -1
    else:
        WAs[p] += 1

print(correct, penalty)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split(' '))
submits = [input().split(' ') for i in range(m)]

WAs = [0] * n
ACs = []
penalty = 0
for submit in submits:
    p, s = submit
    p = int(p) - 1
    if p in ACs:
        continue
    if s == 'AC':
        penalty += WAs[p]
        ACs.append(p)
    else:
        WAs[p] += 1

print(len(ACs), penalty)


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

n, m = map(int, input().split(' '))

WAs = [0] * n
correct = 0
penalty = 0
for i in range(m):
    p, s = input().strip().split(' ')
    p = int(p) - 1
    if WAs[p] == -1:
        continue
    if s == 'AC':
        penalty += WAs[p]
        correct += 1
        WAs[p] = -1
    else:
        WAs[p] += 1

print(correct, penalty)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split(' '))
submits = [list(input().split(' ')) for i in range(m)]

WAs = [0] * n
ACs = []
penalty = 0
for submit in submits:
    p, s = submit
    p = int(p) - 1
    if p in ACs:
        continue
    if s == 'AC':
        penalty += WAs[p]
        ACs.append(p)
    else:
        WAs[p] += 1

print(len(ACs), penalty)


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

n, m = map(int, input().split(' '))

WAs = [0] * n
correct = 0
penalty = 0
for i in range(m):
    p, s = input().strip().split(' ')
    p = int(p) - 1
    if WAs[p] == -1:
        continue
    if s == 'AC':
        penalty += WAs[p]
        correct += 1
        WAs[p] = -1
    else:
        WAs[p] += 1

print(correct, penalty)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split(' '))
submits = [list(input().split(' ')) for i in range(m)]
acs = set([submit[0] for submit in submits if submit[1]=='AC'])

WA_nums = dict()
ACs = []
penalty = 0
for submit in submits:
    p, s = submit
    if not p in acs:
        continue
    elif p in ACs:
        continue
    if s == 'AC':
        if p in WA_nums:
            penalty += WA_nums[p]
        ACs.append(p)
    else:
        if p in WA_nums:
            WA_nums[p] += 1
        else:
            WA_nums[p] = 1

print(len(acs), penalty)


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

n, m = map(int, input().split(' '))

WAs = [0] * n
correct = 0
penalty = 0
for i in range(m):
    p, s = input().strip().split(' ')
    p = int(p) - 1
    if WAs[p] == -1:
        continue
    if s == 'AC':
        penalty += WAs[p]
        correct += 1
        WAs[p] = -1
    else:
        WAs[p] += 1

print(correct, penalty)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split(' '))

WA_nums = dict()
AC = []
penalty = 0
for i in range(m):
    p, s = input().split()
    if p in AC:
        continue
    if s == 'AC':
        if p in WA_nums:
            penalty += WA_nums[p]
        AC.append(p)
    else:
        if p in WA_nums:
            WA_nums[p] += 1
        else:
            WA_nums[p] = 1

print(len(AC), penalty)


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

n, m = map(int, input().split(' '))

WAs = [0] * n
correct = 0
penalty = 0
for i in range(m):
    p, s = input().strip().split(' ')
    p = int(p) - 1
    if WAs[p] == -1:
        continue
    if s == 'AC':
        penalty += WAs[p]
        correct += 1
        WAs[p] = -1
    else:
        WAs[p] += 1

print(correct, penalty)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split(' '))
submits = [input().split() for i in range(m)]

WA_nums = dict()
AC = []
penalty = 0
for submit in submits:
    p, s = submit
    if p in AC:
        continue
    if s == 'AC':
        if p in WA_nums:
            penalty += WA_nums[p]
        AC.append(p)
    else:
        if p in WA_nums:
            WA_nums[p] += 1
        else:
            WA_nums[p] = 1

print(len(AC), penalty)

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

n, m = map(int, input().split(' '))

WAs = [0] * n
correct = 0
penalty = 0
for i in range(m):
    p, s = input().strip().split(' ')
    p = int(p) - 1
    if WAs[p] == -1:
        continue
    if s == 'AC':
        penalty += WAs[p]
        correct += 1
        WAs[p] = -1
    else:
        WAs[p] += 1

print(correct, penalty)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split(' '))
submits = [input().split() for i in range(m)]

WA_nums = dict()
AC = []
penalty = 0
for submit in submits:
    p, s = submit
    if s == 'AC':
        if p in AC:
            continue
        if p in WA_nums:
            penalty += WA_nums[p]
        AC.append(p)
    else:
        if p in WA_nums:
            WA_nums[p] += 1
        else:
            WA_nums[p] = 1

print(len(AC), penalty)

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

n, m = map(int, input().split(' '))

WAs = [0] * n
correct = 0
penalty = 0
for i in range(m):
    p, s = input().strip().split(' ')
    p = int(p) - 1
    if WAs[p] == -1:
        continue
    if s == 'AC':
        penalty += WAs[p]
        correct += 1
        WAs[p] = -1
    else:
        WAs[p] += 1

print(correct, penalty)