int binary_search_last_occurrence(const vector<int>& lst, int target) {
if (lst.empty()) return -1;
int low = 0, high = lst.size() - 1;
while (low < high) {
int mid = (low + high + 1) / 2;
if (lst[mid] <= target) {
low = mid;
} else {
high = mid - 1;
}
}
if (lst[low] == target)
return low;
else
return -1;
}