function lowerBound(a: number[], x: number): number {
let L = 0, R = a.length;
while (L < R) {
const M = L + ((R - L) >> 1);
if (a[M] < x) L = M + 1; else R = M;
}
return L;
}
inline int read() {
int x = 0, f = 1; char c = getchar_unlocked();
while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar_unlocked(); }
while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar_unlocked(); }
return x * f;
}
inline void write(int x) {
if (x < 0) { putchar_unlocked('-'); x = -x; }
if (x >= 10) write(x / 10);
putchar_unlocked(x % 10 + '0');
}