Function to obtain and return the index of lower_bound of k
int getLowerBound ( int BITree [ ] , int arr [ ] , int n , int k ) { int lb = -1 ; int l = 0 , r = n - 1 ; while ( l <= r ) { int mid = l + ( r - l ) / 2 ; if ( getSum ( BITree , mid ) >= k ) { r = mid - 1 ; lb = mid ; } else l = mid + 1 ; } return lb ; } void performQueries ( int A [ ] , int n , int q [ ] [ 3 ] ) {