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


sel = []
cur = None
ans = 0
for E,S in ES:
    if cur is None or cur < S:
        sel.append((S,E))
        cur = E
        ans += 1
print(ans)

Solution (Python):
N, *XL = map(int, open(0).read().split())

A = sorted(((x - l, x + l) for x, l in zip(*[iter(XL)] * 2)), key=lambda x: x[1])

ans = 0
cur = -10 ** 9
for s, t in A:
    if cur <= s:
        ans += 1
        cur = t

print(ans)

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

t = [(x + l, x - l) for x, l in XL]
t.sort()
max_r = -float('inf')
result = 0
for i in range(N):
    r, l = t[i]
    if max_r <= l:
        result += 1
        max_r = r
print(result)

Solution (Python):
l=[]
for i in range(int(input())):
    x,y=map(int,input().split())
    l.append((x+y,x-y))
l.sort()
t,a=l[0][1],0
for j,i in l:
    if t<=i:
        a+=1
        t=j
print(a)

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

ans = n
r = ll.pop()[0]

while ll:
  while ll and ll[-1][1] > r:
    ans -= 1
    ll.pop()
  if ll:
    r = ll.pop()[0]

print(ans)

Solution (Python):
n = int(input().strip())
xl = [list(map(int, input().split())) for i in range(n)]
lst=[[0]*2 for _ in range(n)]

for i in range(n):
    lst[i][0]=xl[i][0]-xl[i][1]
    lst[i][1]=xl[i][0]+xl[i][1]

lst.sort(key=lambda x: x[1])
ans=0
last=-10**10
for i in range(n):
    if last <= lst[i][0]:
        ans+=1
        last=lst[i][1]
print(ans)

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


def main():
    N = int(input())
    robo = []
    for i in range(N):
        x, l = [int(x) for x in input().split()]
        robo.append((x-l, x+l))
    robo.sort()
    robo.sort(key=lambda x: x[1])

    ans = N
    l, r = robo[0]
    for i in range(1, N):
        if robo[i][0] < r:
            ans -= 1
        else:
            l, r = robo[i]
    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):


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

areas = [(x - l, x + l) for x, l in zip(X, L)]
areas = sorted(areas, key=lambda x:x[-1])



ok = [areas[0]]
for area in areas[1:]:
    if ok[-1][-1] <= area[0]:
        ok.append(area)


print(len(ok))

Solution (Python):
n = int(input())
robots = []
for _ in range(n):
    xi, li = map(int, input().split())
    robots.append((xi + li, xi - li))
robots.sort()
ans = n
pre_right = robots[0][0]
for i in range(1, n):
    now_left = robots[i][1]
    if pre_right > now_left:
        ans -= 1
    else:
        pre_right = robots[i][0]
print(ans)

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

C.sort(key = lambda x: x[1])
ans = 0
a = -float("inf")
for i in range(N):
	if C[i][0] >= a:
		a = C[i][1]
	else:
		ans += 1

print(N-ans)

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

sel = []
cur = None
ans = 0
for E,S in ES:
    if cur is None or cur <= S:
        sel.append((S,E))
        cur = E
        ans += 1
print(ans)

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

Solution (Python):

import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, X: "List[int]", L: "List[int]"):
    s = [X[i]-L[i] for i in range(N)]
    e = [X[i]+L[i] for i in range(N)]
    se = [[s[i],e[i]] for i in range(N)]
    se = sorted(se, key=lambda x:x[1])

    ans = [se[0]]

    for i in range(1, N):
        if se[i][0] < ans[-1][1]:
            continue
        else:
            ans.append(se[i])

    
    print(len(ans))

    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):
from operator import itemgetter

N = int(input())
X=[]
ans=0
for i in range(N):
    H = list(map(int, input().split()))
    O=[]
    O.append(H[0]-H[1])
    O.append(H[0]+H[1])
    X.append(O)

X=sorted(X, key=itemgetter(1))
S=X[0][1]
ans+=1
for i in range(len(X)):
    if(X[i][0]>=S):
        ans+=1
        S=X[i][1]
"""
while(len(X)>0):
    
    ans+=1
    S=X[0][1]
    X.remove(X[0])
    I = []
    for i in range(len(X)):
        if(X[i][0]>=S):
            I.append(X[i])
    X=I
    
"""


print(ans)

Solution (Python):
n = int(input())
s = [None] * n
for i in range(n):
    x, l = map(int, input().split())
    s[i] = x-l, x+l

s.sort(key=lambda x: x[1])
ans, c = 0, -float("inf")

for l, r in s:
    if c > l: continue
    ans += 1
    c = r

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.sort(key=lambda _x: _x[1])
cnt = 1
limit = r[0][1]
for ri in r[1:]:
    if ri[0] >= limit:
        cnt += 1
        limit = ri[1]
print(cnt)

Solution (Python):
N = int(input())
xl = [list(map(int, input().split())) for _ in range(N)]
rl = []
for i in range(N):
    rl.append((xl[i][0] - xl[i][1], xl[i][0] + xl[i][1]))
rl.sort(key=lambda x: x[1])
cnt = 0
tmp = -10 ** 18

for i, j in rl:
    if tmp <= i:
        cnt += 1
        tmp = j
print(cnt)

Solution (Python):
N = int(input())
XL = [list(map(int,input().split())) for _ in range(N)]
r_l = []
for n in range(N):
  xl = XL[n]
  x = xl[0]
  l = xl[1]
  r_l.append([x-l,x+l])

r_l = sorted(r_l,key = lambda x:x[1])
ans = 1
l = r_l[0][1]
for a in r_l:
  if a[0]<l:
    continue
  else:
    ans += 1
    l = a[1]
    
print(ans)

Solution (Python):
n=int(input())
li=[None]*n
for i in range(0,n):
    flag=True
    x,l=map(int, input().split())
    li[i]=(x+l, x-l)
li=sorted(li)
count=1
x,y=li[0]
for i in range(1,n):
    x2,y2=li[i]
    if y2 < x:
        continue
    count=count+1
    x=x2
print(count)

Solution (Python):
N = int(input())
XL = [list(map(int,input().split())) for _ in range(N)]
r_l = []
for n in range(N):
  xl = XL[n]
  x = xl[0]
  l = xl[1]
  r_l.append([x-l,x+l])

r_l = sorted(r_l,key = lambda x:x[1])
ans = 1
l = r_l[0][1]
for a in r_l:
  if a[0]<l:
    continue
  else:
    ans += 1
    l = a[1]
    
print(ans)

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

min_max = sorted([[list[0] - list[1], sum(list)] for list in robots], key=lambda val: val[1])
           
remove = 0
max_range = -1e9 - 1
for robot in min_max:
  if max_range <= robot[0]:
    max_range = robot[1]
  else:
    remove += 1
  
print(n - remove)

Solution (Python):
N = int(input())
X = [0] * N
for i in range(N):
    x, l = map(int, input().split())
    X[i] = x, l, x - l, x + l

X.sort(key=lambda x: x[3])  
right = X[0][3]
count = 1
for i in range(1, N):
    if right <= X[i][2]:
        count += 1
        right = X[i][3]

print(count)

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

if n == 1:
  print(n)
else:
  XL = sorted(X, key=lambda x: x[3])

  

  ans = 0
  temp = -1 * (10**9)

  for i in range(n):
    if temp <= XL[i][2]:
      ans += 1
      temp = XL[i][3]

  print(ans)

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

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

xl = sorted(xl)

cur = -10**9
ans = 0
for r in xl:
    if cur <= r[1]:
        ans +=1
        cur = r[0]

print(ans)

Solution (Python):
N = int(input())
arms = []
for _ in range(N):
    x1, l1 = map(int, input().split())
    arms.append([x1+l1, x1-l1])
    
arms.sort()

last = -(10 ** 9)
ans = 0
for i in range(N):
    if last <= arms[i][1]:
        ans += 1
        last = arms[i][0]
    else:
        continue
    
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()

cur = -float('inf')
ans = 0
for i in range(n):
    t, s = robots[i]
    if cur <= s:
        ans += 1
        cur = t

print(ans)

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

grid = [list([0,0]) for i in range(n)]

for i in range(n):
    grid[i][0] = x[i][0] - x[i][1]
    grid[i][1] = x[i][0] + x[i][1]

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

cnt = 1
a = new_grid[0][1]

for i in range(n):
    if a <= new_grid[i][0]:
        cnt += 1
        a = new_grid[i][1]
print(cnt)

Solution (Python):
from bisect import bisect_left as lower_bound
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


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


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False


def main():
    N = I()
    XL = [None] * N
    ans = 0

    for i in range(N):
        X, L_ = MI()
        XL[i] = (X, L_, i)

    arr = [None] * N
    for i in range(N):
        arr[i] = (XL[i][0] - XL[i][1], XL[i][0] + XL[i][1])

    arr = sorted(arr, key=lambda a: a[1])
    maxv = -(10 ** 9)
    cur = maxv
    for i in range(N):
        if cur <= arr[i][0]:
            cur = arr[i][1]
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

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

ans = 0
last = -1e10
for r, l in R:
    if last <= l:
        ans += 1
        last = r
print(ans)

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

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

Solution (Python):
N = int(input())
S = [tuple(map(int, input().split())) for i in range(N)]
T = list(map(lambda j:(j[0]-j[1], j[0]+j[1]), S))

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

for i, t in enumerate(T):
  if i>0:
    if end <= t[0]:
      res += 1
      start = t[0]
      end = t[1]
  else:
    start = t[0]
    end = t[1]
    res = 1

print(res)

Solution (Python):
n = int(input())
ans = 1
a = []
d = {}
for i in range(n):
  x,l = map(int, input().split())
  a.append((x+l,x-l))
if n == 1:
  print(ans)
else:
  a.sort(key=lambda x:(x[0],x[1]))
  gl = a[0][0]
  st = a[0][1]
  for i in range(1,n):
    if gl<=a[i][1]:
      ans += 1
      gl = a[i][0]
  print(ans)

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

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):
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
xl = []
for i in range(n):
    xx,ll = inm()
    xl.append((xx+ll,xx-ll))
xl.sort()

ddprint(xl)

cnt = 1
i = 0
while i<n-1:
    nxtj = -1
    for j in range(i+1,n):
        if xl[i][0]<=xl[j][1]:
            
            cnt += 1
            nxtj = j
            break
    i = nxtj if nxtj>0 else n
    

print(cnt)

Solution (Python):
def main():
    N = int(input())
    nodes = []

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

    nodes.sort()

    last_end = -999999999999999999
    ans = 0
    for node in nodes:
        end, start = node
        if last_end <= start:
            ans += 1
            last_end = end

    print(ans)


main()

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

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

Solution (Python):
n = int(input())
x = []
for i in range(n):
    X,L = map(int, input().split())
    x.append([X-L,X+L])
x.sort(key=lambda x:x[0])
ans = n
tmp = x[0][1]
for i in range(1,n):
    if tmp>x[i][0]:
        ans -=1
        tmp = min(tmp,x[i][1])
    else:
        tmp = x[i][1]
print(ans)

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

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())
x=[]
l=[]
for i in range(n):
    a,b=map(int,input().split())
    x.append(a)
    l.append(b)

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

Solution (Python):
n=int(input())
X=[]
for i in range(n):
    x,l=[int(_) for _ in input().split()]
    X+=[(x-l,x+l)]
X.sort(key=lambda x:x[0])
ans=n
tmp=X[0][1]
for i in range(1,n):
    if tmp>X[i][0]:
        ans-=1
        tmp=min(tmp,X[i][1])
    else:
        tmp=X[i][1]
print(ans)

Solution (Python):
from operator import itemgetter

n = int(input())
data = [()]*n
for i in range(n):
    x, l = map(int, input().split())
    data[i] = (x-l,x+l)
data.sort(key = itemgetter(1))
ans = 0
prev_r = -10**18
for l, r in data:
    if prev_r >  l:
      continue
    ans += 1
    prev_r = r

print(ans)

Solution (Python):
n=int(input())
ans=0
cnt=-(10**9)-1
li=[]
for i in range(n):
    X,L=map(int,input().split())
    li.append([X+L,L])
li=sorted(li,key=lambda x:x[0])
for i in range(n):
    if cnt>li[i][0]-li[i][1]*2:
        ans+=1
    else:
        cnt=li[i][0]
print(n-ans)

Solution (Python):
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


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

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

    print(res)


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
itv=[]
for _ in range(n):
    x,l=map(int,input().split())
    itv.append((x+l,x-l))
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())
x = []
l = []
for i in range(N):
    x1,l1=[int(i) for i in input().split()]
    x.append(x1)
    l.append(l1)

Range = []

for i in range(N):
  max_i = x[i] + l[i]
  min_i = x[i] - l[i]
  Range.append((min_i,max_i))

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

a = 1
for i in range(N-1):
  if Range[a][0] >= Range[a-1][1]:
    a += 1
  else:
    Range.pop(a)

print(a)

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

Solution (Python):
def solve():
  n = int(input())
  query  =[]
  for i in range(n):
    x,l = (int(i) for i in input().split())
    query.append((x+l,max(0,x-l)))
  query.sort()
  nowr = 0
  ans = 0
  for i in range(n):
    r,l = query[i]
    
    if nowr <= l:
      nowr = r
      ans += 1
  print(ans)
solve()

Solution (Python):
N = int(input())
X = []
X_L = []
X_L_dict = {}
for i in range(N):
    x, l = map(int, input().split())
    X_L.append([x-l, x+l])
    X.append(x-l)
X_L.sort(key=lambda x:x[1])
X.sort()

last = None

count = 0

for x_l in X_L:
    
    if last is None or last <= x_l[0]:
        count += 1
        last = x_l[1]
print(count)

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, XL):
    s = []
    for x, l in XL:
        lp, rp = x-l, x+l
        s.append((lp, rp))

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

    ans = 0
    t = -INF
    for l, r in s:
        if t <= l:
            ans += 1
            t = r

    return ans

def main():
    N = read_int()
    XL = [read_int_n() for _ in range(N)]
    print(slv(N, XL))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
a = []
x = -float("inf")
res = 0
for _ in range(N):
  x, l = map(int, input().split())
  a.append((x - l, x + l))
a.sort(key = lambda x: x[1])
x = -float("inf")

for i in range(N):
  if x <= a[i][0]:
    x = a[i][1]
    res += 1
print(res)

Solution (Python):
N = int(input())
D = []
for i in range(N):
    x, l = map(int, input().split())
    D.append([x-l, x+l])
from operator import itemgetter
D = sorted(D, key = itemgetter(1))
u = -10**10 
cnt = 0
for a, b in D:
    if u <= a:
       cnt += 1
       u = b 
print(cnt)

Solution (Python):
N = int(input())
x = []
l = []
for i in range(N):
    x1,l1=[int(i) for i in input().split()]
    x.append(x1)
    l.append(l1)

Range = []

for i in range(N):
  max_i = x[i] + l[i]
  min_i = x[i] - l[i]
  Range.append((min_i,max_i,x[i], l[i]))

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


a = 1

for i in range(N-1):
  
  if Range[a][0] >= Range[a-1][1]:
    a += 1
  else:
    
      Range.pop(a)
    
      


print(a)

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

Solution (Python):
import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
Y = []
for s in inputs[1:]:
    x, l = map(int, s.split())
    Y.append((x-l, x+l))
Y.sort(key=lambda x: x[1])

cnt = 1
_, r0 = Y[0]
for i in range(1, n):
    l, r = Y[i]
    if r0 <= l:
        cnt += 1
        r0 = r
    
print(cnt)

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

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

RL.sort()
right = -10**9

ans = 0
for r, l in RL:
  if l >= right:
    right = r
    ans += 1
    
print(ans)

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]  
    left = xl[i][0] - xl[i][1]  
    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())
pin = [[0, 0] for i in range(N)]
front = [0 for i in range(N)]
for i in range(N):
    X, L = map(int, input().split())
    pin[i][1] = X - L
    pin[i][0] = X + L
    front[i] = X - L
pin.sort()
ans = 1
i = 1
tmp = pin[0][0]
while i < N:
    if pin[i][1] < tmp:
        i += 1
    else:
        ans += 1
        tmp = pin[i][0]
        i += 1
print(ans)

Solution (Python):
N=int(input())
s=[list(map(int,input().split())) for i in range(N)]
A=N
c=0
s.sort(key=lambda x: x[0])

Check=[[s[i][0]-s[i][1],s[i][0]+s[i][1]] for i in range(N)]
tmp=Check[0][1]
for j in range(1,N):
    if tmp > Check[j][0]:
        c=c+1
        tmp=min(tmp, Check[j][1])
    else:
        tmp=Check[j][1]
    
print(A-c)

Solution (Python):
import sys
from heapq import heappush,heappop
from bisect import bisect_left,bisect_right
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    X,L=[0]*N,[0]*N
    l=[]
    for i in range(N):
        X[i],L[i]=map(int,input().split())
        l.append((X[i]+L[i]-1,X[i]-L[i]))
    l.sort()
    ans=0
    tmp=-INF
    for right,left in l:
        if tmp<left:
            ans+=1
            tmp=right
    print(ans)        
        

if __name__ == '__main__':
    main()

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 robot in 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):
import sys
input = sys.stdin.readline
n = int(input())
X = []
for i in range(n):
  x, l = map(int, input().split())
  X.append([x-l, x+l])
X.sort()
temp = X[0][1]
count = n
for i in range(1,n):
  if temp>X[i][0]:
    count -= 1
    temp = min(temp, X[i][1])
  else:
    temp = X[i][1]
print(count)

Solution (Python):
n  = int(input())
ps = []

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

ps.sort()

x = ps[0][0]
d = 0

for i in range(1, n):
  p = ps[i]
  
  if p[1] < x:
    d += 1
  else:
    x = p[0]

print(n - d)

Solution (Python):
n = int(input())
rob = []
for i in range(n):
    x,l = map(int,input().split())
    rob.append([x-l,x+l])
rob.sort()
ans  = n
right = rob[0][1]
for i,[l,r] in enumerate(rob):
    if i == 0:
        continue
    if l < right:
        ans -= 1
        right = min(right,r)
    else:
        right = r
print(ans)

Solution (Python):
def acinput():
    return list(map(int, input().split(" ")))

N=int(input())
bars=[]
for i in range(N):
    tmp = acinput()
    tmp.extend([tmp[0]-tmp[1],tmp[0]+tmp[1]])
    bars.append(tmp)

bars=sorted(bars,key=lambda x:x[3])



count=0
R=-10000000000
for i in range(0,N):

    if R<=bars[i][2]:
        R=bars[i][3]
        count+=1


print(count)

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

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

Solution (Python):
n = int(input())
X = []
for i in range(n):
  x, l = map(int, input().split())
  X.append([x-l, x+l])
X.sort()
temp = X[0][1]
count = n
for i in range(1,n):
  if temp>X[i][0]:
    count -= 1
    temp = min(temp, X[i][1])
  else:
    temp = X[i][1]
print(count)

Solution (Python):
n = int(input())
X = []
for i in range(n):
  x, l = map(int, input().split())
  X.append([x-l, x+l])
X.sort()
temp = X[0][1]
count = n
for i in range(1,n):
  if temp>X[i][0]:
    count -= 1
    temp = min(temp, X[i][1])
  else:
    temp = X[i][1]
print(count)

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



for i in range(n):
    left.append((l[i][0]+l[i][1],l[i][0]-l[i][1]))
left.sort()   
count = 1
right = 10**10
right = left[0][0]
c = 0

while True:
    
    for i in range(c,n+1):
        if i == n:
            print(count)
            exit()
        if left[i][1] >= right:
            count += 1
            right = left[i][0]
            c = i
            
            
            
    if c == n-1:
        print(count)
        exit()

Solution (Python):
n=int(input())
x,l=[0]*n,[0]*n
xlr=[[0]*2 for i in range(n)]
for i in range(n):
  a,b=map(int,input().split())
  x[i],l[i]=a,b
  xlr[i]=[a-b,a+b]
xlr.sort()
cnt=0
chk=xlr[n-1][0]
for i in range(2,n+1):
  if chk<xlr[n-i][1]:
    cnt+=1
  else:
    chk=xlr[n-i][0]
print(n-cnt)

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

robot=[]

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



RR=robot[0][0]-1
cnt=0

for item in robot:
    if RR<=item[0]:
        cnt+=1
        RR=item[1]
    elif RR>=item[1]:
        RR=item[1]

print(cnt)

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

N = int(input())

table = []

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

table.sort(key=lambda x:x[0])
cur = table[0]
for i in range(1,N):
    if table[i][0] < cur[1]:
        N -= 1
        if cur[1] >= table[i][1]:
            cur = table[i]
    else:
        cur = table[i]

print(N)

Solution (Python):
n = int(input())
x_org = []
for i in range(n):
    x_org.append(input().split())

x = sorted(x_org, key=lambda z: int(z[0]))
removed = 0
for i in range(1, n):
    before = int(x[i][0]) - int(x[i][1])
    after = int(x[i-1][0]) + int(x[i-1][1]) 
    if before < after:
        removed += 1
        if (int(x[i][0]) + int(x[i][1])) > (int(x[i-1][0]) + int(x[i-1][1])):
            x[i] = x[i-1]

print(n - removed)

Solution (Python):
N = int(input())
XLlist = [tuple(map(int, input().split())) for _ in range(N)]
XLlist.sort(key=lambda x: x[0])
ans = 1
x, l = XLlist[0]
rl = x + (l - 1)
for x, l in XLlist:
    ll = x - l
    if ll <= rl:
        rl = min(rl, x + l - 1)
    else:
        ans += 1
        rl = x + l - 1

print(ans)

Solution (Python):



def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    robots = []
    for i in range(n):
        x, l = rli()
        robots.append([x+l, x-l])
    robots.sort()
    r = -1*pow(10, 10)
    ans = 0
    for ro in robots:
        if ro[1] < r:
            continue
        ans += 1
        r = ro[0]
    print(ans)


if __name__ == '__main__':
    main()

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+0.5, x+l-0.5))

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


count = N
temp = X[0][1]
for i in range(N-1):
    if X[i+1][0] < temp:
        count -= 1
        temp = min(temp, X[i+1][1])
    else:
        temp = X[i+1][1]
    

print(count)

Solution (Python):
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()
nl=[]
for i in range(n):
  nl.append([l[i][0]+l[i][1],l[i][0]-l[i][1]])
nl.sort()
if n==1:
  print(1)
else:
  ans=1
  k=nl[0][0]
  for i in range(1,n):
    if k<=nl[i][1]:
      ans+=1
      k=nl[i][0]
  print(ans)

Solution (Python):
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()
nl=[]
for i in range(n):
  nl.append([l[i][0]+l[i][1],l[i][0]-l[i][1]])
nl.sort()
if n==1:
  print(1)
else:
  ans=1
  k=nl[0][0]
  for i in range(1,n):
    if k<=nl[i][1]:
      ans+=1
      k=nl[i][0]
  print(ans)