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

pAC=[]
pWA=[]
for i in range(m):
  p,s=input().split()
  if p not in pAC:
    if s=='AC':
      pAC+=[p]
    else:
      pWA+=[p]

cnt=0
for i in pWA:
  if i in pAC:
    cnt+=1

print(len(set(pAC)),cnt)

Fixed submission:
n,m=map(int,input().split())
ps=[list(map(int,input().replace('WA','0').replace('AC','1').split())) for i in range(m)]
ps.sort(key=lambda x:x[0])

tmp_p=0
ac_cnt=0
wa_cnt=0
wa=0
flg=0
for i in range(m):
  p=ps[i][0]
  s=ps[i][1]
  if tmp_p!=p:
    wa=0
    flg=0
  if s==1 and flg==0:
    flg=1
    ac_cnt+=1
    wa_cnt+=wa
  elif s==0 and flg==0:
    wa+=1
  tmp_p=p
print(ac_cnt, wa_cnt)

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

pAC=[]
pWA=[]
for i in range(m):
  p,s=input().split()
  if p not in pAC:
    if s=='AC':
      pAC+=[p]
    else:
      pWA+=[p]

cnt=0
for i in pWA:
  if i in pAC:
    cnt+=1

print(len(set(pAC)),cnt)

Fixed submission:
n,m=map(int,input().split())
ps=[list(map(int,input().replace('WA','0').replace('AC','1').split())) for i in range(m)]
ps.sort(key=lambda x:x[0])

tmp_p=0
ac_cnt=0
wa_cnt=0
wa=0
flg=0
for i in range(m):
  p=ps[i][0]
  s=ps[i][1]
  if tmp_p!=p:
    wa=0
    flg=0
  if s==1 and flg==0:
    flg=1
    ac_cnt+=1
    wa_cnt+=wa
  elif s==0 and flg==0:
    wa+=1
  tmp_p=p
print(ac_cnt, wa_cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
ps=[list(map(int, input().replace('AC','1').replace('WA','0').split())) for i in range(m)]

pAC=[]
pWA=[]
for i in range(m):
  if ps[i][1]==1 and ps[i][0] not in pAC:
    pAC+=[ps[i][0]]
  elif ps[i][1]==0 and ps[i][0] not in pAC:
    pWA+=[ps[i][0]]

cnt=0
for i in pWA:
  if i in pAC:
    cnt+=1

print(len(set(pAC)),cnt)

Fixed submission:
n,m=map(int,input().split())
ps=[list(map(int,input().replace('WA','0').replace('AC','1').split())) for i in range(m)]
ps.sort(key=lambda x:x[0])

tmp_p=0
ac_cnt=0
wa_cnt=0
wa=0
flg=0
for i in range(m):
  p=ps[i][0]
  s=ps[i][1]
  if tmp_p!=p:
    wa=0
    flg=0
  if s==1 and flg==0:
    flg=1
    ac_cnt+=1
    wa_cnt+=wa
  elif s==0 and flg==0:
    wa+=1
  tmp_p=p
print(ac_cnt, wa_cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
ps=[list(map(int, input().replace('AC','1').replace('WA','-1').split())) for i in range(m)]

pAC=[]
pWA=[]
for i in range(m):
  if ps[i][1]==1 and ps[i][0] not in pAC:
    pAC+=[ps[i][0]]
  elif ps[i][1]==-1 and ps[i][0] not in pAC:
    pWA+=[ps[i][0]]

cnt=0
for i in pWA:
  if i in pAC:
    cnt+=1

print(len(set(pAC)),cnt)

Fixed submission:
n,m=map(int,input().split())
ps=[list(map(int,input().replace('WA','0').replace('AC','1').split())) for i in range(m)]
ps.sort(key=lambda x:x[0])

tmp_p=0
ac_cnt=0
wa_cnt=0
wa=0
flg=0
for i in range(m):
  p=ps[i][0]
  s=ps[i][1]
  if tmp_p!=p:
    wa=0
    flg=0
  if s==1 and flg==0:
    flg=1
    ac_cnt+=1
    wa_cnt+=wa
  elif s==0 and flg==0:
    wa+=1
  tmp_p=p
print(ac_cnt, wa_cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
ps=[list(map(int, input().replace('AC','1').replace('WA','-1').split())) for i in range(m)]

pAC=[]
pWA=[]
for i in range(m):
  if ps[i][1]==1 and ps[i][0] not in pAC:
    pAC+=[ps[i][0]]
  elif ps[i][1]==-1 and ps[i][0] not in pAC:
    pWA+=[ps[i][0]]

pWA2=[]
for i in pWA:
  if i in pAC:
    pWA2+=[i]
pWA=pWA2
print(len(set(pAC)),len(pWA))

Fixed submission:
n,m=map(int,input().split())
ps=[list(map(int,input().replace('WA','0').replace('AC','1').split())) for i in range(m)]
ps.sort(key=lambda x:x[0])

tmp_p=0
ac_cnt=0
wa_cnt=0
wa=0
flg=0
for i in range(m):
  p=ps[i][0]
  s=ps[i][1]
  if tmp_p!=p:
    wa=0
    flg=0
  if s==1 and flg==0:
    flg=1
    ac_cnt+=1
    wa_cnt+=wa
  elif s==0 and flg==0:
    wa+=1
  tmp_p=p
print(ac_cnt, wa_cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
ps=[list(map(int, input().replace('AC','1').replace('WA','-1').split())) for i in range(m)]

pAC=[]
pWA=[]
for i in range(m):
  if ps[i][1]==1 and ps[i][0] not in pAC:
    pAC+=[ps[i][0]]
  elif ps[i][1]==-1 and ps[i][0] not in pAC:
    pWA+=[ps[i][0]]

pWA2=[]
for i in pWA:
  if i in pAC:
    pWA2+=[i]
pWA=pWA2
print(len(set(pAC)),len(pWA))

Fixed submission:
n,m=map(int,input().split())
ps=[list(map(int,input().replace('WA','0').replace('AC','1').split())) for i in range(m)]
ps.sort(key=lambda x:x[0])

tmp_p=0
ac_cnt=0
wa_cnt=0
wa=0
flg=0
for i in range(m):
  p=ps[i][0]
  s=ps[i][1]
  if tmp_p!=p:
    wa=0
    flg=0
  if s==1 and flg==0:
    flg=1
    ac_cnt+=1
    wa_cnt+=wa
  elif s==0 and flg==0:
    wa+=1
  tmp_p=p
print(ac_cnt, wa_cnt)