qyliang/CodeNanoFix huggingface dataset:
Buggy code:
from collections import defaultdict
N,M = map(int,input().split())
AC_List = defaultdict(int)
WA_List = defaultdict(int)

for i in range(M):
    Num,Sta = map(str,input().split())
    if Num in AC_List:
        continue
    else:
        if Sta == "WA":
            WA_List[Num] += 1
        else:
            AC_List[Num] += 1

ansct = 0
for k,v in WA_List:
    if k in AC_List:
        ansct += v
            
print(str(len(AC_List))+" " +str(ansct))
            
            

Fixed code:
from collections import defaultdict
N,M = map(int,input().split())
AC_List = defaultdict(int)
WA_List = defaultdict(int)

for i in range(M):
    Num,Sta = map(str,input().split())
    if Num in AC_List:
        continue
    else:
        if Sta == "WA":
            WA_List[Num] += 1
        else:
            AC_List[Num] += 1

ansct = 0
for k,v in WA_List.items():
    if k in AC_List:
        ansct += v
            
print(str(len(AC_List))+" " +str(ansct))
Buggy code:
N,M = list(map(int,input().split()))
ans = 0
pen = 0

check = {}

for i in range(M):
    if len(check) == N:
        break
    p,S = input().split()
    p = int(p)
    if p not in check:
        if S == 'WA':
            check[p] = 0
        else:
            ans = 1
    else:
        if S == 'WA':
            check[p] += 1
        elif S == 'AC' and check[p] != -1:
            pen += check[p]
            ans += 1
            check[p] == -1

print(ans,pen)

Fixed code:
N,M = list(map(int,input().split()))
ans = 0
pen = 0

check = {}

for i in range(M):
    p,S = input().split()
    p = int(p)
    if p not in check:
        if S == 'WA':
            check[p] = 1
        else:
            ans += 1
            check[p] = -1
    else:
        if S == 'WA' and check[p] != -1:
            check[p] += 1
        elif S == 'AC' and check[p] != -1:
            pen += check[p]
            ans += 1
            check[p] = -1

print(ans,pen)
Buggy code:
N,M=map(int,input().split())
P,S=[],[]
ans,pen=0,0
task=[0]*N
for _ in range(M):
    A,B=map(str,input().split())
    P.append(int(A))
    S.append(B)

for j in range(M):
    if task[A[M]]!=-1 and S[j]=="WA":
        pen+=1
    elif task[A[M]]!=-1 and S[j]=="AC":
        ans+=1
        task[A[M]]=-1
        break
print(ans,pen)

Fixed code:
N,M=map(int,input().split())
P,S=[],[]
ans,pen=0,0
task=[0]*N
for _ in range(M):
    A,B=map(str,input().split())
    P.append(int(A))
    S.append(B)

for j in range(M):
    if task[P[j]-1]!=-1 and S[j]=="WA":
        task[P[j]-1]+=1
    elif task[P[j]-1]!=-1 and S[j]=="AC":
        ans+=1
        pen+=task[P[j]-1]
        task[P[j]-1]=-1
print(ans,pen)
Buggy code:
n,m = map(int,input().split())
ac,wa = 0,0
d = {}
for i in range(m):
  p,s = input().split()
  if p in d:
    if d[p][1]:
      pass
    else:
      if s=="WA":
          d[p][0]+=1
      elif s=="AC":
          d[p][1]=True
          ac+=1
          wa+=d[p][0]
  else:
    if s=="WA":
      d[p]=[1,False]
      wa+=1
    elif s=="AC":
      d[p]=[0,True]
      ac+=1
print(ac,wa)

Fixed code:
n,m = map(int,input().split())
ac,wa = 0,0
d = {}
for i in range(m):
  p,s = input().split()
  if p in d:
    if d[p][1]:
      pass
    else:
      if s=="WA":
          d[p][0]+=1
      elif s=="AC":
          d[p][1]=True
          ac+=1
          wa+=d[p][0]
  else:
    if s=="WA":
      d[p]=[1,False]
    elif s=="AC":
      d[p]=[0,True]
      ac+=1
print(ac,wa)
Buggy code:
N, M = map(int, input().split())
WA = [0] * N
AC = [0] * N

for i in range(M):
  p,s = input().split()
  p = int(p)
  if AC[p-1] == 0:
    if s == "AC":
      AC[p-1] = 1
      else:
        WA[p-1] += 1
        
wa = 0
for j in range(N):
  if AC[j] == 1:
    wa += WA[j]
print(sum(AC),wa)

Fixed code:
N, M = map(int, input().split())
WA = [0] * N
AC = [0] * N

for i in range(M):
  p,s = input().split()
  p = int(p)
  if AC[p-1] == 0:
    if s == "AC":
      AC[p-1] = 1
    else:
        WA[p-1] += 1
        
wa = 0
for j in range(N):
  if AC[j] == 1:
    wa += WA[j]
print(sum(AC),wa)
Buggy code:
#AtCoder
from collections import defaultdict
N, M = map(int, input().split())

d = defaultdict(list)
for i in range(M):
    p, S = input().split()
    d[int(p)].append(S)

a = 0
p = 0

for i in d.items():
    if 'AC' not in i[1]:
        p += len(i[1])
        continue

    if i[1].index('AC'):
        ac_index = i[1].index('AC')
        a += 1
        wanum = i[1][:ac_index]
        p += len(wanum)

print(a, p)

Fixed code:
#AtCoder
from collections import defaultdict
N, M = map(int, input().split())

d = defaultdict(list)
for i in range(M):
    p, S = input().split()
    d[int(p)].append(S)

a = 0
p = 0
for i in d.items():
    if 'AC' not in i[1]:
        continue

    ac_index = i[1].index('AC')
    a += 1

    if 'WA' in i[1]:
        wanum = i[1][:ac_index]
        p += len(wanum)

print(a, p)
Buggy code:
N,M = map(int,input().split())
PS= [[s for s in input().split()] for _ in range(M)]

def main():
    ac = 0
    wa = 0
    dic = {}
    for p,s in PS:
        if s == "AC":
            if p in dic:
                wa += dic[p]
            ac += 1
        else:
            if p in dic:
                dic[p] += 1
            else:
                dic[p] = 1
    print(ac,wa)
    return 


if __name__ == "__main__":
    main()

Fixed code:
N,M = map(int,input().split())
PS= [[s for s in input().split()] for _ in range(M)]

def main():
    ac = 0
    wa = 0
    dic = {}
    cleared = {}
    for p,s in PS:
        if s == "AC" and p not in cleared:
            cleared[p] = True
            if p in dic:
                wa += dic[p]
            ac += 1
        else:
            if p in dic:
                dic[p] += 1
            else:
                dic[p] = 1
    print(ac,wa)
    return 


if __name__ == "__main__":
    main()
Buggy code:
n, m = map(int, input().split())
l = [list(input().split()) for i in range(m)]
wa = [0]*(10**5)
ac = [0]*(10**5)
WA = 0
for i in range(m):
    p, s = input().split()
    P = int(p)
    if ac[P] != 1:
        if s == "WA":
            wa[P] += 1
        else:
            ac[P] += 1
            WA += wa[P]
print(sum(ac), WA)

Fixed code:
n, m = map(int, input().split())
wa = [0]*(10**5)
ac = [0]*(10**5)
WA = 0
for i in range(m):
    p, s = input().split()
    P = int(p)
    if ac[P] != 1:
        if s == "WA":
            wa[P] += 1
        else:
            ac[P] += 1
            WA += wa[P]
print(sum(ac), WA)
Buggy code:
N, M = map(int, input().split(' '))
ac_set = set()
wa_cnt_ls = [0] * N
wa_cnt = 0
for i in range(M):
    p, s = input().split(' ')
    idx = int(p) - 1
    if not s in ac_set:
        if s == 'AC':
            wa_cnt += wa_cnt_ls[idx]
            ac_set.add(s)
        else:
            wa_cnt_ls[idx] += 1
print(len(ac_set), wa_cnt)

Fixed code:
N, M = map(int, input().split(' '))
ac_set = set()
wa_cnt_ls, wa_cnt = [0] * N, 0
for i in range(M):
    p, s = input().split(' ')
    idx = int(p) - 1
    if not idx in ac_set:
        if s == 'AC':
            wa_cnt += wa_cnt_ls[idx]
            ac_set.add(idx)
        else:
            wa_cnt_ls[idx] += 1
print(len(ac_set), wa_cnt)
Buggy code:
N,M=map(int,input().split())
L=[0]*N
A=0
W=0
tmp=0
for i in range(M):
	x,y=input().split()
	t=int(x)
	if L[t-1]==0:
		if y=="WA":
			tmp+=1
			W+=1
		else:
			A+=1
			W+=tmp
			tmp=0
			L[t-1]=1
print(A,W)

Fixed code:
N,M=map(int,input().split())
L=[0]*N
A=0
W=0
tmp=[0]*N
for i in range(M):
	x,y=input().split()
	t=int(x)
	if L[t-1]==0:
		if y=="WA":
			tmp[t-1]+=1
		else:
			A+=1
			W+=tmp[t-1]
			L[t-1]=1
print(A,W)
Buggy code:
import sys
import fractions
from functools import reduce
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
flgs = [False for i in range(n)]
wa = 0
for i in range(m):
    p, s = stdin.readline().split()
    p = int(p)
    if flgs[p-1] is False:
        if s == 'WA':
            wa += 1
        else:
            flgs[p-1] = True
    else:
        if s == 'WA':
            wa += 1
print(flgs.count(True), wa)


Fixed code:
import sys
import fractions
from functools import reduce
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
flgs = [False for i in range(n)]
tmp = [0 for i in range(n)]
for i in range(m):
    p, s = stdin.readline().split()
    p = int(p)
    if flgs[p-1] is False:
        if s == 'WA':
            tmp[p-1] += 1
        else:
            flgs[p-1] = 1
wa = 0
ac = 0
for i in range(n):
    if flgs[i]:
        ac += 1
        wa += tmp[i]
print(ac, wa)
Buggy code:
# ABC 151C
n, m = map(int, input().split())
ac = 0
wa = 0
cnt = [0]*n
for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    if cnt[p] == -1:
        continue
    if s == 'AC':
        ac += 1
        wa += cnt[p]
        cnt[p] = 0
    else:
        cnt[p] += 1
print(ac, wa)


Fixed code:
# ABC 151C
n, m = map(int, input().split())
ac = 0
wa = 0
cnt = [0]*n
for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    if cnt[p] == -1:
        continue
    if s == 'AC':
        ac += 1
        wa += cnt[p]
        cnt[p] = -1
    else:
        cnt[p] += 1
print(ac, wa)
Buggy code:
N, M = [int(x) for x in input().split()]

obj = {}
ii = 0
jj = 0

for i in range(M):
    p = [x for x in input().split()]
    key = p[0]
    res = p[1]
    if key not in obj:
        obj[key] = {'AC': 0, 'WA': 0}
    if res == 'WA' and obj[key]['AC'] > 0:
        obj[key]['WA'] = obj[key]['WA'] + 1
    if res == 'AC':
        obj[key]['AC'] = 1

for k in obj:
    ii = ii + obj[k]['AC']
    jj = jj + obj[k]['WA']


print(ii, jj)

Fixed code:
N, M = [int(x) for x in input().split()]

obj = {}
ii = 0
jj = 0

for i in range(M):
    p = [x for x in input().split()]
    key = p[0]
    res = p[1]
    if key not in obj:
        obj[key] = {'AC': 0, 'WA': 0}
    if res == 'WA' and obj[key]['AC'] == 0:
        obj[key]['WA'] = obj[key]['WA'] + 1
    if res == 'AC':
        obj[key]['AC'] = 1

for k in obj:
    ii = ii + obj[k]['AC']
    if obj[k]['AC'] > 0:
        jj = jj + obj[k]['WA']


print(ii, jj)
Buggy code:
n, m = map(int, input().split())
q_re = set()
ac = 0
wa = 0
dic_wa = {}
for i in range(m):
    q, re = input().split()
    if(re == "WA" and q not in q_re): 
        if(q not in dic_wa): dic_wa[q] = 1
        else: dic_wa[q] += 1
    if(re == "AC" and q not in q_re): 
        ac += 1
        q_re.add(q)
        wa += dic_wa[q]
print(ac, wa)

Fixed code:
n, m = map(int, input().split())
q_re = set()
ac = 0
wa = 0
dic_wa = {}
for i in range(m):
    q, re = input().split()
    if(re == "WA" and q not in q_re): 
        if(q not in dic_wa): dic_wa[q] = 1
        else: dic_wa[q] += 1
    if(re == "AC" and q not in q_re): 
        ac += 1
        q_re.add(q)
        if(q in dic_wa): wa += dic_wa[q]
print(ac, wa)
Buggy code:
N,M = map(int, input().split())
r = {}
a = {}
for i in range(M):
    l = input().split()
    p = int(l[0])
    q = l[1]
    w = q + str(p)
    if r.get(p) == 'AC':
        pass
    else:
        r.update([(p, q)])
        if a.get(w) != None:
            a[w] += 1
        else:
            a.update([(w, 1)])
ks = [k for k, v in r.items() if v == 'AC']
wa = 0
ac = 0
for i in ks:
    wk = 'WA' + str(i)
    ak = 'AC' + str(i)
    if a.get(wk) != None:
        wa += a[wk]
    ac += a[ak]
print(wa, ac)

Fixed code:
N,M = map(int, input().split())
r = {}
a = {}
for i in range(M):
    l = input().split()
    p = int(l[0])
    q = l[1]
    w = q + str(p)
    if r.get(p) == 'AC':
        pass
    else:
        r.update([(p, q)])
        if a.get(w) != None:
            a[w] += 1
        else:
            a.update([(w, 1)])
ks = [k for k, v in r.items() if v == 'AC']
wa = 0
ac = 0
for i in ks:
    wk = 'WA' + str(i)
    ak = 'AC' + str(i)
    if a.get(wk) != None:
        wa += a[wk]
    ac += a[ak]
print(ac, wa)
Buggy code:
n,m=map(int,input().split())

l=[0 for i in range(n)]
t=""
w=0
ww=0
a=0
for i in range(m):
    p,s=input().split()
    if(l[int(p)-1]==1):continue
    if(s=="WA"):
        w+=1
        ww+=1
    if(s=="AC"):
        ww=0
        a+=1
        l[int(p-1)]=1
print(a,w-ww)

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

l=[0 for i in range(n)]
ll=[0 for i in range(n)]
w=0
a=0
for i in range(m):
    p,s=input().split()
    if(l[int(p)-1]==1):continue
    if(s=="WA"):ll[int(p)-1]+=1
    if(s=="AC"):
        l[int(p)-1]=1
        w+=ll[int(p)-1]
        a+=1
print(a,w)
Buggy code:
n, m = map(int, input().split())

solved = [0]* 10**5
penalty_sum = 0
penalty = 0

for _ in range(m):
    q, result = input().split()
    q = int(q)
    
    if result == 'AC':
        if solved[q] == 0:
            penalty_sum += penalty
            penalty = 0
    else:
        if solved[q] == 0:
            penalty += 1

print(str(sum(solved)) + " " + str(penalty_sum))

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

solved = [0]* 10**5
penalty = [0]* 10**5
penalty_sum = 0
for _ in range(m):
    q, result = input().split()
    q = int(q) - 1
    
    if result == 'AC':
        if solved[q] == 0:
            solved[q] = 1
            penalty_sum += penalty[q]
    else:
        if solved[q] == 0:
            penalty[q] += 1

print(str(sum(solved)) + " " + str(penalty_sum))
Buggy code:
N,M = map(int,input().split())
ls2 = []
for i in range(M):
    A,B = map(str,input().split())
    ls = [int(A)-1,B]
    ls2.append(ls)

Pena = 0
corr = 0

ls3 = sorted(ls2, key=lambda x: x[0])
lsans = [[] for i in range(M)]
for i in range(M):
    lsans[ls2[i][0]].append(ls2[i][1])

for i in range(M):
    if bool(lsans[i]):
        for ans in lsans[i]:
            if ans == 'WA':
                Pena += 1
            if ans == 'AC':
                corr += 1
                break
print(corr,Pena)

Fixed code:
N,M = map(int,input().split())
ls2 = []
for i in range(M):
    A,B = map(str,input().split())
    ls = [int(A)-1,B]
    ls2.append(ls)

Pena = 0
corr = 0

#ls3 = sorted(ls2, key=lambda x: x[0])
lsans = [[] for i in range(N)]
for i in range(M):
    lsans[ls2[i][0]].append(ls2[i][1])

for i in range(N):
    if 'AC' in lsans[i]:
        for ans in lsans[i]:
            if ans == 'WA':
                Pena += 1
            if ans == 'AC':
                corr += 1
                break
print(corr,Pena)
Buggy code:
N , M = map(int,input().split())
p = [''] * M
S = [''] * M
A = [0] * N
W = [0] * N
for i in range(M):
    p[i],S[i] = map(str,input().split())
    p[i] = int(p[i])
    if A[p[i]-1] == 0:
        if S[i] == 'WA':
            W[p[i]-1] += 1
        else:
            A[p[i]-1] += 1

for j in range(N):
    if A[j] == 0:
        W[j] =0
 print(sum(A),sum(W))


Fixed code:
N , M = map(int,input().split())
p = [''] * M
S = [''] * M
A = [0] * N
W = [0] * N
for i in range(M):
    p[i],S[i] = map(str,input().split())
    p[i] = int(p[i])
    if A[p[i]-1] == 0:
        if S[i] == 'WA':
            W[p[i]-1] += 1
        else:
            A[p[i]-1] += 1

for j in range(N):
    if A[j] == 0:
        W[j] =0
print(sum(A),sum(W))
Buggy code:
n,m=map(int,input().split())
ac=[0]*(n+1)
wa=[0]*(n+1)
for _ in range(m):
    i,j=input().split()
    i=int(i)
    if j=="AC":
        ac[i]=1
    elif ac[i]==0 and j=="WA":
        wa[i]+=1
print(sum(ac),sum(wa[i] for i in range(m) if ac[i]==1))    

Fixed code:
n,m=map(int,input().split())
ac=[0]*(n+1)
wa=[0]*(n+1)
for _ in range(m):
    i,j=input().split()
    i=int(i)
    if j=="AC":
        ac[i]=1
    elif ac[i]==0 and j=="WA":
        wa[i]+=1
print(sum(ac),sum(wa[i] for i in range(n+1) if ac[i]==1))
Buggy code:
n, m = [int(v) for v in input().split()]

count_map = [0] * m

count = 0
miss = 0
for i in range(m):
	p, s = input().split()
    
    if count_map[p] == True:
      continue
    
    if s == 'AC':
	    count_map[p] = True
        count += 1
    else:
      	miss += 1
      
print(count, miss)




Fixed code:
n, m = [int(v) for v in input().split()]

count_map = [0] * (n + 1)
miss_map = [0] * (n + 1)

count = 0
miss = 0
for i in range(m):
    p, s = input().split()
    p = int(p)

    if count_map[p]:
        continue

    if s == 'AC':
        count_map[p] = True
        count += 1
        miss += miss_map[p]
    else:
        miss_map[p] += 1

print(count, miss)
Buggy code:
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
ans = [[] for i in range(N)]
for i in range(M):
    p,s = [(x) for x in stdin.readline().rstrip().split()]
    ans[int(p)-1].append(s)

ac = 0
pe = 0
tmp = 0
flag = False
for j in range(N):
    for k in ans[j]:
        if k == "WA":
            tmp += 1
        else:
            ac += 1
            pe += tmp
            break
print(ac,pe)

Fixed code:
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
ans = [[] for i in range(N)]
for i in range(M):
    p,s = [(x) for x in stdin.readline().rstrip().split()]
    ans[int(p)-1].append(s)

ac = 0
pe = 0
tmp = 0
flag = False
for j in range(N):
    tmp = 0
    for k in ans[j]:
        if k == "WA":
            tmp += 1
        else:
            ac += 1
            pe += tmp
            tmp = 0
            break
print(ac,pe)
Buggy code:
N,M = map(int,input().split())
#if 'AC':{1:-1}
#if 'WA'*2:{1:2}
problems = {}
correct = 0
penalty = 0
for i in range(M):
    p,s = map(str,input().split())
    p = int(p)
    if p not in problems.keys():
        if s == 'AC':
            problems[p] = -1
            correct += 1
        else: #if s == 'WA' and not ACed yet 
            problems[p] = 1
    else: 
        if s == 'AC' and problems[p] != -1: #first AC
            penalty += problems[p]
            problems[p] = -1
            correct += 1
        else:
            problems[p] += 1
            
print(correct,penalty)

Fixed code:
N,M = map(int,input().split())
#if 'AC':{1:-1}
#if 'WA'*2:{1:2}
problems = {}
correct = 0
penalty = 0
for i in range(M):
    p,s = map(str,input().split())
    p = int(p)
   
    if p not in problems.keys():
        if s == 'AC':
            problems[p] = -1
            correct += 1
        else: #if s == 'WA' and not ACed yet 
            problems[p] = 1
    else: 
        if s == 'AC' and problems[p] != -1: #first AC
            penalty += problems[p]
            problems[p] = -1
            correct += 1
        elif s == 'WA' and problems[p] != -1:
            problems[p] += 1
            
print(correct,penalty)
Buggy code:
N,M=map(int,input().split())
acs=[0 for i in range(N)]
wa=[0 for i in range(N)]

for  i in range(M):
    p,S=map(str,input().split())
    p=int(p)
    if S=='AC':
        acs[p-1]=1
    elif S=='WA' and acs[p-1]==0: 
        wa[p-1]+=1
for i in range(M):
    if acs[i]==0:
        wa[i]=0
ans=[sum(acs),sum(wa)]


Fixed code:
N,M=map(int,input().split())
acs=[0 for i in range(N)]
wa=[0 for i in range(N)]

for  i in range(M):
    p,S=map(str,input().split())
    p=int(p)
    if S=='AC':
        acs[p-1]=1
    elif S=='WA' and acs[p-1]==0: 
        wa[p-1]+=1
for i in range(N):
    if acs[i]==0:
        wa[i]=0
ans=[sum(acs),sum(wa)]
print(*ans)
Buggy code:
N, M = map(int, input().split())
ac = [False] * N
wa_cnt = [0] * N
ac_cnt = 0
for i in range(M):
    p, s = input().split()
    p_i = int(p) - 1
    if s == 'WA':
        if not ac[p_i]:
            wa_cnt[p_i] += 1
    else:
        if not ac[p_i]:
            ac[p_i] = True
            ac_cnt += 1

wa_cnt_sum = 0
for i in range(N):
    if ac_cnt[i]:
        wa_cnt_sum += wa_cnt[i]

print(ac_cnt,wa_cnt_sum)


Fixed code:
N, M = map(int, input().split())
ac = [False] * N
wa_cnt = [0] * N
ac_cnt = 0
for i in range(M):
    p, s = input().split()
    p_i = int(p) - 1
    if s == 'WA':
        if not ac[p_i]:
            wa_cnt[p_i] += 1
    else:
        if not ac[p_i]:
            ac[p_i] = True
            ac_cnt += 1

wa_cnt_sum = 0
for i in range(N):
    if ac[i]:
        wa_cnt_sum += wa_cnt[i]

print(ac_cnt,wa_cnt_sum)
Buggy code:
n, m = map(int, input().split())
li = []
for i in range(m):
  li.append(list(input().split()))
li_a = [0 for i in range(m)]
li_b = [0 for i in range(m)]
a = 0
b = 0
for j in range(m):
  if li[j][1] == "WA":
    li_b[int(li[j][0])] += 1
  elif li[j][1] == "AC" and li_a[j] == 0:
    a += 1
    b += li_b[int(li[j][0])]
    li_a[j] += 1
print(a, b)

Fixed code:
n, m = map(int, input().split())
li = []
for i in range(m):
  li.append(list(input().split()))
li_a = [0 for i in range(n)]
li_b = [0 for i in range(n)]
a = 0
b = 0
for j in range(m):
  if li[j][1] == "WA":
    li_b[int(li[j][0])-1] += 1
  elif li[j][1] == "AC" and li_a[int(li[j][0])-1] == 0:
    a += 1
    b += li_b[int(li[j][0])-1]
    li_a[int(li[j][0])-1] += 1
print(a, b)
Buggy code:
N, M = map(int, input().split())
p = dict()
ans, penalty = 0, 0
for _ in range(M):
  tmp = input()
  if tmp[0] in p:
    continue
  if tmp[1] == 'AC':
    p[tmp[0]] = 1
    ans += 1
  else:
    penalty += 1
print(ans, penalty)

Fixed code:
N, M = map(int, input().split())
p = dict()
ac = dict()
ans, penalty = 0, 0
for _ in range(M):
  tmp = input().split()
  if tmp[0] in ac:
    continue
  if tmp[1] == 'AC':
    ans += 1
    ac[tmp[0]] = 1
    penalty += p.get(tmp[0], 0)
  else:
    p[tmp[0]] = p.get(tmp[0], 0) + 1
print(ans, penalty)
Buggy code:
import sys


def resolve(in_):
    N, M = map(int, next(in_).split())
    PS = tuple(line.strip().split() for line in in_)
    
    ac = set()
    wa = {}

    for p, s in PS:
        if s == 'AC':
            ac.add(p)
        if s == 'WA' and p not in ac:
            wa[p] = wa.setdefault(p, 0) + 1

    penalties = 0
    for k, v in wa.items:
        if k in ac:
            penalties += v
    
    return '{} {}'.format(len(ac), penalties)


def main():
    answer = resolve(sys.stdin)
    print(answer)


if __name__ == '__main__':
    main()


Fixed code:
import sys


def resolve(in_):
    N, M = map(int, next(in_).split())
    PS = tuple(line.strip().split() for line in in_)
    
    ac = set()
    wa = {}

    for p, s in PS:
        if s == 'AC':
            ac.add(p)
        if s == 'WA' and p not in ac:
            wa[p] = wa.setdefault(p, 0) + 1

    penalties = 0
    for k, v in wa.items():
        if k in ac:
            penalties += v
    
    return '{} {}'.format(len(ac), penalties)


def main():
    answer = resolve(sys.stdin)
    print(answer)


if __name__ == '__main__':
    main()
Buggy code:
n, m = map(int, input().split())

ac = [0]*n
wa = [0]*n

for i in range(m):
  p, s = input().split()
  p = int(p)-1

  if s == 'WA' and ac[p] == 0:
    wa[p] += 1
  elif s == 'AC' and ac[p] == 0:
    ac[p] += 1

print(sum(ac), sum(wa[k] for k in [i for i,j in enumerete(ac) if j != 0]))

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

ac = [0]*n
wa = [0]*n

for i in range(m):
    p, s = input().split()

    if s == 'WA' and ac[int(p)-1] == 0:
            wa[int(p)-1] += 1
    elif s == 'AC' and ac[int(p)-1] == 0:
            ac[int(p)-1] += 1

print('%d %d' % (sum(ac), sum([wa[k] for k in [i for i, j in enumerate(ac) if j != 0]])))
Buggy code:
n, m = map(int, input().split())
l = [False] * n
ans = [0, 0]
for i in range(n):
  p, r = map(input().split())
  if l[int(p) - 1] == False:
    if r == "WA":
      c[0] += 1
    elif r == "AC":
      l[int(p) - 1] == True
      c[1] += 1
print(c[1], c[0])

Fixed code:
n, m = map(int, input().split())
l = [False] * n
c = [0] * n
ans = [0, 0]
for i in range(m):
  p, r = map(str, input().split())
  if l[int(p) - 1] == False:
    if r == "WA":
      c[int(p) - 1] += 1
    elif r == "AC":
      l[int(p) - 1] = True
      ans[0] += c[int(p) - 1]
      ans[1] += 1
print(ans[1], ans[0])
Buggy code:
n,m = map(int,input().split())
li = [[0,0] for _ in range(n)]
t1,t2 = 0,0
for i in range(m):
    a,b = input().split()
    if li[int(a)-1][0] != 1:
        if b == "WA":
            li[int(a)-1][1] += 1
        else b == "AC":
            li[int(a)-1][0] += 1
for i in range(n):
    t1 += li[i][0]
    t2 += li[i][1]
print(t1,t2)

Fixed code:
n,m = map(int,input().split())
li = [[0,0] for _ in range(n)]
t1,t2 = 0,0
for i in range(m):
    a,b = input().split()
    if li[int(a)-1][0] != 1:
        if b == "WA":
            li[int(a)-1][1] += 1
        if b == "AC":
            li[int(a)-1][0] += 1
for i in range(n):
    t1 += li[i][0]
    t2 += li[i][1]*li[i][0]
print(t1,t2)