Buggy python submission (verdict: Time Limit Exceeded):
def main() :
  N, M = map(int, input().split())
  p = []
  S = []

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

  s = set(p)
  dict = {}
  for i in s :
    dict[i] = 0
  # print(dict)
  w_cnt = 0
  a_cnt = 0
  skip = []
  for i in range(M) :
    if p[i] not in skip :
      if S[i] == 'WA' :
        dict[p[i]] += 1
        continue
      else :
        a_cnt += 1
        w_cnt += dict[p[i]]
        skip.append(p[i])
        continue

  print(a_cnt, w_cnt)

if __name__ == '__main__' :
  main()

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

p = [0]*(n+1)
q = [False]*(n+1)

for _ in range(m) :
  v,s = input().split()
  v = int(v)
  if q[v] : continue
  if s[0] == 'A' : q[v] = True
  else : p[v] += 1

print(sum(q), sum(p[i] for i in range(n+1) if q[i]))

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

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

s = set(p)
dict = {}
for i in s :
  dict[i] = 0
# print(dict)
w_cnt = 0
a_cnt = 0
skip = []
for i in range(M) :
  if p[i] not in skip :
    if S[i] == 'WA' :
      dict[p[i]] += 1
      continue
    else :
      a_cnt += 1
      w_cnt += dict[p[i]]
      skip.append(p[i])
      continue

print(a_cnt, w_cnt)

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

p = [0]*(n+1)
q = [False]*(n+1)

for _ in range(m) :
  v,s = input().split()
  v = int(v)
  if q[v] : continue
  if s[0] == 'A' : q[v] = True
  else : p[v] += 1

print(sum(q), sum(p[i] for i in range(n+1) if q[i]))

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

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

s = set(p)
dict = {}
for i in s :
  dict[i] = 0
# print(dict)
w_cnt = 0
a_cnt = 0
skip = []
for i in range(M) :
  if p[i] not in skip :
    if S[i] == 'WA' :
      dict[p[i]] += 1
      continue
    else :
      a_cnt += 1
      w_cnt += dict[p[i]]
      skip.append(p[i])
      continue

print(a_cnt, w_cnt)

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

p = [0]*(n+1)
q = [False]*(n+1)

for _ in range(m) :
  v,s = input().split()
  v = int(v)
  if q[v] : continue
  if s[0] == 'A' : q[v] = True
  else : p[v] += 1

print(sum(q), sum(p[i] for i in range(n+1) if q[i]))

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

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

s = set(p)
dict = {}
for i in s :
  dict[i] = 0
# print(dict)
w_cnt = 0
a_cnt = 0
skip = []
for i in range(M) :
  if p[i] not in skip :
    if S[i] == 'WA' :
      dict[p[i]] += 1
      continue
    elif S[i] == 'AC' :
      a_cnt += 1
      w_cnt += dict[p[i]]
      skip.append(p[i])
      continue
  else :
    continue
  # print(a_cnt, w_cnt)

print(a_cnt, w_cnt)

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

p = [0]*(n+1)
q = [False]*(n+1)

for _ in range(m) :
  v,s = input().split()
  v = int(v)
  if q[v] : continue
  if s[0] == 'A' : q[v] = True
  else : p[v] += 1

print(sum(q), sum(p[i] for i in range(n+1) if q[i]))