int bsearch(int l, int r) { while (l < r) { int mid = l + r >> 1; if (check(mid)) l = mid; else r = mid; } return l; }