Shashank is playing a game with his friends.
There are n sticks located in a row at points $a_1,a_2, ...,a_n$. Each stick has a height- $h_i$. A person can chop a stick down, after which it takes over one of the regions [$a_i$ - $h_i$, $a_i$] or [$a_i$, $a_i$ + $h_i$]. The stick that is not chopped remains at the point $a_i$. A person can chop a stick in a particular direction if the region to be taken up by the chopped stick does not overlap with an already existing point. The winner $($s$)$ of the game will be one or more people who can answer the question: What is the maximum number of sticks that can be chopped?
Shashank wants to win the game and hence he needs needs your help in finding out what is the maximum number of sticks that can be chopped down.

-----Input:-----
- The first line of each input contains a single integer n.
- n lines follow. Each of the n lines contain a pair of integers: $a_i,h_i$.

-----Output:-----
Output in a single line answer- the maximum number of sticks that can be chopped down.

-----Constraints-----
- $1 \leq n \leq 10^5$
- $1 \leq a_i,h_i \leq 10^9$
- The pairs are given in the order of ascending $a_i$. No two sticks are located at the same point.

-----Sample Input 1:-----
5
1 2
2 1
5 10
10 9
19 1

-----Sample Input 2:-----
5
1 2
2 1
5 10
10 9
20 1

-----Sample Output 1:-----
3

-----Sample Output 2:-----
4

-----EXPLANATION:-----
In the first example you can fell the sticks as follows:
- chop the stick 1 to the left — now it will take over the region $[ - 1;1]$
- chop the stick 2 to the right — now it will take over the region $[2;3]$
- spare the stick 3— it will take over the point $5$
- spare the stick 4— it will take over the point $10$
- chop the stick 5 to the right — now it will take over the region $[19;20]$

Difficulty: interview

Starter code:

Solutions:
# cook your dish here
n=int(input())
counts=dict()
z=0
upper=None
for i in range(0,n):
 a,h= [int(num) for num in input().split()]
 counts[a]=h
for key,count in counts.items():
 c=0
 x=key-count
 y=key+count
 c1=0
 c2=0
 for j in counts.keys():
  if j==key:
   continue
  else:
   if x<=j<=key:
    c1=0
    break
   else:
    c1=1
 for j in counts.keys():
  if j==key:
   continue
  else:
   if key<=j<=y:
    c2=0
    break
   else:
    c2=1
 if c2==0 and c1==1:
  if upper is None:
   z=z+c1
   upper=key
  else:
   if x>=upper:
    z=z+c1
    upper=key
   else:
    z=z+c2
    upper=key
 elif c2==1 and c1==0:
  if upper is None:
   z=z+c2
   upper=y
  else:
   if upper<=key:
    z=z+c2
    upper=y
   else:
    z=z+c1
    upper=y
 elif c2==1 and c1==1:
  if upper is None:
   z=z+c1
   upper=key
  else:
   if x>=upper:
    z=z+c1
    upper=key
   else:
    if upper<=key:
     z=z+c2
     upper=y
    else:
     z=z+0
     upper=y
 else:
  z=z+0
  upper=key
if len(counts)==1:
 print(1)
else:
 print(z)

l=[]
n=int(input())
for i in range(n):
 l.append(list(map(int,input().split())))
if(n==1):
 print(1)
else:
 c=2
 for i in range(1,n-1):
  if(l[i][0]-l[i][1]>l[i-1][0]):
   c=c+1
  elif(l[i][0]+l[i][1]<l[i+1][0]):
   l[i][0]+=l[i][1]
   c=c+1
 print(c)


# cook your dish here
#Coding is about expressing your feeling and
#there is always a better way to express your feeling _Deepak
import sys
# sys.stdin=open('input.txt','r')
# sys.stdout=open('output.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007
# s=is1()
# n = len(s)
# count,res,flag,subans=1,0,0,1
# subcount=0
# for i in range(0,n-1):
#     if s[i]=='c' or s[i]=='k':
#         flag=1
#         break
#     if s[i]==s[i+1] and (s[i]=='f' or s[i]=='g'):
#         count+=1
#     elif count>1:
#         subans*=(count*(count-1))//2
#         count=1
#         subcount+=1
# if s[-1]=='c' or s[-1]=='k':
#     flag=1
# elif count>1:
#     subans*=(count*(count-1))//2
#     subcount+=1
# if flag:
#     print(0)
# else:
#     res=(1<<(subcount-1))
#     res*=subans
#     print(res%mod)
n = ii1()
arr=[None]*n
for ii in range(n):
 arr[ii]=iia()
count=2
if n==1 or n==2:
 print(n)
else:
 flag=[0]*n
 flag[0]=-1
 flag[-1]=1
 for i in range(1,n-1):
  if flag[i-1]==-1:
   if arr[i][0]-arr[i-1][0]>arr[i][1]:
    flag[i] =- 1
    count += 1
   elif arr[i+1][0]-arr[i][0]>arr[i][1]:
    flag[i] = 1
    count += 1
  elif flag[i-1]==1:
   if arr[i][0]-(arr[i-1][0]+arr[i-1][1])>arr[i][1]:
    flag[i]=-1
    count += 1
   elif arr[i+1][0]-arr[i][0]>arr[i][1]:
    flag[i]=1
    count += 1
  else:
   if arr[i][0]-arr[i-1][0]>arr[i][1]:
    flag[i]=-1
    count+=1
   elif arr[i+1][0]-arr[i][0]>arr[i][1]:
    flag[i]=1
    count+=1
 print(count)





n=int(input())
a=list(range(n))
h=list(range(n))
m=2
for i in range(n):
 a[i],h[i]=[int(s) for s in input().split()]
if n<3:
 m=n
else:
 for j in range(1,n-1):
  if a[j]-h[j]>a[j-1]:
   m+=1
  elif a[j]+h[j]<a[j+1]:
    m+=1
    a[j]=a[j]+h[j]
  else:
   continue

print(m)


# cook your dish here
n = int(input())
l = []
for i in range(n):
 a, h = map(int,input().split())
 l.append([a,h])
if len(l)==1:
 print(1)
 return
p = l[0][0]
count = 2
for i in range(1,len(l)-1):
 if l[i][0]-l[i][1]>p:
  p = l[i][0]
  count+=1
 elif l[i][0]+l[i][1]<l[i+1][0]:
  p = l[i][0]+l[i][1]
  count+=1
 else:
  p = l[i][0]
print(count)

n = int(input())
res = []
for _ in range(n):
 res.append(list(map(int, input().split())))
if n == 1:
 print(1)
 return
if n == 2:
 print(2)
 return
start = 2
for i in range(1, n - 1):
 #first check left
 if (res[i][0] - res[i][1]) > res[i - 1][0]:
  #print(res[i])
  #print(abs(res[i][0] - res[i][1]))
  #print(res[i - 1][0])
  start += 1
  continue
 #check right
 if res[i][0] + res[i][1] < res[i + 1][0]:
  #print(res[i], res[i])
  res[i][0] += res[i][1]
  start += 1
  continue
print(start)

# cook your dish here
n=int(input())
list1=[]
list2=[]
for i in range(n):
 a,h=list(map(int,input().split()))
 list1.append(a)
 list2.append(h)
count=2
for j in range(1,n-1):
 k=list1[j]-list2[j]
 if k>list1[j-1]:
  count+=1
 else:
  z=list1[j]+list2[j]
  if z<list1[j+1]:
   count+=1
   list1[j]=list2[j]+list1[j]
if n==1:
 print('1')
else:
 print(count)

n= int(input())
co =[]
hi=[]
for i in range(n):
 arr=[int(x) for x in input().split()]
 co.append(arr[0])
 hi.append(arr[-1])
 
if n<=2:
 count=n
else:
 count=2
 for i in range(1,n-1):
  if hi[i]<co[i]-co[i-1]:
   count+=1
  elif hi[i]<co[i+1]-co[i]:
   count+=1
   co[i]+=hi[i]
  else:
   continue
print(count)

from sys import*
input= stdin.readline
n=int(input())
t=[]
for i in range(n):
 a,b=list(map(int,input().split()))
 t.append([a,b])
if(n==1):
 c=1
else:
 c=2 #first tree to left and last tree to right
for i in range(1,n-1):
 l = t[i][0]-t[i-1][0]
 r = t[i+1][0] - t[i][0]
 h = t[i][1]
 if(h<l):
  c+=1
 elif(h<r):
  c+=1
  t[i][0]=t[i][0]+h
print(c)


n=int(input())
ans=2

a=[]
for i in range(n):
 a.append(list(map(int,input().split())))
if(n==1):
 print(1)
 return
vector=a[0][0]
for i in range(1,n-1):
 if(a[i][0]-a[i][1]>vector):
  ans+=1
  vector=a[i][0]

 else:
  if(a[i][0]+a[i][1]<a[i+1][0]):
   ans+=1
   vector=a[i][0]+a[i][1]
  else:
   vector=a[i][0]
 

  
 
print(ans)

 


n=int(input())
l=[]
for _ in range(n):
 a,h=map(int,input().split())
 l.append([a,h])
ans=2
if n==1:
 ans=1
 print(ans)
 return
l[0].append("left")
l[n-1].append("right")
for i in range(1,n-1):
 if l[i-1][2]=="right":
  if abs(l[i][0]-(l[i-1][1]+l[i-1][0]))>l[i][1]:
   ans+=1
   l[i].append("left")
  elif abs(l[i][0]-l[i+1][0])>l[i][1]:
   ans+=1
   l[i].append("right")
  else:
   l[i].append("stand")
 else:
  if abs(l[i][0]-l[i-1][0])>l[i][1]:
   ans+=1
   l[i].append("left")
  elif abs(l[i][0]-l[i+1][0])>l[i][1]:
   ans+=1
   l[i].append("right")
  else:
   l[i].append("stand")
print(ans)

from math import inf as inf
from math import *
from collections import *
import sys
from itertools import permutations
#input=sys.stdin.readline
n=int(input())
r=[]
for i in range(n):
 a,h=list(map(int,input().split()))
 r.append([a,h])
s=2
if(n==1):
 print(1)
 return
prev=-10000000000000
for i in range(1,n-1):
 prev=max(r[i-1][0],prev)
 nex=r[i+1][0]
 if(r[i][0]-r[i][1]>prev):
  s+=1
 elif(r[i][0]+r[i][1]<nex):
  s+=1
  prev=r[i][0]+r[i][1]
print(s)


t = int(input())
listt = []
ans = 2

for x in range(t):
 a,b = map(int,input().split())
 listt.append([a,b])
 
i = 1

while i+1<t:
 if listt[i][0] - listt[i][1] > listt[i-1][0]:
  ans = ans+1
 elif listt[i][0] + listt[i][1] < listt[i+1][0]:
  ans = ans+1
  listt[i][0] = listt[i][0]+listt[i][1]
  
 i = i+1
if t == 1:
 print('1')
else:
 print(ans)

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


n = int(input())
mainlist = []
choppedlist = []
for i in range(0,n):
 mainlist.append(input().split())

for i in range(0,n):
 mainlist[i][0] = int(mainlist[i][0])
 mainlist[i][1] = int(mainlist[i][1])

# print('typeis ',type(mainlist[0][0]))

def checkifpossible(mainlist, sublist, right, pos):
 # print('sublist is ', sublist)
 # print('mainlist is ', mainlist)
 returncode = True

 if right:
  for i in range(pos+1, n):
   # print('at right value of m and s are ', mainlist[i][0], ' ',                 sublist[1])
   if mainlist[i][0] <= sublist[1]:
    returncode = False
 else:
  for i in range(0, pos):
   # print('value of m and s are ', mainlist[i][0], ' ', sublist[0])
   if mainlist[i][0] >= sublist[0]:
    # print('setting to False')
    returncode = False
 for j in range(0,len(choppedlist)):
  if choppedlist[j][1] >= sublist[0] and not right:
   # print('overlapping chopped list')
   returncode = False

 return returncode


def choptreetoright(mainlist, pos):
 nonlocal choppedlist
 sublist = []
 sublist.append(mainlist[pos][0])
 sublist.append(mainlist[pos][0] + mainlist[pos][1])
 right = True

 if checkifpossible(mainlist, sublist, right, pos) == True:
  choppedlist.append(sublist)
  return True
 else:
  return False

def choptreetoleft(mainlist, pos):
 nonlocal choppedlist
 sublist = []
 sublist.append(mainlist[pos][0] - mainlist[pos][1])
 sublist.append(mainlist[pos][0])
 right = False
 if checkifpossible(mainlist, sublist, right, pos) == True:
  choppedlist.append(sublist)
  return True
 else:
  return False

if n >= 2:
 counter = 2
elif n == 1:
 counter = 1
else:
 counter = 0

for i in range (1, n-1):
 # print('calling left with i ', i)
 if choptreetoleft(mainlist, i):
  counter = counter + 1
  continue
 # print('calling right with i ', i)
 if choptreetoright(mainlist, i):
  counter = counter + 1

# print('chopped list ', choppedlist)
print(counter)

n = int(input())
mainlist = []
choppedlist = []
for i in range(0,n):
 mainlist.append(input().split())

for i in range(0,n):
 mainlist[i][0] = int(mainlist[i][0])
 mainlist[i][1] = int(mainlist[i][1])

# print('typeis ',type(mainlist[0][0]))

def checkifpossible(mainlist, sublist, right, pos):
 # print('sublist is ', sublist)
 # print('mainlist is ', mainlist)
 returncode = True

 if right:
  for i in range(pos+1, n):
   # print('at right value of m and s are ', mainlist[i][0], ' ',                 sublist[1])
   if mainlist[i][0] <= sublist[1]:
    returncode = False
 else:
  for i in range(0, pos):
   # print('value of m and s are ', mainlist[i][0], ' ', sublist[0])
   if mainlist[i][0] >= sublist[0]:
    # print('setting to False')
    returncode = False
 for j in range(0,len(choppedlist)):
  if choppedlist[j][1] >= sublist[0] and not right:
   # print('overlapping chopped list')
   returncode = False

 return returncode


def choptreetoright(mainlist, pos):
 nonlocal choppedlist
 sublist = []
 sublist.append(mainlist[pos][0])
 sublist.append(mainlist[pos][0] + mainlist[pos][1])
 right = True

 if checkifpossible(mainlist, sublist, right, pos) == True:
  choppedlist.append(sublist)
  return True
 else:
  return False

def choptreetoleft(mainlist, pos):
 nonlocal choppedlist
 sublist = []
 sublist.append(mainlist[pos][0] - mainlist[pos][1])
 sublist.append(mainlist[pos][0])
 right = False
 if checkifpossible(mainlist, sublist, right, pos) == True:
  choppedlist.append(sublist)
  return True
 else:
  return False

if n >= 2:
 counter = 2
elif n == 1:
 counter = 1
else:
 counter = 0

for i in range (1, n-1):
 # print('calling left with i ', i)
 if choptreetoleft(mainlist, i):
  counter = counter + 1
  continue
 # print('calling right with i ', i)
 if choptreetoright(mainlist, i):
  counter = counter + 1

# print('chopped list ', choppedlist)
print(counter)

# cook your dish here
n = int(input())
a = [list(map(int,input().split())) for _ in range(n)]
a = a + [ (float('inf'), -1) ]

c = 0
_w = a[0][0]
for i in range(1,len(a)):
 if a[i][0] - a[i][1] > _w:
  c += 1
  _w = a[i][0]
 elif a[i][0] + a[i][1] < a[i+1][0]:
  c += 1
  _w = a[i][0] + a[i][1]
 else:
  _w = a[i][0]

print(c)



# cook your dish here
n = int(input())
a,h=[],[]
arr = [list(map(int,input().split())) for i in range(n)]
arr = sorted(arr,key=lambda i:i[0])
for i in arr:
 k,m = i
 a.append(k)
 h.append(m)
if n==1 or n==2:
 print(n)
else:
 count,chopped=2,0
 for i in range(1,n-1):
  if a[i]-a[i-1]>h[i] and chopped ==0:
    count+=1
  elif chopped ==1 and a[i]-a[i-1]-h[i-1]>h[i]:
   chopped=0
   count+=1
  elif a[i+1]-a[i]>h[i]:
   count+=1
   chopped=1
  else:
   chopped=0
 print(count)


import numpy as np
n = int(input())
arr = np.empty((n,2),dtype=int)
for i in range(n):
 x = list(map(int,input().split()))
 arr[i]=x
flag = 'l'
if(n==1):
 ans=1
else:
 ans=2
for i in range(1,n-1):
 curr = arr[i]
 pre = arr[i-1]
 next = arr[i+1]
 if(flag=='l'):
  cn_l = curr[0]-curr[1]
  cn_r = curr[0]+curr[1]
  if(cn_l>pre[0]):
   flag='l'
   ans+=1
  elif(cn_r<next[0]):
   flag='r'
   ans+=1
 elif(flag=='r'):
  cn_l = curr[0] - curr[1]
  cn_r = curr[0] + curr[1]
  pre_r = pre[0] + pre[1]
  if(cn_l > pre_r):
   flag = 'l'
   ans+=1
  elif(cn_r < next[0]):
   flag='r'
   ans+=1
print(ans)



n=int(input())
sticks=[]
count=2

for i in range(n):
 inn=input().split(' ')
 sticks.append([int(inn[0]),int(inn[1])])
if len(sticks)<2:
 print(len(sticks))
 return
area=[[sticks[0][0]-sticks[0][1],sticks[0][0]],

[sticks[-1][0],sticks[-1][0]+sticks[-1][1]]

]

# print(sticks)
# print(area)
for i in sticks:
 area.append([i[0],i[0]])
def check(aa,hh):
 a=aa-hh
 h=aa
 flag=0
 for i in area:
  if i==[aa,aa]:
   continue
  if i[0]==i[1] and a<=i[0] and h>=i[0]:
   flag=-1
   break
  if a<=i[0] and h>=i[0]:
   
   flag=-1
   break
  if a<=i[0] and h>=i[1]:
   
   flag=-1
   break
  if a<=i[1] and h>=i[1]:
   
   flag=-1
   break
  if a>=i[0] and h<=i[1]:
   
   flag=-1
   break
 if flag==0:
  return [a,h]
 flag=1
 a=aa
 h=aa+hh
 for i in area:
  if i==[aa,aa]:
   continue
  if i[0]==i[1] and a<=i[0] and h>=i[0]:
   flag=-1
   break
  if a<=i[0] and h>=i[0]:
   
   flag=-1
   break
  if a<=i[0] and h>=i[1]:
   
   flag=-1
   break
  if a<=i[1] and h>=i[1]:
   
   flag=-1
   break
  if a>=i[0] and h<=i[1]:
   
   flag=-1
   break
 if flag==1:
  return [a,h]
 return -1


for i in sticks[1:-1]:
  temp=check(i[0],i[1])
 
  if temp==-1:
   continue
  count+=1
  area.append(temp)

print(count)


 



n=int(input())
ah=[]
for _ in range(n):
 cach=list(map(int,input().split()))
 ah.append(cach)
ah.sort(key=lambda x:x[0])
#print(ah)
lmit=-2*(10**9)
chop=0
for i in range(n-1):
 a=ah[i][0]-ah[i][1]
 b=ah[i][0]
 c=ah[i][0]
 d=ah[i][0]+ah[i][1]
 if b<ah[i+1][0] and a>lmit:
  lmit=b
  chop+=1
  #print("first")
 elif d<ah[i+1][0] and c>lmit:
  #print("sec",a,b,c,d,lmit,ah[i+1][0])
  lmit=d
  chop+=1
  #print("sec")
 else:
  lmit=b
 #print(lmit)
print(chop+1)


n = int(input())

l = []
lc = False
c = 0

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

 l.append([a, h])

 if i == 0:
  c += 1
  lc = True
  continue

 if lc:
  if a - l[-2][0] <= h:
   lc = False

  else:
   c += 1
   lc = True

  continue

 if a - l[-2][0] > l[-2][1]:
  c += 1
  l[-2][0] += l[-2][1]
  l[-2][1] = 0

 if a - l[-2][0] <= h:
  lc = False
 else:
  c += 1
  lc = True

if not lc:
 c += 1

print(c)


# cook your dish here
n = int(input())

occupy = [float("-inf")]
height = [0]
pos = [float("-inf")]

for i in range(n):
  p,h = list(map(int, input().split()))
  pos.append(p)
  height.append(h)
  occupy.append(p)

pos.append(float("inf"))
height.append(0)
occupy.append(float("inf"))

sol = 0
for i in range(1,n+1):
  if pos[i]-height[i] > occupy[i-1]:
   sol +=1
  elif pos[i]+height[i] < occupy[i+1]:
   sol +=1
   occupy[i] = pos[i]+height[i]
   
print(sol)
  
  



# cook your dish here
n=int(input())
out=[0]
dp=[[float("-inf"),float("-inf"),float("-inf")]]
for _ in range(n):
 x=list(map(int,input().split()))
 x=[x[0]-x[1],x[0],x[0]+x[1]]
 dp.append(x)
dp.append([float("inf"),float("inf"),float("inf")])
for i in range(1,len(dp)-1):
 if dp[i-1][2]<dp[i][0]:
  dp[i][2]=dp[i][1]
  out.append(out[-1]+1)
 elif dp[i][2]<dp[i+1][1]:
  out.append(out[-1]+1)
 else:
  dp[i]=[dp[i][1],dp[i][1],dp[i][1]]
  out.append(out[-1])
print(out[-1])