private int upper_bound(int[] arr, int num) {
int l = 0, r = arr.length;
while(l < r) {
int m = (l + r) >> 1;
if(arr[m] > num) {
r = m;
}
else {
l = m + 1;
}
}
return l;
}
private int lower_bound(int[] arr, int num) {
int l = 0, r = arr.length;
while(l < r) {
int m = (l + r) >> 1;
if(arr[m] >= num) {
r = m;
}
else {
l = m + 1;
}
}
return l;
}