Lower bound to count the number of elements having k - th bit in range ( 3 * 2 ^ k - x , 4 * 2 ^ ( k ) - x )
l = lower_bound ( C , C + N , ( 1 << k ) * 3 - x ) - C ; r = lower_bound ( C , C + N , ( 1 << k ) * 4 - x ) - C ; count += ( r - l ) ; }