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

n, m = map(int, input().split())
p, s = [], []
cor, pen = 0, 0
for _ in range(m):
    li = input().split()
    p.append(int(li[0]))
    s.append(li[1])
for j in range(n):
    corFlag = False
    penCnt = 0
    for i in range(m):
        if (p[i] == j + 1):
            if corFlag:
                continue
            elif (s[i] == 'WA'):
                penCnt += 1
            else:
                cor += 1
                corFlag = True
    if corFlag:
        pen += penCnt
print(cor, pen)

Fixed submission:
n, m = map(int, input().split())

hasAC, pena, tmpP= [0] * n, [0] * n, [0] * n

for i in range(m):
    li = input().split()
    p = int(li[0]) - 1
    s = li[1]
    if hasAC[p]:
        continue
    if s == 'AC':
        hasAC[p] = 1
        pena[p] += tmpP[p]
    else:
        tmpP[p] += 1

print(sum(hasAC), sum(pena))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
p, s = [], []
cor, pen = 0, 0
for _ in range(m):
    li = input().split()
    p.append(int(li[0]))
    s.append(li[1])
for j in range(n):
    corFlag = False
    penCnt = 0
    for i in range(m):
        if (p[i] == j + 1):
            if corFlag:
                continue
            elif (s[i] == 'WA'):
                penCnt += 1
            else:
                cor += 1
                corFlag = True
    if corFlag:
        pen += penCnt
print(cor, pen)

Fixed submission:
n, m = map(int, input().split())

hasAC, pena, tmpP= [0] * n, [0] * n, [0] * n

for i in range(m):
    li = input().split()
    p = int(li[0]) - 1
    s = li[1]
    if hasAC[p]:
        continue
    if s == 'AC':
        hasAC[p] = 1
        pena[p] += tmpP[p]
    else:
        tmpP[p] += 1

print(sum(hasAC), sum(pena))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
li = []
for i in range(M):
  liin = input().split()
  li.append([int(liin[0]), liin[1]])

ans1, ans2 = 0, 0
done = []
miss = {}

for i in range(M):
  if li[i][0] in done:
    continue
  if li[i][1] == "AC":
    ans1 += 1
    done.append(li[i][0])
    if li[i][0] in miss:
      ans2 += miss[li[i][0]]
      del miss[li[i][0]]
  else: # "WA"
    if li[i][0] in miss:
      miss[li[i][0]] += 1
    else:
      miss[li[i][0]] = 1

print(ans1,ans2)

Fixed submission:
N, M = map(int, input().split())
li = []
for i in range(M):
  liin = input().split()
  li.append([int(liin[0]), liin[1]])

ans1, ans2 = 0, 0
done = set([0])
miss = {}

for i in range(M):
  if li[i][0] in done:
    continue
  if li[i][1] == "AC":
    ans1 += 1
    done.add(li[i][0])
    if li[i][0] in miss:
      ans2 += miss[li[i][0]]
      del miss[li[i][0]]
  else: # "WA"
    if li[i][0] in miss:
      miss[li[i][0]] += 1
    else:
      miss[li[i][0]] = 1

print(ans1,ans2)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
li = []
for i in range(M):
  liin = input().split()
  li.append([int(liin[0]), liin[1]])

ans1, ans2 = 0, 0
done = []
miss = {}

for i in range(M):
  if li[i][0] in done:
    continue
  if li[i][1] == "AC":
    ans1 += 1
    done.append(li[i][0])
    if li[i][0] in miss:
      ans2 += miss[li[i][0]]
      del miss[li[i][0]]
  else: # "WA"
    if li[i][0] in miss:
      miss[li[i][0]] += 1
    else:
      miss[li[i][0]] = 1

print(ans1,ans2)

Fixed submission:
N, M = map(int, input().split())
li = []
for i in range(M):
  liin = input().split()
  li.append([int(liin[0]), liin[1]])

ans1, ans2 = 0, 0
done = set([0])
miss = {}

for i in range(M):
  if li[i][0] in done:
    continue
  if li[i][1] == "AC":
    ans1 += 1
    done.add(li[i][0])
    if li[i][0] in miss:
      ans2 += miss[li[i][0]]
      del miss[li[i][0]]
  else: # "WA"
    if li[i][0] in miss:
      miss[li[i][0]] += 1
    else:
      miss[li[i][0]] = 1

print(ans1,ans2)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
li = []
for i in range(M):
  liin = input().split()
  li.append([int(liin[0]), liin[1]])

ans = [0, 0]
done = []
miss = {}

for i in range(M):
  if li[i][0] in done:
    continue
  if li[i][1] == "AC":
    ans[0] += 1
    done.append(li[i][0])
    if li[i][0] in miss:
      ans[1] += miss[li[i][0]]
      del miss[li[i][0]]
  else: # "WA"
    if li[i][0] in miss:
      miss[li[i][0]] += 1
    else:
      miss[li[i][0]] = 1

print(ans[0],ans[1])

Fixed submission:
N, M = map(int, input().split())
li = []
for i in range(M):
  liin = input().split()
  li.append([int(liin[0]), liin[1]])

ans1, ans2 = 0, 0
done = set([0])
miss = {}

for i in range(M):
  if li[i][0] in done:
    continue
  if li[i][1] == "AC":
    ans1 += 1
    done.add(li[i][0])
    if li[i][0] in miss:
      ans2 += miss[li[i][0]]
      del miss[li[i][0]]
  else: # "WA"
    if li[i][0] in miss:
      miss[li[i][0]] += 1
    else:
      miss[li[i][0]] = 1

print(ans1,ans2)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = input().split()
N = int(N)
M = int(M)
li = []
for i in range(M):
  liin = input().split()
  li.append([int(liin[0]), str(liin[1])])

ans = [0, 0]
done = []
miss = {}

for i in range(M):
  if li[i][0] in done:
    continue
  if li[i][1] == "AC":
    ans[0] += 1
    done.append(li[i][0])
    if li[i][0] in miss.keys():
      ans[1] += miss[li[i][0]]
      del miss[li[i][0]]
  else: # "WA"
    if li[i][0] in miss.keys():
      miss[li[i][0]] += 1
    else:
      miss[li[i][0]] = 1

print(ans[0],ans[1])

Fixed submission:
N, M = map(int, input().split())
li = []
for i in range(M):
  liin = input().split()
  li.append([int(liin[0]), liin[1]])

ans1, ans2 = 0, 0
done = set([0])
miss = {}

for i in range(M):
  if li[i][0] in done:
    continue
  if li[i][1] == "AC":
    ans1 += 1
    done.add(li[i][0])
    if li[i][0] in miss:
      ans2 += miss[li[i][0]]
      del miss[li[i][0]]
  else: # "WA"
    if li[i][0] in miss:
      miss[li[i][0]] += 1
    else:
      miss[li[i][0]] = 1

print(ans1,ans2)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = input().split()
N = int(N)
M = int(M)
li = []
for i in range(M):
  liin = input().split()
  li.append([int(liin[0]), str(liin[1])])

ans = [0, 0]
done = []
miss = {}

for i in range(M):
  if li[i][1] == "AC":
    if li[i][0] in done:
      pass
    else:
      ans[0] += 1
      done.append(li[i][0])
      if li[i][0] in miss.keys():
        ans[1] += miss[li[i][0]]
        del miss[li[i][0]]
  else: # "WA"
    if li[i][0] in done:
      pass
    else:
      if li[i][0] in miss.keys():
        miss[li[i][0]] += 1
      else:
        miss[li[i][0]] = 1
print(ans[0],ans[1])

Fixed submission:
N, M = map(int, input().split())
li = []
for i in range(M):
  liin = input().split()
  li.append([int(liin[0]), liin[1]])

ans1, ans2 = 0, 0
done = set([0])
miss = {}

for i in range(M):
  if li[i][0] in done:
    continue
  if li[i][1] == "AC":
    ans1 += 1
    done.add(li[i][0])
    if li[i][0] in miss:
      ans2 += miss[li[i][0]]
      del miss[li[i][0]]
  else: # "WA"
    if li[i][0] in miss:
      miss[li[i][0]] += 1
    else:
      miss[li[i][0]] = 1

print(ans1,ans2)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = input().split()
N = int(N)
M = int(M)
li = []
for i in range(M):
  liin = input().split()
  li.append([int(liin[0]), str(liin[1])])
#print(N, M, li)

ans = [0, 0]
done = []
miss = {}

for i in range(M):
  if li[i][1] == "AC":
    if li[i][0] in done:
      pass
    else:
      ans[0] += 1
      done.append(li[i][0])
      if li[i][0] in miss.keys():
        ans[1] += miss[li[i][0]]
  else:
    if li[i][0] in done:
      pass
    else:
      if li[i][0] in miss.keys():
        miss[li[i][0]] += 1
      else:
        miss[li[i][0]] = 1
print(ans[0],ans[1])

Fixed submission:
N, M = map(int, input().split())
li = []
for i in range(M):
  liin = input().split()
  li.append([int(liin[0]), liin[1]])

ans1, ans2 = 0, 0
done = set([0])
miss = {}

for i in range(M):
  if li[i][0] in done:
    continue
  if li[i][1] == "AC":
    ans1 += 1
    done.add(li[i][0])
    if li[i][0] in miss:
      ans2 += miss[li[i][0]]
      del miss[li[i][0]]
  else: # "WA"
    if li[i][0] in miss:
      miss[li[i][0]] += 1
    else:
      miss[li[i][0]] = 1

print(ans1,ans2)