int isqrt(int x) { int a = 0, b = 46340, c; while (a + 1 < b) { c = (a + b) / 2; if (x < c * c) b = c; else a = c; } return a; }