qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N, M = [int(i) for i in input().split()]
pS = {}

for _ in range(M):
    a, s = [i for i in input().split()]
    if a not in pS:
        pS[a] = {}
        if s == 'AC':
            pS[a]['AC'] = True
        else:
            pS[a]['count'] = 1
    else:
        if s == 'AC':
            pS[a]['AC'] = True
        elif 'AC' not in pS[a]:
            pS[a]['count'] += 1

s = 0
a = 0
for v in pS.values():
    s += v['count']
    if 'AC' in v:
        a += 1
    
print(a, s)

Fixed code:
N, M = [int(i) for i in input().split()]
pS = {}

for _ in range(M):
    a, s = [i for i in input().split()]
    if a not in pS:
        pS[a] = {}
        if s == 'AC':
            pS[a]['AC'] = True
        else:
            pS[a]['count'] = 1
    else:
        if s == 'AC':
            pS[a]['AC'] = True
        elif 'AC' not in pS[a]:
            pS[a]['count'] += 1

s = 0
a = 0
for v in pS.values():
    if 'AC' in v and 'count' in v:
        s += v['count']
    if 'AC' in v:
        a += 1
    
print(a, s)
Buggy code:
N,M = map(int,input().split())
dp = [0]*(N+1)
li = []
kaku = [0]*(N+1)
count =0
for m in range(M):
    p,s = input().split()
    p = int(p)
    li.append([p,s])
    
for i in li:
    if i[1]=="WA":
        dp[i[0]] += 1
    
    else:
        kaku[i[0]] = dp[i[0]]

for k in kaku:
    if k != 0:
        count += 1

print(count,sum(kaku))

Fixed code:
N,M = map(int,input().split())
dp = [0]*(N+1)
li = []
kaku = [0]*(N+1)
dpp = [0]*(N+1)
count =0
for m in range(M):
    p,s = input().split()
    p = int(p)
    li.append([p,s])
    
for i in li:
    if i[1]=="WA":
        dp[i[0]] += 1
    
    else:
        if dpp[i[0]] ==0:
            dpp[i[0]]=1
            kaku[i[0]] = dp[i[0]]


print(sum(dpp),sum(kaku))
Buggy code:
from sys import stdin
n,m = map(int, stdin.readline().rstrip().split())

count = 0
penalty = 0
qb = [0]*n
was = [0]*n

for i in range(m):
    p,s = map(str,stdin.readline().rstrip().split())
    p = int(p)
    if s == "AC" and qb[p-1] != "AC":
        qb[p-1] = "AC"
        pentalty += was[p-1]
        count += 1
    elif s == "WA":
        was[p-1] += 1
    else:
        pass

print(count, penalty)

Fixed code:
from sys import stdin
n,m = map(int, stdin.readline().rstrip().split())

count = 0
penalty = 0
qb = [0]*n
was = [0]*n

for i in range(m):
    p,s = map(str,stdin.readline().rstrip().split())
    p = int(p)
    if s == "AC" and qb[p-1] != "AC":
        qb[p-1] = "AC"
        penalty += was[p-1]
        count += 1
    elif s == "WA":
        was[p-1] += 1
    else:
        pass

print(count, penalty)
Buggy code:
N, M = map(int,input().split())
results = [0 for _ in range(N+1)]
wa_cnt = 0
ac_cnt = 0
for _ in range(M):
  problem, result = input().split()
  if results[problem] == 0 and result == 'AC':
    ac_cnt += 1
    results[problem] = 1
  elif results[problem] == 0 and result == 'WA':
    wa_cnt += 1
print(ac_cnt, wa_cnt)

Fixed code:
N, M = map(int,input().split())
results = [0 for _ in range(N+1)]
wa_list = [0 for __ in range(N+1)]
ac_cnt = 0
wa_cnt = 0
for _ in range(M):
  problem, result = input().split()
  if results[int(problem)] == 0 and result == 'AC':
    ac_cnt += 1
    results[int(problem)] = 1
  elif results[int(problem)] == 0 and result == 'WA':
    wa_list[int(problem)] += 1
for i in range(1, N+1):
  if results[i] == 1:
    wa_cnt += wa_list[i]
print(ac_cnt, wa_cnt)
Buggy code:

N,M = map(int,input().split())
ps = [list(map(str,input().split())) for _ in range(M)]

wacnt = [0]*(N+1)
is_ac = [False]*(N+1)
for pp,s in ps:
    p = int(pp)
    if s=='AC':
        is_ac[p] = True
    else:
        if not is_ac[p]:
            wacnt[p] += 1

ans = 0
for l in range(N+1):
    if is_ac[l]:
       ans += wacnt[l]
       
print(ans)

Fixed code:

N,M = map(int,input().split())
ps = [list(map(str,input().split())) for _ in range(M)]

wacnt = [0]*(N+1)
is_ac = [False]*(N+1)
for pp,s in ps:
    p = int(pp)
    if s=='AC':
        is_ac[p] = True
    else:
        if not is_ac[p]:
            wacnt[p] += 1
num = 0
ans = 0
for l in range(N+1):
    if is_ac[l]:
       ans += wacnt[l]
       num += 1
       
print(num,ans)
Buggy code:
n,m = map(int,input().split(' '))
score = 0
penalty = 0
penalties = {}
acs = set()
for _ in range(m):
    num,result = input().split(' ')
    if num in acs:
        continue
    
    if result == "WA":
        if 'num' in penalties:
            penalties['num'] +=1
        else:
            penalties['num'] =1
    else:
        score +=1
        if 'num' in penalties:
            penalty += penalties['num']
        acs.add(num)

print(score,penalty)

Fixed code:
n,m = map(int,input().split(' '))
score = 0
penalty = 0
penalties = {}
acs = set()
for _ in range(m):
    num,result = input().split(' ')
    if num in acs:
        continue
    
    if result == "WA":
        if num in penalties:
            penalties[num] +=1
        else:
            penalties[num] =1
    else:
        score +=1
        if num in penalties:
            penalty += penalties[num]
        acs.add(num)

print(score,penalty)
Buggy code:
nm=list(map(int,input().split()))
ps=[]
for i in range(nm[1]):
    ps.append(list(input().split()))
    ps[-1][0]=int(ps[-1][0])
ac=[0]*nm[0]
wa=0
for i in range(nm[1]):
    if ps[i][1]=="AC":
        if ac[ps[i][0]]==0:
            ac[ps[i][0]]=1
        else:
            pass
    else:
        if ac[ps[i][0]]==0:
            wa+=1
        else:
            pass
print(sum(ac),wa)


Fixed code:
nm=list(map(int,input().split()))
ps=[]
for i in range(nm[1]):
    ps.append(list(input().split()))
    ps[-1][0]=int(ps[-1][0])
ac=[0]*nm[0]
wa=[0]*nm[0]
for i in range(nm[1]):
    if ps[i][1]=="AC":
        if ac[ps[i][0]-1]==0:
            ac[ps[i][0]-1]=1
        else:
            pass
    else:
        if ac[ps[i][0]-1]==0:
            wa[ps[i][0]-1]+=1
        else:
            pass
ans=0
for i in range(nm[0]):
    if ac[i]==1:
        ans+=wa[i]
print(sum(ac),ans)
Buggy code:
lst = []
n, m  = map(int, input().split())
for _ in range(m):
    i, h = input().split()
    lst.append([int(i), str(h)])

jdg_wa = [0] * n 
jdg_ac = [0] * n

for _ in lst:
    idx = _[0] - 1
    if _[1] == 'WA' and jdg_ac[idx] != 1:
        jdg_wa[idx] += 1
    elif _[1] == 'AC':
        jdg_ac[idx] = 1
        penalty += jdg_wa[idx]
        
print(sum(jdg_ac),penalty)

Fixed code:
lst = []
n, m  = map(int, input().split())
for _ in range(m):
    i, h = input().split()
    lst.append([int(i), str(h)])

jdg_wa = [0] * n 
jdg_ac = [0] * n

penalty = 0
for _ in lst:
    idx = _[0] - 1
    if  jdg_ac[idx] != 1:
        if _[1] == 'WA':
            jdg_wa[idx] += 1
        elif _[1] == 'AC':
            jdg_ac[idx] = 1
            penalty +=  jdg_wa[idx]
print(sum(jdg_ac), penalty)
Buggy code:
n,m = map(int,input().split())
a = [input().split() for i in rabge(m)]
p = [int(i[0]) for i in a]
q = [j[1] for j in a]

ac = 0
wa = 0
wa_c = [0]*n
ac_c = [False]*n

for t in range(m):
    if ac_c[p[t]-1]:
        continue
    if q[t] == "AC":
        ac += 1
        ac_c[p[t]-1] = True
        wa += wa_c[p[t]-1]
    else:
        wa_c[p[t]-1] += 1
print(ac,wa)

Fixed code:
n,m = map(int,input().split())
a = [input().split() for i in range(m)]
p = [int(i[0]) for i in a]
q = [j[1] for j in a]

ac = 0
wa = 0
wa_c = [0]*n
ac_c = [False]*n

for t in range(m):
    if ac_c[p[t]-1]:
        continue
    if q[t] == "AC":
        ac += 1
        ac_c[p[t]-1] = True
        wa += wa_c[p[t]-1]
    else:
        wa_c[p[t]-1] += 1
print(ac,wa)
Buggy code:
def ACWA(p,j,p_list):
    if j=="AC":
        p_list[p][0]=1
    else:
        p_list[p][1]+=1
    return p_list
    
N,M = map(int,input().split(" "))
p_list = {}
wa_count = 0

for _ in range(M):
    In = input().split()
    if (In[0] in p_list) == False:
        p_list[In[0]]=[0,0]
        p_list = ACWA(In[0],In[1],p_list)
    else:
        if p_list[In[0]][0]==1:
            continue
        else:
            p_list = ACWA(In[0],In[1],p_list)
                
List = list(p_list.values())
a = 0
b = 0

for i in range(len(List)):
    if List[i][0]==1:
        a+=List[i][0]
        b+=List[i][0]

print("{} {}".format(a,b))

Fixed code:
def ACWA(p,j,p_list):
    if j=="AC":
        p_list[p][0]=1
    else:
        p_list[p][1]+=1
    return p_list
    
N,M = map(int,input().split(" "))
p_list = {}
wa_count = 0

for _ in range(M):
    In = input().split()
    if (In[0] in p_list) == False:
        p_list[In[0]]=[0,0]
        p_list = ACWA(In[0],In[1],p_list)
    else:
        if p_list[In[0]][0]==1:
            continue
        else:
            p_list = ACWA(In[0],In[1],p_list)
                
List = list(p_list.values())
a = 0
b = 0

for i in range(len(List)):
    if List[i][0]==1:
        a+=List[i][0]
        b+=List[i][1]

print("{} {}".format(a,b))
Buggy code:
from sys import stdin as s
n,m=map(int,s.readline().split())
l=[0]*n
wa=[0]*n
cor,pen=0
for i in range(m):
  x,y=s.readline().split()
  x=int(x)-1
  if y=="AC":
    l[x]=1
  elif not l[x]:
    wa[x]+=1
for i in range(n):
  if l[i]:
    cor+=1
    pen+=wa[i]
print(cor,pen)

Fixed code:
from sys import stdin as s
n,m=map(int,s.readline().split())
l=[0]*n
wa=[0]*n
cor,pen=0,0
for i in range(m):
  x,y=s.readline().split()
  x=int(x)-1
  if y=="AC":
    l[x]=1
  elif not l[x]:
    wa[x]+=1
for i in range(n):
  if l[i]:
    cor+=1
    pen+=wa[i]
print(cor,pen)
Buggy code:
n, m = map(int, input().split())
penalty = [0 for x in range(n+1)]
solved = [-1 for x in range(n+1)]
ans = 0
ans_penalty = 0
for i in range(m):
    p, s = map(str, input().split())
    p = int(p)
    if s == "WA":
        if solved[p] == -1:
            penalty[p] += 1
    else:
        ans += 1
        ans_penalty += penalty[p]
        solved[p] = 0
print(ans, ans_penalty)


Fixed code:
n, m = map(int, input().split())
penalty = [0 for x in range(n+1)]
solved = [-1 for x in range(n+1)]
ans = 0
ans_penalty = 0
for i in range(m):
    p, s = map(str, input().split())
    p = int(p)
    if s == "WA":
        if solved[p] == -1:
            penalty[p] += 1
    else:
        if solved[p] == -1:
            ans += 1
            ans_penalty += penalty[p]
            solved[p] = 0
print(ans, ans_penalty)
Buggy code:
n, m = list(map(int, input().split()))

a = [0]*(n+10)
w = [0]*(n+10)

for i in range(0, m):
    p, s = input().split()
    p = int(p)
    if ((s == "AC")&(a[p] == 0)):
        a[p] += 1
    if ((s == "WA")&(a[p] == 0)):
        w[p] += 1
ac = 0
wa = 0
for i in range(0, n+10):
    ac += a[i]
    if a[i]==1:
        wa += w[i]
print(n)
print(a)
print(w)
print(str(ac)+" "+str(wa))

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

a = [0]*(n+10)
w = [0]*(n+10)

for i in range(0, m):
    p, s = input().split()
    p = int(p)
    if ((s == "AC")&(a[p] == 0)):
        a[p] += 1
    if ((s == "WA")&(a[p] == 0)):
        w[p] += 1
ac = 0
wa = 0
for i in range(0, n+10):
    ac += a[i]
    if a[i]==1:
        wa += w[i]
print(str(ac)+" "+str(wa))
Buggy code:
d = [0]*10**5

a = set()
w = 0

for t in open(0):
    p, s = t.split
    p = int(p)
    if "AC" == s and p not in a:
        w += d[p]
        a.add(p)
    if "WA" == s:
        d[p] += 1

print(len(a), w)

Fixed code:
d = [0]*10**5

a = set()
w = 0

for t in open(0):
    p, s = t.split()
    p = int(p)
    if "AC" == s and p not in a:
        w += d[p]
        a.add(p)
    if "WA" == s:
        d[p] += 1

print(len(a), w)
Buggy code:
d = dict()
wa = ac = 0
N, M= map(int,input().split())
for i in range(M):
  a, b = input().split()
  if a not in d:
    d[a] = 0
if d[a] >= 0 and b == "AC":
    ac += 1
    wa += d[a]
    d[a] = -1
elif d[a] >= 0:
    d[a] += 1
print(ac,wa)

Fixed code:
d = dict()
wa = ac = 0
N, M= map(int,input().split())
for i in range(M):
  a, b = input().split()
  if a not in d:
    d[a] = 0
  if d[a] >= 0 and b == "AC":
    ac += 1
    wa += d[a]
    d[a] = -1
  elif d[a] >= 0:
    d[a] += 1
print(ac,wa)
Buggy code:
N ,M = map(int, input().split())
ps = [list(input().split()) for i in range(M)]

ac = [0 for i in range(N)]
wa = [0 for i in range(N)]

for i in range(M):
    s = int(ps[i][0])-1
    if ps[i][1] == "WA" and ac[s] == 0:
        wa[s] += 1

    if ps[i][1] == "AC" and ac[s] == 0:
        ac[s] = 1

for i in range(M):
    if ac[i] == 0:
        wa[i] == 0

print(str(sum(ac)) + " " + str(sum(wa)))


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

ac = [0 for i in range(N)]
wa = [0 for i in range(N)]

for i in range(M):
    s = int(ps[i][0])-1
    if ps[i][1] == "WA" and ac[s] == 0:
        wa[s] += 1

    if ps[i][1] == "AC" and ac[s] == 0:
        ac[s] = 1

for i in range(N):
    if ac[i] == 0:
        wa[i] = 0

print(str(sum(ac)) + " " + str(sum(wa)))
Buggy code:
N,M = map(int,input().split())
li = []
for i in range(M):
    li.append(input().split())


r = ['WA']*(N+1)
o = []
c = 0
ac_c = 0
p_c =0
li.sort()

for ps in li:
    index = int(ps[0])
    if ps[1] == 'WA':
        if r[index] == 'WA':
            
            c+=1

    else: # AC
        if r[index] == 'WA':
            r[index] = 'AC'
            p_c += c
            ac_c += 1
        else:
            pass
        c=0

print(ac_c, p_c)


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


r = ['WA']*(N+1)
wa_li = [0]*(N+1)
o = []
c = 0
ac_c = 0

for ps in li:
    index = int(ps[0])
    if ps[1] == 'WA':
        if r[index] == 'WA':
            wa_li[index]+=1

    else: # AC
        if r[index] == 'WA':
            r[index] = 'AC'
            ac_c += 1
        else:
            pass

p_c =0
for i,v in enumerate(r):
    if v == 'AC':
        p_c+=wa_li[i]

print(ac_c, p_c)
Buggy code:
n, m = [int(x) for x in input().split()]
ac = [0] * (n + 1)
wa = [0] * (n + 1)

for i in range(m):
    p, s = input().split()
    print(p, s)
    p = int(p)
    if s == "AC":
        ac[p] = 1
    if s == "WA" and ac[p] == 0:
        wa[p] += 1

print(sum(ac), sum([p for a, p  in zip(ac, wa) if a == 1]))



Fixed code:
n, m = [int(x) for x in input().split()]
ac = [0] * (n + 1)
wa = [0] * (n + 1)

for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == "AC":
        ac[p] = 1
    if s == "WA" and ac[p] == 0:
        wa[p] += 1

print(sum(ac), sum([p for a, p  in zip(ac, wa) if a == 1]))
Buggy code:
N, M = [int(x) for x in input().split()]

ok = 0
ng = 0
ng_l = {}
end = set()

for _ in range(M):
    p, S = [x for x in input().split()]
    p = int(p)

    if not p in end:
        if S == 'AC':
            ok += 1
            ng += ng_l[p]
            end.add(p)
        else:
            if p in ng_l:
                ng_l[p] += 1
            else:
                ng_l[p] = 1

print('{} {}'.format(ok, ng))


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

ok = 0
ng = 0
ng_l = {}
end = set()

for _ in range(M):
    p, S = [x for x in input().split()]
    p = int(p)

    if not p in end:
        if S == 'AC':
            ok += 1
            end.add(p)

            if p in ng_l:
                ng += ng_l[p]
        else:
            if p in ng_l:
                ng_l[p] += 1
            else:
                ng_l[p] = 1

print('{} {}'.format(ok, ng))
Buggy code:
n, m = map(int, input().split())
ac = [0] * n
pen = [0] * n
pen_count = 0
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if ac[p] == "AC":
        continue
    elif s == "AC":
        ac[p] = "AC"
    else:
        pen[p] += 1

for i in range(n):
    if ac[i] == "AC":
        pen_count = pen[i]

print(ac.count("AC"), pen_count)


Fixed code:
n, m = map(int, input().split())
ac = [0] * n
pen = [0] * n
pen_count = 0
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if ac[p] == "AC":
        continue
    elif s == "AC":
        ac[p] = "AC"
    else:
        pen[p] += 1

for i in range(n):
    if ac[i] == "AC":
        pen_count += pen[i]

print(ac.count("AC"), pen_count)
Buggy code:
n,m = map(int,input().split())
p = []
s = []
for i in range(m):
    P,S = map(str,input().split())
    p.append(int(P))
    s.append(S)
Bool = [0 for i in range(n)]
count = [0 for i in range(n)]

for i in range(m):
    if not Bool[p[i]-1]:
        if s[i] == "WA":
            count[p[i]-1] += 1
        else:
            Bool[p[i]-1] = 1
ans = 0
for i in range(m):
    if Bool[p[i]-1]:
        ans += count[p[i]-1]

print(sum(Bool),ans)

Fixed code:
n,m = map(int,input().split())
p = []
s = []
for i in range(m):
    P,S = map(str,input().split())
    p.append(int(P))
    s.append(S)
Bool = [0 for i in range(n)]
count = [0 for i in range(n)]

for i in range(m):
    if not Bool[p[i]-1]:
        if s[i] == "WA":
            count[p[i]-1] += 1
        else:
            Bool[p[i]-1] = 1
ans = 0
for i in range(n):
    if Bool[i]:
        ans += count[i]

print(sum(Bool),ans)
Buggy code:
import sys
P = 0
N,M = map(int,input().strip().split())
if M == 0:
    print("{0} {1}".format(0,P))
    sys.exit()
ans_list = [list(input().strip().split()) for _ in range(M)]
result = [False] * N
for ans in ans_list:
    if result[int(ans[0])-1] != True
        if ans[1] == "WA":
            P += 1
        elif ans[1] == "AC":
            result[int(ans[0])-1] = True
print("{0} {1}".format(result.count(True),P))

Fixed code:
import sys
P = 0
N,M = map(int,input().strip().split())
if M == 0:
    print("{0} {1}".format(0,0))
    sys.exit()
ans_list = [list(input().strip().split()) for _ in range(M)]
result = [False] * N
wa_count = [0] * N
for ans in ans_list:
    if result[int(ans[0])-1] != True:
        if ans[1] == "WA":
            wa_count[int(ans[0])-1] += 1
        elif ans[1] == "AC":
            result[int(ans[0])-1] = True
for i in range(len(result)):
    if result[i] == True:
        P += wa_count[i]
print("{0} {1}".format(result.count(True),P))
Buggy code:
N, M = map(int, input().split())

p = [0]*M
k = [""] * M

for i in range(M):
    p[i], k[i] = input().split()
    p[i] = int(p[i])
    

ans = [0]*N
pen = [0]*N
accept = 0
pena = 0
for i in range(M):
    if k[i] == "WA" and ans[p[i]] == 0:
        pen[p[i]] += 1
    elif k[i] == "AC" and ans[p[i]] == 0:
        pena += pen[p[i]]
        ans[p[i]] = 1
        accept += 1
        
print(str(accept) + " " + str(pena))

Fixed code:
N, M = map(int, input().split())

p = [0] * M
k = [""] * M

for i in range(M):
    p[i], k[i] = input().split()
    p[i] = int(p[i])-1
    

ans = [0]*N
pen = [0]*N
accept = 0
pena = 0
for i in range(M):
    if k[i] == "WA" and ans[p[i]] == 0:
        pen[p[i]] += 1
    elif k[i] == "AC" and ans[p[i]] == 0:
        pena += pen[p[i]]
        ans[p[i]] = 1
        accept += 1
        
print(str(accept) + " " + str(pena))
Buggy code:
n,m = map(int,input().split())
wa = [0]*n
ac = [False]*n
for i in range(m):
    p,s = map(str,input().split())
    if s == "AC":
        ac[int(p)-1] = True
    else:
        if not ac[int(p)-1]:
            wa[int(p)-1] += 1
ac_num = 0
for i in range(n):
    if ac[i]: ac_num += 1
print(ac_num)
print(sum(wa))


Fixed code:
n,m = map(int,input().split())
wa = [0]*n
ac = [False]*n
for i in range(m):
    p,s = map(str,input().split())
    if s == "AC":
        ac[int(p)-1] = True
    else:
        if not ac[int(p)-1]:
            wa[int(p)-1] += 1
ac_num = 0
wa_num = 0
for i in range(n):
    if ac[i]:
        ac_num += 1
        wa_num += wa[i]
print(ac_num, wa_num)
Buggy code:
# coding: utf-8
import math
N, M = map(int,input().split())
#N = int(input())
#K = int(input())
#S = input()
ans = 0
#l = list(map(int,input().split()))
#A = list(map(int,input().split()))
F = [False] * (N+1)
P = [0] * (N+1)
l = []
for i in range(M):
    p, s = map(str,input().split())
    p = int(p)
    l.append([p, s])
    if s == "WA" and not F[p]:
        P[p] += 1
    if s == "AC" and not F[p]:
        ans += 1
        F[p] = True
pen = 0
#print(l)
for i in range(M):
    p = l[i][0]
    if F[p]:
        pen += P[p]
print(ans, pen)

Fixed code:
# coding: utf-8
import math
N, M = map(int,input().split())
#N = int(input())
#K = int(input())
#S = input()
ans = 0
#l = list(map(int,input().split()))
#A = list(map(int,input().split()))
F = [False] * (N+1)
pen = 0
P = [0] * (N+1)
for i in range(M):
    p, s = map(str,input().split())
    p = int(p)
    if s == "WA" and not F[p]:
        P[p] += 1
    if s == "AC" and not F[p]:
        ans += 1
        pen += P[p]
        F[p] = True

print(ans, pen)
Buggy code:
n, m = map(int, input().split())

ac = [0]*(n+1)
wa = [0]*(n+1)

for _ in range(m):
    a, b = input().split()
    a = int(a)
    if b == 'AC':
        ac[a] = 1
    else: 
        if ac[a] == 0:
            wa[a] = wa[a] + 1

for i in range(n+1):
    wa[a] = wa[a] * ac[a]

print(sum(ac), sum(wa))



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

ac = [0]*(n+1)
wa = [0]*(n+1)

for _ in range(m):
    a, b = input().split()
    a = int(a)
    if b == 'AC':
        ac[a] = 1
    else: 
        if ac[a] == 0:
            wa[a] = wa[a] + 1

for i in range(n+1):
    wa[i] = wa[i] * ac[i]

print(sum(ac), sum(wa))
Buggy code:
from collections import defaultdict


def main():
    N, M = map(int, input().split())
    pS = defaultdict(list)
    for i in range(M):
        p, S = input().split()
        pS[p].append(S)

    ac = 0
    wa = 0
    for pp in pS:
        tmp = pS[pp]
        for t in tmp:
            wa_tmp = 0
            if t == 'WA':
                wa_tmp += 1
            else:
                ac += 1
                wa += wa_tmp
                break
    print(ac, wa)


if __name__ == "__main__":
    main()


Fixed code:
from collections import defaultdict


def main():
    N, M = map(int, input().split())
    pS = defaultdict(list)
    for i in range(M):
        p, S = input().split()
        pS[p].append(S)

    ac = 0
    wa = 0
    for pp in pS:
        tmp = pS[pp]
        wa_tmp = 0
        for t in tmp:
            if t == 'WA':
                wa_tmp += 1
            else:
                ac += 1
                wa += wa_tmp
                break
    print(ac, wa)


if __name__ == "__main__":
    main()
Buggy code:
import sys
a,b=map(int,input().split())
account=0
wacount=0
acbox=[0]*(a+1)
wabox=[0]*(a+1)
for i in range(b):
  p,q=input().split()
  p=int(p)
  if q=="WA":
    if acbox[p]==0:
      wabox[p]+=1
  else:
    if acbox[p]!=0:
      account+=1
      wacount+=wabox[p]
      acbox[p]=+1
print(account,wacount)

Fixed code:
a,b=map(int,input().split())
account=0
wacount=0
acbox=[0]*(a+1)
wabox=[0]*(a+1)
for i in range(b):
  p,q=input().split()
  p=int(p)
  if q=="WA":
    if acbox[p]==0:
      wabox[p]+=1
  else:
    if acbox[p]==0:
      account+=1
      wacount+=wabox[p]
      acbox[p]=+1
print(account,wacount)
Buggy code:
n,m = map(int,input().split())
p_list = [input().split() for i in range(m)]

ans_list = [[[0] for i in range(2)] for j in range(n)]
#print(ans_list[0])
for i in range(m):
    p_num = int(p_list[i][0])
    if p_list[i][1] == "WA":
        ans_list[p_num-1][1]  = 1
    else:
        ans_list[p_num-1][0]  = 1
count1 = 0
count2 = 0
for i in range(n):
    if ans_list[i][0] == 1:
        count += 1
        if ans_list[i][1] == 1:
            count2 += 1
print(count1,count2)


Fixed code:
n,m = map(int,input().split())
p_list = [input().split() for i in range(m)]

ans_list = [[0 for i in range(2)] for j in range(n)]
#print(ans_list[0])
for i in range(m):
    p_num = int(p_list[i][0])
    if ans_list[p_num-1][0] != 1:
        if p_list[i][1] == "WA":
            ans_list[p_num-1][1]  =  ans_list[p_num-1][1] + 1
        else:
            ans_list[p_num-1][0]  = 1
count1 = 0
count2 = 0
for i in range(n):
    if ans_list[i][0] == 1:
        count1 += 1
        count2 += ans_list[i][1]
print(count1,count2)
Buggy code:
n,m = map(int,input().split())
ac_list = [0]*n
wa_list = [0]*n
pena = 0
for i in range(m):
    p,s = input().split()
    if s == 'AC':
        if ac_list[int(p)-1] == 0:
            ac_list[int(p)-1] =1
            pena += wa_list[int(p)-1]
        
    if s == 'WA':
        if ac_list[int(p)-1] == 0:
            wa_list[int(p)-1] += 1
            
print('{0} {1}'.format(sum(ac_list) , pena)

Fixed code:
n,m = map(int,input().split())
ac_list = [0]*n
wa_list = [0]*n
pena = 0
for i in range(m):
    p,s = input().split()
    if s == 'AC':
        if ac_list[int(p)-1] == 0:
            ac_list[int(p)-1] =1
            pena += wa_list[int(p)-1]
        
    if s == 'WA':
        if ac_list[int(p)-1] == 0:
            wa_list[int(p)-1] += 1
            
print('{0} {1}'.format(sum(ac_list) , pena))