qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N = int(input())
se = [()] * N
for i in range(N):
	x, l = map(int, input().split())
	se[i] = (x-l, x+l)
se = sorted(se, key=lambda x: x[1])
ans = N
for i in range(1, N):
	if se[i-1][1] > se[i][0]:
		ans -= 1
print(ans)

Fixed code:
N = int(input())
se = [[]] * N
for i in range(N):
	x, l = map(int, input().split())
	se[i] = [x-l, x+l]
se = sorted(se, key=lambda x: x[1])
ans = N
for i in range(1, N):
	if se[i-1][1] > se[i][0]:
		se[i][1] = se[i-1][1]
		ans -= 1
print(ans)
Buggy code:
import sys
readline = sys.stdin.buffer.readline

from collections import deque
from copy import copy,deepcopy
from itertools import permutations,combinations
from pprint import pprint

def myinput():
    return map(int,readline().split())

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    return data.sort(key=lambda x:x[col],reverse=True)

n = int(input())
xl = [ list(myinput()) for _ in range(n) ]

ls = []
for i in range(n):
    x = xl[i][0]
    l = xl[i][1]
    s = x - l
    e = x + l
    d= [s,e]
    ls.append(d)
# print(ls)
ls.sort(key=lambda x:x[1],reverse=False)
# print(ls)

count = 0
e = -1*float("inf")
for i in range(n):
    ns,ne = ls[i]
    if ns>=e:
        count += 1
        e = copy(ne)
    else:
        pass

print(count)

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

from collections import deque
from copy import copy,deepcopy
from itertools import permutations,combinations
from pprint import pprint

def myinput():
    return map(int,input().split())

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    return data.sort(key=lambda x:x[col],reverse=True)

n = int(input())
xl = [ list(myinput()) for _ in range(n) ]
# print(xl)

ls = []
for i in range(n):
    x = xl[i][0]
    l = xl[i][1]
    s = x - l
    e = x + l
    d = [s,e]
    ls.append(d)
# print(ls)
ls.sort(key=lambda x:x[1],reverse=False)
# print(ls)

count = 0
e = -1*float("inf")
for i in range(n):
    ns,ne = ls[i]
    if ns>=e:
        count += 1
        e = copy(ne)
    else:
        pass

print(count)
Buggy code:
N = int(input())
R = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x:x[0])

remain = list(range(N))
left = 0
i = 1
while i < N:
  print(remain)
  x_l, length_l = R[left]
  x, length = R[i]
  if x-x_l < length_l+length:
    remain.pop(remain.index(i))
  else:
    left = i
  i += 1
print(len(remain))

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

remain = list(range(N))
ans = N
left = 0
i = 1
while i < N:
  x_l, length_l = R[left]
  x, length = R[i]
  if x-x_l < length_l+length:
    ans -= 1
  else:
    left = i
  i += 1
print(ans)
Buggy code:
n=int(input())
X=[]
for i in range(n):
    x,l=[int(_) for _ in input().split()]
    X+=[tuple(x-l,x+l)]
X.sort(key=lambda x:x[0])
ans=n
tmp=X[0][1]
for i in range(1,n):
    if tmp>X[i][0]:
        ans-=1
        tmp=min(tmp,X[i][1])
    else:
        tmp=X[i][1]
print(ans)

Fixed code:
n=int(input())
X=[]
for i in range(n):
    x,l=[int(_) for _ in input().split()]
    X+=[(x-l,x+l)]
X.sort(key=lambda x:x[0])
ans=n
tmp=X[0][1]
for i in range(1,n):
    if tmp>X[i][0]:
        ans-=1
        tmp=min(tmp,X[i][1])
    else:
        tmp=X[i][1]
print(ans)
Buggy code:
N = int(input())
robot = []
for _ in range(N):
  r = []
  x, l = map(int, input().split())
  a = x + l 
  b = x - l
  r += [a, b]
  robot.append(r)
Robot = sorted(robot)
 
robot_count = [Robot[0]]
for i in range(1, N):
  if Robot[i][1] > robot_count[-1][0]:
    robot_count.append(Robot[i])
 
print(len(robot_count))

Fixed code:
N = int(input())
robot = []
for _ in range(N):
  r = []
  x, l = map(int, input().split())
  a = x + l - 1
  b = x - l
  r += [a, b]
  robot.append(r)
Robot = sorted(robot)

robot_count = [Robot[0]]
for i in range(1, N):
  if Robot[i][1] > robot_count[-1][0]:
    robot_count.append(Robot[i])

print(len(robot_count))
Buggy code:
n = int(input())
x = [0]*n
l = [0]*n
for i in range(n):
    x[i] , l[i] = map(int, input().split())
itv = [[0 for i in range(2)] for j in range(n)]
for i in range(n):
    a = x[i]+l[i]
    b = x[i]-l[i]
    itv[i][0] = a
    itv[i][1] = b
itv.sort()

ans = 0
curx = -1000000000

for i in range(n):
    if curx <= itv[i][0]:
        curx = itv[i][1]
        ans += 1
        
print(ans)

Fixed code:
n = int(input())
x = [0]*n
l = [0]*n
for i in range(n):
    x[i] , l[i] = map(int, input().split())
itv = [[0 for i in range(2)] for j in range(n)]
for i in range(n):
    a = x[i]+l[i]
    b = x[i]-l[i]
    itv[i][0] = a
    itv[i][1] = b
itv.sort()

ans = 0
curx = -10000000000

for i in range(n):
    if curx <= itv[i][1]:
        curx = itv[i][0]
        ans += 1
        
print(ans)
Buggy code:
n = int(input())
a = []
for _ in range(n):
    a.append(list(map(int,input().split())))

d = [[a[i][0]-a[i][1],a[i][0]+a[i][1]] for i in range(n)]

d = sorted(d, key = lambda x: x[1])
#print(d)

b = [-100000000000000000]
c = [0]


for i in range(n):
    for j in range(len(b)):
        if d[i][0] >= b[j]:
            b = [d[i][1]]
            c = [c[j] + 1]
            break
        else:
            b.append(d[i][1])
            c.append(c[j]+1)
    
    #print(b)
    #print(c)

print(max(c))
        
    


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

d = [[a[i][0]-a[i][1],a[i][0]+a[i][1]] for i in range(n)]

d = sorted(d, key = lambda x: x[1])
#print(d)

b = [-100000000000000000]
c = [0]


for i in range(n):
    for j in range(len(b)):
        if d[i][0] >= b[j]:
            b = [d[i][1]]
            c = [c[j] + 1]
            break

    
    #print(b)
    #print(c)

print(max(c))
Buggy code:
N = int(input())

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

arm = sorted(arm, key=lambda x: x[1])
print(arm)

count = 0
i = arm[0][0]
for start, end in arm:
    if start < i:
        continue
    i = end
    count += 1

print(count)


Fixed code:
N = int(input())

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

arm = sorted(arm, key=lambda x: x[1])

count = 0
i = arm[0][0]
for start, end in arm:
    if start < i:
        continue
    i = end
    count += 1

print(count)
Buggy code:
def main():
    N, *XL = map(int, open(0).read().split())
    # print(N, XL)
    robots = [0]*N
    for i in range(N):
        X, L = XL[2 * i + 0], XL[2 * i + 1]
        robots[i] = (X - L, X + L)
    robots.sort(key=lambda x: x[1])
    # print(robots)
    ans = 0
    last = robots[0][0] - 1
    for robot in robots:
        if last <= robot[1]:
            last = robot[1]
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()


Fixed code:
def main():
    N, *XL = map(int, open(0).read().split())
    # print(N, XL)
    robots = [0]*N
    for i in range(N):
        X, L = XL[2 * i + 0], XL[2 * i + 1]
        robots[i] = (X - L, X + L)
    robots.sort(key=lambda x: x[1])
    # print(robots)
    ans = 0
    last = robots[0][0] - 1
    for robot in robots:
        if last <= robot[0]:
            last = robot[1]
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()
Buggy code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
x = [[0]*2 for i in range(n)]
for i in range(n):
    x[i][0], x[i][1] = MAP()

x.sort()
tmp = -inf
ans = n
for i in range(n):
    if tmp > x[i][0] - x[i][1]:
        ans -= 1
        tmp = min(tmp, x[i][0] + x[i][1])
        print(i)
    else:
        tmp = x[i][0] + x[i][1]
print(ans)

Fixed code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
x = [[0]*2 for i in range(n)]
for i in range(n):
    x[i][0], x[i][1] = MAP()

x.sort()
tmp = -inf
ans = n
for i in range(n):
    if tmp > x[i][0] - x[i][1]:
        ans -= 1
        tmp = min(tmp, x[i][0] + x[i][1])
    else:
        tmp = x[i][0] + x[i][1]
print(ans)
Buggy code:
n = int(input())
XL = []
for i in range(n):
  x, l = map(int, input().split())
  XL.append([x, l])
  
XL.sort(key=lambda x: x[0]-x[1])

seen = -10**10
ans = 0
for i in range(n):
  rob = XL[i]
  if seen <= rob[0]+rob[1]:
    seen = rob[0]+rob[1]
    ans += 1

print(ans)

Fixed code:
n = int(input())
XL = []
for i in range(n):
  x, l = map(int, input().split())
  XL.append([x, l])
  
XL.sort(key=lambda x: x[0]+x[1])

seen = -10**10
ans = 0
for i in range(n):
  rob = XL[i]
  if seen <= rob[0]-rob[1]:
    seen = rob[0]+rob[1]
    ans += 1

print(ans)
Buggy code:
from operator import itemgetter
N = int(input())
arms = []
finishtime = float('-inf')
for i in range(N):
    x,l = map(int,input().split())
    arms.append((x-l,x+l))
arms.sort(key=itemgetter(1))
cnt=0
for L,R in arms:
    if R >= finishtime:
        cnt+=1
        finishtime = R
print(cnt)

Fixed code:
from operator import itemgetter
N = int(input())
arms = []
finishtime = float('-inf')
for i in range(N):
    x,l = map(int,input().split())
    arms.append((x-l,x+l))
arms.sort(key=itemgetter(1))
cnt=0
for L,R in arms:
    if finishtime<=L:
        cnt+=1
        finishtime = R
print(cnt)
Buggy code:
n = int(input())
lis = []
lis2 = []
for _ in range(n):
  x, l= list(input().split(" "))
  p_d = int(x) + int(l)
  m_d = int(x) - int(l)
  lis.append([m_d, p_d])

lis.sort
a = -10 ** 10
x = 0

for b in range(n):
  if lis[b][0] >= a:
    x += 1
    a = lis[b][1]

print(x)

Fixed code:
n = int(input())
lis = []
for _ in range(n):
  x, l= list(input().split(" "))
  p_d = int(x) + int(l)
  m_d = int(x) - int(l)
  lis.append([p_d, m_d])

lis.sort()
a = -10 ** 10
x = 0

for b in range(n):
  if lis[b][1] >= a:
    x += 1
    a = lis[b][0]

print(x)
Buggy code:
N = int(input())
TS = []
for _ in range(N):
    X,L = map(int, input().split())
    TS.append([X,L])
 
mlist=[]
for i in range(N):
    mlist.append([TS[i][0] - TS[i][1], TS[i][0] + TS[i][1]])
 
mlist.sort()
print(mlist)

cur = -10**10
ans=0
for i in range(N):
    if mlist[i][0] >= cur:
        ans+=1
        cur = mlist[i][1]
print(ans)

Fixed code:
N = int(input())
TS = []
for _ in range(N):
    X,L = map(int, input().split())
    TS.append([X,L])

mlist=[]
for i in range(N):
    mlist.append([TS[i][0] + TS[i][1], TS[i][0] - TS[i][1]])

mlist.sort()

cur = -10**10
ans=0
for i in range(N):
    if mlist[i][1] >= cur:
        ans+=1
        cur = mlist[i][0]
print(ans)
Buggy code:
n = int(input())
li=[None]*2
lis=[]
count=0
for i in range(n):
    x, l = map(int, input().split())
    li[0] = x+l
    li[1] = x-l
    lis.append(li)
lis.sort()
kari_r = -(10 ** 18)
print(lis)
for r, l in lis:
        if kari_r > l:
            continue
        count+=1
        kari_r = r
            
print(count)

Fixed code:
n = int(input())
lis=[]
count=0
for i in range(n):
    li=[None]*2
    x, l = map(int, input().split())
    li[0] = x+l
    li[1] = x-l
    lis.append(li)
lis.sort()
kari_r = -(10 ** 18)
for r, l in lis:
        if kari_r > l:
            continue
        count+=1
        kari_r = r
            
print(count)
Buggy code:
N = int(input())
ranges = []
for _ in range(N):
    x, l = map(int, input().split())
    ranges.append([x + l - 1, x - l + 1])
ranges.sort()

sx = ranges[0][0]
ans = 1
for i in range(N):
    if sx <= ranges[i][1]:
        ans += 1
        sx = ranges[i][0]
print(ans)


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

sx = ranges[0][0]
ans = 1
for i in range(N):
    if sx <= ranges[i][1]:
        ans += 1
        sx = ranges[i][0]
print(ans)
Buggy code:
N=int(input())

robot=[]
for _ in range(N):
    x,l=map(int,input().split())
    robot.append((x+l-1,x-l+1))
robot.sort(reverse=True)

tmp=-10**10
ans=0
for i in range(N):
    end,start=robot[i]
    if tmp<start:
        tmp=end
        ans+=1
print(ans)




Fixed code:
N=int(input())

robot=[]
for _ in range(N):
    x,l=map(int,input().split())
    robot.append((x+l,x-l))
robot.sort()

tmp=-10**10
ans=0
for i in range(N):
    end,start=robot[i]
    if tmp<=start:
        tmp=end
        ans+=1
print(ans)
Buggy code:
N = int(input())
MAX_list = []
ans = 0
A = -10**9

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

for m, l in MAX_list:
    if l > A:
        ans += 1
        A = m

print(ans)

Fixed code:
N = int(input())
MAX_list = []
ans = 0
A = -10**9-2

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

for m, l in MAX_list:
    if l >= A:
        ans += 1
        A = m

print(ans)
Buggy code:
from operator import itemgetter
N= int(input())
ans = 1
a = []

for i in range(N):
    tmpa, tmpb = map(int,input().split())
    a.append([tmpa+tmpb, tmpa-tmpb])

a.sort()
    
tmp = a[0][1]
for i in range(1, N):
    if a[i][0] >= tmp:
        ans += 1
        tmp = a[i][1]
print(ans)

Fixed code:
from operator import itemgetter
N= int(input())
ans = 1
a = []

for i in range(N):
    tmpa, tmpb = map(int,input().split())
    a.append([tmpa+tmpb, tmpa-tmpb])

a.sort()
    
tmp = a[0][0]
for i in range(1, N):
    if a[i][1] >= tmp:
        ans += 1
        tmp = a[i][0]
print(ans)
Buggy code:
N = int(input())
ls = []
for _ in range(N):
    x, l = map(int, input().split())
    ls.append([x-l, x+l])

ans = N
for i in range(1, N):
    if ls[i-1][1] > ls[i][0]:
        ls[i][1] = ls[i-1][1]
        ans -= 1
print(ans)

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

ans = N
for i in range(1, N):
    if ls[i-1][1] > ls[i][0]:
        ls[i][1] = ls[i-1][1]
        ans -= 1
print(ans)
Buggy code:
import sys; readline = sys.stdin.readline

N = int(readline())
X, L = zip(*[map(int, readline().split()) for i in range(N)])

rm = -10000000
dropc = 0
for i in range(N):
    if X[i] - L[i] < rm:
        if rm > X[i] + L[i]:
            rm = X[i] + L[i]
        dropc += 1
    else:
        rm = X[i] + L[i]

print(N - dropc)


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

N = int(readline())
XL = [list(map(int, readline().split())) for i in range(N)]
XL.sort()
X, L = zip(*XL)

rm = -10000000
dropc = 0
for i in range(N):
    if X[i] - L[i] < rm:
        if rm > X[i] + L[i]:
            rm = X[i] + L[i]
        dropc += 1
    else:
        rm = X[i] + L[i]

print(N - dropc)
Buggy code:
n = int(input())
d = []
left = []
right = []
for i in range(n):
    x,l = map(int, input().split())
    # num , left , right
    d.append([x-l+1,x+l-1])

d.sort()
p = d[0][1]
ans = n
for i in range(1,n):
    if d[i][0] <= p:
        p = min(p,d[i][1])
    else:
        ans -= 1
        p = d[i][1]
print(ans)

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

d.sort()
p = d[0][1]
ans = n
for i in range(1,n):
    if d[i][0] < p:
        ans -= 1
        p = min(p,d[i][1])
    else:
        p = d[i][1]
print(ans)
Buggy code:
from collections import deque
n = int(input())
cou = n
l_h = []
for i in range(n):
  x,l  = map(int,input().split())
  l_h.append([x-l,x+l])
l_h.sort(key=lambda x: x[1])
d = deque(l_h)
t= d.popleft()
a,b = t[0],t[1]
for i in range(n-1):
  m= d.popleft()
  c,e= m[0],m[1]
  if b<=c:
    b = d
  else:
    cou -= 1
print(cou)

Fixed code:
from collections import deque
n = int(input())
cou = n
l_h = []
for i in range(n):
  x,l  = map(int,input().split())
  l_h.append([x-l,x+l])
l_h.sort(key=lambda x: x[1])
d = deque(l_h)
t= d.popleft()
a,b = t[0],t[1]
for i in range(n-1):
  m= d.popleft()
  c,e= m[0],m[1]
  if b<=c:
    b = e
  else:
    cou -= 1
print(cou)
Buggy code:
def main():
    n=int(input())
    xs=[0]*n
    ls=[0]*n
    ranges=[0]*n
    for i in range(n):
        xs[i],ls[i]=map(int,input().split())
        ranges[i]=[xs[i]-ls[i],xs[i]+ls[i]]
    ranges.sort(key=lambda x:x[1])
    count=0
    point=-10000
    for irange in ranges:
        if irange[0]>=point:
            count+=1
        point=irange[1]
    print(count)
if __name__ == "__main__":
    main()


Fixed code:
def main():
    n=int(input())
    xs=[0]*n
    ls=[0]*n
    ranges=[0]*n
    for i in range(n):
        xs[i],ls[i]=map(int,input().split())
        ranges[i]=[xs[i]-ls[i],xs[i]+ls[i]]
    ranges.sort(key=lambda x:x[1])
    count=0
    point=-1000000000000
    for irange in ranges:
        if irange[0]>=point:
            count+=1
            point=irange[1]
    print(count)
if __name__ == "__main__":
    main()
Buggy code:
import math
N = int(input())
X = []
for _ in range(N):
  x, l = map(int,input().split())
  X.append([x+l, x-l])
sorted_X = sorted(X, key=lambda x:(x[1], x[2]))
ans = 1
cnt = sorted_X[0][0]
for i in range(N):
  if sorted_X[i][1] >= cnt:
    ans += 1
    cnt = sorted_X[i][0]
print(ans)

Fixed code:
import math
N = int(input())
X = []
for _ in range(N):
  x, l = map(int,input().split())
  X.append([x+l, x-l])
sorted_X = sorted(X, key=lambda x:(x[0], x[1]))
ans = 1
cnt = sorted_X[0][0]
for i in range(N):
  if sorted_X[i][1] >= cnt:
    ans += 1
    cnt = sorted_X[i][0]
print(ans)
Buggy code:
N = int(input())

xl = []

for i in range(N):
    xl.append(list(map(int,input().split())))

itv = []

for i in range(N):
    right = xl[i][0] + xl[i][1]  ##right
    left = xl[i][0] - xl[i][1]  ##left   
    itv.append([right,left])
itv.sort()

ass = 0
tt = -1e10
for i in range(N):
    if tt < itv[i][1]:
        ass += 1
        tt = itv[i][0]
print(ass)



Fixed code:
N = int(input())

xl = []

for i in range(N):
    xl.append(list(map(int,input().split())))

itv = []

for i in range(N):
    right = xl[i][0] + xl[i][1] - 0.01 ##right
    left = xl[i][0] - xl[i][1] + 0.01 ##left   
    itv.append([right,left])
itv.sort()

ass = 0
tt = -1e10
for i in range(N):
    if tt < itv[i][1]:
        ass += 1
        tt = itv[i][0]
print(ass)
Buggy code:
import sys
input = sys.stdin.readline


N = int(input())
start = []
end = []
itv = []
for i in range(N):
    X, L = (int(i) for i in input().split())
    itv.append([X+L, X-L])
    #start.append(X-L)
    #end.append(X+L)

#XL = [[int(i) for i in input().split()] for i in range(N)] 

count = N
#line = [0] * (2*(10**9) +1)
XL = sorted(XL)


itv.sort()

ass = 0
tt = 0
for i in range(N):
    if tt < itv[i][1]:
        ass += 1
        tt = itv[i][0]
print(ass)


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


N = int(input())
start = []
end = []
itv = []
for i in range(N):
    X, L = (int(i) for i in input().split())
    itv.append([X+L, X-L])
    #start.append(X-L)
    #end.append(X+L)

#XL = [[int(i) for i in input().split()] for i in range(N)] 

#line = [0] * (2*(10**9) +1)

itv.sort()

#print(itv)

ass = 0
tt = 0-10**9
for i in range(N):
    if tt <= itv[i][1]:
        ass += 1
        tt = itv[i][0]
print(ass)
Buggy code:
n = int(input())
xl = [list(map(int, input().split())) for _ in range(n)]
ran = [[xl[i][0]-xl[i][1], xl[i][0]+xl[i][1]] for i in range(n)]
ran = sorted(ran, key=lambda x:x[1])
ans = n
right = ran[0][1]
for i in range(1, n):
  l, r = ran[i]
  if l < right < r:
    print(i, right)
    ans -= 1 
  else:
    right = r 

print(ans)


Fixed code:
n = int(input())
xl = [list(map(int, input().split())) for _ in range(n)]
ran = [[xl[i][0]-xl[i][1], xl[i][0]+xl[i][1]] for i in range(n)]
ran = sorted(ran, key=lambda x:x[1])
ans = 1
right = ran[0][1]
for i in range(n):
  l, r = ran[i]
  if l >= right:
    ans += 1 
    right = r 

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

itv.sort()

ans, t = 0, 0
for [x, l] in itv:
    if t <= l:
        ans += 1
        t = x

print(ans)


Fixed code:
n = int(input())
itv = []
for i in range(n):
    x,l = map(int, input().split())
    start = x - l if x - l > 0 else 0
    end = x + l
    itv.append([end, start])

itv.sort()

ans, t = 0, 0
for [x, l] in itv:
    if t <= l:
        ans += 1
        t = x

print(ans)
Buggy code:
import sys
input=sys.stdin.buffer.readline

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

L.sort(key=lambda x:x[1])
ans=0
cur=-1
for a,b in L:
  if a>=cur:
    cur=b
    ans+=1
print(ans)

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

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

L.sort(key=lambda x:x[1])
ans=0
cur=-11111111111111111
for a,b in L:
  if a>=cur:
    cur=b
    ans+=1
print(ans)
Buggy code:
N = int(input())
A = []
for i in range(a):
    x, l = map(int, input().split())
    A.append([x+l, x-l])
A.sort()
ans = 1
check1 = A[0]
for i in range(1, N):
    check2 = A[i]
    if check1[0] <= check2[1]:
        ans += 1
        check1 = check2
print(ans)

Fixed code:
N = int(input())
A = []
for i in range(N):
    x, l = map(int, input().split())
    A.append([x+l, x-l])
A.sort()
ans = 1
check1 = A[0]
for i in range(1, N):
    check2 = A[i]
    if check1[0] <= check2[1]:
        ans += 1
        check1 = check2
print(ans)
Buggy code:
N = int(input())
XL = []
for n in range(N):
    XL.append([int(x) for x in input().split()])
XL = sorted(XL, key=lambda x:x[0]+x[1])
m = 0
ans = 0
for n in range(N):
    if XL[n][0]-XL[n][1] >= m:
        ans += 1
        m = XL[n][0]+XL[n][1]
print(ans)



Fixed code:
N = int(input())
XL = []
for n in range(N):
    XL.append([int(x) for x in input().split()])
XL = sorted(XL, key=lambda x:x[0]+x[1])
m = -float("inf")
ans = 0
for n in range(N):
    if XL[n][0]-XL[n][1] >= m:
        ans += 1
        m = XL[n][0]+XL[n][1]
print(ans)
Buggy code:
n = int(input())

xl =[]
for i in range(n):
    x,l = map(int,input().split())
    xl.append([x-l+1,x+l-1])
 
xl.sort(key=lambda x: x[1])
print(xl)
arm = xl[0][1] 
cnt = 1
for i in range(1,n):
    x,l = xl[i][0],xl[i][1]

    if arm < xl[i][0]:
        arm = xl[i][1]
        cnt +=1
        
print(cnt) 

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(key=lambda x: x[1])

arm = xl[0][1] 
cnt = 1
for i in range(1,n):
    x,l = xl[i][0],xl[i][1]

    if arm <= xl[i][0]:
        arm = xl[i][1]
        cnt +=1
        
print(cnt)
Buggy code:
N = int(input())
XL = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    XL.append(array)
XL = sorted(XL)
Y = 0
cnt = 0
for i in range(N):
    if XL[i][0]-XL[i][1]>=Y:
        cnt += 1
        Y = XL[i][0]+XL[i][1]
    else:
        Y = min(Y,XL[i][0]+XL[i][1])
print(cnt)

Fixed code:
N = int(input())
XL = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    XL.append(array)
XL = sorted(XL)
Y = 0
cnt = 0
for i in range(N):
    if max(XL[i][0]-XL[i][1],0)>=Y:
        cnt += 1
        Y = XL[i][0]+XL[i][1]
    else:
        Y = min(Y,XL[i][0]+XL[i][1])
print(cnt)