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):
import bisect
import collections
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n = ri()
ls = rils(n)
ls = [(x - l + 0.5, x + l - 0.5) for x, l in ls]
ls.sort(key=lambda x: x[1])
pos = [r for _, r in ls]

dp = collections.defaultdict(int)
prev_r = None
for l, r in ls:
    i = bisect.bisect_left(pos, l)
    if i > 0:
        dp[r] = max(dp[r], dp[pos[i - 1]] + 1)
    else:
        dp[r] = max(dp[r], 1)
    if prev_r:
        dp[r] = max(dp[r], dp[prev_r])
    prev_r = r
print(max(dp.values()))

Solution (Python):
N = int(input())
xl = []
for i in range(N):
    x,l = list(map(int,input().split()))
    xl.append([x - l, x + l])
    

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

Solution (Python):
N = int(input())
A = []
for _ in range(N):
    x, l = map(int, input().split())
    A.append((x+l, x-l+1))
A.sort()
now = A[0][0]
ans = 1
for r, l in A:
    if now<l:
        ans+=1
        now = r
print(ans)

Solution (Python):
def Segment(x, l, n): 
    if (n == 1): 
        return 1
    ans = 1
      
    for i in range(1, n): 
        if (x[i] - l[i] >= x[i - 1]): 
            ans += 1
        else:
            x[i] = x[i-1] 
        
        
        
        
    return ans 

def main():
    N = int(input())
    X, L = [], []
    for n in range(N):
        x, l = list(map(int, input().split()))
        X.append(x+l)
        L.append(2*l)
    X, L = zip(*sorted(zip(X, L)))
    X = list(X)
    L = list(L)

    print(Segment(X, L, N))

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
a = sorted((tuple(map(int, input().split())) for _ in range(n)), key=sum)
r = 0
p = -10**9
for x, l in a:
  if x - l >= p:
    r += 1
    p = x + l
print(r)

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

first_robot=ls.pop(0)
prev_right=first_robot[0]+first_robot[1]

for i,robot in enumerate(ls):
    left=robot[0]-robot[1]
    right=robot[0]+robot[1]
    if left<prev_right:
        n-=1
        if right<prev_right:
            prev_right=right
    else:
        prev_right=right
print(n)

Solution (Python):
N = int(input())
XL = []
for i in range(N):
    XL.append(list(map(int,input().split())))
XL.sort(key=lambda x:x[0])
ans = 0
left = XL[0][0]-XL[0][1]
right = XL[0][0]+XL[0][1]
for i in range(1,N):
    new_left = XL[i][0]-XL[i][1]
    new_right = XL[i][0]+XL[i][1]
    
    if new_left >= right:
        left = new_left
        right = new_right
    else:
        ans += 1
        if new_right < right:
            left = new_left
            right = new_right
print(N-ans)

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

c.sort(key=lambda x:x[0])

for i in range(n):
    a = c[i][0] - c[i][1]
    b = c[i][0] + c[i][1]
    c[i][0] = a
    c[i][1] = b

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

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

paths = []
for x, l in XL:
    paths.append((x-l, x+l))
paths = sorted(paths, key=lambda x: x[1])

ans = 0
cur = None
for (l, r) in paths:
    if cur is None or cur <= l:
        ans += 1
        cur = r

print(ans)

Solution (Python):
from collections import defaultdict
N = int(input())
ps = []
for i in [0]*N:
    X,L = map(int, input().split(' '))
    ps.append((X-L,X+L))

ps.sort(key=lambda x:x[1])
now = -10**10
ans = 0
for l,r in ps:
    if now <= l:
        now = r
        ans += 1
print(ans)

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

x=[[d[i][0]+d[i][1],d[i][0],d[i][1]] for i in range(n)]
x.sort()
t=0
t2=-10**9-1
ans=0
for i in range(n):
  if t<x[i][0] and t2 <= (x[i][1]-x[i][2]):
    ans+=1
    t=x[i][0]
    t2=x[i][0]
print(ans)

Solution (Python):
H = int(input())
list = []
for i in range(H): 
    n = input()    
    m = n.split()
    p = [int(i) for i in m]
    q = [p[0]-p[1],p[0]+p[1]]
    list.append(q)
newlist = sorted(list)
z = [-1000000000000000000,-100000000000000000]
a = 0
for i in newlist:
    if i[0] >= z[1]:
        z = i
        a = a + 1
    else:
        if i[1] < z[1]:
            z = i

print(a)

Solution (Python):

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

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


ans = 0
t = -(10**10)
for i in range(n):
    if a[i][0] >= t:
        ans += 1
        t = a[i][1]
print(ans)

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

segs = sorted([(p - r, p + r) for p, r in a], key=lambda x: x[1])
dp = [1] + [0] * (n - 1)
for i in range(1, n):
    dp[i] = dp[i - 1]
    left, right = -1, i
    while left + 1 < right:
        mid = (left + right) >> 1
        if segs[mid][1] <= segs[i][0]:
            left = mid
        else:
            right = mid
    if left != -1:
        dp[i] = max(dp[i], 1 + dp[left])
print(dp[n - 1])

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




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

Solution (Python):
from heapq import heappop, heappush
from bisect import bisect_right


class SegmentTree(object):

    def __init__(self, init_array, seg_func=min, seg_func_null=10 ** 9 + 7):

        self.seg_func = seg_func
        self.seg_func_null = seg_func_null
        self.n = 1
        while self.n < len(init_array):
            self.n *= 2
        self.dat = [0] * (2 * self.n - 1)
        for i in range(len(init_array)):
            self.dat[self.n - 1 + i] = init_array[i]
        for i in range(self.n - 2, -1, -1):
            self.dat[i] = self.seg_func(self.dat[2 * i + 1], self.dat[2 * i + 2])

    def update(self, k, a):
        k += self.n - 1
        self.dat[k] = a
        while k > 0:
            k = (k - 1) // 2
            self.dat[k] = self.seg_func(self.dat[k * 2 + 1], self.dat[k * 2 + 2])

    def query(self, p, q):
        
        if q <= p:
            return self.seg_func_null

        p += self.n - 1
        q += self.n - 2
        res = self.seg_func_null

        while q - p > 1:
            if p & 1 == 0:
                res = self.seg_func(res, self.dat[p])
            if q & 1 == 1:
                res = self.seg_func(res, self.dat[q])
                q -= 1
            p = p // 2
            q = (q-1) // 2
        if p == q:
            res = self.seg_func(res, self.dat[p])
        else:
            res = self.seg_func(self.seg_func(res, self.dat[p]), self.dat[q])

        return res


def solve(n, x_list, le_list):
    right_limits = dict()
    for i in range(n):
        right_limits[x_list[i] + le_list[i]] = 0
    right_limits_list = list(sorted(list(right_limits.keys())))
    s = SegmentTree([0] * len(right_limits_list), max, -1)

    h = []
    for i in range(n):
        heappush(h, (x_list[i] + le_list[i], i))

    for k in range(n):
        right, i = heappop(h)
        left = x_list[i] - le_list[i]
        ind_left = bisect_right(right_limits_list, left)
        ind_right = bisect_right(right_limits_list, right) - 1
        if ind_left == 0:
            r = s.query(ind_right, ind_right + 1)
            if r == 0:
                s.update(ind_right, 1)
        else:
            r = s.query(ind_right, ind_right + 1)
            l_max = s.query(0, ind_left)
            if r < l_max + 1:
                s.update(ind_right, l_max + 1)

    return s.query(0, n)


def main():
    n = int(input())
    x_list = [0] * n
    le_list = [0] * n
    for i in range(n):
        x, le = map(int, input().split())
        x_list[i] = x
        le_list[i] = le
    res = solve(n, x_list, le_list)
    print(res)


def test():
    assert solve(4, [2, 4, 9, 100], [4, 3, 3, 5]) == 3
    assert solve(2, [8, 1], [20, 10]) == 1
    assert solve(5, [10, 2, 4, 6, 8], [1, 1, 1, 1, 1]) == 5


if __name__ == "__main__":
    test()
    main()

Solution (Python):
''' Hey stalker :) '''
INF = 10**10
def main():
    
    ''' Cook your dish here! '''
    n = get_int()
    points = defaultdict(list)
    dp = [0]
    for _ in range(n):
        x, l = get_list()
        points[x+l].append(max(0, x-l))
        if max(0, x-l) not in points:
            points[max(0, x-l)] = []
    indexOfPoint = {0: 0}
    for i, point in enumerate(sorted(points)):
        indexOfPoint[point] = i+1
        dp.append(dp[-1])
        for cp in points[point]:
            dp[-1] = max(dp[-1], 1 + dp[indexOfPoint[cp]])
        continue
    print(dp[-1])


''' Pythonista fLite 1.1 '''
import sys
from collections import defaultdict, Counter
from bisect import bisect_left, bisect_right


input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()

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

remove = 0
reach = 0

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

    if i == 0:
        reach = right
        continue

    if reach > left:
        reach = min(reach, right)
        remove += 1
    else:
        reach = right

print(N - remove)

Solution (Python):

import sys
INF = float("inf")


def solve(N: int, X: "List[int]", L: "List[int]"):

    
    segs = [(x-l, x+l) for x, l in zip(X, L)]
    segs.sort(key=lambda x: x[1])  

    
    DP = [0]*N
    DP[0] = 1
    for i in range(1, N):
        
        if segs[i-1][1] <= segs[i][0]:
            DP[i] = DP[i-1]+1
        else:
            
            DP[i] = DP[i-1]
            
            left = -1
            right = i-1
            while right-left > 1:
                mid = (right+left)//2
                if segs[mid][1] <= segs[i][0]:
                    left = mid
                else:
                    right = mid
            
            if left == -1:
                buf = 1
            else:
                buf = DP[left]+1
            DP[i] = max(buf, DP[i-1])
    print(DP[-1])

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    X = [int()] * (N)  
    L = [int()] * (N)  
    for i in range(N):
        X[i] = int(next(tokens))
        L[i] = int(next(tokens))
    solve(N, X, L)


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
import bisect

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

robots.sort()
right_x_list = [x[0] for x in robots]

dp = [0 for _  in range(n + 1)]

for i in range(0, n):
	j = bisect.bisect_right(right_x_list, robots[i][1] - robots[i][2])
	
	dp[i + 1] = max(dp[j] + 1, dp[i])

print(dp[-1])

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

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

ass = 0
tt = -float("inf")
for i in range(n):
    if tt < itv[i][1]:
        ass += 1
        tt = itv[i][0]
print(ass)

Solution (Python):

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

for i in range(N):
    XL.append(list(map(int,input().split())))
    
XL.sort()
ans=N
r=XL[0][0]+XL[0][1]

for i in range(1,N):
    l=XL[i][0]-XL[i][1]
    if r > l:
        ans-=1
        if r > XL[i][0]+XL[i][1]:
            r=XL[i][0]+XL[i][1]
    else:
        r=XL[i][0]+XL[i][1]

print(ans)

Solution (Python):
import math
N = int(input())
arms = [list(map(int,input().split(" "))) for _ in range(N)]
robots = [((x-l),(x + l)) for x,l in arms]
robots = sorted(robots,key=lambda x:(x[0],x[1]))
ans = N
l,r = robots[0] 
for robot in robots[1:]:
    newl,newr = robot
    if r > newl: 
        if  r > newr: 
            r = newr

        ans -= 1
    else:
        l = newl
        r = newr

print(ans)

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

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



ans = 1
right = L[0][1]
for i in range(1, n):
    next_left = L[i][0]
    next_right = L[i][1]

    if next_left < right:
        continue
    else:
        ans += 1
        right = next_right

print(ans)

Solution (Python):
def main():
    N = int(input())
    R = []
    for _ in range(N):
        x, l = map(int, input().split())
        R.append((x - l, x + l))
    R.sort(key=lambda x: x[1])
    r = 0
    m = -10**10
    for xl, xr in R:
        if m <= xl:
            m = xr
            r += 1
    print(r)

main()

Solution (Python):
import sys
from collections import deque

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())

sys.setrecursionlimit(10 ** 9)


def main():
    N = INT()
    l = []
    for _ in range(N):
        X, L = MAP()
        l.append([X-L, X+L])

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

    cnt = N
    xm, xl = q.popleft()
    for i in range(N-1):
        nm, nl = q.popleft()
        if nm < xl:
            cnt -= 1
            if nl < xl:
                xm = nm
                xl = nl
        else:
            xm = nm
            xl = nl

    print(cnt)


if __name__ == '__main__':
    main()

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

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

point.sort()

dp = []
dp.append([1,point[0][1]+point[0][0]])
for i in range(1,N):
    x = point[i][0]
    l = point[i][1]
    n = dp[i-1][0]
    if dp[i-1][1]<=x-l:
        dp.append([n+1, x+l])
    else:
        dp.append([n,min(dp[i-1][1],x+l)])

ans = dp[-1][0]
print(ans)

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

length = []
for i in range(N):
    s = XL[i][0] - XL[i][1]
    f = XL[i][0] + XL[i][1]
    length.append([s, f])

length = sorted(length, key=lambda x:x[1])
ans = 0
f = - (10**9+7)
for i in range(N):
    if f <= length[i][0]:
        ans += 1
        f = length[i][1] - 0.5

print(ans)

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

li2 = []
for i in range(n):
    li2.append([li[i][0]-li[i][1],li[i][0]+li[i][1]])

li2.sort()

nw = li2[0][1]
ans = 1
for i in range(1,n):
    if li2[i][0] >= nw:
        ans += 1
        nw = li2[i][1]
    elif li2[i][1] < nw:
        nw = li2[i][1]


print(ans)

Solution (Python):
from operator import itemgetter

N = int(input())
X = []
L = []
for _ in range(N):
    row = list(map(int,input().split()))
    X.append(row[0])
    L.append(row[1])


c = list(zip(X, L))
c.sort(key=itemgetter(0))
X, L = zip(*c)


stack = []
stack.append(0)

for i in range(1,N):
    X1 = X[stack[-1]]
    L1 = L[stack[-1]]
    X2 = X[i]
    L2 = L[i]
    
    
    if X1+L1 <= X2-L2:
        stack.append(i)
    else:
        
        if X1+L1 <= X2+L2:
            
            continue
        else:
            
            stack.pop()
            stack.append(i)


print(len(stack))

Solution (Python):
import numpy as np

n = int(input())

left = np.zeros(n)
right = np.zeros(n)
for i in range(n):
    x, l = map(int, input().split())
    left[i] = int(x-l)
    right[i] = int(x+l)

sort_ind = np.argsort(right)
left = left[sort_ind]
right = right[sort_ind]

ans = 0
right_now = -1 * 10**10
for i in range(n):
    if(left[i] >= right_now):
        ans += 1
        right_now = right[i]

print(ans)

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

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

ans = n
pos = 0
tmp_l,tmp_r = 0,0
for i in range(n):
    x,l,r = lst[i]
    if i==0:
        pos = x
        tmp_l, tmp_r = l,r
    else:
        
        if tmp_r <= l:
            pos = x
            tmp_l = l
            tmp_r = r
        
        else:
            ans -= 1
            if tmp_r <= r:
                continue
            else:
                pos = x
                tmp_l = l
                tmp_r = r
print(ans)

Solution (Python):


n = int(input())
T = []

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

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

ans = 1
cur = T[0]

for k, v in enumerate(T):
    if k == 0: continue
    if v[0] >= cur[1]:
        ans += 1
        cur = v

print(ans)

Solution (Python):
n=int(input())
x=[]
for i in range(n):
  x1,l1=map(int,input().split())
  x.append([x1+l1,l1])
x.sort()
s=1
m=x[0][0]
for i in range(n):
  if m<=x[i][0]-2*x[i][1]:
    s+=1
    m=x[i][0]
print(s)

Solution (Python):
import copy

n = int(input())
A = []

for i in range(n):
    a = [int(x) for x in input().split()]
    a.append(a[0]+a[1])
    A.append(a)

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


count = 0
max_l = -10000000000
for i in A:
    if i[0]-i[1] >= max_l:
        count += 1
        max_l = i[2]

print(count)

Solution (Python):
from sys import stdin

N = int(stdin.readline().rstrip())

XL = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(N)]
R = []
for i in range(N):
    R.append([XL[i][0] - XL[i][1], XL[i][0] + XL[i][1]])
R.sort(key=lambda x:x[1])
ans = [R[0]]

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

print(len(ans))

Solution (Python):
N = int(input())
robots = []
for _ in range(N):
    X,L = map(int,input().split(' '))
    x = X-L
    l = 2*L
    robots.append([x,l+x])
robots.sort()


cnt = 0
start = robots[0][0]
end = robots[0][1]
result = []
for i in range(1,N):
    x = robots[i][0]
    l = robots[i][1]
    if x < end:
        if end < l:
            continue
        else:
            start = x
            end = l
    else:
        result.append([start,end])
        start = x
        end = l
print(len(result)+1)

Solution (Python):
import sys

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








def main():
	n=int(input())
	li=[]
	for i in range(n):
		x,l=map(int,input().split())
		li.append([x-l,x+l])
	li.sort(key=lambda x: x[0])
	
	b=li[0][1]
	ans=n
	
	for i in range(1,n):
		if li[i][0]<b:
			b=min(b,li[i][1])
			ans-=1
		else:
			b=li[i][1]
	print(ans)




if __name__ == "__main__":
	main()

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

range_dct = {}
for i in range(N):
    x, l = map(int, input().split())
    range_dct[x] = x + l

range_dct_sorted = sorted(range_dct.items(), key=lambda x:x[1])

counter = 0
right = -100000000000

for key, value in range_dct_sorted:
    if right <= key * 2 - value:
        right = value
        counter += 1

print(counter)

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]])
C=sorted(B, key=lambda x: x[1])
cnt=0
r=-1*10**9
for i in range(N):
  if r<=C[i][0]:
    cnt+=1
    r=C[i][1]
print(cnt)

Solution (Python):
N=int(input())
lr=[[] for _ in range(N)]

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

lr.sort()
r_max=lr[0][1]

ans=N
for i in range(1,N):
    if lr[i][0]<r_max:
        ans-=1
        r_max=min(r_max,lr[i][1])
    else:
        r_max=max(r_max,lr[i][1])
    
print(ans)

Solution (Python):
from operator import itemgetter

n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
s = [i[0]-i[1] for i in a]
t = [i[0]+i[1] for i in a]

st = sorted([(s[i], t[i]) for i in range(n)], key=itemgetter(1))
ans = 0
last = -10**10

for i in range(n):
    if last <= st[i][0]:
        ans += 1
        last = st[i][1]

print(ans)

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

xl = (map(int, input().split()) for _ in range(n))
w = [(x - l, x + l) for x, l in xl]
w = sorted(w, key=lambda x: x[1])
cur = w[0][1]
res = 1
for l, r in w[1:]:
    if l >= cur:
        res += 1
        cur = r
print(res)

Solution (Python):
n=int(input())
a=[]
for i in range(n):
  x,l=map(int,input().split())
  a.append((x+l,2*l))
a.sort()
ans=1
x,l=a[0]
for i in range(1,n):
  xx,ll=a[i]
  if x<=xx-ll:
    ans+=1
    x,l=xx,ll
print(ans)

Solution (Python):
N = int(input())
xl = []
for i in range(N):
    tmp = list(map(int, input().split()))
    if tmp[0] - tmp[1] < 0:
        xl.append((tmp[0] + tmp[1], 0))
    else:
        
        xl.append((tmp[0] + tmp[1], tmp[0] - tmp[1]))
        
xl_sorted = sorted(xl, key=lambda x: x[0])

ans = 0
t = 0

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

Solution (Python):
n=int(input())
a=[[int(i) for i in input().split()]for i in range(n)]
b=[]
for i in a:
    b.append([i[0]-i[1],i[0]+i[1]])

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

i=1
finish=c[0][1]
cnt=1
while i<n:
    if c[i][0]>=finish:
        finish=c[i][1]
        cnt+=1
    i+=1
print(cnt)

Solution (Python):
def solve():
    N = int(input())
    R = [None] * N
    for i in range(N):
        x, l = map(int, input().split())
        R[i] = (x + l, x - l)
    R.sort()
    
    right_most = R[0][0]
    save = 1
    for i in range(1, N):
        if R[i][1] >= right_most:
            save += 1
            right_most = R[i][0]

    left_most = R[N-1][1]
    saver = 1
    for i in reversed(range(N-1)):
        if R[i][0] <= left_most:
            saver += 1
            left_most = R[i][1]


    print(max(save, saver))


    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
N = int(input())
a = 0
ans = 0
rob = []
for i in range(N):
    x,l = map(int,input().split())
    rob.append((x-l,x+l,x,l))
rob.sort()
for i in range(N):
    a,b,c,d = rob[i]
    rob[i] = (b,a,c,d)
rob.sort()
for i in range(N):
    p,q,x,l = rob[i]
    if i == 0:
        a = x + l
        ans += 1
    if x - l >= a:
        a = x + l
        ans += 1
print(ans)

Solution (Python):

N=int(input()) 
XL = [[int(i) for i in input().split()] for i in range(N)] 
rl = [[x[0]+x[1],x[0]-x[1]] for x in XL]
rl = sorted(rl)

p = rl[0][0]
cnt = 1
for x in rl:
  if x[1] >=p:
    cnt += 1
    p = x[0]
    
print(cnt)

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

robots = []

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

    robots.append((x - l, x + l))

robots.sort()


def opt(robots):
    l = len(robots)
    count = 0
    i = 1
    robot1 = robots[0]
    while i < l:
        robot2 = robots[i]
        if robot1[1] > robot2[0]:
            if robot1[1] < robot2[1]:
                robot2 = robot1
            count += 1
        robot1 = robot2
        i += 1
    return l - count

print(opt(robots))

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

robot = heapq.heappop(robots)
max_right = robot[0] + robot[1]
del_count = 0
for i in range(len(robots)):
    robot = heapq.heappop(robots)
    if max_right > robot[0] - robot[1]:
        del_count += 1
        max_right = min(max_right, robot[0] + robot[1])
    else:
        max_right = robot[0] + robot[1]
print(n-del_count)

Solution (Python):
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
from itertools import permutations, combinations
from heapq import heappop, heappush

sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): 
    return int(input())
def inpm(): 
    return map(int,input().split())
def inpl(): 
    return list(map(int, input().split()))
def inpls(): 
    return list(input().split())
def inplm(n): 
    return list(int(input()) for _ in range(n))
def inpll(n): 
    return [list(map(int, input().split())) for _ in range(n)]
 
def main():
    n = inp()
    LR = []
    for _ in range(n):
        x,l = inpm()
        LR.append((x-l,x+l))
    LR.sort()
    ans = 1
    index = 1
    l,r = LR[0]
    while index < n:
        if LR[index][0] < r and l < LR[index][1]:
            r = min(r,LR[index][1])
            index += 1
        else:
            ans += 1
            [l,r] = LR[index]
            index += 1
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
from collections import namedtuple


def solve(arms):
    arms = sorted(arms, key=lambda x: x.right)
    right = -float("inf")
    res = 0
    for arm in arms:
        if right <= arm.left:
            res += 1
            right = arm.right

    return res


Arm = namedtuple("Arm", ["center", "left", "right"])


arms = []
N = int(input())
for _ in range(N):
    x, length = [int(val) for val in input().split(" ")]
    arm = Arm(x, x - length, x + length)
    arms.append(arm)


ans = solve(arms)
print(ans)

Solution (Python):
N = int(input())
A = [list(map(int,input().split())) for _ in range(N)]
B = sorted([[A[i][0]-A[i][1],A[i][0]+A[i][1]] for i in range(N)],key=lambda x:x[1])
cur = 1
C = [B[0]]
while cur<N:
    if B[cur][0]>=C[-1][1]:
        C.append(B[cur])
    cur += 1
print(len(C))

Solution (Python):
import heapq
N = int(input())
robo = list(list(map(int,input().split()))for _ in range(N))
robo.sort(key=lambda x:x[0])
queue = []
for x,l in robo:
    heapq.heappush(queue,[x+l,x-l])
ans = 0
left = -float('inf')
while queue:
    q = heapq.heappop(queue)
    if q[1] >= left:
        left = q[0]
        ans += 1
print(ans)

Solution (Python):
n = int(input())
ls = []
for i in range(n):
    x,l = map(int,input().split())
    ls.append([x-l,l+x])
    
r = n
ls = sorted(ls, key=lambda item: item[1])
for i in range(1,n):
    if ls[i][0] < ls[i-1][1]:
      ls[i][1] = ls[i-1][1]
      r -=1
        
print(r)

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

def compress(L):
    L2 = list(set(L))
    L2.sort()
    C = {v : k for k, v in enumerate(L2)}
    return L2, C

class Segtree:
    def __init__(self, A, intv, initialize = True, segf = max):
        self.N = len(A)
        self.N0 = 2**(self.N-1).bit_length()
        self.intv = intv
        self.segf = segf
        if initialize:
            self.data = [intv]*self.N0 + A + [intv]*(self.N0 - self.N)
            for i in range(self.N0-1, 0, -1):
                self.data[i] = self.segf(self.data[2*i], self.data[2*i+1]) 
        else:
            self.data = [intv]*(2*self.N0)
        
    def update(self, k, x):
        k += self.N0
        self.data[k] = x
        while k > 0 :
            k = k >> 1
            self.data[k] = self.segf(self.data[2*k], self.data[2*k+1])
    
    def query(self, l, r):
        L, R = l+self.N0, r+self.N0
        s = self.intv
        while L < R:
            if R & 1:
                R -= 1
                s = self.segf(s, self.data[R])
            if L & 1:
                s = self.segf(s, self.data[L])
                L += 1
            L >>= 1
            R >>= 1
        return s
    
    def binsearch(self, l, r, check, reverse = False):
        L, R = l+self.N0, r+self.N0
        SL, SR = [], []
        while L < R:
            if R & 1:
                R -= 1
                SR.append(R)
            if L & 1:
                SL.append(L)
                L += 1
            L >>= 1
            R >>= 1
        
        if reverse:
            for idx in (SR + SL[::-1]):
                if check(self.data[idx]):
                    break
            else:
                return -1
            while idx < self.N0:
                if check(self.data[2*idx+1]):
                    idx = 2*idx + 1
                else:
                    idx = 2*idx
            return idx
        else:
            for idx in (SL + SR[::-1]):
                if check(self.data[idx]):
                    break
            else:
                return -1
            while idx < self.N0:
                if check(self.data[2*idx]):
                    idx = 2*idx
                else:
                    idx = 2*idx + 1
            return idx

N = int(readline())
XL = [tuple(map(int, readline().split())) for _ in range(N)]
LR = [(x-l, x+l) for x, l in XL]

M = 2*N+1
inf = 1<<31
S = set([-inf])
for l, r in LR:
    S.add(l)
    S.add(r)
_, Cs = compress(list(S))
LR = [(Cs[l], Cs[r]) for l, r in LR]


table = [-inf]*M
for l, r in LR:
    table[r] = max(table[r], l)
dp = Segtree([None]*M, -inf, initialize = False, segf = max)
dp.update(0, 0)
for r in range(1, M):
    if table[r] == -inf:
        continue
    l = table[r]
    k = dp.query(0, l+1)
    dp.update(r, 1+k)

print(dp.query(0, M))

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

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


ans1=0
r=-10**9-1
for X,L in XL:
    if X-L>=r:
        ans1+=1
        r=X+L
ans2=0
l=-10**9+1
for X,L in reversed(XL):
    if X+L<=l:
        ans2+=1
        l=X-L

print(max(ans1,ans2))