Function to obtain and return the index of lower_bound of k
def getLowerBound ( BITree , arr , n , k ) : NEW_LINE INDENT lb = - 1 NEW_LINE l = 0 NEW_LINE r = n - 1 NEW_LINE while ( l <= r ) : NEW_LINE INDENT mid = l + ( r - l ) // 2 NEW_LINE if ( getSum ( BITree , mid ) >= k ) : NEW_LINE INDENT r = mid - 1 NEW_LINE lb = mid NEW_LINE DEDENT else : NEW_LINE INDENT l = mid + 1 NEW_LINE DEDENT DEDENT return lb NEW_LINE DEDENT def performQueries ( A , n , q ) : NEW_LINE