Buggy python submission (verdict: Time Limit Exceeded):
def main():
  AC = 0
  WA = 0
  
  solving = {}
  solved = []
  
  N,M = map(int, input().split())
  
  P = [0] * M
  S = [0] * M
  
  for i in range(M):
    p, s = input().split()
    if p in solved:
      continue
    elif s == 'WA':
      if p in solving:
        _wa = solving[p]
        solving[p] = _wa + 1
      else:
        solving[p] = 1
    else:
      AC += 1
      if p in solving:
      	WA += solving[p]
      solved.append(p)
  
  print(AC, WA)
  return 0
 
if __name__ == "__main__":
  main()

Fixed submission:
def main():
  AC = 0
  WA = 0
  
  solving = {}
  solved = {}
  
  N,M = map(int, input().split())
  
  for i in range(M):
    p, s = input().split()
    if p in solved:
      continue
    elif s == 'WA':
      if p in solving:
        _wa = solving[p]
        solving[p] = _wa + 1
      else:
        solving[p] = 1
    else:
      AC += 1
      if p in solving:
      	WA += solving[p]
      solved[p] = True
  
  print(AC, WA)
  return 0
 
if __name__ == "__main__":
  main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
  AC = 0
  WA = 0
  
  solving = {}
  solved = []
  
  N,M = map(int, input().split())
  
  Q = [] 
  
  P = [0] * M
  S = [0] * M
  
  for i in range(M):
    p, s = input().split()
    if p in solved:
      continue
    elif s == 'WA':
      if p not in solved:
        if p in solving:
          _wa = solving[p]
          solving[p] = _wa + 1
        else:
          solving[p] = 1
    else:
      AC += 1
      if p in solving:
      	WA += solving[p]
      solved.append(p)
  
  print(AC, WA)
  return 0

if __name__ == "__main__":
  main()

Fixed submission:
def main():
  AC = 0
  WA = 0
  
  solving = {}
  solved = {}
  
  N,M = map(int, input().split())
  
  for i in range(M):
    p, s = input().split()
    if p in solved:
      continue
    elif s == 'WA':
      if p in solving:
        _wa = solving[p]
        solving[p] = _wa + 1
      else:
        solving[p] = 1
    else:
      AC += 1
      if p in solving:
      	WA += solving[p]
      solved[p] = True
  
  print(AC, WA)
  return 0
 
if __name__ == "__main__":
  main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
  AC = 0
  WA = 0
  
  N,M = map(int, input().split())
  
  Q = [] 
  
  P = [0] * M
  S = [0] * M
  
  for i in range(M):
    _p, _s = input().split()
    P[i] = int(_p)
    S[i] = _s
    
  for i,s in enumerate(S):
    if s == 'AC' and P[i] not in Q:
      AC += 1
      for j in range(i):
        if P[j] == P[i] and S[j] == 'WA':
          WA += 1
      Q.append(P[i])
  
  print(AC, WA)
  return 0

if __name__ == "__main__":
  main()

Fixed submission:
def main():
  AC = 0
  WA = 0
  
  solving = {}
  solved = {}
  
  N,M = map(int, input().split())
  
  for i in range(M):
    p, s = input().split()
    if p in solved:
      continue
    elif s == 'WA':
      if p in solving:
        _wa = solving[p]
        solving[p] = _wa + 1
      else:
        solving[p] = 1
    else:
      AC += 1
      if p in solving:
      	WA += solving[p]
      solved[p] = True
  
  print(AC, WA)
  return 0
 
if __name__ == "__main__":
  main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
  AC = 0
  WA = 0
  
  N,M = map(int, input().split())
  
  Q = [0] * N
  
  P = [0] * M
  S = [0] * M
  
  for i in range(M):
    _p, _s = input().split()
    P[i] = int(_p)
    S[i] = _s
    
  for i,s in enumerate(S):
    if s == 'AC':
      if Q[P[i]-1]  == 0:
        AC += 1
        for j in range(i):
          if P[j] == P[i] and S[j] == 'WA':
          	WA += 1
        Q[P[i]-1]  = 1
  
  print(AC, WA)
  return 0

if __name__ == "__main__":
  main()

Fixed submission:
def main():
  AC = 0
  WA = 0
  
  solving = {}
  solved = {}
  
  N,M = map(int, input().split())
  
  for i in range(M):
    p, s = input().split()
    if p in solved:
      continue
    elif s == 'WA':
      if p in solving:
        _wa = solving[p]
        solving[p] = _wa + 1
      else:
        solving[p] = 1
    else:
      AC += 1
      if p in solving:
      	WA += solving[p]
      solved[p] = True
  
  print(AC, WA)
  return 0
 
if __name__ == "__main__":
  main()