Problem:
 Score : 200 points    Problem Statement In a factory, there are N robots placed on a number line.
Robot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.  We want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect.
Here, for each i ( 1 \leq i \leq N ), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i , excluding the endpoints.  Find the maximum number of robots that we can keep.      Constraints  1 \leq N \leq 100,000  0 \leq X_i \leq 10^9 ( 1 \leq i \leq N )  1 \leq L_i \leq 10^9 ( 1 \leq i \leq N )  If i \neq j , X_i \neq X_j .  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  X_1  L_1  X_2  L_2  \vdots  X_N  L_N       Output Print the maximum number of robots that we can keep.        Sample Input 1 4
2 4
4 3
9 3
100 5      Sample Output 1 3  By removing Robot 2 , we can keep the other three robots.       Sample Input 2 2
8 20
1 10      Sample Output 2 1       Sample Input 3 5
10 1
2 1
4 1
6 1
8 1      Sample Output 3 5

Solution (Python):

N = int(input())
L = []

for _ in range(N):
	a, b = map(int, input().split())
	L.append((a-b, a+b))

L = sorted(L, key = lambda x:x[1])
start = L[0][1]
ans = 1

for i in range(1, N):
	if start <= L[i][0]:
		ans += 1
		start = L[i][1]
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
N=int(input())
list=[0 for i in range(N)]
for  i in range(N):
 x,l=map(int,input().split())
 list[i]=[x-l,x+l]
list.sort(key=lambda x: x[1])
ans=0
haji=-(10**10)
for  i in range(N):
 if list[i][0]>=haji:
  ans+=1
  haji=list[i][1]
print(ans)

Solution (Python):
def main():
    
    
    N = int(input())
    sec = [[0,0] for _ in range(N)]
    for i in range(N):
        X,L = map(int, input().split())
        sec[i][0] = X+L
        sec[i][1] = X-L
    
    sec = sorted(sec)
    ans = 1
    now = sec[0][0]
    for i in range(1,N):
        if sec[i][1]>=now:
            
            ans += 1
            now = sec[i][0]
    print(ans)

main()

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from operator import itemgetter



N = int(readline())
m = map(int,read().split())
XL = zip(m,m)

LR = [(x-l,x+l) for x,l in XL]
LR.sort(key = itemgetter(1))

INF = 10 ** 18
prev_R = -INF
cnt = 0
for L,R in LR:
    if prev_R > L:
        continue
    cnt += 1
    prev_R = R

print(cnt)

Solution (Python):
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)

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

Solution (Python):
import numpy as np

N = int(input())
X = [[] for _ in range(N)]
L = [[] for _ in range(N)]

for i in range(N):
    X[i], L[i] = map(int, input().split())
    
    
def indexSort(L):
    D = dict(zip(range(len(L)), L))
    E = sorted(D.items(), key=lambda x: x[1])
    F = [e[0] for e in E]
    return F

L1 = [x-l for x, l in zip(X, L)]
L2 = [x+l for x, l in zip(X, L)]


Ind = np.argsort(L2)

Remain = [Ind[0]]
i = 0
while i < len(Ind)-1:
    now = Remain[-1]
    After = Ind[i+1:]

    skip = 0
    for after in After:
        if L2[now] > L1[after]:

            skip += 1
        else:

            Remain.append(after)
            break
    i += 1 + skip  
print(len(Remain))

Solution (Python):
n = int(input())

t = []
for i in range(n):
   x,l = map(int,input().split())
   t.append((x+l,x-l))
t.sort()
max_r = -float('inf')
ans = 0
for i in range(n):
    if max_r<=t[i][1]:
        ans+=1
        max_r=t[i][0]
print(ans)

Solution (Python):
N = int(input())
robots = [tuple(map(int,input().split())) for _ in range(N)]
 
robots = [(x+l,x-l) for x,l in robots]
 
robots.sort()
 
cnt = 0
last = -float('inf')
for r,l in robots:
    if last <= l:
        cnt += 1
        last = r
 
print(cnt)

Solution (Python):
n = int(input())
L = []
for _ in range(n):
    x, l = map(int, input().split())
    L.append([x - l, x + l])
L = sorted(L, key=lambda x: x[1])
ans = 0
r = -float('inf')
for i in range(n):
    if L[i][0] >= r:
        ans += 1
        r = L[i][1]
print(ans)

Solution (Python):


N = int(input().strip())
XL_list = [list(map(int, input().rstrip().split())) for i in range(N)]


section = []

for X,L in XL_list:
    section.append( ( X - L , X + L ) )


section.sort(key= lambda x: x[1])
prev_tail = -float("inf")
cnt = 0

for left,right in section:
    if prev_tail <= left:
        cnt += 1
        prev_tail = right
        

print(cnt)

Solution (Python):
N = int(input())
rob = [] 

for i in range(N):
    x, l = map(int,input().split())
    t = x + l
    rob.append((t,x,l))

rob.sort()
Max = -float("inf")
ans = 0
for i in range(len(rob)): 
    t = rob[i][0]
    x = rob[i][1]
    l = rob[i][2]
    if x-l < Max:
        continue
    else:
        ans += 1
        Max = t
print(ans)

Solution (Python):



n = int(input().rstrip())
x_list = []
l_list = []
start_end_list = []

for i in range(n):
    xi, li = map(int, input().split())
    x_list.append(xi)
    l_list.append(li)

    start = xi - li
    if start < 0:
        start = 0
    end = xi + li

    start_end_list.append([start, end])



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

past_end = 0
remain_machine = 0
for st_en in start_end_list:
    start, end = st_en
    if start >= past_end:
        past_end = end
        remain_machine += 1

print(remain_machine)

Solution (Python):
n = int(input())
dat = []
for _ in range(n):
    x, l =map(int, input().split())
    dat.append([x-l, x+l])
dat.sort(key=lambda x: x[1])

prevr = -99999999999999999
res = 0
for i in range(n):
    if dat[i][0] >= prevr:
        prevr = dat[i][1]
        res += 1
print(res)

Solution (Python):
n = int(input())

xl = [list(map(int, input().split())) for _ in range(n)]


position = [(xl[i][0]-xl[i][1],xl[i][0]+xl[i][1]) for i in range(n)]
position = sorted(position, key=lambda x: x[1])

min_arm = -float('inf')
ans = 0


for pos in position:
    
    if  min_arm <= pos[0]:
        ans += 1
        min_arm = pos[1]
print(ans)

Solution (Python):
def m():
    N = int(input())
    XL = [list(map(int, input().split())) for _ in range(N)]
    ST = [[xl[0] - xl[1], xl[0] + xl[1]] for xl in XL]
    ST.sort(key=lambda x: x[1])
    ans = 1
    right = ST[0][1]
    for i in range(1, N):
        if right <= ST[i][0]:
            right = ST[i][1]
            ans += 1
    return ans


print(m())

Solution (Python):
import sys

import math





input=sys.stdin.readline
n=int(input())
xl=[list(map(int,input().split())) for _ in range(n)]
xl.sort(key=lambda x:x[0])
xb=xl[0][0]
lb=xl[0][1]
c=0
for i in range(1,n):
    x=xl[i][0]
    l=xl[i][1]
    if x-l<xb+lb:
        c+=1
        if x+l<xb+lb:
            xb=x
            lb=l
    else:
        xb=x
        lb=l
print(n-c)

Solution (Python):
N = int(input())
l = []

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

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

start = l[0][1]
ans = 1
for i in range(1,N):
    if start <= l[i][0]:
        start = l[i][1]
        ans += 1

print(ans)

Solution (Python):
N=int(input())
XL=[list(map(int,input().split())) for i in range(N)]

R=[]
for i in range(N):
    a=max(0,XL[i][0]-XL[i][1])
    b=XL[i][1]+XL[i][0]
    R.append([b,a])
R.sort()

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

Solution (Python):
import numpy as np
n = int(input())

sg = []

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

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

prev = sg[0][1]

ans = 0
for i in range(1, n):
    if prev > sg[i][0]:
        ans += 1
    else:
        prev = sg[i][1]

print(n - ans)

Solution (Python):
N = int(input())
l = []

for _ in range(N):
    a, b =map(int, input().split())
    l.append((a-b, a+b))

l = sorted(l, key=lambda x:x[1])
start = l[0][1]
ans = 1

for i in range(1, N):
    
    if start <= l[i][0]:
        ans += 1
        start = l[i][1]
print(ans)

Solution (Python):
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)

Solution (Python):
N = int(input())
array = [list(map(int, input().split())) for i in range(N)]
for line in array:
    line.append(line[0] - line[1])
    line.append(line[0] + line[1])
array = sorted(array, key=lambda x: x[3])

count = 0
max_r = -float('inf')
for i in range(N):
    current = array[i]
    if current[2] >= max_r:
        count += 1
        max_r = current[3]
print(count)

Solution (Python):
import sys
sys.setrecursionlimit(10**7)


def test(array, index, last_position, count, min_count):
    
    if min_count[0] != -1 and count >= min_count[0]:
        return
    if index + 1 == len(array):
        
        min_count[0] = count if min_count[0] == - \
            1 or count < min_count[0] else min_count[0]
        return
    current = array[index]

    
    if last_position >= current[2]:
        test(array, index + 1, last_position, count + 1, min_count)
    
    else:
        test(array, index + 1, index, count, min_count)


N = int(input())
array = [list(map(int, input().split())) for i in range(N)]
for line in array:
    line.append(line[0] - line[1])
    line.append(line[0] + line[1])
array = sorted(array, key=lambda x: x[3])

count = 0
max_r = -float('inf')
for i in range(N):
    current = array[i]
    
    
    if current[2] >= max_r:
        
        count += 1
        max_r = current[3]

print(count)

Solution (Python):



def main():
    N = int(input())
    X = [None] * N
    for i in range(N):
        x, l = map(int, input().split())
        X[i] = (x+l,x-l)
    X.sort()
    ans = 0
    maxT = - 10**18
    for i in range(N):
        if maxT <= X[i][1]:
            ans += 1
            maxT = X[i][0]
    print(ans) 


if __name__ == "__main__":
    main()

Solution (Python):
import sys,bisect

input=sys.stdin.readline

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

robot.sort()
pos=[robot[i][0] for i in range(N)]
arm=[-1]*N
for i in range(0,N):
    index=bisect.bisect_right(pos,robot[i][0]-2*robot[i][1])
    arm[i]=index-1

dp=[0]*N
dp[0]=1
Max=[0]*N
Max[0]=1
for i in range(1,N):
    if arm[i]==-1:
        dp[i]=1
    else:
        dp[i]=1+Max[arm[i]]
    Max[i]=max(dp[i],Max[i-1])

print(max(dp))

Solution (Python):
n = int(input())

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


biggest_right = 2 * -10**9 - 1
counter = 0
for left, right in Robo:
    if biggest_right <= left:
        counter += 1
        biggest_right = max(right, biggest_right)
print(counter)

Solution (Python):
from sys import stdin
def main():
    
    readline=stdin.readline
    n=int(readline())
    xl=[0]*n
    for i in range(n):
        xl[i]=list(map(int,readline().split()))

    a=[[0,0] for _ in range(n)]
    for i in range(n):
        a[i][0]=xl[i][0]-xl[i][1]
        a[i][1]=xl[i][0]+xl[i][1]
    a.sort(key=lambda x:x[1])
    s=a[0][1]
    
    ans=1
    for i in range(1,n):
        if s<=a[i][0]:
            ans+=1
            s=a[i][1]

    print(ans)
    
if __name__=="__main__":
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10**6) 
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque 


from collections import Counter

from itertools import accumulate

from heapq import heapify,heappop,heappush




def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N=len(v)
    size=len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def main():
    mod = 10**9+7
    

    N = int(input())
    
    
    
    s = tuple(tuple(map(int, input().split())) for i in range(N)) 

    l=[(s[i][0]+s[i][1],s[i][0]-s[i][1]) for i in range(N)]
    l.sort()

    cur=l[0][0]
    ans=1
    for rob in l[1:]:
        if cur>rob[1]:
            continue
        ans+=1
        cur=rob[0]
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
N=int(input())
XL=sorted([list(map(int,input().split())) for i in range(N)],key=lambda x:x[0]+x[1])
count=0
left=-10**9
for x,l in XL:
    if left<=x-l:
        count+=1
        left=x+l
print(count)

Solution (Python):
N=int(input())
XL=sorted([list(map(int,input().split())) for i in range(N)],key=sum)
count=0
left=-10**9
for x,l in XL:
    if left<=x-l:
        count+=1
        left=x+l
print(count)

Solution (Python):








def main():
    N = int(input())
    XL = [None] * N
    for n in range(N):
        X, L = map(int,input().split())
        XL[n] = (X-L,X+L)
    XL.sort(key=lambda x:x[1])
    ret = 0
    TMP = XL[0][0]
    for x in XL:
        if TMP <= x[0]:
            TMP = x[1]
            ret += 1
    print(ret)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
robo_range = []
for _ in range(N):
  X, L = map(int,input().rstrip().split())
  robo_range.append((X-L,X+L))
robo_range_sort = sorted(robo_range,key = lambda x:x[1])
ans = 0
cut = -float('inf')
for i in range(N):
  if cut <= robo_range_sort[i][0]:
    ans += 1
    cut = robo_range_sort[i][1]
print(ans)

Solution (Python):
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)

Solution (Python):
M,a=-float("inf"),0
for X,L in sorted([list(map(int,a.split()))for a in open(0)][1:],key=sum):
 if M<=X-L:a+=1;M=X+L
print(a)

Solution (Python):
M,a=-float("inf"),0
for X,L in sorted(zip(*[iter(map(int,open(0).read().split()[1:]))]*2),key=sum):
 l,r=X-L,X+L
 if M<=l:a+=1;M=r
print(a)

Solution (Python):
M,a =-float("inf"),0
for X,L in sorted(zip(*[iter(map(int,open(0).read().split()[1:]))]*2),key=sum):
 l,r=X-L,X+L
 if M<=l:a+=1;M=r
print(a)

Solution (Python):

INF = float("inf")
n, *d = map(int, open(0).read().split())
p = sorted(zip(*[iter(d)]*2), key=sum)
M, a = -INF, 0
for X, L in p:
    l, r = X-L, X+L
    if M <= l:
        a += 1
        M = r
print(a)

Solution (Python):
N=int(input())
arms=[list(map(int,input().split())) for _ in range(N)]
points=[]
for i in range(N):
    points.append([arms[i][0]-arms[i][1],arms[i][0]+arms[i][1]])

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

nowr=-float("inf")
cnt=0
for i in points:
    l,r=i
    if nowr<=l:
        nowr=r
        cnt=cnt+1
print(cnt)

Solution (Python):
n = int(input())
line = []
for _ in range(n):
    x, l = map(int, input().split())
    s, g = x-l, x+l
    line.append([g, s])

line.sort()
ans = 1
now_g = line[0][0]

for g, s in line[1:]:
    if now_g <= s:
        ans += 1
        now_g = g

print(ans)

Solution (Python):
n=int(input())
xl=[list(map(int,input().split())) for _ in range(n)]
lr=[[xl[i][0]-xl[i][1],xl[i][0]+xl[i][1]] for i in range(n)]
lr.sort(key=lambda x:x[1])
ans=n
r=lr[0][1]
for i in range(1,n):
  if lr[i][0]<r:
    ans-=1
  else:
    r=lr[i][1]
print(ans)

Solution (Python):
N = int(input())

R = []

for i in range(N):
    x, l = map(int, input().split())
    R.append((x-l,x+l))

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

ans = 0
right = -10**9 - 1
i = 0
while(i < N):
    left = R_sorted[i][0]
    if left >= right:
        ans += 1
        right = R_sorted[i][1]
    i += 1

print(ans)

Solution (Python):
from operator import itemgetter

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

l.sort(key = itemgetter(1))
cnt = 0
s = - 10 ** 10
for i in range(N):
  if l[i][0] >= s:
    s = l[i][1]
  else:
    cnt += 1
print(N-cnt)

Solution (Python):
import sys
input = sys.stdin.readline
n = int(input())
info = [0] * n
for i in range(n):
    x, l = map(int, input().split())
    info[i] = [x+l, x, l]

info.sort()
ans = 1
right = info[0][1] + info[0][2]
for i in range(1, n):
    if right <= info[i][1] - info[i][2]:
        ans += 1
        right = info[i][1] + info[i][2]
print(ans)

Solution (Python):
import sys
n = int(input())
info = [0] * n
for i in range(n):
    x, l = map(int, input().split())
    info[i] = [x+l, x, l]

info.sort()
ans = 1
right = info[0][1] + info[0][2]
for i in range(1, n):
    if right <= info[i][1] - info[i][2]:
        ans += 1
        right = info[i][1] + info[i][2]
print(ans)

Solution (Python):
N=int(input())
L=[]
for i in range(N):
    x,l=map(int,input().split())
    a,b=x-l,x+l
    L.append((a,b))
L.sort(key=lambda  ab: ab[1])

robot=1
b=L[0][1]
for i in range(1,N):
    A,B=L[i]
    if A>=b:
        robot+=1
        b=B
print(robot)

Solution (Python):
N = int(input())
ABs = []
for i in range(N):
  X, L = map(int, input().split())
  A, B = X-L, X+L
  ABs.append((A, B))
ABs.sort(key=lambda AB: AB[1])

r = 1
b = ABs[0][1]
for i in range(1, N):
  A, B = ABs[i]
  if A >= b:
    r += 1
    b = B
print(r)

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]





N = ii()
XL = li2(N)
R = dp2(0, 2, N)

for i in range(N):
    R[i][0] = XL[i][0] - XL[i][1]
    R[i][1] = XL[i][0] + XL[i][1]


R = sorted(R, key=lambda x:x[1])
m = -float('inf')
cnt = 0
for i in range(N):
    if R[i][0] >= m:
        cnt += 1
        m = R[i][1]

print(cnt)

Solution (Python):
N = int(input())
lls = []
rls = []
sels = []
for _ in range(N):
    x,l = map(int, input().split())
    lls.append(x-l)
    rls.append(x+l)
    sels.append([x-l,x+l])

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

start = -float('inf')

ans = 0
for item in sels:
    if start <= item[0]:
        ans += 1
        start = item[1]

print(ans)

Solution (Python):
from collections import defaultdict

def main():
    N = int(input())
    robots = []
    for _ in range(N):
        x,l = [int(x) for x in input().split()]
        robots.append((x-l, x+l))

    
    cnt = 0
    t = -float('inf')
    for start,end in sorted(robots, key=lambda x:x[1]):
        
        if t <= start:
            
            cnt += 1
            t = end
    print(cnt)
        

if __name__ == '__main__':
    main()

Solution (Python):


N = int(input().split()[0])
xlt_list = []

for _ in range(N):
    x, l = list(map(int, input().split()))
    xlt_list.append((x, l, x + l))

xlt_list = sorted(xlt_list, key=lambda x: x[2])
count = 0
before_t = -float("inf")
for i, xlt in enumerate(xlt_list):
    x, l, t = xlt
    if x - l >= before_t:
        count += 1
        before_t = t

ans = count
print(ans)

Solution (Python):
import numpy as np

N = int(input())
X = np.zeros([N,4], dtype=int)

for i in range(N):
    X[i,0], X[i,1] = map(int, input().split())
    X[i,2], X[i,3] = X[i,0] - X[i,1], X[i,0] + X[i,1]    

col_num = 3
X = X[np.argsort(X[:, col_num])]
cnt = 1
r_min = X[0,3]
for i in range(1,N):
    if X[i,2] >= r_min:
        cnt += 1
        r_min = X[i,3]
print(cnt)

Solution (Python):
N = int(input())
xl = [list(map(int, input().split())) for _ in range(N)]

xl.sort()

ans = N
rpre = xl[0][0] + xl[0][1]

for x, l in xl[1:]:
    ll = max(x - l, 0)
    rr = x + l
    if ll < rpre:
        ans -= 1
        if rr < rpre: rpre = rr
    else:
        rpre = rr

print(ans)

Solution (Python):
n = int(input())
xl = [list(map(int, input().split())) for _ in range(n)]
robot = []

for v in xl:
    robot.append([v[0]-v[1], v[0]+v[1]])
robot.sort(key=lambda x:x[1])

prev = 0
cnt = 0
for i in range(1, n):
    if robot[prev][1] > robot[i][0]:
        cnt += 1
    else:
        prev = i
print(n-cnt)

Solution (Python):
import sys, re
from math import ceil, floor, sqrt, pi, factorial
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce

def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    n = i_input()
    num_list = []
    for _ in range(n):
        x, l = i_map()
        left = x - l
        right = x + l
        tmp = [right, left]
        num_list.append(tmp)

    num_list.sort()

    ans = 0
    max_right = -INF

    for i in range(n):
        right, left = num_list[i]
        if max_right <= left:
            ans += 1
            max_right = right

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
arms = []
ans = 1
for i in range(N):
    X,L = (int(x) for x in input().split())
    arms.append((X-L,X+L))
arms.sort(key=lambda x:x[1])
limit = arms[0][1]
for x in arms[1:]:
    if x[0] < limit:
        continue
    else:
        limit = x[1]
        ans += 1
print(ans)

Solution (Python):
import heapq
from sys import stdin
input = stdin.readline



n = int(input())





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


def main():
    p = []
    for x,l in xl:
        p.append([x-l,x+l])
    p = sorted(p, key=lambda x:x[1])

    ans = 0
    mx = -10**10
    for st in p:
        s,t = st[0],st[1]
        if s>=mx:
            ans+=1
            mx=t
    print(ans)



    
    

if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.buffer.readline
from operator import itemgetter

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

Solution (Python):
_, *_XL = open(0).read().split()

XL = list(zip(*[map(int, iter(_XL))]*2))

ans = 0
t = -10**10 

arms = [(X-L, X+L) for X, L in XL]
arms_sorted = sorted(arms, key=lambda k:k[1])

ans = 0

for s, e in arms_sorted:
    if t <= s:
        t = e
        ans += 1
        
print(ans)

Solution (Python):
N = int(input())
R = sorted([list(map(int, input().split())) for i in range(N)])
T = []
for i in range(N):
    T.append([R[i][0] + R[i][1], R[i][0] - R[i][1]])
T.sort(reverse=True)
while len(T) - 1 > 0:
    t = T.pop()
    i = 1
    while len(T) and t[0] > T[-1][1]:
        N -= 1
        i += 1
        T.pop()
print(N)

Solution (Python):
N = int(input())
X = [list(map(int, input().split())) for i in range(N)]
LR = [[x[0]-x[1], x[0] + x[1]] for x in X]
LR.sort(key=lambda x:x[1])

A = 1
right = LR[0][1]
for i in range(1, N):
    if right <= LR[i][0]:
        A += 1
        right = LR[i][1]
print(A)

Solution (Python):



def main():
    N = int(input())
    XL = [None] * N
    for n in range(N):
        X, L = map(int,input().split())
        XL[n] = [X-L,X+L]
    XL.sort(key=lambda x:x[1])
    ret = 1
    TMP = XL[0][1]
    for x in XL[1:]:
        if TMP<=x[0]:
            TMP = x[1]
            ret += 1
    print(ret)

if __name__ == '__main__':
    main()

Solution (Python):
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)

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

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

ans = 1
p = R[0][1]
for i in range(1, N):
    if p <= R[i][0]:
        ans += 1
        p = R[i][1]

print(ans)

Solution (Python):
n=int(input())
k=[[0,0] for i in range(n)]
for i in range(n):
    a,l=map(int,input().split())
    left=a-l
    right=a+l
    k[i][0]=left
    k[i][1]=right
k.sort(key=lambda x:x[1])
tmp=k[0][1]
ans=1
for i in range(n):
    if k[i][0]>=tmp:
        tmp=k[i][1]
        ans+=1
print(ans)

Solution (Python):
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])
ans = 0
arm = -10**18
for i in range(n):
    if arm<=xl[i][0]:
        ans += 1
        arm = xl[i][1]
print(ans)

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

count = 0
current = -1 * float('inf')
for x in sorted(X, key=lambda x: x[1]):
    if x[0] >= current:
        count += 1
        current = x[1]
print(count)

Solution (Python):
n = int(input())
robots = [tuple(map(int,input().split())) for _ in range(n)]

robots =[(x+l,x-l) for x,l in robots]

robots.sort()

cnt = 0
last = -float('inf')
for r,l in robots:
    if last <= l:
        cnt += 1
        last = r
print(cnt)

Solution (Python):
import sys
from collections import deque, Counter, defaultdict
from itertools import permutations
import heapq


def resolve():
    N = int(sys.stdin.readline().strip())
    pq = []
    for _ in range(N):
        X, L = map(int, sys.stdin.readline().strip().split())
        heapq.heappush(pq, (X + L, X - L))
    ans = 0
    while pq:
        ans += 1
        right, _ = heapq.heappop(pq)
        if pq:
            _, next_left = pq[0]
            while next_left < right:
                heapq.heappop(pq)
                if not pq:
                    break
                _, next_left = pq[0]

    print(ans)


if __name__ == "__main__":
    resolve()

Solution (Python):
n=int(input())
l=sorted([list(map(int,input().split())) for i in range(n)],key=lambda x:x[0]-x[1],reverse=1)
now=float("INF")
ans=0
for i in l:
    if sum(i)<=now:
        now=i[0]-i[1]
        ans+=1
print(ans)

Solution (Python):
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)

Solution (Python):
n = int(input())
xl = [list(map(int, input().split())) for i in range(n)]
l = [[i[0] + i[1], i[0] - i[1]] for i in xl]
l.sort(key=lambda x:x[0])
ans = 0
m = 10 ** 9 * -1
for i in range(n):
    if m <= l[i][1]:
        ans += 1
        m = l[i][0]
print(ans)

Solution (Python):
N = int(input())
ST = []
for i in range(N):
    x, l = list(map(int, input().split()))
    ST.append([x-l, x+l])
ST.sort(key = lambda x :x[1])
startT = ST[0][1]
ans = 1
if N != 1:
    for i in range(1,N):
        if startT <= ST[i][0]:
            startT = ST[i][1]
            ans += 1
            
print(ans)

Solution (Python):
def main():
    N = int(input())
    L = []
    for i in range(N):
        xi, li = map(int, input().split())
        s = xi - li
        f = xi + li
        L.append((f, s))
    
    L.sort()

    ans = 0
    finish = -float("inf")
    for i in L:
        if finish <= i[1]:
            ans += 1
            finish = i[0] 

    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())

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

robots.sort()

ans = n
n_r = robots[0][0]
for i in range(1, n):
    r = robots[i][0]
    l = robots[i][1]
    if n_r > l:
        ans -= 1
    else:
        n_r = r

print(ans)

Solution (Python):
import sys
import math
import itertools
import numpy
import collections

rl = sys.stdin.readline

n = int(rl())
se = []
for _ in range(n):
    x, r = map(int, rl().split())
    start, end = x-r, x+r
    se.append([start, end])
se.sort(key=lambda x: x[1])

cur = se[0][0]
cnt = 0
for i in se:
    if cur <= i[0] <= i[1]:
        cur = i[1]
        cnt += 1
print(cnt)

Solution (Python):
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)

Solution (Python):

import sys
import collections

sys.setrecursionlimit(10 ** 7)


N = int(input().rstrip())


A = list(tuple(map(int, input().rstrip().split())) for _ in range(N))

array = []
for s, t in A:
    array.append((s + t, s - t))

array.sort()


ans = 0
t = -1e9
for e, s in array:
    if t <= s:
        t = e
        ans += 1

print(ans)

Solution (Python):
n = int(input())
L = [list(map(int,input().split())) for _ in range(n)]
L.sort(key=lambda x:x[0]+x[1])
seen=-10**10
cnt=0
for i in range(n):
    if seen<=L[i][0]-L[i][1]:
        seen=L[i][0]+L[i][1]
        cnt+=1
print(cnt)

Solution (Python):
def solve():
    n = int(input())
    x, l = [0]*n, [0]*n
    for i in range(n):
        x[i], l[i] = map(int, input().split())
    hoge = []
    for i in range(n):
        hoge.append([x[i]+l[i], x[i]-l[i]])
    hoge.sort()
    t = -1000000000000000000000
    ans = 0
    for i in range(n):
        if t <= hoge[i][1]:
            ans += 1
            t = hoge[i][0]
    print(ans)
    return 0
 
if __name__ == "__main__":
    solve()

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    N=int(input())
    A=[]
    for i in range(N):
        X,L=map(int,input().split())

        A.append([X-L,X+L])

    A=sorted(A, key=lambda x: x[1])
    cur=-(10**10)
    cnt=0
    for i in range(N):
        if A[i][0]<cur: continue
        else:
            cur=A[i][1]
            cnt+=1
    print(cnt)



    
    

    
resolve()