int isqrt(int n) { if (n <= 0) return 0; int x = n; int y = (x + 1) >> 1; while (y < x) { x = y; y = (x + n ~/ x) >> 1; } return x; }