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