qyliang/CodeNanoFix huggingface dataset:
Buggy code:
INF = 2 * (10 ** 9) - 1

n = int(input())
xl = [[0] * 2 for i in range(n)]
for i in range(n) :
    x, l = map(int, input().split())
    xl[i][0] = x-l+1 if x-l+1 >= 0 else 0
    xl[i][1] = x+l-1 if x+l-1 <= INF else INF

xl.sort(key=lambda x:x[1])

cnt = 0
print(xl)
cur = -1
ans = 0

for i in range(n) :
    if cur < xl[i][0] :
        #print(i)
        ans += 1
        cur = xl[i][1]
        #prinst(xl[i])


print(ans)


Fixed code:
INF = 2 * (10 ** 9) - 1

n = int(input())
xl = [[0] * 2 for i in range(n)]
for i in range(n) :
    x, l = map(int, input().split())
    xl[i][0] = x-l
    xl[i][1] = x+l

xl.sort(key=lambda x:x[1])

cnt = 0
#print(xl)
cur = -10 ** 10
ans = 0

for i in range(n) :
    if cur <= xl[i][0] :
        #print(i)
        ans += 1
        cur = xl[i][1]
        #prinst(xl[i])


print(ans)
Buggy code:
N = int(input())

lob = []

for _ in range(N):
    X, L = map(int,input().split())
    lob.append([X + L - 1, X - L + 1])

lob.sort()

ans = 0
last = 0
for l in lob:
    if last < l[1]:
        ans += 1
        last = l[0]

print(ans)

Fixed code:
N = int(input())

lob = []

for _ in range(N):
    X, L = map(int,input().split())
    lob.append([X + L, X - L])

lob.sort()

ans = 0
last = (-1) * 10 ** 9 - 1
for l in lob:
    if last <= l[1]:
        ans += 1
        last = l[0]

print(ans)
Buggy code:
n = int(input())
xl = sorted([list(map(int, input().split())) for _ in range(n)], key = lambda x: x[0]+x[1])

x, l = xl[0]
ans = n
for i in range(1, n):
    if x+l-1 <= xl[i][0]-xl[i][1]+1:
        x, l = xl[i]
    else:
        ans -= 1
print(xl)
print(ans)

Fixed code:
n = int(input())
xl = sorted([list(map(int, input().split())) for _ in range(n)], key = lambda x: x[0]+x[1])

x, l = xl[0]
ans = n
for i in range(1, n):
    if x+l-1 < xl[i][0]-xl[i][1]:
        x, l = xl[i]
    else:
        ans -= 1


print(ans)
Buggy code:
# coding: utf-8
def main():
    n = int(input())
    inputs = [input().split() for i in range(n)]
    inputs_list = []
    for i in inputs:
        if int(i[0]) - int(i[1]) < 0:
            inputs_list.append([0, int(i[0]) + int(i[1])])
        else:
            inputs_list.append([int(i[0]) - int(i[1]), int(i[0]) + int(i[1])])
    sorted_data = sorted(inputs_list, key=lambda x: (x[1]))

    ans = [sorted_data[0]]
    cur = ans[0][1]
    for i in range(len(sorted_data) - 1):
        print(cur, sorted_data[i + 1][0])
        if cur <= sorted_data[i + 1][0]:
                ans.append(sorted_data[i + 1])
                cur = sorted_data[i + 1][1]
    print(len(ans))


if __name__ == '__main__':
    main()


Fixed code:
# coding: utf-8
def main():
    n = int(input())
    inputs = [input().split() for i in range(n)]
    inputs_list = []
    for i in inputs:
        if int(i[0]) - int(i[1]) < 0:
            inputs_list.append([0, int(i[0]) + int(i[1])])
        else:
            inputs_list.append([int(i[0]) - int(i[1]), int(i[0]) + int(i[1])])
    sorted_data = sorted(inputs_list, key=lambda x: (x[1]))

    ans = [sorted_data[0]]
    cur = ans[0][1]
    for i in range(len(sorted_data) - 1):
        if cur <= sorted_data[i + 1][0]:
                ans.append(sorted_data[i + 1])
                cur = sorted_data[i + 1][1]
    print(len(ans))


if __name__ == '__main__':
    main()
Buggy code:
import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
Y = []
for s in inputs[1:]:
    x, l = map(int, s.split())
    Y.append((x-l+1, x+l-1))
Y.sort(key=lambda x: x[0])

cnt = 0
l0, r0 = Y[0]
for i in range(1, n):
    l, r = Y[i]
    if r >= l0:
        cnt += 1
        if r0 > r:
            l0, r0 = l, r
print(n-cnt)

Fixed code:
import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
Y = []
for s in inputs[1:]:
    x, l = map(int, s.split())
    Y.append((x-l, x+l))
Y.sort(key=lambda x: x[1])

cnt = 1
_, r0 = Y[0]
for i in range(1, n):
    l, r = Y[i]
    if r0 <= l:
        cnt += 1
        r0 = r
    
print(cnt)
Buggy code:
def acinput():
    return list(map(int, input().split(" ")))

N=int(input())
bars=[]
for i in range(N):
    tmp = acinput()
    tmp.extend([tmp[0]-tmp[1],tmp[0]+tmp[1]])
    bars.append(tmp)

bars=sorted(bars,key=lambda x:x[3])

print(bars)

count=0
R=-10000000000
for i in range(0,N):

    if R<=bars[i][2]:
        R=bars[i][3]
        count+=1


print(count)


Fixed code:
def acinput():
    return list(map(int, input().split(" ")))

N=int(input())
bars=[]
for i in range(N):
    tmp = acinput()
    tmp.extend([tmp[0]-tmp[1],tmp[0]+tmp[1]])
    bars.append(tmp)

bars=sorted(bars,key=lambda x:x[3])

#print(bars)

count=0
R=-10000000000
for i in range(0,N):

    if R<=bars[i][2]:
        R=bars[i][3]
        count+=1


print(count)
Buggy code:
N = int(input())
a = sorted([(x + l, x - l) for x, l in (map(int, l.split()) for l in sys.stdin)])

last = a[0][0]
ans = 1

for r, l in a[1:]:
    if last <= l:
        ans += 1
        last = r

print(ans)



Fixed code:
import sys
N = int(input())
a = sorted([(x + l, x - l) for x, l in (map(int, l.split()) for l in sys.stdin)])

last = a[0][0]
ans = 1

for r, l in a[1:]:
    if last <= l:
        ans += 1
        last = r

print(ans)
Buggy code:
c = input()
print(chr(ord("")+1))

Fixed code:
c = ord(input())
c += 1
print(chr(c))
Buggy code:
s = input() #alphabet hitotsu sakino moji
print(chr(ord(s) + 1)

Fixed code:
s = input() #alphabet hitotsu sakino moji
print(chr(ord(s) + 1))
Buggy code:
# simply use double ifs
s = input()
print(chr(ord(s))+1)


Fixed code:
# simply use double ifs
s = input()
print(chr(ord(s)+1))
Buggy code:
C = input()

print(chr(ord(C)+1)

Fixed code:
C=input()
C=chr(ord(C) + 1)
print(C)
Buggy code:
import sys
# row = sys.stdin.readline
row = open('input.txt', 'r').readline
def read_string(row):
    return row().rstrip()
  
inp = read_string(row)
print(chr(ord(inp) + 1))

Fixed code:
import sys

row = sys.stdin.readline
# row = open('input.txt', 'r').readline
def read_string(row):
    return row().rstrip()
  
inp = read_string(row)
print(chr(ord(inp) + 1))
Buggy code:
from sys import stdin

C = input()

print(chr(ord(C + 1)))

Fixed code:
from sys import stdin

C = input()
c = ord(C)

print(chr(c + 1))
Buggy code:
letter = ord(input())
print(chr(c+1))

Fixed code:
letter = ord(input())
print(chr(letter+1))
Buggy code:
a = input()
ascii_a = ord(a)
# print(ascii_a)
next_ascii_a = ascii_a +1
chr(next_ascii_a)

Fixed code:
a = input()
ascii_a = ord(a)
# print(ascii_a)
next_ascii_a = ascii_a +1
print(chr(next_ascii_a))
Buggy code:
C = input('')
chr(ord(C) + 1)



Fixed code:
C = input('')
print (chr(ord(C) + 1))
Buggy code:
C = str(input())
print chr(ord(C) + 1)

Fixed code:
C = input()
 
print(chr(ord(C)+1))
Buggy code:
a = input()

print(chr(ord('a') + 1))

Fixed code:
a = input()
a = ord(a) + 1
print(chr(a))
Buggy code:
x = input()
print chr(ord(x) + 1)

Fixed code:
x = input()
print(chr(ord(x) + 1))
Buggy code:
c=input()
print chr(ord(c) + 1)

Fixed code:
c=input()
ans=chr(ord(c)+1)
print(ans)
Buggy code:
N = str(input())
chr(ord(N)+1)

Fixed code:
N = str(input())
print(chr(ord(N)+1))
Buggy code:
s = input()
  print(chr(ord(s)+1))

Fixed code:
s=input()
x=ord(s)
print(chr(x+1))
Buggy code:
s = input()

print(chr(ord(s) + 1)


Fixed code:
s = input()

print(chr(ord(s) + 1))
Buggy code:
str1 = input()
asc = ord(str1) + 1
print(asc)
ans = chr(asc)
print(ans)


Fixed code:
str1 = input()
ans = chr(ord(str1) + 1)
print(ans)
Buggy code:
a=input()
print(str(ord(a)+1)

Fixed code:
a = str(input())

print(chr(ord(a) + 1))
Buggy code:
x = input()
print(chr(ord(x)+1)

Fixed code:
x = input()
y = chr(ord(x) + 1)
print(y)
Buggy code:
s=input()
print (chr(ord(s) + 1)

Fixed code:
s = input()
c = ord(s)
c += 1
print (chr(c))
Buggy code:
C = input()
c = chr(ord(c)+1)
print(c)

Fixed code:
C = input()
c = chr(ord(C)+1)
print(c)
Buggy code:
C = input()
print(chr(ord(c)+1))

Fixed code:
c = input()
c = ord(c)
c += 1
c = chr(c)
print(c)
Buggy code:
s = input()
tmp = ord(s)
ans = tmp += 1
print(chr(ans))

Fixed code:
s = input()
tmp = ord(s)
ans = tmp + 1
print(chr(ans))
Buggy code:
a = input()
print(chr(ord(a)+1)

Fixed code:
a = chr(ord(input())+1)
print(a)
Buggy code:
C = input()
print chr(ord('C') + 1)

Fixed code:
C = print(chr(ord(input()) + 1))
Buggy code:
c=input()
print(chr(ord(c)+1)

Fixed code:
c=input()

ans=chr(ord(c)+1)

print(ans)
Buggy code:
a = int(input())
print(chr(ord(a)+1)

Fixed code:
a=ord(input())
print(chr(a+1))
Buggy code:
C=input()
print(chr(ord(c[0])+1))

Fixed code:
C=input()
print(chr(ord(C[0])+1))
Buggy code:
C = input()
print chr(ord(C) + 1)

Fixed code:
C=input()
C=chr(ord(C)+1)
print(C)
Buggy code:
c = input()
print chr(ord(c) + 1)

Fixed code:
c = input()
print (chr(ord(c) + 1))
Buggy code:
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import itertools
# import math

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H = readline().decode('utf8')
print(chr(ord(H) + 1))


Fixed code:
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import itertools
# import math

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H = readline().decode('utf8').strip()
print(chr(ord(H) + 1))
Buggy code:
s = input()
print chr(ord(s) + 1)

Fixed code:
s=input()
num=ord(s)
print(chr(num+1))
Buggy code:
s = input()
print chr(ord(s[0]) + 1)

Fixed code:
s = input()
print(chr(ord(s[0]) + 1))
Buggy code:


C = input()
C_asc ord(C)
ret = chr(C_asc + 1)
print(ret)


Fixed code:

C = input()
C_asc = ord(C)
ret = chr(C_asc + 1)
print(ret)
Buggy code:
C = input()
print(chr(ord(C)+1)

Fixed code:

C = str(input())

print(chr(ord(C) + 1))
Buggy code:
s = input()
print(chr(ord(s)+1)))

Fixed code:
s=input()
print(chr(1+ord(s)))
Buggy code:
C = input()
print(chr(ord(C)+1)    

Fixed code:
C = input()
N = ord(C) + 1
print(chr(N))
Buggy code:
# A - Next Alphabet
def main():
    C = input().rstrip()
    ans = chr(ord(C) + 1)
    print(C)


if __name__ == "__main__":
    main()


Fixed code:
# A - Next Alphabet
def main():
    C = input().rstrip()
    ans = chr(ord(C) + 1)
    print(ans)


if __name__ == "__main__":
    main()
Buggy code:
S=input()

print(chr(ord(S)+1)

Fixed code:
S=input()

print(chr(ord(S)+1))
Buggy code:
c=input()
chr(ord(c+1))
print(c)


Fixed code:
c = input()

a = ord(c)

a += 1
print(chr(a))
Buggy code:
a = input()
print chr(ord(a) + 1)

Fixed code:
a = input()
b = chr(ord(a) + 1)
print(b)
Buggy code:
str = input(str)
print(chr(ord(str)+1))

Fixed code:
C = str(input())
print(chr(ord(C) + 1))
Buggy code:
# !/use/bin/python3

"""
https://atcoder.jp/contests/abc151/tasks/abc151_a
Next Alphabate
"""

def solve(c):
    print(c)
    ans = ord(c)
    return chr(ans+1)

if __name__ == "__main__":
    c = input()
    print(solve(c))


Fixed code:
# !/use/bin/python3

"""
https://atcoder.jp/contests/abc151/tasks/abc151_a
Next Alphabate
"""

def solve(c):
    ans = ord(c)
    return chr(ans+1)

if __name__ == "__main__":
    c = input()
    print(solve(c))
Buggy code:
print(chr(ord(input())+1)

Fixed code:
print(chr(ord(input())+1))
Buggy code:
a=input()
print=(chr(ord(a)+1))


Fixed code:
a = input()
print (chr(ord(a) + 1))
Buggy code:
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m=map(int,input().split())
ps=[input().split() for i in range(m)]

dic={}
anslst=[0]*n
for i in range(m):
    p,s=ps[i]
    if s=="AC":
        dic[p]=1
    else:
        if p in dic:
            continue
        else:
            anslst[int(p)-1]+=1

print(len(dic))
print(sum(anslst))

Fixed code:
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m=map(int,input().split())
ps=[input().split() for i in range(m)]

dic={}
anslst=[0]*n
for i in range(m):
    p,s=ps[i]
    if s=="AC":
        dic[p]=1
    else:
        if p in dic:
            continue
        else:
            anslst[int(p)-1]+=1


ans=0
for i in dic.keys():
    ans+=anslst[int(i)-1]
print(len(dic),ans)
Buggy code:
input_int_list = list(map(int, input().split()))


N = input_int_list[0]
M = input_int_list[1]

Q_ans_list = [0] * N

ans_correct = 0
ans_penalty = 0

for i in range(M):
	input_list_i = list( input().split())
	Q_num = int(input_list_i[0])
	if input_list_i[1] == "WA":
		if Q_ans_list[Q_num] != -1:
			Q_ans_list[Q_num] = Q_ans_list[Q_num] + 1
	elif input_list_i[1] == "AC":
		if Q_ans_list[Q_num] != -1:
			ans_correct = ans_correct + 1
			ans_penalty = ans_penalty + Q_ans_list[Q_num]
			Q_ans_list[Q_num] = -1





print(ans_correct,ans_penalty)



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


N = input_int_list[0]
M = input_int_list[1]

Q_ans_list = [0] * (N+1)

ans_correct = 0
ans_penalty = 0

for i in range(M):
	input_list_i = list( input().split())
	Q_num = int(input_list_i[0])
	if input_list_i[1] == "WA":
		if Q_ans_list[Q_num] != -1:
			Q_ans_list[Q_num] = Q_ans_list[Q_num] + 1
	elif input_list_i[1] == "AC":
		if Q_ans_list[Q_num] != -1:
			ans_correct = ans_correct + 1
			ans_penalty = ans_penalty + Q_ans_list[Q_num]
			Q_ans_list[Q_num] = -1





print(ans_correct,ans_penalty)
Buggy code:
n,m=map(int,input().split())
tmp=[0]*n
wtmp=[0]*n
for _ in range(m):
    P,s=map(str,input().split())
    p=int(P)
    p-=1
    if not tmp[p]==0:
        continue
    if s=='AC':
        tmp[p]=1
    else:
        wtmp[p]+=1
ans1=sum(tmp)
for i in range(n):
    ans2=0
    if tmp[i]==1:
        ans2+=wtmp[i]
print(ans1,ans2)



Fixed code:
n,m=map(int,input().split())
tmp=[0]*n
wtmp=[0]*n
for _ in range(m):
    P,s=map(str,input().split())
    p=int(P)
    p-=1
    if not tmp[p]==0:
        continue
    if s=='AC':
        tmp[p]=1
    else:
        wtmp[p]+=1
ans1=sum(tmp)
ans2=0
for i in range(n):
    if tmp[i]==1:
        ans2+=wtmp[i]
print(ans1,ans2)
Buggy code:
n,m=map(int,input().split())
ps=[list(input().split()) for i in range(m)]
pen=[0]
rig=[0]

for i in range(m):
  if ps[i][1] == "AC":
    rig[int(ps[i][0])-1]=1
  else:
    if rig[int(ps[i][0]-1)] == 0:
      pen[int(ps[i][0]-1)]+=1

cnt1,cnt2=0,0
for i in range(n):
  if rig[i]==1:
    cnt1+=rig[i]
    cnt2+=pen[i]
    
print(str(cnt1)+" "+str(cnt2))

Fixed code:
n,m=map(int,input().split())
ps=[list(input().split()) for i in range(m)]
pen=[0]*n
rig=[0]*n

for i in range(m):
  if ps[i][1] == "AC":
    rig[int(ps[i][0])-1]=1
  else:
    if rig[int(ps[i][0])-1] == 0:
      pen[int(ps[i][0])-1]+=1

cnt1,cnt2=0,0
for i in range(n):
  if rig[i]==1:
    cnt1+=rig[i]
    cnt2+=pen[i]
    
print(str(cnt1)+" "+str(cnt2))
Buggy code:
n, m = input().split()
n = int(n)
m = int(m)
results = []
for i in range(m):
    results.append(list(input().split()))

wa = 0
ac = 0

dic = {}
for q, a in results:
    if q not in dic.keys():
        dic[q] = {"ac": False, "wa": 0}
    if dic[q]["ac"] is False and a == "WA":
        wa += 1
    elif dic[q]["ac"] is False and a == "AC":
        ac += 1
        dic[q]["ac"] = True
    elif dic[q]["ac"] is True:
        pass
    print(dic, ac, wa)

print(ac, wa)

Fixed code:
n, m = input().split()
n = int(n)
m = int(m)
results = []
for i in range(m):
    results.append(list(input().split()))

wa = 0
ac = 0

dic = {}
for q, a in results:
    if q not in dic.keys():
        dic[q] = {"ac": False, "wa": 0}
    if dic[q]["ac"] is True:
        pass
    elif dic[q]["ac"] is False and a == "WA":
        dic[q]["wa"] += 1
    elif dic[q]["ac"] is False and a == "AC":
        ac += 1
        dic[q]["ac"] = True
for x in dic.keys():
    if dic[x]["ac"] is True:
        wa += dic[x]["wa"]

print(ac, wa)
Buggy code:
n, m = (int(i) for i in input().split())
p = [None] * m
s = [None] * m
for i in range(m):
    p[i], s[i] = (j for j in input().split())
    p[i] = int(p[i])
    
pena = [0] * m
ac   = [0] * m
for i in range(m):
    q_index = p[i]-1
    if s[i] == 'AC': 
        ac[q_index] = 1
    if s[i] == 'WA':
        if ac[q_index] == 0: pena[q_index] += 1
        
print(sum(ac), sum(pena))

Fixed code:
n, m = (int(i) for i in input().split())
p = [None] * m
s = [None] * m
for i in range(m):
    p[i], s[i] = (j for j in input().split())
    p[i] = int(p[i])
    
pena = [0] * n
ac   = [0] * n

for i in range(m):
    q_index = p[i]-1
    if s[i] == 'AC': 
        ac[q_index] = 1
    if s[i] == 'WA':
        if ac[q_index] == 0: pena[q_index] += 1
        
ac_num = 0
pena_num = 0
for i in range(n):
    if ac[i] == 1:
        ac_num += 1
        pena_num += pena[i]

print(ac_num, pena_num)
Buggy code:
import sys

n, m = map(int, sys.stdin.readline().split())
pv = []
for _ in range(m):
    p, s = sys.stdin.readline().split()
    p = int(p) - 1
    v = 1 if s == 'AC' else 0
    pv.append((p, v))

def main():
    wa = [0] * n
    ac = [0] * n
    for p, c in pv:
        wa[p] += (ac[p] | v) ^ 1
        ac[p] |= v
    for p in range(n): wa[p] *= ac[p]
    print(sum(ac), sum(wa))

if __name__ ==  '__main__':
    main()

Fixed code:
import sys

n, m = map(int, sys.stdin.readline().split())
pv = []
for _ in range(m):
    p, s = sys.stdin.readline().split()
    p = int(p) - 1
    v = 1 if s == 'AC' else 0
    pv.append((p, v))

def main():
    wa = [0] * n
    ac = [0] * n
    for p, v in pv:
        wa[p] += (ac[p] | v) ^ 1
        ac[p] |= v
    for p in range(n): wa[p] *= ac[p]
    print(sum(ac), sum(wa))

if __name__ ==  '__main__':
    main()
Buggy code:
num_of_probs, num_of_submission = [ int(i) for i in input().split(" ") ]

solution_table = {}

for i in range(0, num_of_submission):
  prob, result = [ i for i in input().split(" ") ]

  if solution_table.get(int(prob)) == None:
    solution_table[int(prob)] = {"WA": 0, "AC": 0}

  if result == "WA":
    if solution_table[int(prob)]["AC"] == 0:
      solution_table[int(prob)]["WA"] += 1
  else:
    solution_table[int(prob)]["AC"] += 1
  
  print(solution_table)

total_wa = 0
for value in solution_table.values():
  total_wa += value['WA']

print( total_wa )
  
  

Fixed code:
num_of_probs, num_of_submission = [ int(i) for i in input().split(" ") ]

solution_table = {}

for i in range(0, num_of_submission):
  prob, result = [ i for i in input().split(" ") ]

  if solution_table.get(int(prob)) == None:
    solution_table[int(prob)] = {"WA": 0, "AC": 0}

  if result == "WA":
    if solution_table[int(prob)]["AC"] == 0:
      solution_table[int(prob)]["WA"] += 1
  else:
    if solution_table[int(prob)]["AC"] == 0:
      solution_table[int(prob)]["AC"] += 1

total_ac = 0
total_wa = 0
for value in solution_table.values():
  if value['AC'] > 0:
    total_wa += value['WA']
    total_ac += value['AC']

print( total_ac, total_wa )
Buggy code:
import itertools
n, m = map(int, input().split())
P = [input().split() for i in range(m)]
P = list(itertools.chain.from_iterable(P))
ac_list = [0] * n
wa_list = [0] * n

counta = 0
countb = 0
for i in range(1, m * 2, 2):
    if P[i] == "AC" and ac_list[int(P[i - 1])] == 0:
        counta += 1
        ac_list[int(P[i - 1])] = 1
        countb += wa_list[int(P[i - 1]) - 1]
    elif P[i] == "WA":
        wa_list[int(P[i - 1]) - 1] += 1
    else:
        continue

print(counta, countb)


Fixed code:
import itertools
n, m = map(int, input().split())
P = [input().split() for i in range(m)]
P = list(itertools.chain.from_iterable(P))
ac_list = [0] * n
wa_list = [0] * n
counta = 0
countb = 0
for i in range(1, m * 2, 2):
    if P[i] == "AC" and ac_list[int(P[i - 1])-1] == 0:
        counta += 1
        ac_list[int(P[i - 1])-1] = 1
        countb += wa_list[int(P[i - 1]) - 1]
    elif P[i] == "WA":
        wa_list[int(P[i - 1]) - 1] += 1
    else:
        continue

print(counta, countb)
Buggy code:
N,M=map(int,input().split())
wa=[0]*N
ac=[0]*N

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

penalty=[wa[j] for j,k in enumerate(ac) if not K==0]
print("%d %d" %(sum(ac),sum()))

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

penalty=[wa[k] for k in [i for i,j in enumerate(ac) if j!=0]]    
print("%d %d" % (sum(ac),sum(penalty)))
Buggy code:
# -*- coding: utf-8 -*-

N,M = list(map(int, input().split()))

AC = [False for _ in range(N)]
WA = [0 for _ in range(N)]

for _ in range(M):
    p,s = input().split()
    p = int(p)
    if AC[p]:
        continue
    if s=='AC':
        AC[p] = True
    else:
        WA[p] += 1

print(sum(AC), sum(WA))

Fixed code:
# -*- coding: utf-8 -*-

N,M = list(map(int, input().split()))

AC = [False for _ in range(N)]
WA = [0 for _ in range(N)]
total_WA = 0

for _ in range(M):
    p,s = input().split()
    p = int(p)-1
    if AC[p]:
        continue
    if s=='AC':
        AC[p] = True
        total_WA += WA[p]
    else:
        WA[p] += 1

print(sum(AC), total_WA)
Buggy code:
N,M = map(int,input().split())
di = {}
pe = 0
ac = 0
for i in range(M):
    inp = input().split(" ")
    if inp[1] == "WA":
        if inp[0] in di:
            if di[inp[0]] == "WA":
                pe+=1
        else:
            di[inp[0]] = "WA"
            pe+=1
            
    else:
        di[inp[0]] = "AC"
for v in di.values():
    if v == "AC":
        ac += 1
print(str(pe)+" "+str(ac))

Fixed code:
N,M = map(int,input().split())
di = {}
pe = 0
ac = 0
for i in range(M):
    inp = input().split(" ")
    if inp[1] == "WA":
        if inp[0] in di:
            if di[inp[0]] >= 1:
                di[inp[0]] += 1
        else:
            di[inp[0]] = 1
            
            
    else:
        if inp[0] in di:
            pe += di[inp[0]]
            di[inp[0]] = 0
        di[inp[0]] = 0
        
for v in di.values():
    if v == 0:
        ac += 1
print(str(ac)+" "+str(pe))
Buggy code:
n,m = map(int,input().split())
pS_list = [list(input().split()) 
           for nesya in range(m)]
ac = 0
wa = 0
q_list = [0]*n
for ps in ps_list:
  p = int(ps[0])-1
  s = ps[1]
  if q_list[p] == 1:
    continue
  if s == 'WA':
    q_list[p] -= 1
  else:
    a = q_list[p]
    wa -= a
    ac += 1
    q_list[p] = 1
print(ac,wa)

Fixed code:
n,m = map(int,input().split())
pS_list = [list(input().split()) 
           for nesya in range(m)]
ac = 0
wa = 0
q_list = [0]*n
for ps in pS_list:
  p = int(ps[0])-1
  s = ps[1]
  if q_list[p] == 1:
    continue
  if s == 'WA':
    q_list[p] -= 1
  else:
    a = q_list[p]
    wa -= a
    ac += 1
    q_list[p] = 1
print(ac,wa)
Buggy code:
n,m=map(int,input().split())
p=[list(input().split()) for _ in range(m)]
a=[0]*(n+1)
w=[0]*(n+1)
for i in range(m):
    if a[int(p[i][0])]==0 and p[i][1]=='AC':
        a[int(p[i][0])]+=1
    if a[int(p[i][0])]==0 and p[i][1]=='WA':
        w[int(p[i][0])]+=1
a=np.array(a)
w=np.array(w)
aw=a*w
print(sum(a),sum(aw))

Fixed code:
import numpy as np
n,m=map(int,input().split())
p=[list(input().split()) for _ in range(m)]
a=[0]*(n+1)
w=[0]*(n+1)
for i in range(m):
    if a[int(p[i][0])]==0 and p[i][1]=='AC':
        a[int(p[i][0])]+=1
    if a[int(p[i][0])]==0 and p[i][1]=='WA':
        w[int(p[i][0])]+=1
a=np.array(a)
w=np.array(w)
aw=a*w
print(sum(a),sum(aw))
Buggy code:
n,m=[int(i) for i in input().split()]
ac=[0]*n
wa=[0]*n
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=="AC":
        if check[p]==0:
            check[p]=1
    else:
        if check[p]==0:
            wa[p]+=1
    
for i in range(n):
    wa[i]=wa[i]*ac[i]
print(sum(check),wa)

Fixed code:
n,m=[int(i) for i in input().split()]
ac=[0]*n
wa=[0]*n
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=="AC":
        if ac[p]==0:
            ac[p]=1
    else:
        if ac[p]==0:
            wa[p]+=1
    
for i in range(n):
    wa[i]=wa[i]*ac[i]
print(sum(ac),sum(wa))