int binarySearch(vector<int>& arr, int p, int r, int num) {
while (p <= r) {
int mid = (p + r)/2;
if (arr[mid] == num) return mid;
else if (arr[mid] > num) r = mid-1;
else p = mid+1;
}
return -1;
}