qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n = int(input())

xl = []

for i in range(n):
    x,l = map(int,input().split())
    xl.append([x-l,x+l])
xl.sort()
ans = -10**10
count = 0
for j in range(n):
    if xl[i][1] > ans:
        count +=1
        ans = xl[i][0]
print(count)

Fixed code:
n = int(input())

xl = []

for i in range(n):
    x,l = map(int,input().split())
    xl.append([x+l,x-l])
xl.sort()
ans = -10**10
count = 0
for j in range(n):
    if xl[j][1] >= ans:
        count +=1
        ans = xl[j][0]
print(count)
Buggy code:
N = int(input())

XL = []
for i in range(N):
    tmp = list(map(int, input().split()))
    XL.append(tmp)
    
XL = sorted(XL, key=lambda x:x[0])

i = 0
now = 0
count = 0
while i <= len(XL)-2:
    now_arm = XL[now][0] + XL[now][1]
    if now_arm > XL[i+1][0] - XL[i+1][1]:
        count += 1
    else:
        now = i
    i += 1    


print(XL)
print(len(XL) - count)

Fixed code:
N = int(input())

XL = []
for i in range(N):
    tmp = list(map(int, input().split()))
    XL.append(tmp)
    
XL = sorted(XL, key=lambda x:x[0])

i = 0
now = 0
count = 0
while i <= len(XL)-2:
    now_arm = XL[now][0] + XL[now][1]
    if now_arm > XL[i+1][0] - XL[i+1][1]:
        count += 1
        if XL[i+1][0] + XL[i+1][1] < now_arm:
            now = i+1
        else:
            pass
    else:
        now = i+1
    i += 1    


#print(XL)
print(len(XL) - count)
Buggy code:
n = int(input())
xl_lis = []
for i in range(n):
    xl_lis.append(list(map(int, input().split())))
fe_lis = []
for x, l in xl_lis:
    fe_lis.append([x - l, x + l])
curr = float("-inf")
cnt = 0
for f, e in fe_lis:
    if curr <= f:
        cnt += 1
        curr = e
print(cnt)        

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

for x, l in xl_lis:
    fe_lis.append([x - l, x + l])
fe_lis.sort(key = lambda x:x[1])        
curr = float("-inf")
cnt = 0
for f, e in fe_lis:
    if curr <= f:
        cnt += 1
        curr = e
print(cnt)
Buggy code:
N, *XL = map(int, open(0).read().split())
XL = sorted((x - l, x + l) for x, l in zip(*[iter(XL)] * 2))
curr = -float("inf")
ans = 0
for x, l in XL:
    if x - l >= curr:
        curr = x + l
        ans += 1
print(ans)


Fixed code:
N, *XL = map(int, open(0).read().split())
XL = sorted((x + l, x - l) for x, l in zip(*[iter(XL)] * 2))
curr = -float("inf")
ans = 0
for right, left in XL:
    if left >= curr:
        curr = right
        ans += 1
print(ans)
Buggy code:
(N,), *XL = [list(map(int, s.split())) for s in open(0)]
XL.sort(key=lambda x: x[0] + x[1])
print(XL)
curr = -float("inf")
ans = 0
for x, l in XL:
    if x - l >= curr:
        curr = x + l
        ans += 1
print(ans)


Fixed code:
(N,), *XL = [list(map(int, s.split())) for s in open(0)]
XL.sort(key=lambda x: x[0] + x[1])
curr = -float("inf")
ans = 0
for x, l in XL:
    if x - l >= curr:
        curr = x + l
        ans += 1
print(ans)
Buggy code:
input = sys.stdin.readline
 
n = int(input())
robots = []
for i in range(n):
    x, l = [int(item) for item in input().split()]
    robots.append((x+l, x-l))
 
robots.sort()
 
cnt = 0
node = -10**12
for end, start in robots:
    if start >= node:
        node = end
        cnt += 1
print(cnt)

Fixed code:
import sys
input = sys.stdin.readline
 
n = int(input())
robots = []
for i in range(n):
    x, l = [int(item) for item in input().split()]
    robots.append((x+l, x-l))
 
robots.sort()
 
cnt = 0
node = -10**12
for end, start in robots:
    if start >= node:
        node = end
        cnt += 1
print(cnt)
Buggy code:
import sys
input = sys.stdin.buffer.readline
from operator import itemgetter

def main():
    N = int(input())
    lr = []
    for _ in range(N):
        p,l = map(int,input().split())
        lr.append((p-l,p+l))
        
    lr.sort(key = itemgetter(0,1))
    print(lr)
    now = -10**10
    count = 0
    for i in range(N):
        if now <= lr[i][0]:
            count += 1
            now = lr[i][1]
        
    print(count)
    
if __name__ == "__main__":
    main()


Fixed code:
import sys
input = sys.stdin.buffer.readline
from operator import itemgetter

def main():
    N = int(input())
    lr = []
    for _ in range(N):
        p,l = map(int,input().split())
        lr.append((p-l,p+l))
        
    lr.sort(key = itemgetter(1,0))
    now = -10**10
    count = 0
    for i in range(N):
        if now <= lr[i][0]:
            count += 1
            now = lr[i][1]
        
    print(count)
    
if __name__ == "__main__":
    main()
Buggy code:
from operator import itemgetter
n=int(input())
xl=[list(map(int,input().split()))for i in range(N)]
R=[list(xl[i][0]-xl[i][1],xl[i][0]+xl[i][1]) for i in range(n)]
r=sorted([(R[i][0],R[i][1]) for i in range(n)],key=itemgetter(1))
s=r[0][1]
ans=1
for i in range(1,n):
    if r[i][0]>s:
        s=r[i][1]
        ans+=1
print(ans)

Fixed code:
from operator import itemgetter
n=int(input())
xl=[list(map(int,input().split()))for i in range(n)]
R=[(xl[i][0]-xl[i][1],xl[i][0]+xl[i][1]) for i in range(n)]
r=sorted([(R[i][0],R[i][1]) for i in range(n)],key=itemgetter(1))
s=r[0][1]
ans=1
for i in range(n-1):
    if r[i+1][0]>=s:
        s=r[i+1][1]
        ans+=1
print(ans)
Buggy code:
n = int(input())
xl = [list(map(int, input().split())) for _ in range(n)]
le = [[p[0]-p[1], p[0]+p[1]] for p in xl]
le.sort(key= lambda x: x[1])

ans = 0
right = -1
for i in range(n):
    if right <= le[i][0]:
        ans += 1
        right = le[i][1]

print(ans)

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

ans = 0
right = -(10 ** 9) - 1
for i in range(n):
    if right <= le[i][0]:
        ans += 1
        right = le[i][1]

print(ans)
Buggy code:
n = int(input())
lst = []
for i in range(n):
    x, l = map(int, input().split())
    lst.append((x + l, x - l))

sorted_lst = sorted(lst)
num = 0
ans = n
while True:
    tmp = sorted_lst[num][0]
    for i in range(num + 1, n):
        if tmp > sorted_lst[i][1]:
            ans -= 1
            print(num, i)
        else:
            num = i
            break
        if i == n - 1:
            num = i
            break
    if num == n - 1:
        break

print(ans)

Fixed code:
n = int(input())
lst = []
for i in range(n):
    x, l = map(int, input().split())
    lst.append((x + l, x - l))

sorted_lst = sorted(lst)
num = 0
ans = n
while True:
    tmp = sorted_lst[num][0]
    for i in range(num + 1, n):
        if tmp > sorted_lst[i][1]:
            ans -= 1
        else:
            num = i
            break
        if i == n - 1:
            num = i
            break
    if num == n - 1:
        break

print(ans)
Buggy code:
def main():
    n = int(input())
    x = []
    xl = {}
    tmp = []
    ans = 0
    maxtmp = 0
    for i in range(n):
        xx, ll = map(int,input().split())
        if maxtmp < xx:
            maxtmp = xx
        low = xx-ll+1
        high = xx+ll-1
        lmh = [low,xx,high]
        tmp.append(lmh)


    tmp.sort()
    high = -1
    for i, a in enumerate(tmp):
        if a[0] > high:
            high = a[2]
            ans += 1
        else:
            continue

    print(ans)
    return


if __name__=='__main__':
    main()


Fixed code:
def main():
    n = int(input())
    x = []
    xl = {}
    tmp = []
    ans = 0
    maxtmp = 0
    for i in range(n):
        xx, ll = map(int,input().split())
        if maxtmp < xx:
            maxtmp = xx
        low = xx-ll
        high = xx+ll
        lmh = [high,xx,low]
        tmp.append(lmh)


    tmp.sort()
    high = tmp[0][0]
    ans = 1
    for i in range(1,len(tmp)):
        a = tmp[i]
        if a[2] >= high:
            high = a[0]
            ans += 1
        else:
            continue

    print(ans)
    return


if __name__=='__main__':
    main()
Buggy code:
import sys
from operator import itemgetter

n = int(input())
robots = []
for line in sys.stdin:
    X, L = map(int, line.split())
    l, r = X - L, X + L
    robots.append((l, r))
robots.sort(key=itemgetter(1))

curr = -1
ans = 0
for l, r in robots:
    if curr > l:
        continue
    ans += 1
    curr = r
print(ans)


Fixed code:
import sys
from operator import itemgetter

n = int(input())
robots = []
for line in sys.stdin:
    X, L = map(int, line.split())
    l, r = X - L, X + L
    robots.append((l, r))
robots.sort(key=itemgetter(1))

curr = -(10 ** 10)
ans = 0
for l, r in robots:
    if curr > l:
        continue
    ans += 1
    curr = r
print(ans)
Buggy code:
N = int(input())
A = []
for i in range(N):
    x,l = map(int,input().split())
    A.append([x-l+1,x+l-1])
B=sorted(A,key=lambda x: x[1],reverse = True)
s = B[0][1]
n = 1
for i in range(1,N):
    a = B[i][0]
    b = B[i][1]
    if a >= n:
        n += 1
        s = b
print(n)

Fixed code:
N = int(input())
A = []
for i in range(N):
    x,l = map(int,input().split())
    A.append([x-l,x+l])
B=sorted(A,key=lambda x: x[1])
s = B[0][1]
n = 1
for i in range(1,N):
    a = B[i][0]
    b = B[i][1]
    if a >= s:
        n += 1
        s = b
print(n)
Buggy code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')

N=int(input())


l=[]

for i in range(N):
	a,b=map(int,input().split())
	st,fin=(a-b,a+b)
	l.append([fin,st])


list=sorted(l)

pt=list[0][0]
cnt=1

print(list)

for j in range(1,N):
	if pt<= list[j][1]:
		cnt+=1
		pt=list[j][0]

print(cnt)
	
	

Fixed code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')

N=int(input())


l=[]

for i in range(N):
	a,b=map(int,input().split())
	st,fin=(a-b,a+b)
	l.append([fin,st])


list=sorted(l)

pt=list[0][0]
cnt=1


for j in range(1,N):
	if pt<= list[j][1]:
		cnt+=1
		pt=list[j][0]

print(cnt)
Buggy code:
N = int(input())
robot = []
ans = 0
for i in range(N):
    x,l = map(int,input().split())
    robot.append([x-l,x+l])
robot.sort()

cur = -float('inf')

for i in range(N):
    if cur <= robot[i][1]:
        ans += 1
        cur = robot[i][0]

print(ans)

Fixed code:
N = int(input())
robot = []
ans = 0
for i in range(N):
    x,l = map(int,input().split())
    robot.append([x+l,x-l])
robot.sort()

cur = -float('inf')

for i in range(N):
    if cur <= robot[i][1]:
        ans += 1
        cur = robot[i][0]

print(ans)
Buggy code:
n = int(input())
Y = [list(map(int,input().split())) for _ in range(n)]
X = []
for y in Y:
    X.append(y[0]-y[1],y[0]+y[1])
X.sort()
ans = n
right = X[0][1]
for i in range(1,n):
    left = X[i][0]
    if left < right:
        ans -= 1
    else:
        right = X[i][1]
print(ans)

Fixed code:
n = int(input())
Y = [list(map(int,input().split())) for _ in range(n)]
X = []
for y in Y:
    X.append([y[0]+y[1],y[0]-y[1]])
X.sort()
ans = n
right = X[0][0]
for i in range(1,n):
    left = X[i][1]
    if left < right:
        ans -= 1
    else:
        right = X[i][0]
print(ans)
Buggy code:
import sys
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7
n=int(input())
xl=[list(map(int,input().split())) for i in range(n)]
from collections import deque
# for i in range(n):
#     right.append(xl[i][0]+xl[i][1])
#     left.append(xl[i][0]-xl[i][1])
ans=0
xl.sort()
# right.sort()
# left.sort()
d=deque(xl)
while d:
    tmp=d.popleft()
    # print(tmp)
    # print(d)
    while d:
        if tmp[0]+tmp[1]>d[0][0]-d[0][1]:
            ans+=1
            if tmp[0]+tmp[1]<d[0][0]+d[0][1]:
                # print(d.popleft(),1)
                break
            else:
                continue
        else:
            break
if n==1:
    print(1)
    quit()

print(n-ans)

Fixed code:
import sys
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7
n=int(input())
xl=[list(map(int,input().split())) for i in range(n)]
from collections import deque
# for i in range(n):
#     right.append(xl[i][0]+xl[i][1])
#     left.append(xl[i][0]-xl[i][1])
ans=0
xl.sort()
# right.sort()
# left.sort()
d=deque(xl)
while d:
    tmp=d.popleft()
    while d:
        if tmp[0]+tmp[1]>d[0][0]-d[0][1]:
            ans+=1
            if tmp[0]+tmp[1]>d[0][0]+d[0][1]:
                # d.popleft()
                break
            elif tmp[0]-tmp[1]>d[0][0]-d[0][1]:
                d.popleft()
            else:
                d.popleft()
        else:
            break
if n==1:
    print(1)
    quit()

print(n-ans)
Buggy code:
n = int(input())

robot_list = []

for i in range(n):
    x, l = list(map(int, input().split()))
    robot_list.append([x+l, x-l, l])

delete_robot = 0
robot_list.sort()
temp_robot = robot_list[0]

for i in range(n-1):
    if temp_robot[0] < robot_list[i+1][1]:
        delete_robot += 1
    else:
        temp_robot = robot_list[i+1]

print(n - delete_robot)


Fixed code:
n = int(input())

robot_list = []

for i in range(n):
    x, l = list(map(int, input().split()))
    robot_list.append([x+l, x-l, l])

delete_robot = 0
robot_list.sort()
temp_robot = robot_list[0]

for i in range(n-1):
    if temp_robot[0] > robot_list[i+1][1]:
        delete_robot += 1
    else:
        temp_robot = robot_list[i+1]

print(n - delete_robot)
Buggy code:
    p = sorted([(a+b, a-b) for a, b in zip(x, l)])
    _, th = p[0]
    best = 0
    for t, s in p:
        if th <= s:
            best += 1
            th = t
    return best

n = int(input())
x = [0]*n
l = [0]*n
for i in range(n):
    x[i], l[i] = map(int, input().split())
print(solve(n, x, l))

Fixed code:
def solve(n, x, l):
    p = sorted([(a+b, a-b) for a, b in zip(x, l)])
    _, th = p[0]
    best = 0
    for t, s in p:
        if th <= s:
            best += 1
            th = t
    return best

n = int(input())
x = [0]*n
l = [0]*n
for i in range(n):
    x[i], l[i] = map(int, input().split())
print(solve(n, x, l))
Buggy code:
N = int(input())
ts = []
for _ in range(N):
    x, l = map(int,input().split())
    t = min(x+l,10**9)
    s = max(x-l,0)
    ts.appned([t,s])

ts.sort()

tmp = 0
count = 0
for n in ts:
    if tmp<=n[1]:
        count += 1
        tmp = n[0]

print(count)


Fixed code:
N = int(input())
ts = []
for _ in range(N):
    x, l = map(int,input().split())
    t = min(x+l,10**9)
    s = max(x-l,0)
    ts.append([t,s])

ts.sort()

tmp = 0
count = 0
for n in ts:
    if tmp<=n[1]:
        count += 1
        tmp = n[0]

print(count)
Buggy code:
from operator import itemgetter

N = int(input())
X=[]
ans=0
for i in range(N):
    H = list(map(int, input().split()))
    O=[]
    O.append(H[0]-H[1])
    O.append(H[0]+H[1])
    X.append(O)
#print(X)
X=sorted(X, key=itemgetter(1))
S=X[0][1]
ans+=1
for i in range(len(X)):
    if(X[i][0]>S):
        ans+=1
        S=X[i][1]
"""
while(len(X)>0):
    #print(X)
    ans+=1
    S=X[0][1]
    X.remove(X[0])
    I = []
    for i in range(len(X)):
        if(X[i][0]>=S):
            I.append(X[i])
    X=I
    #print(I)
"""


print(ans)


Fixed code:
from operator import itemgetter

N = int(input())
X=[]
ans=0
for i in range(N):
    H = list(map(int, input().split()))
    O=[]
    O.append(H[0]-H[1])
    O.append(H[0]+H[1])
    X.append(O)
#print(X)
X=sorted(X, key=itemgetter(1))
S=X[0][1]
ans+=1
for i in range(len(X)):
    if(X[i][0]>=S):
        ans+=1
        S=X[i][1]
"""
while(len(X)>0):
    #print(X)
    ans+=1
    S=X[0][1]
    X.remove(X[0])
    I = []
    for i in range(len(X)):
        if(X[i][0]>=S):
            I.append(X[i])
    X=I
    #print(I)
"""


print(ans)
Buggy code:
INF = float("inf") #const

def main():
    n = int(input())
    ls = [list(map(int,input().split())) for _ in range(n)]
    #start ls[i][0] - ls[i][1]. goal ls[i][0] + ls[i][1]
    ls = sorted(ls,key = lambda x:x[0])
    print(ls)

    ans = 0; t = -INF
    for i in range(n):
        if t <= ls[i][0] - ls[i][1]:
            ans += 1
            t = ls[i][0] + ls[i][1]
    print(ans)


if __name__ == "__main__":
    main()


Fixed code:
INF = float("inf") #const

def main():
    n = int(input())
    ls = [list(map(int,input().split())) for _ in range(n)]
    #start ls[i][0] - ls[i][1]. goal ls[i][0] + ls[i][1]
    robot = [(ls[i][0] + ls[i][1],ls[i][0] - ls[i][1]) for i in range(n)]
    robot = sorted(robot,key = lambda x: x[0])
    #(goal,start)

    ans = 0; latest = -INF
    for i in range(n):
        if latest <= robot[i][1]:
            ans += 1
            latest = robot[i][0]
    print(ans)


if __name__ == "__main__":
    main()
Buggy code:
N=int(input())
import sys
l=[i.rstrip().split() for i in sys.stdin.readlines()]
l=[list(map(int,i)) for i in l]
l=[[i-j,i+j] for i,j in l]
from operator import itemgetter
l.sort(key=itemgetter(1))
ans=N
for i in range(N-1):
   end=l[i][1]
   if l[i+1][0] < end:
      ans-=1
   else:
      end=l[i+1][1]
print(ans)

Fixed code:
N=int(input())
import sys
l=[i.rstrip().split() for i in sys.stdin.readlines()]
l=[list(map(int,i)) for i in l]
l=[[i-j,i+j] for i,j in l]
from operator import itemgetter
l.sort(key=itemgetter(1))
ans=N
end=l[0][1]
for i in range(N-1):
   if l[i+1][0] < end:
      ans-=1
   else:
      end=l[i+1][1]
print(ans)
Buggy code:
n = int(input())
ls = []
for i in range(n):
    x,l = map(int,input().split())
    ls.append([x-l,l+x])

ls = sorted(ls, key=lambda x: x[1])
ans = n
print(ls)

for i in range(1,n):
    if ls[i][0] < ls[i-1][1]:
      ls[i][1] = ls[i-1][1]
      ans -=1

print(ans)

Fixed code:
n = int(input())
ls = []
for i in range(n):
    x,l = map(int,input().split())
    ls.append([x-l,l+x])

ls = sorted(ls, key=lambda x: x[1])
ans = n

for i in range(1,n):
    if ls[i][0] < ls[i-1][1]:
      ls[i][1] = ls[i-1][1]
      ans -=1

print(ans)
Buggy code:
n=int(input())
x=[]
l=[]
for i in range(n):
    a,b=map(int,input().split())
    x.append(a)
    l.append(b)

ans = [[0 for i in range(2)] for j in range(n)]
for i in range(n):
    ans[i][1]=(x[i]+l[i])
    ans[i][0]=max(0,x[i]-l[i])
ans.sort()
count=1
j=0
for i in range(n-1):
    
    if ans[j][1]<=ans[i+1][0] and ans[i][1]>ans[i+1][1]:
        count+=1
        j=i+1
print(count)



Fixed code:
n=int(input())
x=[]
l=[]
for i in range(n):
    a,b=map(int,input().split())
    x.append(a)
    l.append(b)

ans = [[0 for i in range(2)] for j in range(n)]
for i in range(n):
    ans[i][1]=(x[i]+l[i])
    ans[i][0]=max(0,x[i]-l[i])
ans.sort()
count=1
j=0
for i in range(n-1):
    
    if ans[j][1]<=ans[i+1][0] :
        count+=1
        j=i+1
    else:
        if ans[j][1]>ans[i+1][1]:
           j=i+1  
print(count)
Buggy code:
n = int(input())
xl = [list(map(int, input().split())) for i in range(n)]
xl = sorted([[x-l+1,x+l-1] for x,l in xl], key = lambda x: x[1])
print(xl)
now = - 10 ** 10
ans = 0
for s,e in xl:
  if s > now:
    ans += 1
    now = e
print(ans)

Fixed code:
n = int(input())
xl = [list(map(int, input().split())) for i in range(n)]
xl = sorted([[x-l,x+l] for x,l in xl], key = lambda x: x[1])
now = - 10 ** 10
ans = 0
for s,e in xl:
  if s >= now:
    ans += 1
    now = e
print(ans)
Buggy code:
n = int(input())
xl = []
lr = []
for _ in range(n):
    x, l = map(int, input().split())
    lr.append([x-l, x+l])
    xl.append([x, l])

xl.sort()
lr.sort()
lr.append([-float("inf"), -float("inf")])

l = lr[0][0]
r = lr[0][1]

ans = 0
for i in range(1, len(lr)):
    if  lr[i][0] <= r:
        l = lr[i][0]
        r = lr[i][1]
        ans += 1

print(ans)


Fixed code:
n = int(input())
xl = []
lr = []
for _ in range(n):
    x, l = map(int, input().split())
    xl.append([x, l])
    lr.append([x-l, x+l])

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

ans = 0
r = -float("inf")
for i in range(n):
    if r <= lr[i][0]:
        ans += 1
        r = lr[i][1]

print(ans)
Buggy code:
n = int(input())
ls = []
for i in range(n):
    x,l = map(int,input().split())
    ls.append([x-l,l+x])

ls.sort(key=lambda x:x[1])
ans = 0

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

Fixed code:
n = int(input())
ls = []
for i in range(n):
    x,l = map(int,input().split())
    ls.append([x-l,l+x])
    
ls = sorted(ls, key=lambda item: item[1])
ans = n

for i in range(1,n):
    if ls[i][0] < ls[i-1][1]:
      ls[i][1] = ls[i-1][1]
      ans -=1
        
print(ans)
Buggy code:
import numpy as np

stdin = np.fromstring(open(0).read(), np.int64, sep=' ')
N = stdin[0]
XL = stdin[1:].reshape(-1, 2).T
x = XL[0]
l = XL[1]
arg = np.argsort(x)
x = x[arg]
l = l[arg]

xr = x + l
xl = x - l

count = 0
i = 0
while i < N - 1:
    for j in range(i + 1, N):
        if xr[i] >= xl[j]:
            count += 1
        else:
            i = j
    else:
        break
print(N - count)

Fixed code:
import numpy as np

stdin = np.fromstring(open(0).read(), np.int64, sep=' ')
N = stdin[0]
XL = stdin[1:].reshape(-1, 2).T
x = XL[0]
l = XL[1]
arg = np.argsort(x)
x = x[arg]
l = l[arg]
xleft = x - l
xright = x + l

count = 0
i = 0
while i < N - 1:
    for j in range(i + 1, N):
        if xright[i] > xright[j]:
            count += 1
            i = j
            break
        if xright[i] > xleft[j]:
            count += 1
            j = j + 1
        else:
            i = j
            break
    else:
        i = N - 1

print(N - count)
Buggy code:
length = int(input())
target = []
for i in range(length):
    s, e = map(int, input().split(" "))
    target.append([s, s + e])
target.sort(key = lambda x: x[1])
answer = 0
before_e = float("inf")
# print(target)
for s, e in target:
    # print(before_s, before_e, s, e)
    if s >= before_e:
        # print(1, before_s, before_e, s, e)
        answer += 1
    else:
        before_e = e
print(length - answer)

Fixed code:
length = int(input())
target = []
for i in range(length):
    s, e = map(int, input().split(" "))
    target.append([s - e, s + e])
target.sort(key = lambda x: x[1])
answer = 0
before_e = -float("inf")
for s, e in target:
    # print(before_e, s, e)
    if s < before_e:
        answer += 1
    else:
        before_e = e
print(length - answer)
Buggy code:
class Robot:
    def __init__(self, left, right):
        self.left = left
        self.right = right
    
    def __lt__(self, other):
        return self.right < other.right

n = int(input().rstrip())
robos = [None] * n

for i in range(n):
    line = input().rstrip().split(' ')
    robos[i] = Robot(int(line[0]) - int(line[1]), int(line[0]) + int(line[1])

robos.sort()

cur = -1000000000
ans = 0
for i in range(n):
    if cur <= robos[i].left:
        ans += 1
        cur = robos[i].right

print(ans)

Fixed code:
class Robot:
    def __init__(self, left, right):
        self.left = left
        self.right = right
    
    def __lt__(self, other):
        return self.right < other.right

n = int(input().rstrip())
robos = [None] * n

for i in range(n):
    line = input().rstrip().split(' ')
    robos[i] = Robot(int(line[0]) - int(line[1]), int(line[0]) + int(line[1]))

robos.sort()

cur = -1000000000
ans = 0
for i in range(n):
    if cur <= robos[i].left:
        ans += 1
        cur = robos[i].right

print(ans)
Buggy code:
s=int(input())
t=[]
for i in range(N):
    u,l = map(int,input().split())
    t.append((u-l,u+l-1))
t.sort(key=lambda x: x[1])
d=-10*10
ans=0
for i in range(s):
  a=t[i][0]-t[i][1]
  if d<a:
    ans+=1
    d=a+2*t[i][1]-1
print(ans)

Fixed code:
s=int(input())
t=[]
for i in range(s):
    u,l=map(int,input().split())
    t.append((u-l,u+l-1))
t.sort(key=lambda x: x[1])
d=-10**10
ans=0
for i in range(s):
  if d<t[i][0]:
    ans+=1
    d=t[i][1]
print(ans)
Buggy code:
import sys
input = sys.stdin.readline

n = int(input())
xl = [list(map(int, input().split())) for _ in range(n)]
xl2 = sorted([[x - l + 1, x + l - 1] for x, l in xl])

ans = n
mr = xl2[0][0] - 1
for l, r in xl2:
    if l <= mr:
        ans -= 1
    else:
        mr = l

print(ans)


Fixed code:
import sys
input = sys.stdin.readline

n = int(input())
xl = [list(map(int, input().split())) for _ in range(n)]
xl2 = sorted([[x + l, x - l] for x, l in xl])

ans = 0
mr = xl2[0][1]
for r, l in xl2:
    if l >= mr:
        ans += 1
        mr = r
print(ans)