import java.math.BigInteger;
import java.util.Random;
class Ideone
{
{
}
{
return n(n, n3).add(n(n, n5)).subtract(n(n, n9)).subtract(n(n, n15));
}
{
n = n.subtract(n1).divide(m);
return n.multiply(n.add(n1)).divide(n2).multiply(m);
}
public static void main
(String[] args
) {
System.
out.
println("N=300000: " + f
("300000")); System.
out.
println("N=1000000: " + f
("1000000")); System.
out.
println("N=123456789: " + f
("123456789"));
System.
out.
printf("N=%d: %d%n", n, f
(n
));
System.
out.
printf("N=%d: %d%n", n, f
(n
)); }
}
aW1wb3J0IGphdmEubWF0aC5CaWdJbnRlZ2VyOwppbXBvcnQgamF2YS51dGlsLlJhbmRvbTsKCmNsYXNzIElkZW9uZQp7CiAgICBzdGF0aWMgZmluYWwgQmlnSW50ZWdlciBuMSA9IEJpZ0ludGVnZXIuT05FOwogICAgc3RhdGljIGZpbmFsIEJpZ0ludGVnZXIgbjIgPSBCaWdJbnRlZ2VyLnZhbHVlT2YoMik7CiAgICBzdGF0aWMgZmluYWwgQmlnSW50ZWdlciBuMyA9IEJpZ0ludGVnZXIudmFsdWVPZigzKTsKICAgIHN0YXRpYyBmaW5hbCBCaWdJbnRlZ2VyIG41ID0gQmlnSW50ZWdlci52YWx1ZU9mKDUpOwogICAgc3RhdGljIGZpbmFsIEJpZ0ludGVnZXIgbjkgPSBCaWdJbnRlZ2VyLnZhbHVlT2YoOSk7CiAgICBzdGF0aWMgZmluYWwgQmlnSW50ZWdlciBuMTUgPSBCaWdJbnRlZ2VyLnZhbHVlT2YoMTUpOwoKICAgIHN0YXRpYyBCaWdJbnRlZ2VyIGYoU3RyaW5nIG4pCiAgICB7CiAgICAgICAgcmV0dXJuIGYobmV3IEJpZ0ludGVnZXIobikpOwogICAgfQoKICAgIHN0YXRpYyBCaWdJbnRlZ2VyIGYoQmlnSW50ZWdlciBuKQogICAgewogICAgICAgIHJldHVybiBuKG4sIG4zKS5hZGQobihuLCBuNSkpLnN1YnRyYWN0KG4obiwgbjkpKS5zdWJ0cmFjd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