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

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


t = robo[0][1]
cnt = 1

for i in range(1, N):
    j = robo[i]
    if j[0] >= t:
        t = j[1]
        cnt += 1

print(cnt)

Solution (Python):
q = list()
for _ in range(int(input())):
  x,l = map(int, input().split())
  q.append((x-l,x+l))
q.sort(key=lambda x:x[1])
cur = -10**10
cnt = 0
for s,t in q:
  if cur <= s:
    cnt += 1
    cur = t
print(cnt)

Solution (Python):
N = int(input())
A = []
for i in range(N):
    X,L = map(int,input().split())
    A.append((X,L))
A.sort(key=lambda x:x[0]+x[1])
ans = 0
b = -float("inf")
for a in A:
    if b<=(a[0]-a[1]):
        ans+=1
        b = (a[0]+a[1])
print(ans)

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

mx = -(10 ** 9)
n = 0
for x, l in robots:
    if x - l >= mx:
        n += 1
        mx = x + l
    else:
        mx = min(mx, x + l)

print(n)

Solution (Python):

import sys
input = sys.stdin.buffer.readline


from collections import defaultdict


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


def main():
	N = int(input())
	S = []
	for i in range(N):
		X, L = getlist()
		S.append([X + L, X - L])
	S = sorted(S)
	
	ans = 1
	val = S[0][0]
	for i in range(1, N):
		if S[i][1] >= val:
			ans += 1
			val = S[i][0]
	print(ans)
	


if __name__ == '__main__':
	main()

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

lr = []
for x, l in xl:
    lr.append([x - l, x + l])

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

cnt = 1
left, right = lr[0]
for ll, rr in lr:
    if ll >= right:
        cnt += 1
        left = ll
        right = rr

print(cnt)

Solution (Python):

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

ans = 0
prev = -10**9 - 7

for i in range(n):
    if A[i][1] >= prev:
        prev = A[i][0]
        ans += 1
print(ans)

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

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

r_max = -10**10
ans = 0
for l,r in LR:
    if l >= r_max:
        r_max = r
        ans += 1
print(ans)

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

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


right = LR[0][1]
answer = 1

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

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

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

ans = 0
tmp = -10 ** 12
for x, y in S:
    if tmp <= x:
        ans += 1
        tmp = y
        
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))

INF = 1e10
last = -INF
    
robots.sort()

ans = 0
for (r, l) in robots:
    if l < last:continue
    ans += 1
    last = r

print(ans)

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

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


ans = 0
RNow = -float('inf')
for L, R in LRs:
    if RNow <= L:
        ans += 1
        RNow = R

print(ans)

Solution (Python):
from sys import stdin
from itertools import repeat
def main():
    n = int(stdin.readline())
    dat = map(int, stdin.read().split(), repeat(10, 2 * n))
    b = [(dat[i*2] + dat[i*2+1], dat[i*2] - dat[i*2+1]) for i in xrange(n)]
    b.sort()
    ans = 1
    c = b[0][0]
    for r, l in b:
        if l >= c:
            ans += 1
            c = r
    print ans
main()

Solution (Python):
def main():
    n = int(input())
    xl = [list(map(int, input().split())) for _ in [0]*n]
    xy = [(x-l, x+l) for x, l in xl]
    xy.sort(key=lambda x: x[1])
    cnt = 0
    now = -10**10
    for x, y in xy:
        if x >= now:
            cnt += 1
            now = y
    print(cnt)


main()

Solution (Python):
N = int(input())
robots = []
for _ in range(N):
    X, L = map(int, input().split())
    robots.append((X+L, X-L))
robots.sort()
ans = 0
last_end = -10 ** 10
for end, start in robots:
    if last_end <= start:
        last_end = end
        ans += 1
print(ans)

Solution (Python):
N = int(input())
L = [[int(l) for l in input().split()] for _ in range(N)]

for i in range(N):
    L[i] = [L[i][0]+L[i][1], L[i][0], L[i][1]]
    
L.sort()
ans = 0
x = -10**10
for i in range(N):
    if x <= L[i][1]-L[i][2]:
        ans += 1
        x = L[i][0]

print(ans)

Solution (Python):
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


N = int(sys.stdin.buffer.readline())
X, L = list(zip(*[map(int, sys.stdin.buffer.readline().split()) for _ in range(N)]))


X = np.array(X, dtype=int)
L = np.array(L, dtype=int)

R = X + L
L = X - L
I = R.argsort()
R = R[I].tolist()
L = L[I].tolist()

ans = 0
m = -INF
for l, r in zip(L, R):
    if m <= l:
        m = r
        ans += 1
print(ans)

Solution (Python):


import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read





n = int(input())

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

from operator import itemgetter
res.sort(key=itemgetter(1))



ans = 0
now = res[0][0] - 10
for l,r in res:
    if now <= l:
        ans += 1
        now = r
    

print(ans)

Solution (Python):
n=int(input())
XL=[]
for i in range(n):
  x,l=map(int,input().split())
  XL.append([x-l,x,x+l])
ans=0
cur=-float("inf")
XL.sort(key=lambda x:x[2])
for x1,x2,x3 in XL:
  if x1>=cur:
    cur=x3
    ans+=1
  else:
    continue
print(ans)

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

n = int(input())
L = [list(map(int,input().split())) for i in range(n)]
A= []

for i in range(n):
    A.append([L[i][0]-L[i][1], L[i][0]+L[i][1]])
A.sort(key=lambda x:x[1])

m = -float("inf")
ans = 0
for i in range(n):
    if m > A[i][0]:
        ans += 1
    else:
        m = A[i][1]
print(n-ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
XL = [LIST() for _ in range(N)]

range_lis = [(x[0]-x[1], x[0]+x[1]) for x in XL]


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

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

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

ls2 = list()

for i in range(n):
    ls2.append([ls[i][0]-ls[i][1], ls[i][0]+ls[i][1]])

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

idx=ls2[0][0]
ans=0

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

print(ans)

Solution (Python):

import sys
input = sys.stdin.readline

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

robots.sort()

cnt = 0
node = -10**12
for end, start in robots:
    if start >= node:
        node = end
        cnt += 1
print(cnt)

Solution (Python):
def examA():
    H = I()
    W = I()
    N = I()
    ans = (N-1)//max(H,W) + 1
    print(ans)
    return

def examB():
    N = I()
    XL = [LI()for _ in range(N)]
    for i in range(N):
        XL[i][0] += XL[i][1]
    XL.sort()

    ans = 0
    now = -inf
    for i in range(N):
        if XL[i][0]-XL[i][1]*2>=now:
            ans +=1
            now = XL[i][0]
    print(ans)
    return

def examC():
    return

def examD():
    return

def examE():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examB()

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

X = []

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

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

count = 0
prev = -10**27
for i in range(N):
    if prev<=X[i][0]:
        prev = X[i][1]
        count+=1

print(count)

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

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

print(ans)

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

xl.sort(key=lambda x: x[0] + x[1])
ans = 0
i = 0
j = -10**9*2
while i < n:
    t = xl[i]
    if j <= t[0] - t[1]:
        ans += 1
        j = t[0] + t[1]
    i += 1
print(ans)

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

N = int(input())

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

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

count = 0
tmp = - 10 ** 18
for i in lst:
    if tmp <= i[0]:
        count += 1
        tmp = i[1]

print (count)

Solution (Python):
n = int(input())
li = [None] * n
for i in range(n):
    x, l = map(int, input().split())
    li[i] = (x - l, x + l)
li.sort(key=lambda x: x[1])
f = -float('inf')
ans = 0
for p, q in li:
    if p >= f:
        ans += 1
        f = q
print(ans)

Solution (Python):
from operator import itemgetter


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

li = []
for i in range(n):
    x, l = info[i]
    li.append((x - l, x + l))
li = sorted(li, key = itemgetter(1))

r_max = - 10**18
ans = 0
for i in range(n):
    l, r = li[i]
    if r_max <= l:
        ans += 1
        r_max = r
print(ans)

Solution (Python):
N = int(input())
ans = 0
a = - (1 << 100)
X = []
for _ in range(N):
    x, l = map(int, input().split())
    X.append((x, l))
X = sorted(X)
for x, l in X:
    if a > x - l:
        a = min(a, x + l)
    else:
        a = x + l
        ans += 1
print(ans)

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

R = [(X - L, X + L) for X, L in XL]
R.sort(key=lambda x: x[1])

ret = 0
rmax = -float('inf')
for l, r in R :
  if l >= rmax :
    ret += 1
    rmax = r
    
print(ret)

Solution (Python):
n = int(input())
arms = [list(map(int, input().split())) for _ in range(n)]
arms.sort(key=lambda x: x[0]+x[1])
ans = 0
cur = -10**20
for x, l in arms:
	if x-l >= cur:
		ans += 1
		cur = x+l
print(ans)

Solution (Python):
n=int(input())
d=sorted([list(map(int,input().split()))for i in range(n)],key=lambda x:x[0]+x[1])
c=-float("INF")
an=0
for i,j in d:
    if i-j>=c:
        an+=1
        c=i+j
print(an)

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)