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 sys
INF = 1 << 60
MOD = 10**9 + 7 
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    A = []
    for _ in range(int(input())):
        x, l = map(int, input().split())
        A.append((x - l, x + l))

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

Solution (Python):
from operator import itemgetter
N=int(input())
arms=[]
for _ in range(N):
    x,l=map(int,input().split())
    a,b=x-l,x+l
    arms.append([a,b])

arms.sort(key=itemgetter(1))

cnt=1
tmp=arms[0][1]
for arm in arms:
    if arm[0]<tmp: continue
    cnt+=1
    tmp=arm[1]

print(cnt)

Solution (Python):
import math , sys
N = int( input() )

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


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

Y = X[0]
Ri = Y[-1]
ans = 1

j=0

for i in range(1,N):
    Y = X[i]
    if Y[1] >= Ri:
        ans+=1
        Ri = Y[-1]
print(ans)

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7

    n=I()
    lis=[[0,0] for i in range(n)]
    for i in range(n):
        x,l=LI()
        lis[i][0]=x-l
        lis[i][1]=x+l
    lis.sort(key=lambda x:x[1])
    now=-inf
    ans=0
    for i in range(n):
        if lis[i][0]>=now:
            now=lis[i][1]
            ans+=1
    print(ans)
        
        
        
        



        
        
        
        
        
    
if __name__=="__main__":
    main()

Solution (Python):
n = int(input())
arm = []
for _ in range(n):
    x, l = map(int,input().split())
    arm.append([x-l, x+l])
arm.sort(key=lambda x: x[1])
cnt = 0
pr = -float('inf')
for a in arm:
    if pr <= a[0]:
        cnt += 1
        pr = a[1]
print(cnt)

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

tmpx = arms[0][1]
ans = 1
for i in range(1, len(arms)):
  if tmpx <= arms[i][0]:
    ans += 1
    tmpx = arms[i][1]

print(ans)

Solution (Python):

def resolve():
    N = int(input())

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

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

    cnt = 0
    pre = -(1 << 60)
    for (l, r) in P:
        if pre > l:
            continue
        cnt += 1
        pre = r

    print(cnt)


if __name__ == "__main__":
    resolve()

Solution (Python):
import math
from typing import List, Any


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


def solve() -> Any:
    N = read_int()
    answer = 0
    INF = 10**10
    XL = []
    for i in range(N):
        XL.append(read_ints())
    XL.sort(key=lambda xl: xl[0]+xl[1])
    current = -INF
    for x, l in XL:
        if x-l >= current:
            answer += 1
            current = x+l
    return answer


if __name__ == '__main__':
    print(solve())

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

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

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

Solution (Python):
import sys

input = sys.stdin.readline

def main():
    N = int(input())
    P = []
    for i in range(N):
        X, L = map(int, input().split())
        S, T = X-L, X+L
        P.append((S, T))
    P.sort(key=lambda x: x[1])

    ans = 0
    r = -float('inf')
    for s, t in P:
        if s >= r:
            ans += 1
            r = t
    print(ans)

if __name__ == "__main__":
    main()

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

lis.sort()

m = -(10**9+7)
ans = 0

for i in range(n):
    a ,b = lis[i]
    if m <= b:
        ans += 1
        m = a
    
print(ans)

Solution (Python):
N = int(input())
table = []
for i in range(N):
    X,L = map(int,input().split())
    table.append((X-L,X+L))
table = sorted(table, key=lambda x:x[1])

cur = 0
l_cur, r_cur = table[0]
ans = N
for i in range(1,N):
    l,r = table[i]
    if r_cur > l:
        ans -= 1
    else:
        l_cur, r_cur = l,r
print(ans)

Solution (Python):
import numpy as np
import itertools
import queue

def accept_input():
    N = int(input())
    xl = []
    ll = []
    for _ in range(N):
        x,l = map(int,input().split())
        xl.append(x)
        ll.append(l)
    return N,xl,ll


N,xl,ll = accept_input()
tl = [x+l for x,l in zip(xl,ll)]
argtl = np.argsort(tl)
robotl = []
for i in range(N):
    if robotl == []:
        robotl.append(argtl[i])
    else:
        curx = xl[robotl[-1]]
        curl = ll[robotl[-1]]
        if curx+curl <= xl[argtl[i]] - ll[argtl[i]]:
            robotl.append(argtl[i])
print(len(robotl))

Solution (Python):
n=int(input())
p=[]
for _ in range(n):
  a,b=map(int,input().split())
  p.append([a-b,a+b])

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

ans=0
cur=(10**9)*-1
for i in range(n):
  if cur<=p[i][0]:
    
    ans+=1
    cur=p[i][1]
print(ans)

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

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

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

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

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

ans = 0
prev = -float("INF")
for l, r in LR:
    if prev <= l:
        ans += 1
        prev = r

print(ans)

Solution (Python):
n=int(input());M=sorted([[x+y,x-y]for x,y in [list(map(int,input().split()))for _ in "_"*n]]);a=1;X=M[0][0]
for x,y in M:X=max(X,x*(b:=X<=y));a+=b
print(a)

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

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

N=intput()
L=[]
for i in range(N):
    x,l=mint() 
    L.append([x+l,l])
L.sort()
tmp = -INF
ans = 0
for l in L:
    if l[0]-2*l[1]>=tmp:
        ans+=1
        tmp=l[0]
print(ans)

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

print(ans)

Solution (Python):
from operator import itemgetter

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

for i in range(n):
    XL[i].append(XL[i][0]+XL[i][1])

XL.sort(key=itemgetter(2))

cnt=1
choice=0

for i in range(n):
    if XL[choice][2]<=XL[i][0]-XL[i][1]:
        choice=i
        cnt+=1

print(cnt)

Solution (Python):
import sys



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


def input_int():
    return int(input())


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


def main():
    n = input_int()
    arms = []
    
    for _ in range(n):
        x, l = input_int_list()
        arms.append((x - l, x + l))
    arms = sorted(arms, key=lambda x: x[1])
    prev_r = -float("inf")
    cnt = 0
    for left, right in arms:
        if prev_r > left:
            continue
        cnt += 1
        prev_r = right

    print(cnt)

    return


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=sorted(R,key=lambda x:x[1])
ans=n
for i in range(1,n):
  if R[i][0]<R[i-1][1]:
    ans-=1
    R[i][1]=R[i-1][1]
  
print(ans)

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

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

for i in range(n):
    temp = 0 if a[i][0] - a[i][1] < 0 else a[i][0] - a[i][1]
    a[i][1] = a[i][0]+a[i][1]
    a[i][0] = temp

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

ans = n
right = 0
for j in a:
    if right > j[0]:
        ans -= 1
    else:
        right = j[1]

print(ans)

Solution (Python):
n = int(input())
s = [[]]*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])

n = len(s)
cnt = 1

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

print(cnt)

Solution (Python):

from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop, heapify
import copy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)





def LI(): return list(map(int, sys.stdin.buffer.readline().split()))




def I(): return int(sys.stdin.buffer.readline())





def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()




def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')







def IR(n): return [I() for i in range(n)]







def LIR(n): return [LI() for i in range(n)]







def SR(n): return [S() for i in range(n)]







def LSR(n): return [LS() for i in range(n)]







def SRL(n): return [list(S()) for i in range(n)]


def main():
    n = I()
    ranges = []
    for i in range(n):
        x, l = LI()
        ranges.append([x - l, x + l])
    ranges.sort(key=lambda x: x[1])
    ans = n
    for i in range(1, n):
        if ranges[i - 1][1] > ranges[i][0]:
            ans -= 1
            ranges[i][1] = ranges[i - 1][1]
    print(ans)


if __name__ == "__main__":
    main()

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

Solution (Python):
N = int(input())
pos_list = [[0] * 2 for i in range(N)]
for i in range(N):
    X, L = map(int, input().split())
    pos_list[i] = [X + L, X - L]
    
sorted_data = sorted(pos_list)

ans = 0
current = -(10 ** 9)
for val in sorted_data:
    if current <= val[1]:
        ans += 1
        current = val[0]
print(ans)

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

ans = 0
current = -(10 ** 9)
for val in sorted_data:
    if current <= val[1]:
        ans += 1
        current = val[0]
print(ans)

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

intervals = []

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

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

cnt = n
lastEnd = intervals[0][1]

for i in range(1, n):
    if intervals[i][0] < lastEnd:
        cnt -= 1
    else:
        lastEnd = intervals[i][1]

print(cnt)

Solution (Python):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    span = [None for _ in range(n)]
    for i in range(n):
        x, l = LI()
        span[i] = [x-l, x+l]
    span.sort(key=lambda x: x[1])
    choice = [[-float("inf"),-float("inf")]]
    for each_span in span:
        if choice[-1][1] <= each_span[0]:
            choice.append(each_span)
    
    ans = len(choice)-1
    print(ans)
main()

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

for i in range(N):
  dist[i][0] = arm[i][0] + arm[i][1]
  dist[i][1] = arm[i][0]
  dist[i][2] = arm[i][1]

dist.sort()

ans = 1
left = dist[0][1] + dist[0][2]
for i in range(1, N):
  if left <= dist[i][1] - dist[i][2]:
    ans += 1
    left = dist[i][1] + dist[i][2]

print(ans)

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

d=[1,sum(rb[0])]
for i in range(1,len(rb)):
  if sum(rb[i])<d[1]:
    d[1]=sum(rb[i])
  elif rb[i][0]-rb[i][1]>=d[1]:
    d[0]+=1
    d[1]=sum(rb[i])
print(d[0])

Solution (Python):
n=int(input())
a=[]
for _ in range(n):
    i,j=map(int,input().split())
    a+=[[i+j,i-j]]
a.sort()
b,c=-10**9,0
for i,j in a:
    if j>=b:
        c+=1
        b=i
print(c)

Solution (Python):
N=int(input())
X=[]
for i in range(N):
	x, L = map(int, input().split())
	X.append([x-L, x+L])
from operator import itemgetter

W=sorted(X, key=itemgetter(1))

ans=0
last=-float("inf")

for s, e in W:
	if s>=last:
		last=e
		ans+=1
print(ans)

Solution (Python):
N=int(input())
INF=10**20
 
X=[]
for i in range(N):
  x,l=map(int,input().split())
  X.append((x-l,x+l-1))
  
X = sorted(X,key=lambda x:x[1])

last=0
ans=1
for i in range(1,N):
  if X[last][1]<X[i][0]:
    ans += 1
    last=i
  else:
    continue
    
print(ans)

Solution (Python):
from collections import deque
N = int(input())
L = []
for _ in range(N):
  x, l = map(int, input().split())
  L.append([x-l, x+l])
L.sort(key=lambda x: x[1])
L = deque(L)
s, ans = -10**8, 0
while L:
  l = deque.popleft(L)
  if s<=l[0]:
    ans += 1
    s = l[1]
print(ans)

Solution (Python):
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
b=[[a[i][0]+a[i][1],a[i][0]-a[i][1]] for i in range(n)]
b.sort()
ans=1
tmp=b[0][0]
for i in range(n):
  if tmp<=b[i][1]:
    ans+=1
    tmp=b[i][0]
print(ans)

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

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

robot_list = []

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

delete_robot = 0
robot_list.sort()
temp_robot = robot_list[0]

for i in range(n-1):
    if temp_robot[0] > robot_list[i+1][1]:
        delete_robot += 1
    else:
        temp_robot = robot_list[i+1]

print(n - delete_robot)

Solution (Python):

from operator import itemgetter

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

st = sorted([(x[i] - l[i], x[i] + l[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):
from operator import itemgetter
n = int(input())
lis = []
for _ in range(n):
    x,l = map(int,input().split())
    lis.append([x-l,x+l])
lis.sort(key = itemgetter(1))
ans = 0
last = -float("inf")
for i in range(n):
    if lis[i][0] >= last:
        ans += 1
        last = lis[i][1]
print(ans)

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

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

now = -float("inf")
ans = 0
for left, right in XL:
    if now <= left:
        now = right
        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])
    
ls = sorted(ls, key=lambda x: x[1])
ans = n

for i in range(1,n):
    if ls[i][0] < ls[i-1][1]:
      ls[i][1] = ls[i-1][1]
      ans -=1
        
print(ans)

Solution (Python):
N,sections=int(input()),[]

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

sections.sort()

res=N
r,l=sections.pop(0)
for nr,nl in sections:
    if nl<r:
        res-=1
    else:
        r=nr
print(res)

Solution (Python):
n = int(input())
a = []
for _ in range(n):
    c0, c1 = map(int, input().split())
    a.append([c0-c1, c0+c1])
a.sort(key=lambda x: x[1])
ans, b = 1, a[0][1]
for i in a[1:]:
    if b <= i[0]:
        b = i[1]
        ans += 1
print(ans)

Solution (Python):
def main():
    n = int(input())
    A = []
    for _ in range(n):
        x, l = map(int, input().split())
        A.append([x - l, x + l])
    A.sort(key = lambda x: x[1])
    ans, lmax = 0, -10 ** 11
    for a in A:
        if lmax <= a[0]:
            ans += 1
            lmax = a[1]
    print(ans)

if __name__ == '__main__':
    main()

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

    robot.sort(key=lambda x: x[1])
    cnt = 1
    l = robot[0][1]
    for i in range(1,N):
        if l <= robot[i][0]:
            cnt += 1
            l = robot[i][1]

    print(cnt)


if __name__ == "__main__":
    main()

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

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

K=0
x=-float("inf")

for a,b in A:
    if x<=a:
        K+=1
        x=b

print(K)

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

l_list = sorted(l_list, key=lambda a:a[1])

t = l_list[0][1]
ans = 1
for i in range(1, n):
    s = l_list[i][0]
    if s < t:
        continue
    t = l_list[i][1]
    ans += 1

print(ans)

Solution (Python):

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

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])
ans = 1
length = R[0][1]
for r in R:
  if length <= r[0]:
    ans += 1
    length = r[1]

print(ans)

Solution (Python):
M,*li = [list(map(int,i.split())) for i in open(0)]
M = M[0]
row = [[x-y,x+y] for x,y in li]
row.sort(key = lambda x:x[1])
ans = 0
s = -1*float('inf')
for rs,rt in row:
    if s <= rs:
        ans += 1
        s = rt
print(ans)

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

lst = []
for _ in range(N):
  x, d = map(int, input().split())
  l = x - d
  r = x + d
  lst.append([l,r])
  
lst.sort(key=lambda x:x[1])

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

Solution (Python):
import sys
import itertools

import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines



N = int(input())
A = [0] * N
for i in range(N):
    x, l = map(int, input().split())
    A[i] = (x - l, x + l)
A = sorted(A, key=lambda x: x[1])

last = -INF
ans = 0
for l, r in A:
    if l < last:
        continue
    ans += 1
    last = r
print(ans)

Solution (Python):
N=int(input())
xl=[list(map(int,input().split()))for _ in range(N)]
rl=[[x+l,x-l]for x,l in xl]
rl.sort()
now=-10**9
ans=0
for r,l in rl:
    if l>=now:
        ans+=1
        now=r
print(ans)

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

ans=N
K=sorted(arms.keys())
now=0
count=[]
for k in K:
    now+=arms[k]
    for kk in point[k]:
        count.append(kk)
    for i in range(count.count(k)):
        count.remove(k)
    if now>=2:
        ans-=now-1
        now=1
        C=sorted(count)[::-1]
        for c in C[:-1]:
            arms[c]+=1
            count.remove(c)

print(ans)

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

Solution (Python):
import sys
import math
import itertools
import collections
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    N = NI()
    XL = [NLI() for _ in range(N)]
    
    
    arm_range = []
    for n in range(N):
        arm_range.append([XL[n][0]-XL[n][1],XL[n][0]+XL[n][1]])
    
    
    sorted_arm_range = sorted(arm_range, key=lambda x: x[1])  
    
    
    ans = 1
    arm_end = sorted_arm_range[0][1]
    
    if N == 1:
        ans = 1
    else:
        for n in range(N-1):
            if sorted_arm_range[n+1][0] >= arm_end:
                arm_end = sorted_arm_range[n+1][1]
                ans += 1

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
rng = [[] for _ in range(n)]
for i in range(n):
  x,l=map(int,input().split())
  rng[i] = [x-l,x+l]
rng.sort(key=lambda y:y[1])
cnt=0
t_mx=-(10**10)
for i in range(n):
  if t_mx > rng[i][0]:
    cnt += 1
  else:
    t_mx = rng[i][1]
print(n-cnt)

Solution (Python):
n=int(input())
rng = [[] for _ in range(n)]
for i in range(n):
  x,l=map(int,input().split())
  rng[i] = [x-l,x+l]
rng.sort(key=lambda y:y[1])
cnt=0
t_mx=-(10**10)
for i in range(n):
  if t_mx > rng[i][0]:
    cnt += 1
  else:
    t_mx = rng[i][1]
print(n-cnt)

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

for i in range(1,n):
    if ls[i][0] < ls[i-1][1]:
      ls[i][1] = ls[i-1][1]
      ans -=1
        
print(ans)

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


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

last = -float('inf')
count = 0
for i in ls:
    if last <= i[0]:
        count += 1
        last = i[1]
print(count)

Solution (Python):
from operator import itemgetter
N, *A = map(int, open(0).read().split())
X = [(x-l, x+l) for x, l in zip(*[iter(A)]*2)]
X.sort(key=itemgetter(1))
ans = 0
R = -float('inf')
for l, r in X:
    if R <= l:
        ans += 1
        R = r
print(ans)

Solution (Python):
N, *A = map(int, open(0).read().split())
X = [(x-l, x+l) for x, l in zip(*[iter(A)]*2)]
X.sort()
ans = 1
L, R = X[0]
for l, r in X[1:]:
    if R <= l:
        ans += 1
        L = l
        R = r
    elif R > r:
        R = r
print(ans)

Solution (Python):
import sys


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


N = int(input())

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

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

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

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

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

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

ans = 0
cur = -1e9
for i in range(N):
    s, t = ST[i]
    if cur <= s:
        ans += 1
        cur = t
print(ans)

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

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

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

ans = 0
cur = -1e9
for i in range(N):
    S, T = ST[i]
    if cur <= S:
        ans += 1
        cur = T
print(ans)

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

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

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

last = robo[0][1]
cnt = 1
for r in robo[1:]:
    if r[0] >= last:
        cnt += 1
        last = r[1]

print(cnt)

Solution (Python):

N = int(input())
data = []
for _ in range(N):
    X, L = map(int, input().split())
    data.append((X-L, X+L))
data = sorted(data, key=lambda x: x[1])
count = 1
j = 0
for i in range(1, N):
    if data[i][0] >= data[j][1]:
        j = i
        count += 1
print(count)

Solution (Python):
def Schedule(schedule):
    """
    :return: 複数の区間が与えられた時の重複の無い区間の選び方の最大数
    """
    schedule = sorted(schedule, key=lambda x: x[1])
    N = len(schedule)
    res = 0
    end = -float("inf")

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



import sys
input = sys.stdin.readline

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

print(Schedule(schedule))

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


ans=0
last=-float("INF")
for i in range(n):
    if last<=A[i][0]:
        ans+=1
        last=A[i][1]

print(ans)

Solution (Python):

import sys

sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read


sys.setrecursionlimit(10**7)







INF = 1 << 50



def run():
    N = int(sysread())
    XL = []
    for i in range(N):
        x,l = map(int, sysread().split())
        XL.append((x-l, l+x))
    XL = sorted(XL, key = lambda x:x[1])
    
    ans = 0
    pre_end = - (1 << 50)
    for left,right in XL:
        if pre_end <= left:
            ans += 1
            pre_end = right
    print(ans)


if __name__ == "__main__":
    run()

Solution (Python):






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





mylist = sorted(mylist,key=lambda x:x[1])
cnt = 1
p = mylist[0][1]
for i in range(1,N):
    if mylist[i][0] < p:
        continue
    else:
        cnt += 1
        p = mylist[i][1]
print(cnt)

Solution (Python):
n=int(input())
itv=[]
for i in range(n):
  x,l=map(int,input().split())
  itv+=[(x+l,x-l)]
itv=sorted(itv)
l=-10**18
cnt=0
for t,s in itv:
  if l<=s:
    l=t
    cnt+=1
print(cnt)

Solution (Python):
from sys import maxsize
N = int(input())
arms = []
for i in range(N):
    x, l = map(int, input().split())
    arms.append((x-l, x+l))

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

end = -maxsize

res = 0

for arm in arms:
    if end <= arm[0]:
        res += 1
        end = arm[1]
print(res)

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((a, b))
A = sorted(A, key = lambda x:x[1])
cnt = 0
right = -float('inf')
for i in range(n):
    if right <= A[i][0] :
        cnt += 1
        right = A[i][1]
print(cnt)

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

ans = 1
for i in range(N):
    if (i == 0):
        first = R[0][1]
        continue

    if first <= R[i][0]:
        first = R[i][1]
        ans += 1

print(ans)

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

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

R.sort()

l = -(1 << 40)

cnt = 0
for r in R:
    if l <= r[1]:
        cnt += 1
        l = r[0]

print(cnt)

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)