Function to return count of deleted indices which are to the left of the current index
int deleted ( int seg [ ] , int l , int r , int start , int end , int current ) { if ( end < l or start > r ) return 0 ; if ( start >= l and end <= r ) return seg [ current ] ; int mid = ( start + end ) / 2 ; return deleted ( seg , l , r , start , mid , 2 * current + 1 ) + deleted ( seg , l , r , mid + 1 , end , 2 * current + 2 ) ; }