import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array, std.typecons, std.container; import std.math, std.numeric, core.bitop; enum mod = 10L ^^ 9 + 7; void main() { int x, y; scan(x, y); int[int] sq; /* foreach (i ; 0 .. 10^^4) { sq[i*i] = i; } */ int ans; foreach (i ; 0 .. 10^^4) { foreach (j ; 0 .. i + 1) { int d = i*i + j*j; if (d < x || d > y) continue; debug { writefln("i, j, d = %d, %d, %d", i, j, d); } if (i == 0 || j == 0 || i == j) { sq[d] += 4; } else { sq[d] += 8; } ans = max(ans, sq[d]); } } /+ foreach (r ; x .. y + 1) { int tmp; foreach (i ; 0 .. r) { int d = r - i*i; if (d < 0) { break; } if (!(d in sq)) { continue; } int j = sq[d]; if (i > j) { break; } debug { writefln("(i, j) = (%d, %d)", i, j); } if (i == j || i == 0) { tmp += 4; } else { tmp += 8; } } ans = max(ans, tmp); } +/ writeln(ans); } void scan(T...)(ref T args) { import std.stdio : readln; import std.algorithm : splitter; import std.conv : to; import std.range.primitives; auto line = readln().splitter(); foreach (ref arg; args) { arg = line.front.to!(typeof(arg)); line.popFront(); } assert(line.empty); } void fillAll(R, T)(ref R arr, T value) { static if (is(typeof(arr[] = value))) { arr[] = value; } else { foreach (ref e; arr) { fillAll(e, value); } } }