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())
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[0],reverse=True)
B = sorted(B,key=lambda x:x[1])
cnt = 1
cur = B[0][1]
for i in range(1,N):
    if B[i][0]>=cur:
        cnt += 1
        cur = B[i][1]
print(cnt)

Solution (Python):
N = int(input())
st = []
for i in range(N):
  x,l=map(int,input().split())
  s = max(x-l,0)
  t = min(x+l,10**9)
  st.append([t,s])
st.sort()

count = 0
lastT=0
for i in range(N):
  if st[i][1]>=lastT:
    count+=1
    lastT = st[i][0]
    
print(count)

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

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

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

for st, en in spans:
    if cur_end_time > st:
        continue
    ans += 1
    cur_end_time = en
print(ans)

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

st = [[x-l, x+l] for x, l in xl] 

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

result = 1

p = st[0][1] 
for i in range(1, n):
    if p <= st[i][0]:
        p = st[i][1] 
        result += 1 
print(result)

Solution (Python):
N=int(input())
numbers=[]
for _ in range(N):
    X,L=map(int,input().split())
    left=X-L
    right=X+L
    numbers.append([right,left])
numbers=sorted(numbers)
answer=1
large=numbers[0][0]
for  _ in range(len(numbers)-1):
    if numbers[answer][0]>large and numbers[answer][1]>=large:
        large=numbers[answer][0]
        answer+=1
    else:
        del numbers[answer]
print(answer)

Solution (Python):
from collections import *
from heapq import *
import sys
input=lambda :sys.stdin.readline().rstrip()


N=int(input())
XL=sorted([list(map(int,input().split())) for i in range(N)],key=lambda x:x[0])

lst=[0]
for i in range(1,N):

    X1,L1=XL[lst[-1]]
    X2,L2=XL[i]
    
    
    if X1+L1<=X2-L2:
        lst.append(i)
        
    else:
        if X1+L1>X2+L2:
            lst.pop()
            lst.append(i)
            

print(len(lst))

Solution (Python):
n = int(input())
xl = [list(map(int,input().split())) for _ in range(n)]
st = [[x-l, x+l] for x, l in xl]
st = sorted(st, key=lambda x: x[1])
result = 1
p = st[0][1]
for i in range(1, n):
    if p <= st[i][0]:
        p = st[i][1]
        result += 1
print(result)

Solution (Python):
from operator import itemgetter

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

for xl in XL:
    xl.append(xl[0]+xl[1])

XL.sort(key=itemgetter(2))

count=0
j=0

for i in range(1,N):
    if XL[j][2]>XL[i][0]-XL[i][1]:
        count+=1
    else:
        j=i

print(N-count)

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

from operator import itemgetter
st = sorted([[x - l, x + l] for x, l in xl], key=itemgetter(1))



last = -float('Inf')
ans = 0
for s, t in st:
    
    if s >= last:
        ans += 1
        last = t
print(ans)

Solution (Python):
N = int(input())
ts=[]
for i in range(N):
  x, l = map(int,input().split())
  s = max(x-l,0)
  t = min(10**9,x+l)
  ts.append([t,s])
ts.sort()

count = 0
lastT = 0
for i in ts:
  if i[1]>=lastT:
    count+=1
    lastT=i[0]
print(count)

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 = 0
tmp = -float('inf')
for l, r in R:
    if tmp <= l:
        ans += 1
        tmp = r
print(ans)

Solution (Python):
def solve():
    N = int(input())
    rng = []
    for i in range(N):
        X, L = map(int, input().split())
        first = X - L
        last = X + L
        rng.append((first,last))
    
    rng.sort(key=lambda x:x[1])

    prev_last = -float('inf')
    cnt = 0
    for i in range(N):
        if rng[i][0] >= prev_last:
            cnt += 1
            prev_last = rng[i][1]
    
    print(cnt)
    
if __name__ == '__main__':
    solve()

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

robots.sort()
robots_arms = [[r[0] - r[1],r[0], r[0] + r[1]] for r in robots ]
left_robot = [-float('inf')]*3
ans = 0
for robot in robots_arms:
    if left_robot[2] <= robot[0]:
        ans += 1
        left_robot = robot
    elif left_robot[2] > robot[2]:
            left_robot = robot
    else:
        left_robot = left_robot
print(ans)

Solution (Python):
N = int(input())
S = []
for i in range(N):
    xi, li = map(int, input().split())
    S.append([xi - li, xi + li])

from operator import itemgetter
S = sorted(S, key=itemgetter(1))

ans = 0
last = -1*float('Inf')
for si in S:
    if si[0] >= last:
        ans += 1
        last = si[1]

print(ans)

Solution (Python):
n = int(input())
s = []
for _ in range(n):
    x, l = map(int, input().split())
    s.append([x + l, x - l])
s.sort()
t = s[0][0]
ans = 1
for i in range(1, n):
    if s[i][1] >= t:
        ans += 1
        t = s[i][0]
print(ans)

Solution (Python):

N = int(input())

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

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

ret = 1
cur = x_l_pairs[0][1]
for left, right in x_l_pairs:
    
    if cur <= left:
        ret += 1
        cur = right

print(ret)

Solution (Python):
N = int(input())
X = []
L = []
for i in range(N) :
    p, q = map(int,input().split())
    X.append(p)
    L.append(q)

Arm = []
for i in range(N) :
    Arm.append([X[i]-L[i], X[i]+L[i]])

Arm.sort(key=lambda x:x[1])
ans = 0
mxa = -10**10
for a in Arm :
    if a[0] >= mxa :
        mxa = a[1]
        ans += 1

print(ans)

Solution (Python):
n = int(input())
robotList=[]
for i in range(n):
  x,l = map(int,input().split())
  s = max(x-l,0)
  t = min(10**9,x+l)  
  robotList.append([t,s])
  
robotList.sort()

count = 0
tmp = 0
for robot in robotList:
  if robot[1] >= tmp:
    count += 1
    tmp = robot[0]

print(count)

Solution (Python):
from sys import stdin

N = int(stdin.readline())
xl = [list(map(int, stdin.readline().split())) for _ in range(N)]

inf = 10 ** 20

left = inf
right = -inf
ans = N

lr = []

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

lr.sort()

for l, r in lr:

    if l >= right:
        right = r
        left = l
    else:
        ans -= 1
        if r < right:
            right = r
            left = l

print(ans)

Solution (Python):

n = int(input())
x_l = [0]*n
x_plus_l = [0]*n








for i in range(n):
    x,l = map(int,input().split())
    x_l[i] = x-l
    x_plus_l[i] = x+l
x_l,x_plus_l = zip(*sorted(zip(x_l,x_plus_l)))
cnt = 1
i = 1
X = min(x_plus_l)


while i < n:
    if x_l[i] >= X:
        cnt += 1
        X = x_plus_l[i]
        
    else:
        if cnt != 1:
            X = min(X,x_plus_l[i])
    i += 1
print(cnt)

Solution (Python):
from sys import stdin
input=stdin.readline
n=int(input())
l=[tuple(map(int,input().split())) for i in range(n)]
l.sort(key=lambda x:sum(x))
pre=-10**8
cnt=0
for i,j in l:
  if pre<=i-j:cnt+=1;pre=i+j
print(cnt)

Solution (Python):
N = int(input())
lst = []
for i in range(N):
    a, b = map(int, input().split())
    lst.append([a+b, a-b])
lst.sort()

cnt = 1
x = lst[0][0]
for i in lst:
    if x <= i[1]:
        cnt += 1
        x = i[0]

print(cnt)

Solution (Python):
num = int(input())
base = []
count = 0
t = -10**9

for i in range(num):
  temp = list(map(int,input().split()))
  base.append([temp[0]-temp[1],temp[0]+temp[1]])
  
base.sort(key=lambda x:x[1])

for temp in base:
  if t <= temp[0]:
    count = count + 1
    t = temp[1]
    
print(count)

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

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

intervals.sort(key=lambda ab: ab[1])
ans = 1
position = intervals[0][1]
for i in range(1,N):
  if position <= intervals[i][0]:
    ans += 1
    position = intervals[i][1]
print(ans)

Solution (Python):
n = int(input())
Y = [list(map(int,input().split())) for _ in range(n)]
X = []
for y in Y:
    X.append([y[0]+y[1],y[0]-y[1]])
X.sort()
ans = n
right = X[0][0]
for i in range(1,n):
    left = X[i][1]
    if left < right:
        ans -= 1
    else:
        right = X[i][0]
print(ans)

Solution (Python):
if __name__ == "__main__":
    n = int(input())
    robot = list()
    for i in range(n):
        x, l = map(int, input().split())
        robot.append([x - l, x + l])

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

    ans = 0
    arm_pos = -10 ** 9 - 1
    for r in robot:
        if r[0] >= arm_pos:
            ans += 1
            arm_pos = r[1]

    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])
t0 = st[0][1]
cnt = n
for s,t in st[1:]:
    if t0 <= s:
        t0 = t
    else:
        cnt -=1
print(cnt)

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()
cnt = 1
right = st[0][0]
for i in range(1, n):
    if right <= st[i][1]:
        right = st[i][0]
        cnt += 1

print(cnt)

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


migigawa = l_rng[0][1]
cnt = 1
for i in l_rng:
  if migigawa <= i[0]:
    migigawa = i[1]
    cnt = cnt +1
print(cnt)

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

Solution (Python):
def main():
    robot = int(input())
    right_lim = 0
    answer = 1
    robot_info = []
    for _ in range(robot):
        coordinate, arm_length = map(int, input().split())
        robot_info.append([coordinate - arm_length, coordinate + arm_length])
    robot_info = sorted(robot_info, key=lambda x: x[1])
    for i in range(robot):
        if i == 0:
            right_lim = robot_info[i][1]
        elif right_lim <= robot_info[i][0]:
            right_lim = robot_info[i][1]
            answer += 1
    print(answer)


if __name__ == '__main__':
    main()

Solution (Python):
from operator import itemgetter
X = []
L = []

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

robo = sorted([(X[i]-L[i], X[i]+L[i]) for i in range(n)], key=itemgetter(1))

ans = 0
end = -float("inf")
for i in range(n):
    if end <= robo[i][0]:
        ans += 1
        end = robo[i][1]

print(ans)

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

rXL = []
for i, j in XL:
    rXL.append([i - j, i + j])
rXL = sorted(rXL, key = lambda x: x[1])
TF = [True for _ in range(N)]

maxr = rXL[0][1]
for i in range(1, N):
    if maxr <= rXL[i][0]:
        maxr = rXL[i][1]
    else:
        TF[i] = False

print(sum(TF))

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

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

a.sort()

ans = 0
b = - float('inf')
for t, s in a:
    if s >= b:
        b = t
        ans += 1

print(ans)

Solution (Python):
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
import sys
input = sys.stdin.readline

sys.setrecursionlimit(2147483647)

def main():
  n = int(input())
  
  L = []
  for i in range(n):
    x, l = map(int, input().split())
    L.append((x-l, x+l))
  L = sorted(L, key = itemgetter(1))
  r_max = -10 ** 18
  ans=0
  for i in range(n):
    l_end, r_end = L[i]
    if r_max <= l_end:
      ans+=1
      r_max = r_end
  print(ans)
  
  
  
if __name__ == '__main__':
  main()

Solution (Python):
from operator import itemgetter

def solve():
    N = int(input())
    X = []
    for i in range(N):
        xx, ll = map(int, input().split())
        X.append((xx-ll, xx+ll))
    X.sort(key=itemgetter(1))
    count = 0
    cur = -float('inf')
    for i in range(N):
        c, d = X[i]
        if cur <= c:
            count += 1
            cur = d
    return count

print(solve())

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):
n = int(input())

l = []
for _ in range(n):
    tmp = list(map(int,input().split()))
    l.append([tmp[0] - tmp[1],tmp[0] + tmp[1]])

l.sort()
l = l[::-1]
now = l[0][0]
ans = 1
for i in range(1,n):
    if now >= l[i][1]:
        now = l[i][0]
        ans += 1

print(ans)

Solution (Python):
n=int(input())
l=[]
for i in range(n):
  x,y=map(int,input().split())
  l.append([x-y,x+y])
count=0
l=sorted(l)
l=l[::-1]
count+=1
now=l[0][0]
for i in range(1,n):
  if now>=l[i][1]:
    now=l[i][0]
    count+=1
  else:
    pass
print(count)

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

Solution (Python):
n=int(input())
a=[]
for i in range(n):
  x,l=map(int,input().split())
  a.append([x+l,max(0,x-l)])
a.sort()
r=0
c=0
for i in range(n):
  if a[i][1]>=r:
    r=a[i][0]
    c+=1
print(c)

Solution (Python):
from collections import deque
N = int(input())
lis = []
ans = []
lis_append=lis.append
for i in range(N):
    x,l = map(int, input().split(" "))
    lis_append((x+l,x-l))
lis.sort()
lis = deque(lis)
ans.append(lis.popleft())
while lis:
    a = lis.popleft()
    if a[1] >= ans[-1][0]:
        ans.append(a)
print(len(ans))

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

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(key=lambda x: x[1])
t = rob[0][0]
ans = 0
for l, r in rob:
  if t <= l:
    ans += 1
    t = r
print(ans)

Solution (Python):
n=int(input())
arms=[]
for _ in range(n):
    x,l=map(int,input().split())
    arms.append([x-l,x+l])
arms.sort()
now=arms[0][1]
cnt=0
for arm in arms[1:]:
    if now<=arm[0]:
        now=arm[1]
    elif now<=arm[1]:
        cnt+=1
    else:
        cnt+=1
        now=arm[1]
print(n-cnt)

Solution (Python):
from operator import itemgetter

n = int(input())

robots = [tuple(map(int, input().split())) for _ in range(n)]
robots = sorted([(x-t, x+t) for x, t in robots], key=itemgetter(1))

counter = 1
now = robots[0][1]
for robot in robots[1:]:
    if now <= robot[0]:
        counter += 1
        now = robot[1]

print(counter)

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

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

arms.sort()

trash_count = 0
focus_point = 0

focus_point = arms[0][1]
for arm in arms[1:]:
    if focus_point <= arm[0]:
        focus_point = arm[1]
    elif focus_point <= arm[1]:
        trash_count += 1
    else:
        trash_count += 1
        focus_point = arm[1]

print(N-trash_count)

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

lis = sorted(lis, key=lambda x:x[2])
lis = deque(lis)

end = lis[0][2]
start = lis[0][1]
lis.popleft()
cnt = 1
while lis:
    x, y, z = lis.popleft()
    if y < end:
        continue
    elif y >= end:
        start = y
        end = z
        cnt += 1

print(cnt)

Solution (Python):
N=int(input())
L=[list(map(int,input().split())) for i in range(N)]
R=[]
for i in range(N):
  a=max(0,L[i][0]-L[i][1])
  b=L[i][0]+L[i][1]
  R.append([b,a])
R.sort()

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

Solution (Python):
def main():
    n = int(input())
    robot = [None]*n
    for i in range(n):
        x, arm = map(int, input().split())
        robot[i] = [x - arm, x + arm]
    robot.sort(key=lambda x: x[1])
    ans = 0
    x = -1 * (10)**9
    for i in range(n):
        if x <= robot[i][0]:
            ans += 1
            x = robot[i][1]
    print(ans)

if __name__ == "__main__":
    main()

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)

'''
①入力
N=int(input())
XL=[list(map(int,input().split())) for i in range(N)]
Nはロボットの個数
XLは座標Xと腕の長さLのリスト

②リストの編集
ロボットの腕の始点(a)と終点(b)を保存するリスト(R)を作成する

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()
リストRは終点昇順でソートしておく

③区間スケジューリング＆出力
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)
ansは選んだロボットの個数
con_lは最後に選んだロボットの腕の終点

forループ内の処理は最後に選んだロボットの終点(con_l)より大きい始点(R[i][1])を持つロボットを貪欲的に探索するようになっている
Rは終点昇順でソートしてあるため、探索していく中で最小の終点のものを常に選択するようになっている
見つかるたびにansに+1してcon_lを更新する
出力して終了
'''

Solution (Python):
from sys import stdin
N = int(stdin.readline().rstrip())
data = []
for i in range(N):
    X,L = [int(x) for x in stdin.readline().rstrip().split()]
    data.append((X+L,X-L))

ans = 0
left = -10**9-1
for k,j in sorted(data):
    if j >= left:
        left = k
        ans += 1
print(ans)

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

P = [0] * 150

robot = []

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

    left = X-L
    right = X+L

    
    robot.append([right,left])

robot = sorted(robot)

cnt = 0 
last_right = -float('inf') 

for i in range(N):
    if last_right <= robot[i][1]:
        cnt += 1
        last_right =  robot[i][0]

print(cnt)

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

Solution (Python):
n = int(input())
xl = [list(map(int, input().split())) for _ in range(n)]
ran = [[xl[i][0]-xl[i][1], xl[i][0]+xl[i][1]] for i in range(n)]
ran = sorted(ran, key=lambda x:x[1])
ans = 1
right = ran[0][1]
for i in range(n):
  l, r = ran[i]
  if l >= right:
    ans += 1 
    right = r 

print(ans)

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

Solution (Python):
n = int(input())
robot = []
for i in range(n):
    x, l = map(int,input().split())
    robot.append([x + l, x - l]) 
robot.sort()
preright = robot[0][1]
ans = 0
for i in range(n):
    left = robot[i][1]
    
    if preright <= left:
        ans += 1
        preright = robot[i][0]
print(ans)

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

ans = N
for i in l:
    x = 0 if i[0]-i[1] < 0 else i[0]-i[1]
    i[1] = i[0]+i[1]
    i[0] = x
    
l.sort(key=lambda x:x[1])

right = 0
for i in range(N):
    if right > l[i][0]:
        ans-=1
    else:
        right = l[i][1]

print(ans)

Solution (Python):
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])
before = -10**9
ans = 0

for i, j in l:
    if i>=before:
        ans += 1
        before = j

print(ans)

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

r = -10**10
ans = 0
for i in b:
	if i[1] >= r:
		ans += 1
		r = i[0]
	else:
		continue
print (ans)

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


L = [[0,0,0,0] for i in range(N)]
t=-1*(10**9)
s=0
for i in range(N):
    L[i][0],L[i][1] = map(int,input().split())
    L[i][2]=L[i][0]+L[i][1]
    L[i][3]=L[i][0]-L[i][1]

L=sorted(L,key=lambda x: x[2])

for i in range(N):
    if(t<=L[i][3]):
        s+=1
        t=L[i][2]

print(s)

Solution (Python):
N = int(input())
X = [0]*N
L = [0]*N
Y = []

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

Y.sort()

count = 0
length = -10**10
for i in range(N):
    if Y[i][1] >= length:
        count += 1
        length = Y[i][0]

print(count)

Solution (Python):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N, *xl = map(int, read().split())
    XL = []

    for x, l in zip(*[iter(xl)]*2):
        XL.append((x-l, x+l))

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

    ans = 0
    end = -10**9
    for s,e in XL:
        if s >= end:
            ans += 1
            end = e
    
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
N=int(input())
X=[]
for i in range(N):
    a,b=map(int,list(input().split(" ")))
    X.append([a+b,a-b])
X.sort()
D={}
D[0]=1
exe=[0]
for i in range(1,N):
    k=X[i][0]
    if X[i][1]<X[exe[-1]][0]:
        D[i]=D[exe[-1]]
    else:
        D[i]=D[exe[-1]]+1
        exe.append(i)
print(len(exe))

Solution (Python):
N = int(input())
a = []
for i in range(N):
	X, L = map(int, input().split())
	a.append((X + L, X - L))
a.sort()
b = [a[0][0]]
i = 1
while i < N:
	if b[len(b) - 1] <= a[i][1]:
		b.append(a[i][0])
	i += 1
print(len(b))

Solution (Python):
INF = float("inf") 

def main():
    n = int(input())
    ls = [list(map(int,input().split())) for _ in range(n)]
    
    robot = [(ls[i][0] + ls[i][1],ls[i][0] - ls[i][1]) for i in range(n)]
    robot = sorted(robot,key = lambda x: x[0])
    

    ans = 0; latest = -INF
    for i in range(n):
        if latest <= robot[i][1]:
            ans += 1
            latest = robot[i][0]
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
xllist=[list(map(int,input().split())) for _ in range(n)]
s_e=[]
for xl in xllist:
    s_e.append([xl[0]-xl[1],xl[0]+xl[1]])
s_e.sort(key=lambda x: x[1])
now=s_e.pop(0)[1]
ans=1
for xl in s_e:
    if now<=xl[0]:
        ans+=1
        now=xl[1]
print(ans)

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

Solution (Python):
from operator import itemgetter

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

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

x=sorted(x,key=itemgetter(1))
ans=1
r=x[0][1]
for i in range(1,n):
    if r<=x[i][0]:
        ans+=1
        r=x[i][1]

print(ans)

Solution (Python):
N = int(input())
robot_list = []
for i in range(N):
  X, L = map(int, input().split())
  left_edge = X - L
  right_edge = X + L
  robot_list.append([left_edge, right_edge])

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

res = 0
index = - pow(10, 10)
for i in range(N):
  if robot_list[i][0] >= index:
    index = robot_list[i][1]
    res += 1

print(res)

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

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

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

armmax=-10**10
cnt=0
for left,right,x in xl:
    if armmax<=left:
        armmax=right
        cnt+=1

print(cnt)

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

ts.sort()
ans = 0
T = float("inf") * - 1
for i in range(n):
    if T <= ts[i][1]:
        ans += 1
        T = ts[i][0]

print(ans)

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

cur=-10**9
ans=0
for xx in x:
    if xx[1]>=cur:
        ans+=1
        cur=xx[0]
print(ans)

Solution (Python):
from operator import itemgetter

N = int(input())
R = [0]*N
for i in range(N):
    X_i, L_i = map(int, input().split())
    R[i] = (X_i-L_i,X_i+L_i)
R.sort(key=itemgetter(1))

ans, loc = 0, -(float('inf'))
for i in range(len(R)):
    if loc <= R[i][0]:
        ans += 1
        loc = R[i][1]
print(ans)

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

for i in range(N):
    X, L = map(int, input().split())
    X1.append([X+L, X-L])
X1.sort()
ans = -10**10
cnt = 0
for j in range(N):
    if(X1[j][1] >= ans):
        cnt += 1
        ans = X1[j][0]
print(cnt)

Solution (Python):
import sys
N = int(input())
a = sorted([(x+l, x-l) for x, l in (map(int, l.split()) for l in sys.stdin)])

last = a[0][0]
ans = 1

for r, l in a[1:]:
    if(last <= l):
        ans += 1
        last = r
print(ans)

Solution (Python):
import sys
N = int(input())
a = sorted([(x + l, x - l) for x, l in (map(int, l.split()) for l in sys.stdin)])

last = a[0][0]
ans = 1

for r, l in a[1:]:
    if last <= l:
        ans += 1
        last = r

print(ans)

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

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

previous = 0
total = 1

for i in range(1, N):
  if newXL[i][0] < newXL[previous][1]:
    pass
  else:
    previous = i
    total += 1
    
print(total)

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

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

L.sort(key=lambda x:x[1])
ans=0
cur=-11111111111111111
for a,b in L:
  if a>=cur:
    cur=b
    ans+=1
print(ans)

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

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


c = sorted(zip(e_p, s_p))
e_p, s_p = zip(*c)


e = -float('inf')
count = 0
for i in range(N):
    if s_p[i] >= e:
        count += 1
        e = e_p[i]
print(count)

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

xl = []

for i in range(n):
    x,l = map(int,input().split())
    xl.append([x+l,x-l])
xl.sort()
ans = -10**10
count = 0
for j in range(n):
    if xl[j][1] >= ans:
        count +=1
        ans = xl[j][0]
print(count)

Solution (Python):
N = int(input())
R = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x:x[0]+x[1])

remain = list(range(N))
ans = N
left = 0
i = 1
while i < N:
  x_l, length_l = R[left]
  x, length = R[i]
  if x-x_l < length_l+length:
    ans -= 1
  else:
    left = i
  i += 1
print(ans)

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

s = []
f = []
res = 1

for i in range(n):
    s.append(l[i][0]-l[i][1])
    f.append([l[i][0]+l[i][1], i])
    
f = sorted(f)


m = f[0][0]
for i in range(1, n):
    if s[f[i][1]] >= m:
        res += 1
        m = f[i][0]
    
print(res)

Solution (Python):
n = int(input())
l = []
for _ in range(n):
  x,y = map(int, input().split())
  l.append([x+y,x-y])
l=sorted(l)
 
tmp = l[0][0]
count = n
for p in l[1:]:
  if tmp <= p[1]:
    tmp = p[0]
  else:
    tmp = min(tmp,p[0])
    count -= 1
print(count)

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

lis.sort()
a = -10 ** 10
x = 0

for b in range(n):
  if lis[b][1] >= a:
    x += 1
    a = lis[b][0]

print(x)

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

lis.sort()
a = -10 ** 10
x = 0

for b in range(n):
  if lis[b][1] >= a:
    x += 1
    a = lis[b][0]

print(x)

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

mlist=[]
for i in range(N):
    mlist.append([TS[i][0] + TS[i][1], TS[i][0] - TS[i][1]])

mlist.sort()

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

Solution (Python):
H = int(input())
x = [[float('inf')]*2 for i in range(H)]

for i in range(H):
    X, L = map(int, input().split())
    x[i][0] = X - L
    x[i][1] = X + L

from operator import itemgetter
sf = sorted(x, key=itemgetter(1))

ans = 0
last = float('inf')*-1

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

print(ans)

Solution (Python):
H = int(input())
x = [[float('inf')]*2 for i in range(H)]

for i in range(H):
    X, L = map(int, input().split())
    x[i][0] = X - L
    x[i][1] = X + L

from operator import itemgetter
sf = sorted(x, key=itemgetter(1))

ans = 0
last = float('inf')*-1

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

print(ans)

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


st = [(xl[i][0]-xl[i][1],xl[i][0]+xl[i][1]) for i in range(n)]

st.sort(key=lambda x:x[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 = [list(map(int,input().split())) for i in range(n)]

XL.sort(key = lambda x:sum(x))
ans = 0
f = -1000000001
for x,l in XL:
    if x - l >= f:
        ans += 1
        
        f = x + l
print(ans)

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

XL.sort(key=lambda x: sum(x))
f = -99999999999
ans = 0
for x, l in XL:
    if x - l >= f:
        ans += 1
        f = x + l

print(ans)

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

d = []
for x, l in XL:
    d.append([x + l, l])

d.sort()

inf = float('inf')

pre = - inf
ans = N
for dd in d:
    if dd[0] - 2 * dd[1] < pre:
        ans -= 1
    else:
        pre = dd[0]

print(ans)