Scanf.scanf "%d %d" (fun n k ->
    Printf.printf "%d\n" @@
        if k mod 2 = 1 then let c = n / k in c * c * c else
            let q1 = n / k in
            let q2 = (n / (k / 2) + 1) / 2 in
            q1 * q1 * q1 + q2 * q2 * q2
)