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 math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    xl = sorted([LI() for _ in range(n)], key=lambda x: [sum(x), x])
    r = 0
    c = -inf
    for x,l in xl:
        if x-l >= c:
            r += 1
            c = x+l

    return r


print(main())

Solution (Python):

si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n=ni()
l=[]
for i in range(n):
    a,b=nm()
    l.append([a+b,a-b])
l.sort(key=lambda x:x[0])

cur=-10**9
ans=0
for ll in l:
    if ll[1]>=cur:
        ans+=1
        cur=ll[0]
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 = sorted(robots, key=lambda x: x[1])
robots.append([-2*10**9, 2*10**9])

cnt = 1
current_end = robots[0][1]
for i in range(1, n):
    if current_end <= robots[i][0]:
        cnt += 1
        current_end = robots[i][1]

print(cnt)

Solution (Python):
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
A.sort(key=lambda x:x[0])
X = []
L = []
for l in A:
    X.append(l[0])
    L.append(l[1])

pl = X[0] + L[0]
k = 0
for i in range(1, N):
    pr = X[i] - L[i]
    if pl > pr:
        k += 1
        pl = min(pl, X[i] + L[i])
    else:
        pl = X[i] + L[i]


print(N - k)

Solution (Python):
from operator import itemgetter

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

for i in range(n):
    x = XLs[i][0]
    l = XLs[i][1]
    XLs[i].append(x+l)



XLs.sort(key=itemgetter(2))

choice = -10**10
cnt = 0
for i in range(n):
    x = XLs[i][0]
    l = XLs[i][1]

    if choice <= x-l:
        choice = x+l
        cnt += 1

print(cnt)

Solution (Python):
N = int(input())
XL = [tuple(map(int, input().split())) for _ in range(N)]
XL.sort(key=lambda x: x[0]+x[1])
cnt = 0
now = 10 ** 9 * -1
for x, l in XL:
    if now <= x - l:
        cnt += 1
        now = x + l

print(cnt)

Solution (Python):



from operator import itemgetter


n = int(input())

in_list = list()

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

in_list.sort(key=itemgetter(3))


wkx_a = in_list[0][0]
wkl_a = in_list[0][1]
wkxr_a = in_list[0][3]
ans = 1

for i in range(1, n):
    x = in_list[i][0]
    l = in_list[i][1]
    if wkxr_a <= in_list[i][2]:
        wkx_a = x
        wkl_a = l
        wkxr_a = in_list[i][3]
        ans = ans + 1


print(ans)

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

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

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

left=-float('inf')
count=0
for i in range(n):
    if a[i][2]>=left:
        count+=1
        left=a[i][3]

print(count)

Solution (Python):

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

res = 1
t = A[0]
for i in range(1,a):
    l = A[i]
    
    if t[0] < l[0] :
        if l[1]-l[2]<t[0]<l[0]:continue
        else:
            res+=1
            t = l
    elif t[0] > l[0]: 
        if l[1]-l[2]<t[1]-t[2]<l[0]:continue
        else:
            res+=1
            t = l
print(res)

Solution (Python):
a = int(input())
A = []
for i in range(a):
    x,L = map(int,input().split())
    A.append([x+L,x-L])
A.sort()

res = 1
t = A[0]
for i in range(1,a):
    l = A[i]
    if t[0] <= l[1]:
        t = l
        res+=1
print(res)

Solution (Python):
n=int(input())
sec=[list(map(int,input().split())) for i in range(n)]
for i in range(n):
    sec[i][0]+=sec[i][1]
    sec[i][1]*=-2
    sec[i][1]+=sec[i][0]
sec.sort()

ans=0

t=-10000000000
for i in range(n):
    
    if t<=sec[i][1]:
        ans+=1
        t=sec[i][0]
print(ans)

Solution (Python):

import sys
INF = float("inf")


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

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

    last = -INF
    count = 0
    for i in range(N):
        if last <= segs[i][0]:
            last = segs[i][1]
            count += 1
    print(count)

    return


def main():

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


if __name__ == '__main__':
    main()

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

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

I.sort(key=lambda a: (a[1], a[0]))

x = -10**100
ans = 0
for l, r in I:
  if l >= x:
    ans += 1
    x = r

print(ans)

Solution (Python):
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

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

N=one_int()

machines = []

for i in range(N):
    X,L=two_int()
    minL=max(1,X-L)
    maxL=X+L
    machines.append([X,L, minL, maxL])



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

output=[[0,0,0,0]]
for m in machines:
    if output[-1][3] <= m[2]:
        output.append(m)

print(len(output)-1)

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

lr = []
for i in range(n):
    l = max(xl[i][0] - xl[i][1], 0)
    r = max(xl[i][0] + xl[i][1], 0)
    lr.append([l, r])

lr.sort(key=lambda x: x[1])
keep = [False] * n


cur = 0
for i in range(n):
    if cur <= lr[i][0]:
        keep[i] = True
        cur = lr[i][1]

ans = sum(keep)
print(ans)

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

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

ans = 0
tmp = -10**9

for s, t in ll:
  if s >= tmp:
    ans += 1
    tmp = t

print(ans)

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

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

ans = 0
tmp = -10**9

for l in ll:
  if l[0] >= tmp:
    ans += 1
    tmp = l[1]

print(ans)

Solution (Python):
import sys
n = int(input())
xl = []
for _ in range(n):
    x, l = map(int, input().split())
    xl.append((x, l))
xl.sort(key=lambda x:x[0])
if n==1:
    print(1)
    sys.exit(0)
i=0
j=1
ans=n
while j<len(xl):
    if xl[i][0]+xl[i][1] <= xl[j][0]-xl[j][1]:
        i = j
        j = i+1
    else:
        ans -= 1
        if xl[i][0]+xl[i][1] < xl[j][0]+xl[j][1]:
            j += 1
        else:
            i = j
            j = i+1
print(ans)

Solution (Python):


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

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

arm.sort()

lowest = float("-inf")
cnt = 0

for x,l in arm:
    if l>=lowest:
        lowest = x
        cnt += 1

print(cnt)

Solution (Python):
import sys


def main():
    input = sys.stdin.readline
    N = int(input())

    robots = list()

    for i in range(N):
        x, arm = map(int, input().split())
        right = x+arm
        robots.append([x, right])

    robots.sort(key=lambda x: x[1])
    count = 0
    last_r = -10**10
    for x, r in robots:
        l = x - (r - x)
        if l < last_r:
            count += 1
        else:
            last_r = r

    print(N - count)


if __name__ == '__main__':
    main()

Solution (Python):

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)

def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max,mod=DIV):
    fac,finv,inv = [0]*max, [0]*max, [0]*max
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod -inv[mod%i] * (mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
    class CONV:
        def __init__(self):
            pass
        def ncr(self,n,k):
            if(n<k):
                return 0
            if(n<0 or k<0 ):
                return 0
            return fac[n]*(finv[k]*finv[n-k]%mod)%mod
    return CONV()



def main():
    N = iRaw()
    XLs = [isRaw() for _ in range(N)]
    XLs.sort(key = lambda xl:xl[0]+xl[1])
    curX = -(10**10)
    curL = 0
    ans = 0
    for X,L in XLs:
        if curX+curL <= X-L:
            ans+=1
            curX = X
            curL = L
    return ans


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

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

Solution (Python):
n,*t=map(int,open(0).read().split())
*z,=sorted(zip(*[iter(t)]*2))
s=set()
for i in range(n-1):
    if i in s:
        continue
    x,l=z[i]
    j=i+1
    while 1:
        y,r=z[j]
        if x+l>y-r:
            if y+r<x+l:
                s|={i}
                break
            else:
                s|={j}
        else:
            break
        j+=1
        if j==n:break
print(n-len(s))

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

ans = 0
tmp = -10**9

for l in ll:
  if l[0] >= tmp:
    ans += 1
    tmp = l[1]

print(ans)

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

lr = []
for i in range(n):
    l = max(xl[i][0] - xl[i][1], 0)
    r = max(xl[i][0] + xl[i][1], 0)
    lr.append([r, l])

lr = sorted(lr)
keep = [False] * n


cur = 0
for i in range(n):
    if cur <= lr[i][1]:
        keep[i] = True
        cur = lr[i][0]
'''
for j in range(n - 1):
    if keep[j]:
        if lr[j][0] == lr[j + 1][0]:
            keep[j + 1] = False
        elif lr[j][0] < lr[j + 1][0]:
            keep[j + 1] = False
'''

ans = sum(1 for x in range(n) if keep[x])
print(ans)

Solution (Python):

def main():
    n = int(input())
    inputs = [input().split() for i in range(n)]
    inputs_list = []
    for i in inputs:
        if int(i[0]) - int(i[1]) < 0:
            inputs_list.append([0, int(i[0]) + int(i[1])])
        else:
            inputs_list.append([int(i[0]) - int(i[1]), int(i[0]) + int(i[1])])
    sorted_data = sorted(inputs_list, key=lambda x: (x[1]))

    ans = [sorted_data[0]]
    cur = ans[0][1]
    for i in range(len(sorted_data) - 1):
        if cur <= sorted_data[i + 1][0]:
                ans.append(sorted_data[i + 1])
                cur = sorted_data[i + 1][1]
    print(len(ans))


if __name__ == '__main__':
    main()

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

ans = 0
tmp = -10**9

for s, t in ll:
  if s >= tmp:
    ans += 1
    tmp = t

print(ans)

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, key=lambda x: x[1])

ans = 0
tmp = -10**9

for s, t in ll:
  if s >= tmp:
    ans += 1
    tmp = t

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


cur_r = LR[0][1]
c = 1
for l, r in LR[1:]:
    if cur_r <= l:
        c += 1
        cur_r = r
print(c)

Solution (Python):
N = int(input())
r = [list(map(int, input().split())) for _ in range(N)]
a = []
for i in r:
    a.append((i[0]-i[1],i[0]+i[1]))
a.sort(key=lambda x:x[1])
ans = 0
cur = -float('inf')
for i in a:
    if i[0] < cur:
        continue
    ans += 1
    cur = i[1]
print(ans)

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

    ans = 0
    max = -10**9

    for r in robo:
        if r[0] >= max:
            ans += 1
            max = r[1]
    print(ans)
    return 0

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
r = [list(map(int, input().split())) for _ in range(N)]
a = []
for i in r:
    a.append((i[0]+i[1],i[0]-i[1]))
a.sort()
ans = 0
cur = -float('inf')
for i in a:
    if i[1] < cur:
        continue
    ans += 1
    cur = i[0]
print(ans)

Solution (Python):
n=int(input())
lists=[]
for i  in range(n):
    x,y=map(int,input().split())
    lists.append((x-y,x+y))
lists=sorted(lists,key=lambda x:(x[1]))
A=1
P=lists[0]
for i in range(1,len(lists)):
    if lists[i][0]>=P[1]:
        A+=1
        P=lists[i]
print(A)

Solution (Python):



n = int(input())
lo = []
sh = []

result = 0

MAX = -(10**20)

for i in range(n):
    a,b =map(int, input().split())
    lo.append(a-b)
    sh.append(a+b)
    
c=zip(lo,sh)
d = sorted(c, key=lambda x:x[1])

for i in range(n):
    if MAX <= d[i][0]:
        result += 1
        MAX=d[i][1]

print(result)

Solution (Python):
N = int(input())
r = [list(map(int, input().split())) for _ in range(N)]
a = []
for i in r:
    a.append((i[0]+i[1],i[0]-i[1]))
a.sort()
ans = 0
cur = a[0][1]
for i in a:
    if i[1] < cur:
        continue
    ans += 1
    cur = i[0]
print(ans)

Solution (Python):
n=int(input())
lo=[]
sh=[]

result=0

MAX = -(10**20)

for i  in range(n):
    xx,ll=map(int, input().split())
    lo.append(xx+ll)
    sh.append(xx-ll)
    

c=zip(sh,lo)
d=sorted(c,key=lambda x:x[1])

for i in range(n):
    if MAX <= d[i][0]:
        result+=1
        MAX=d[i][1]

print(result)

Solution (Python):
N = int(input())
XL = [tuple(map(int,input().split())) for i in range(N)]
XL.sort(key=lambda x: x[0]+x[1])
right = -float('inf')
ans = 0
for x,l in XL:
    s,t = x-l, x+l
    if s >= right:
        right = t
        ans += 1
print(ans)

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

ra.sort(key=lambda x:x[1])
t = ra[0][1]
ans = 1
for i in range(1,n):
    if ra[i][0] >= t:
        ans += 1
        t = ra[i][1]

print(ans)

Solution (Python):


import sys
input=sys.stdin.readline

n=int(input())

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

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

pre_x=xl[0][1]

cnt=0
for i in range(1,n):
    if xl[i][0]<pre_x:
        cnt+=1
    else:
        pre_x=xl[i][1]
print(n-cnt)

Solution (Python):
from operator import itemgetter

N=int(input())
grid=[]
for i in range(N):
    xi,li=map(int,input().split())
    grid.append((xi-li,xi+li))
grid = sorted(grid, key=itemgetter(1))
res=1
cur=grid[0]

for i, a in enumerate(grid):
    if i==0:
        continue
    if a[0]>=cur[1]:
        res+=1
        cur=a
print(res)

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

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

leave = [P[0]]
for i in range(1, N):
    
    leave_max = leave[-1][0] + leave[-1][1]
    p_min = P[i][0] - P[i][1]
    if leave_max <= p_min:
        leave.append(P[i])
    else:
        continue
        
print(len(leave))

Solution (Python):
def resolve():
    import sys
    from operator import itemgetter
    readline = sys.stdin.readline
    N = int(readline())
    LR = [None] * N
    for i in range(N):
        p, l = map(int, input().split())
        LR[i] = [p-l, p+l]
    LR.sort(key=itemgetter(1))

    pre_r = -(10**18)
    count = 0
    for l, r in LR:
        if pre_r <= l:
            count += 1
            pre_r = r
    print(count)

resolve()

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


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


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def f(A):
    min_num = A[0] + A[-1]


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

    res = 0
    T = None    
    for r in R:
        if T is None or r[0] >= T:
            T = r[1]
            res += 1

    print(res)


if __name__ == "__main__":
    main()

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

ans = 0
current = float('-inf')
for x, l in XL:
    if current <= x - l:
        current = x + l
        ans += 1
print(ans)

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

cnt = 0
reach = None
for l, r in lr:
    if reach is not None and l < reach:
        continue
    reach = r
    cnt += 1
print(cnt)

Solution (Python):
N = int(input())
XL = [tuple(map(int,input().split())) for i in range(N)]
XL.sort(key=lambda x: x[0]+x[1])
right = -float('inf')
ans = 0
for x,l in XL:
    s,t = x-l, x+l-1
    if s > right:
        right = t
        ans += 1
print(ans)

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

XL = sorted(XL, key=lambda x: x[0]+x[1])

ans = 1
right = XL[0][0] + XL[0][1]

for i in range(1, N):
    if right <= XL[i][0] - XL[i][1]:
        right = XL[i][0] + XL[i][1]
        ans += 1

print(ans)

Solution (Python):
N = int(input())
lr = [[0,0]]*N

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

ans = 1
now_r = lr_s[0][1]

for i in range(1,N):
    next_l = lr_s[i][0]
    next_r = lr_s[i][1]
    if now_r > next_l: 
        now_r = min(now_r,next_r)
        
    else:
        
        ans += 1
        now_r = next_r
        
print(ans)

Solution (Python):
N = int(input())
XL = [tuple(map(int,input().split())) for i in range(N)]
XL.sort(key=lambda x: x[0]+x[1])
right = -float('inf')
ans = 0
for x,l in XL:
    s,t = x-l, x+l-1
    if s > right:
        right = t
        ans += 1
print(ans)

Solution (Python):

N = int(input())
S = []
T = []
for i in range(N):
    X_temp, L_temp = map(int, input().split())
    S.append(X_temp - L_temp)
    T.append(X_temp + L_temp)


import numpy as np
S = np.array(S)
T = np.array(T)
idx = np.argsort(T)

S = S[idx]
T = T[idx]
answer = 0
length = -10**10
for i in range(N):
    if length <= S[i]:
        answer += 1
        length = T[i]

print(answer)

Solution (Python):
import math
import sys

m=10**9 + 7 
sys.setrecursionlimit(1000010)
INF=10 ** 10
N = int(input())
XL = [list(map(int,input().split())) for _ in range(N)]
XLs =sorted([ [xl[0]+xl[1],xl[0]-xl[1]] for xl in XL ])


t = -INF 
n = 0

for xl in XLs:
    if t <= xl[1]:
        t = xl[0]
        n = n + 1
print(n)

Solution (Python):
N = int(input())
XL = [tuple(map(int,input().split())) for i in range(N)]
XL.sort(key=lambda x: x[0]+x[1])
right = -float('inf')
ans = 0
for x,l in XL:
    s,t = x-l, x+l
    if s >= right:
        right = t
        ans += 1
print(ans)

Solution (Python):

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

tmp= x[0]
for i in range(n-1):
    if tmp[1] <= x[i+1][0]:
        tmp = x[i+1]
    elif tmp[1] <= x[i+1][1]:
        ans -= 1
    else:
        tmp = x[i+1]
        ans -= 1
print(ans)

Solution (Python):
N = int(input())
XL = [tuple(map(int,input().split())) for i in range(N)]
XL.sort(key=lambda x: x[0]+x[1])
right = -float('inf')
ans = 0
for x,l in XL:
    s,t = x-l, x+l-1
    if s > right:
        right = t
        ans += 1
print(ans)

Solution (Python):
from operator import itemgetter

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

for _ in range(N):
    a, b = map(int, input().split())
    A.append((a - b, a + b))
A.sort(key=itemgetter(1))

res = 1
cur = A[0]

for i, a in enumerate(A):
    if i == 0:
        continue
    if a[0] >= cur[1]:
        res += 1
        cur = a

print(res)

Solution (Python):
N = int(input())
XL = [tuple(map(int,input().split())) for i in range(N)]
XL.sort(key=lambda x: x[0]+x[1])
right = -float('inf')
ans = 0
for x,l in XL:
    s,t = x-l, x+l
    if s >= right:
        right = t
        ans += 1
print(ans)

Solution (Python):
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 S(): return input()


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


def MS(): return map(str, 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 erase_overlap_intervals(intervals):
        """
        :type intervals: List[Interval]
        :rtype: int
        """
        result, prev = 0, 0
        for i in range(1, len(intervals)):
            if intervals[i][0] < intervals[prev][1]:
                if intervals[i][1] < intervals[prev][1]:
                    prev = i
                result += 1
            else:
                prev = i
        return result


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

    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])
    print(N - erase_overlap_intervals(arr))


if __name__ == '__main__':
    main()

Solution (Python):
import math,sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
lili=lambda:list(map(int,sys.stdin.readlines()))
li = lambda:list(map(int,input().split()))

I=lambda:int(input())
S=lambda:input().strip()
mod = 1000000007

n=I()
a=[]
b=[]
for i in range(n):
    x,l=li()
    a.append([x-l,x+l])
a.sort()
l,r=a[0][0],a[0][1]

c=0
d=0
for i in range(1,n):
    k=a[i]
    p,q=k[0],k[1]
    if(l<=p and r>=q):
        l,r=p,q
        c+=1
    elif(r<p):
        l,r=p,q
    elif(r==p):
        l,r=p,q
    else:
        c+=1


print(n-c)

Solution (Python):
n = int(input())
robots = []
for i in range(n):
    x_tmp, l_tmp = (int(i) for i in input().split())
    robots.append([x_tmp - l_tmp, x_tmp + l_tmp])

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

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

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

cnt=0
min=-10**18

for r,l in list:
 if min<=r:
  cnt+=1
  min=l
print(cnt)

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

arm_range = sorted(arm_range)

limit = arm_range[0][0]
ans = 1

for i in range(1,N):
    if arm_range[i][1] >= limit:
        ans += 1
        limit = arm_range[i][0] 

print(ans)

Solution (Python):
n=int(input())
ll=[]
for _ in range(n):
    x,l=map(int,input().split())
    ll.append((x+l,x-l))
ll=sorted(ll)
ans=0
c=-10**10
for t,s in ll:
    if c<=s:
        c=t
        ans+=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):

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

MIN_MAX_LIST = list(zip(MIN, MAX))




MIN_MAX_LIST_SORTED  = sorted(MIN_MAX_LIST, key=itemgetter(1))


count=0
previous_MAX = -1000000000
for j in range(N):
    
    if previous_MAX <= MIN_MAX_LIST_SORTED[j][0]:
        count += 1
        previous_MAX = MIN_MAX_LIST_SORTED[j][1]
print(count)

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

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

mylist.sort()


mymin = -9999999999
myans = 0
for n in range(N):
    
    if mymin <= mylist[n][1]:
        myans += 1
        mymin = mylist[n][0]
        
print(myans)

Solution (Python):
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 = -float("inf")
for end, start in robots:
    if start >= node:
        node = end
        cnt += 1
print(cnt)

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

lst = []
for i in range(n):
    xi, li = map(int, input().split())
    lst.append([xi, li])

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

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

cnt = 1
right = lst_2[0][1]
for i in range(1, n):
    if lst_2[i][0] >= right:
        right = lst_2[i][1]
        cnt += 1

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

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

for i in range(N):

    if nrmax <= RL[i][1]:
        ans += 1
        nrmax = RL[i][0]

print (ans)

Solution (Python):
n = int(input())
robots = []
for _ in range(n):
    xi, li = map(int, input().split())
    robots.append((xi - li, xi + li))
robots.sort(key=lambda x: x[1])
ans = 0
pre_r = -float('inf')
for l, r in robots:
    if pre_r <= l:
        ans += 1
        pre_r = r
print(ans)

Solution (Python):
n = int(input())
a = [[0,0] for _ in range(n)]

for i in range(n):
    a[i][0],a[i][1]=map(int,input().split())
    a[i][0],a[i][1]=(a[i][0]-a[i][1]),(a[i][0]+a[i][1])
a.sort(key=lambda x: x[1])
INF = 10**10
preR = -INF
cnt=0
for L,R in  a:
    if L<preR:
        continue
    cnt+=1
    preR=R
print(cnt)

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

temp = l[0][0]
count = n
i = 1
for i in range(1,n):
  if temp <= l[i][1]:
    temp = l[i][0]
  else:
    temp = min(temp,l[i][0])
    count -= 1
print(count)

Solution (Python):
import sys
from operator import itemgetter

n = int(input())
robots = []
for line in sys.stdin:
    X, L = map(int, line.split())
    l, r = X - L, X + L
    robots.append((l, r))
robots.sort(key=itemgetter(1))

curr = -(10 ** 10)
ans = 0
for l, r in robots:
    if curr > l:
        continue
    ans += 1
    curr = r
print(ans)

Solution (Python):
import sys
from pprint import pprint

def solve(n, x, l):
    r = []
    for i in range(n):
        r.append((x[i] + l[i], x[i] - l[i]))

    pre_e = -1 * 10**9
    ans = 0
    for e, s in sorted(r):
        
        
        if  pre_e <= s:
            
            pre_e = e
            ans += 1
    print(ans)


if __name__ == '__main__':
    n = int(sys.stdin.readline().strip())
    x = [0] * n
    l = [0] * n
    for i in range(n):
        x[i], l[i] = map(int, sys.stdin.readline().strip().split(" "))
    solve(n, x, l)

Solution (Python):
def main():
    n = int(input())
    robots = []
    for _ in range(n):
        x, l = map(int, input().split())
        robots.append((x-l, x+l))
    robots.sort(key=lambda x: x[1])
    count = 1
    robot = robots[0]
    for r in robots:
        if robot[1] <= r[0]:
            robot = r
            count += 1
    print(count)


if __name__ == "__main__":
    main()

Solution (Python):
from operator import itemgetter


def solve():
    N = int(input())
    XL = [[] for _ in range(N)]
    for i in range(N):
        XL[i] = list(map(int, input().split()))
    
    XL.sort(key=itemgetter(0))
    ans = N
    r = sum(XL[0])
    for i in range(1, N):
        if XL[i][0] - XL[i][1] < r:
            ans -= 1
            r = min(r, sum(XL[i]))
        else:
            r = sum(XL[i])
    print(ans)


if __name__ == '__main__':
    solve()

Solution (Python):
import sys
from operator import itemgetter

input = sys.stdin.readline


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

    xlr.sort()

    ans = N
    mi = xlr[0][1]
    for i in range(N - 1):
        if xlr[i + 1][0] < mi:
            mi = min(xlr[i + 1][1], mi)
            ans -= 1
        else:
            mi = xlr[i + 1][1]


    print(ans)


if __name__ == '__main__':
    main()

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

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

cur = -1000000000
ans = 0
for i in range(n):
   if (cur <= r[i][1]):
      ans += 1
      cur = r[i][0]

print(ans)