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())
XL = []
for i in range(N):
    x,l = map(int,input().split())
    XL.append((x-l,x+l-1))

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

ans = 0
t = -10**10
for i in range(N):
    if t < XL[i][0]:
        ans += 1
        t = XL[i][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-1))

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

ans = 0
t = -10**10
for i in range(N):
    if t < XL[i][0]:
        ans += 1
        t = XL[i][1]
print(ans)

Solution (Python):


N = int(input())
robot_number = 0
arm_ranges = []
for n in range(N):
    [x, l] = [int(i) for i in input().split()]
    minimum = x - l
    maximum = x + l
    arm_ranges.append((maximum, minimum))


arm_ranges_sorted = sorted(arm_ranges)

(ma, mi) = arm_ranges_sorted[0]
now_max = ma
robot_number += 1
for arm_range in arm_ranges_sorted[1:]:
    (ma, mi) = arm_range
    if mi >= now_max:
        robot_number += 1
        now_max = ma

print(robot_number)

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

    X_L = tuple(tuple(int(j) for j in input().split()) for i in range(N))
    ranges = tuple((x - l, x + l) for x, l in X_L)
    sorted_X_L = sorted(X_L, key=lambda x: x[0])

    

    x_max = - 1e9
    x_min = 2e9

    allowed = []

    for i in range(N):
        i_min = sorted_X_L[i][0] - sorted_X_L[i][1]  
        i_max = sorted_X_L[i][0] + sorted_X_L[i][1]  

        if i_min >= x_max:
            allowed.append(sorted_X_L[i])
            x_max = max(x_max, i_max)
            x_min = min(x_min, i_min)
        elif i_max <= x_max:
            allowed[-1] = sorted_X_L[i]
            x_max = i_max

    print(len(allowed))


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np

N=int(input())
XL=[]
for i in range(N):
    XL.append(list(map(int,list(input().split()))))
XL=np.asarray(XL)
XLs=XL[np.argsort(XL[:,0])]
right=XLs[0][0]+XLs[0][1]
ans=1
for i in range(N-1):
    if right-(XLs[i+1][0]+XLs[i+1][1])>0:
        right=XLs[i+1][0]+XLs[i+1][1]
    elif XLs[i+1][0]-XLs[i+1][1]-right>=0:
        ans+=1
        right=XLs[i+1][0]+XLs[i+1][1]
print(ans)

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
l = [None]*N
for i in range(N):
    l[i] = list(map(int, input().split()))
l.sort()

prek = l[0][0]
prea = l[0][1]
cnt = N

for i in range(1,N):
    k,a = l[i]
    pre_reach = prek+prea
    now_reach_m = k-a
    now_reach_p = k+a
    
    if pre_reach>now_reach_m:
        
        if pre_reach>now_reach_p:
            cnt -= 1
            prek = k
            prea = a
        else:
            cnt -= 1
    else:
        prek = k
        prea = a
print(cnt)

Solution (Python):


iim = lambda: map(int, input().rstrip().split())

from bisect import bisect_left

def resolve():
    N = int(input())
    
    MX = 10**9
    S = []
    for i in range(N):
        x, l = iim()
        i = x - l
        if i < 0:
            i = 0
        j = x + l
        if j > MX:
            j = MX

        a = [i, j]
        S.append(a)
    S.sort()

    ans = 0
    last = MX+1
    n = 1
    for x, y in S:
        if y < last:
            last = y
        elif last <= x:
            n += 1
            last = y

    print(n)






if __name__ == "__main__":
    resolve()

Solution (Python):
N = int(input())
robots = {}
for _ in range(N):
    pos,armlen = map(int,input().split())
    robots[pos] = armlen

robots = sorted(robots.items(),key=lambda x:x[0])
range_min = robots[0][0] + robots[0][1]
ans = 1
for robot in robots[1:]:
    pos,armlen = robot
    if range_min <= (pos-armlen):
        ans += 1
        range_min = pos+armlen
    else:
        if range_min > (pos+armlen):
            range_min = pos+armlen

print(ans)

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if x[mid] >= n:
        rr = mid
    else:
        ll = mid+1


n = onem()
a = []
b = []
for i in range(n):
    x,c = m()
    a.append([x-c-1,x+c-1])
    b.append([x-c-1,x+c-1])

a.sort(key = lambda x:(x[1]))
b.sort()
aa = []

for i in range(n):
    if not aa:
        aa.append(a[0])
        bbb = a[0][1]
    else:
        if bbb <= a[i][0]:
            aa.append(a[i])
            bbb = a[i][1]
        else:
            continue

print(len(aa))

Solution (Python):
n = int(input())
from collections import defaultdict
d = defaultdict(list)
X = []
xl = [tuple(map(int,input().split())) for i in range(n)]
for x,l in xl:
    d[x].append(x-l)
    d[x].append(x+l)
    X.append(x)

X.sort()


n_remove = 0


for i in range(1,n):
    x_1 = X[i-1]
    x_2 = X[i]
    min_1 , max_1 = d[x_1]
    min_2 , max_2 = d[x_2]

    if max_1 > min_2:
        n_remove += 1
        if max_2 >= max_1:
            d[x_2] = d[x_1]
            X[i] = X[i-1]


ans = n - n_remove
print(ans)

Solution (Python):
n = int(input())
x = []
l = []
c = []
d = {}
 
for i in range(n):
    xx,ll = map(int, input().split())
    x.append(xx)
    l.append(ll)
    d[xx] = ll
 
 
dct = sorted(d.items())
 
f = 0
ans = 0
f = dct[0][0] + dct[0][1]
for i in range(1,len(dct)):
    if f > dct[i][0] - dct[i][1]:
        ans += 1
        f = min(f,dct[i][0]+dct[i][1])
    else:
        f = dct[i][0]+dct[i][1]
 
 
print(n-ans)

Solution (Python):
n = int(input())
x_l = {}
for i in range(n):
    x,l = map(int, input().split())
    x_l[x] = l
if n ==1 :
    print(1)
    exit()
del_num = 0
sort_x = sorted(x_l.keys())
min_max = [max(0, sort_x[0] - x_l[sort_x[0]]), min(10**9, sort_x[0] + x_l[sort_x[0]])]
for i in sort_x[1:]:
    if min_max[1] >  (i - x_l[i]):
        del_num+=1
        min_max[1] = min(min_max[1], x_l[i] + i) 
    else:
        min_max[1] = (i + x_l[i])
print(n-del_num)

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

l = r[0]
ri = 1
ans = N
while ri < N:
    x1, l1 = l
    x2, l2 = r[ri]
    if (x1+l1) > (x2-l2):
        if (x1+l1) > (x2+l2):
            l = r[ri]
            ri += 1
        else:
            ri += 1
        ans -= 1
    else:
        l = r[ri]
        ri += 1
print(ans)

Solution (Python):

n = int(input())
rl = []
for i in range(n):
    x,l = map(int,input().split())
    rl.append([x+l,x-l])
rl.sort()
ans = 1
migihasi = rl[0][0]
hasikouho = []
for i in range(1,n):
    right = rl[i][0]
    left = rl[i][1]
    if left < migihasi:continue
    migihasi = right
    ans += 1

    
        
 
print(ans)

Solution (Python):
N = int(input())
xs = []
r = 1
for i in range(N):
    x, l = map(int, input().split())
    a,b = x-l, x+l
    xs.append((a,b))
xs.sort()
xs = xs[::-1]
for i, (a, b) in enumerate(xs):
    if i == 0:
        ba, bb= a, b
        continue
    if ba<b:
        continue
    else:
         ba, bb = a, b
         r += 1
print(r)

Solution (Python):
n = int(input())
x_l = []
for i in range(n):
    x,l = map(int,input().split())
    x_l.append([x-l,x+l])
x_l = sorted(x_l, key=lambda x:x[0])
x_r = sorted(x_l, key=lambda x:x[1])
ans_l = n
ans_r = n
for i in range(n-1):
    if x_l[i][1] > x_l[i+1][0]:
        ans_l -= 1
        x_l[i+1] = x_l[i]
    if x_r[i][1] > x_r[i+1][0]:
        ans_r -= 1
        x_r[i+1] = x_r[i]
print(max(ans_l, ans_r))

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

cnt = 0
i = 0
j = 0

while i < n-1:
    j = i+1
    while j < n:
        if (robo[i][0]+robo[i][1]) > (robo[j][0] - robo[j][1]):
            
            cnt+=1
            if (robo[i][0]+robo[i][1]) > (robo[j][0]+robo[j][1]):
                i = j
                j+=1
            else:
                j+=1
            if j == n:
                i = j
                break
        else:
            i=j
            break

print(n-cnt)

Solution (Python):
N = int(input())
arr = [list(map(int,input().split())) for i in range(N)]
arr = sorted(arr, key=lambda x: x[0])
F = [True]*N
P = [0]*N
for i in range(N):
  P[i] = [arr[i][0]-arr[i][1], arr[i][0]+arr[i][1]]
P = sorted(P,key=lambda x:x[1])
ind = 0
for i in range(1,N):
  if P[i][0] < P[ind][1]:
    F[i] = False
  else:
    ind = i
print(F.count(True))

Solution (Python):
import sys
bbn=1000000007
	


		
def main():
	n = int(input())
	al=[]
	for i in range(n):
		b , c = map(int, input().split())
		al.append([b+c,b-c,b,c])
	al.sort()
	
	init=al[0]
	count=1
	for right,left,x,l in al[1:]:
		if left >= init[0]:
			count+=1
			init=[right,left,x,l]
	print(count)
		
	
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):

N = int(input())

robo_dic = {}
for i in range(N):
    X, L = map(int, input().split())
    robo_dic[X] = L

robo_list = sorted(robo_dic.keys())

max_place = robo_list[0] + robo_dic[robo_list[0]]
ans = 1
for i in range(1, len(robo_list)):
    x = robo_list[i]
    l = robo_dic[x]
    if max_place <= x - l:
        ans += 1
        max_place = x + l
    else:
        max_place = min(max_place, x + l)
print(ans)

Solution (Python):




import sys
input = sys.stdin.readline



def main():
    N = int(input())
    X = []
    L = []
    LX = []
    for i in range(N):
        temp = list(map(int,input().split()))
        LX.append([temp[0]+temp[1],temp[0]-temp[1]])

    LX.sort()

    res = 0
    end = - 10 ** 9

    for i in range(N):
        if end <= LX[i][1]:
            res += 1
            end = LX[i][0]

    print(res)



main()

Solution (Python):
import sys
input=sys.stdin.readline
n=int(input())
m=[]
for i in range(n):
    x,l=map(int,input().split())
    m.append((x+l,x-l))
m.sort()
ans=1
limit=m[0][0]
for i in range(1,n):
    if m[i][1]<limit:
        continue
    ans+=1
    limit=m[i][0]
print(ans)

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

tmp = sum(xl[0])

res = 0
for i in range(1, n):
    x, l = xl[i]
    if tmp > x-l:
        res += 1
        tmp = min(tmp, x+l)
    else:
        tmp = x+l

print(n-res)

Solution (Python):


n = int(input())
a = []
b = []
b2 = []
c = []
count = 0
max = 0

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

a.sort(key=lambda x: x[2])

for i in a:
    if max != 0 and i[0]-i[1] < max:
        count += 1
    else:
        max = i[2]
    
print(n - count)

Solution (Python):
n=int(input())
xls=[list(map(int,input().split())) for _ in range(n)]
lrs=sorted((x-l,x+l) for x,l in xls)
res=0
most_r=lrs[0][0]
for l,r in lrs:
  if l>=most_r:
    res+=1
    most_r=r
  elif most_r>r:
    most_r=r
print(res)

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

a=[0]*n
b=[0]*n


for i in range(n):
    a[i],b[i]=x[i]-l[i],x[i]+l[i]


c=[[0]*2  for i in range(n)]


for j in range(n):
    c[j][0]=b[j]
    c[j][1]=a[j]


c.sort()


ans=0
z=c[0][1]
for i in range(n):
    if c[i][1]>=z:
        ans+=1
        z=c[i][0]

print(ans)

Solution (Python):
from itertools import groupby
from operator import itemgetter
import numpy as np
N = int(input())
arm = []
for i in range(N):
  x, l = map(int, input().split())
  a = [x-l, x+l]
  arm.append(a)
arm = sorted(arm, key=lambda x: x[1])
now = arm[0][1]
count = 1
for i in range(1,N):
  if now <= arm[i][0]:
    count += 1
    now = arm[i][1]
print(count)

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

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

Solution (Python):
import sys

input = sys.stdin.readline

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

count = 1
arms = []
for i in range(len(xl)):
    a = xl[i][0] - xl[i][1]
    b = xl[i][0] + xl[i][1]
    arms.append([a, b])
arms.sort(key=lambda x: x[1])
min = arms[0][1]


for i in range(1, n):
    if min <= arms[i][0]:
        count += 1
        min = arms[i][1]

print(count)

Solution (Python):
n = int(input())
lr = []
for _ in range(n):
    x, l = map(int, input().split())
    lr.append((x-l, x+l))
lr = sorted(lr, key=lambda x:x[0])
prev = lr[0]
ans = 1
for i in range(1, n):
    if prev[1] <= lr[i][0]:
        ans += 1
        prev = lr[i]
    else:
        if prev[1] > lr[i][1]:
            prev = lr[i]

print(ans)

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

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





itv.sort()



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

Solution (Python):
n=int(input())
A=[list(map(int,input().split())) for i in range(n)]
B=[]
for i in range(n):
    B.append([A[i][0]-A[i][1],A[i][0]+A[i][1]])
B=sorted(B)
point=B[0][1]
a,b=1,1
for i in range(1,n):
    if B[i][0]>=point:
        point=B[i][1]
        a +=1

point=B[-1][0]
for i in reversed(range(0,n-1)):
    if B[i][1]<=point:
        point=B[i][0]
        b +=1

print(max(a,b))

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
xl = [LI() for _ in range(n)]
xl.sort()
ans = 0
h = []
for x,l in xl:
    heappush(h,(x+l,x-l))
ans = 0
now = -inf
while h:
    r,l = heappop(h)
    if now <= l:
        now = r
    else:
        ans += 1
print(n-ans)

Solution (Python):
import sys
n = int(input())
xl = []
for _ in range(n):
    x, l = map(int, input().split())
    xl.append((x, l))
xl.sort(key=lambda x:x[0])
i = 0
if n==1:
    print(1)
    sys.exit(0)
while i<len(xl)-1:
    if xl[i][0]+xl[i][1] <= xl[i+1][0]-xl[i+1][1]:
        i += 1
    else:
        if xl[i][0]+xl[i][1] < xl[i+1][0]+xl[i+1][1]:
            del xl[i+1]
        else:
            del xl[i]
print(len(xl))

Solution (Python):
N = int(input())
li = []
for i in range(N):
    hontai, ude = map(int, input().split())
    li.append([hontai, ude, hontai-ude, hontai+ude])
li.sort(key=lambda x:x[3])

count = 1
now = li[0][3]
for i in range(1, N):
    if now <= li[i][2]:
        count += 1
        now = li[i][3]
    
print(count)

Solution (Python):
n = int(input())
xls = [list(map(int, input().split()))for i in range(n)]
xls.sort(key=lambda x:sum(x))

ans = 0
now = -1e11
for i in range(n):
    if now<=xls[i][0]-xls[i][1]:
        ans += 1
        now = xls[i][0]+xls[i][1]
print(ans)

Solution (Python):
N = int(input())
robots = []
for _ in range(N):
    X, L = map(int, input().split())
    robots.append([X + L, X - L])
robots.sort()
now = -float("inf")
ans = 0
for i in range(N):
    if robots[i][1] >= now:
        now = robots[i][0]
        ans += 1
print(ans)

Solution (Python):
def main():
    N = int(input())
    li = []
    for _ in range(N):
        a,b = [int(n) for n in input().split()]
        li.append([a-b,a+b])
    
    
    res = N
    
        
    
    
    
    
    
    
    
    
    li.sort(key=lambda x:-x[0])
    
    last = (10**10,10**10)
    for a in li:
        
        if a[1] > last[0]:
            last = last
            res-=1
        else:
            last=a
    print(res)

main()

Solution (Python):
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    n = int(input().strip())
    x = [[0, 0] for  _ in range(n)]
    for i in range(n):
        p, q = list(map(int, input().strip().split()))
        x[i][0] = p-q
        x[i][1] = p+q
    x = sorted(x, key=itemgetter(1))
    m = x[0][1]
    ans = 1
    for mi, ma in x[1:]:
        if m <= mi:
            m = ma
            ans += 1

    
    
    
    
    

    
    
    
    
    
    

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
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 
    left = xl[i][0] - xl[i][1] + 0.01 
    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)

Solution (Python):
N = int(input())
K = list()
for _ in range(N):
    x, l = map(int, input().split())
    K.append((x-l, x+l))
K = list(sorted(K, key=lambda x: x[1]))
ans = N
for i in range(N-1):
    if K[i][1] > K[i+1][0]:
        ans -= 1
        if K[i][1] < K[i+1][1]:
            K[i+1] = K[i]
        else:
            K[i] = K[i+1]
print(ans)

Solution (Python):
from operator import itemgetter

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

XL = sorted(XL, key=itemgetter(1))
i = 1
while i != len(XL):
    if XL[i][0] < XL[i-1][1]:
        XL.pop(i)
    else:
        i += 1

print(len(XL))

Solution (Python):


import sys
from operator import itemgetter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
LR = []
for i in range(N):
    x, l = MAP()
    LR.append((x-l, x+l-1))

LR.sort(key=itemgetter(1))
cur = -INF
cnt = 0
for l, r in LR:
    if cur < l:
        cur = r
        cnt += 1
print(cnt)

Solution (Python):
def main():
    n = int(input())
    x = []
    l = []
    for i in range(n):
        tmp = list(map(int, input().split()))
        x.append(tmp[0] - tmp[1])
        l.append(tmp[0] + tmp[1])
    x, l = zip(*sorted(zip(x, l)))
    maxcount = 0
    preve = 0
    idx = 0
    while idx < n:
        tmps = x[idx]
        tmpe = l[idx]
        if preve == 0:
            maxcount += 1
            preve = tmpe
        elif tmps >= preve:
            maxcount += 1
            preve = tmpe
        elif tmpe < preve:
            preve = tmpe
        idx += 1
    print(maxcount)
    return

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
a = sorted([list(map(int, input().split())) for _ in range(n)])
r = a[0][0]+a[0][1]
l = 0
for j in range(1,n):
    i = a[j]
    l = i[0]-i[1]
    if r <= l:
        r = i[0]+i[1]
    else:
        n -= 1
        r = min(r,i[0]+i[1])
print(n)

Solution (Python):
n = int(input())
xl = [[int(i) for i in input().split(' ')] for j in range(n)]

ls = sorted([[i-j, i+j] for i, j in xl], key=lambda x: x[1])

i, dr = 0, 0
while True:
    if (len(ls)<=1) | (i+1 >= len(ls)):
        break
    a, b = ls[i], ls[i+1]
    if a[1]>b[0]:
        dr += 1
        ls.pop(i+1)
    else:
        i += 1

print(len(ls))

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

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

XL.sort(key=lambda x:(x[0],x[1]))
now=XL[0][0]+XL[0][1]
ans=0
for i in range(1,n):
  x,l=XL[i]
  if x-l<now:
    ans+=1
    if x+l<now:
      now=x+l
  else:
    now=x+l
print(n-ans)

Solution (Python):
N = int(input())
robot = {}

for i in range(N):
  x, l = map(int, input().split())
  robot[x] = l

s_robot = sorted(robot.items(), key=lambda x:x[0])

pre_arm = -10**10
cnt = 0
for key, val in s_robot:
  l_arm = key - val
  r_arm = key + val
  if pre_arm > l_arm:
    cnt += 1
    if pre_arm > r_arm:
      pre_arm = r_arm
  else:
    pre_arm = r_arm
    
print(N-cnt)

Solution (Python):
from operator import itemgetter
N=int(input())
xl=[list(map(int, input().split())) for i in range(N)]
ab=[[xl[i][0]-xl[i][1], xl[i][0]+xl[i][1]] for i in range(N)]
ab=sorted(ab, key=itemgetter(0))
hiku=0
a=ab[0][0]
b=ab[0][1]
for i in range(1, N):
  if b>ab[i][0]:
    hiku+=1
    b=min(b, ab[i][1])
  else:
    b=ab[i][1]
      
print(N-hiku)

Solution (Python):
import sys

N=input()

X=[]
for _ in range(N):
    x,l=map(int, sys.stdin.readline().split())
    X.append((x-l,x+l))

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

ans=0
end=float("-inf")
for l,r in X:
    if end<=l and end<r:
        ans+=1
        end=r

print ans

Solution (Python):
N = int(input())
XL = sorted(list(map(int, input().split())) for _ in range(N))

i, j = 0, 1
count = N
while j < N:
  if XL[i][0] + XL[i][1] > XL[j][0] - XL[j][1]:
    if XL[i][0] + XL[i][1] < XL[j][0] + XL[j][1]:
      j += 1
    else:
      i, j = j, j + 1
    count -= 1
  else:
    i, j = j, j + 1
print(count)

Solution (Python):
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)
from functools import lru_cache


def resolve():
    global N, grid

    
    N = [int(x) for x in sys.stdin.readline().split()][0]  
    
    
    grid = [[int(x) for x in sys.stdin.readline().split()]
            for _ in range(N)]  

    logger.debug('{}'.format([]))

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

    grid = sorted(grid)

    ans = 0
    t = - 10**10

    for right, left,  in grid:
        if t <= left:
            ans += 1
            t = right

    print(ans)

if __name__ == "__main__":
    resolve()





import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4
2 4
4 3
9 3
100 5"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2
8 20
1 10"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5
10 1
2 1
4 1
6 1
8 1"""
        output = """5"""
        self.assertIO(input, output)

Solution (Python):
def main():
    N = int(input())
    A = []
    for _ in range(N):
        X, L = map(int, input().split())
        A.append((X, L))
 
    A.sort()
    cnt = 0
    right = 0
    left = 0
    for i in range(N):
        if i == 0:
            left = A[i][0] - A[i][1]
            right = A[i][0] + A[i][1]
        else:
            tmp_left = A[i][0] - A[i][1]
            tmp_right = A[i][0] + A[i][1]
            if tmp_right < right:
                left = tmp_left
                right = tmp_right
                cnt += 1
            elif tmp_left < right:
                cnt += 1
            else:
                left = A[i][0] - A[i][1]
                right = A[i][0] + A[i][1]
 
    print(N - cnt)

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
X = []
x_wid = []
counter = 0
Min = 0
Max = 0

for i in range(n):
  X.append(list(map(int,input().split())))
  
X = sorted(X)

for i in range(n):
  if i == 0:
    Min = X[i][0] - X[i][1]
    Max = X[i][0] + X[i][1]
  else:
    if (X[i][0] - X[i][1]) < Max:
      counter += 1
      Max = min(Max, X[i][0] + X[i][1])
    else:
      Max = X[i][0] + X[i][1]


print(n - counter)

Solution (Python):
N = int(input())
kukan = [[] for _ in range(N)]
for i in range(N):
    X, Len = map(int, input().split())
    kukan[i] = [X - Len, X + Len]

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


p = -10 ** 9
ans = 0
for k in kukan:
    if p <= k[0]:
        
        ans += 1
        p = k[1]
        pass
    else:
        
        pass
print(ans)

Solution (Python):
N = int(input())
robots = [[int(x) for x in input().split()] for _ in range(N)]
robots = [(x - l,  x + l) for x, l in robots]
robots.sort(key=lambda x: x[1])
cur = float('-inf')
count = 0
for left, right in robots:
    if cur <= left:
        cur = right
        count += 1
print(count)

Solution (Python):
N = int(input())
ROB = [list(map(int, input().split())) for _ in range(N)]
ROB = sorted(ROB, key=lambda x:x[0])
right = ROB[0][0] + ROB[0][1]
ans = 1
for i in range(N-1):
  if(right <= ROB[i+1][0] - ROB[i+1][1]):
    ans += 1
    right = ROB[i+1][0] + ROB[i+1][1]
  else:
    right = min(right, ROB[i+1][0] + ROB[i+1][1])
print(ans)

Solution (Python):
import numpy as np

n=int(input())

Z=np.zeros((n,4))
for i in range(n):
    Z[i][0],Z[i][1]=map(int, input().split())
    Z[i][2]=Z[i][0]+Z[i][1]
    Z[i][3]=Z[i][0]-Z[i][1]
Z2=Z[np.argsort(Z[:,2])]

ans=1
border=Z2[0][2]
for i in range(1,n):
    if Z2[i][3]>=border:
        ans+=1
        border=Z2[i][2]

print(ans)

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()

r = - 10 ** 9 - 1
cnt = 0
for i in range(n):
    if r <= robots[i][1]:
        cnt += 1
        r = robots[i][0]
print(cnt)

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

list_ = list()

for i in range(N):
  X,L = map(int,input().split())
  max_ = min(10**9,X+L-0.1)
  min_ = max(0,X-L+0.1)
  list_.append((X,min_,max_))
list_.sort()

d = 0
nowmax = -1
nowmin = -1

for x, min_, max_ in list_:
  if nowmax > min_:
    d += 1
    nowmax = min(nowmax,max_)
  else:
    nowmin = min_
    nowmax = max_
  
print(N-d)

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

target = 0
sum = N
for i in range(N-1):
  if (XL[target][0] + XL[target][1]) > (XL[i+1][0] - XL[i+1][1]):
    if (XL[target][0] + XL[target][1]) >= (XL[i+1][0] + XL[i+1][1]):
      target = i + 1
    sum = sum-1
  else:
    target = i + 1
    
print(sum)

Solution (Python):
N = int(input())
X = []
p = 0
for i in range(N):
    X.append(tuple([int(n) for n in input().split()]))
a = sorted(X)
while p<len(a)-1:
    if a[p][0]+a[p][1] > a[p+1][0]+a[p+1][1]:
        a.pop(p)
    elif  a[p][0]+a[p][1] > a[p+1][0]-a[p+1][1]:
        a.pop(p+1)
    else:
        p += 1
print(len(a))

Solution (Python):
N = int(input())
num_list = [[int(item) for item in input().split()] for _ in range(N)]
num_list2 = []
for x, l in num_list:
    num_list2.append([x-l, x+l])

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


temp_max = num_list2[0][1]
cnt = 1

for l, h in num_list2:
    if l >= temp_max:
        cnt += 1
        temp_max = h

print(cnt)

Solution (Python):
n = int(input())
dic = {}

for i in range(n):
    inp = list(map(int, input().split()))
    dic[inp[0]] = inp[1]

dic = sorted(dic.items())
ans = 1
pre = dic[0][0]+dic[0][1]
fidx = 0
for i in range(1, n):
    n_s = dic[i][0]+dic[i][1]
    if pre > n_s:
        pre = n_s
        fidx = i
idx = fidx

for i in range(fidx+1, n):
    if dic[idx][0]+dic[idx][1] > dic[i][0]-dic[i][1]:
        if dic[idx][0]+dic[idx][1] > dic[i][0]+dic[i][1]:
            idx = i
    else:
        ans += 1
        idx = i


print(ans)

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

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

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