Maximum of $\prod_{k=1}^{n} { f(c_k) }$ where $f(m) = \sum_{k=1}^{m} k^2, \sum_{i=1}^{n} c_i = 2020$. What's the maximum of  $\prod_{k=1}^{n} { f(c_k) }$ where $f(m) = \sum_{k=1}^{m} k^2, \sum_{i=1}^{n} c_i = 2020$. $n$ can be any integers?
Since $f(1) = 1, f(2) = 5, f(3) = 14, f(4) = 30$.
It seems like we are better off using $f(3)$ as much as possible, followed by $f(4)$ and followed by $f(2)$. But is there a rigorous proof?
 A: The idea is, indeed, to find the optimal way to split $2020$ into smaller parts.
Capitalizing on the fact that the number of parts is unconstrained. Below I will frequently compare various ways of splitting a total $N$ into smaller parts, looking for the maximal product.
A starting point is the well known formula
$$
f(m)=\frac16m(m+1)(2m+1).
$$
Using this we easily see that the inequality
$$
f(2)f(m)>f(m+2)
$$
holds whenever $m\ge3$. This is hardly surprising. After all, the left hand side is a cubic polynomial of $m$ with leading coefficient $2f(2)/6=5/3$ but the right hand side is a cubic polynomial of $m$ with leading coefficient $2/6=1/3$. So the inequality automatically holds for large values of $m$, and we only need to find when.
This has the immediate consequence that at the maximum we always have $c_i<5$ for all $i$. This is because if $c_i$ were $\ge5$, the product $\prod_i f(c_i)$ increases, when we split $c_i$ to $(c_i-2)+2$. All because $f(2)f(c_i-2)>f(c_i)$.
As you already observed, we don't want to have two $2$s among the $c_i$s given that $f(4)>f(2)^2$; $4$ gives a larger product than $2+2$.

At this point we know that the optimal collection of $c_i$s has $3$s and $4$s and at most a single $2$.

Let's look at $4$s next. We have $4+4=8$ and
$$f(4)^2=900<980=5\cdot14^2=f(2)f(3)^2,$$
where also $8=2+3+3$. Therefore we can conclude that we never want to have more than a single $4$; it pays to use $2+3+3$ instead of $4+4$.
Do we want to have both $2$ and $4$? As above,
$$
f(2)f(4)=150<196=f(3)^2.$$
It follows that instead of using $2+4$ we get a higher product with $3+3$ instead.

So, as you predicted, it is all $3$s and then, if necessary, we can use a single $2$ or a single $4$.

Notice that so far we have not used the number $2020$ at all. This holds for any number $N\ge8$ in place of $2020$, and the arguments above all go through.
All that remains is to observe that
$$
2020=673\cdot3+1.
$$
So to make $\sum_ic_i$ equal to $2020$ we need an extra four, and the answer is
$$
f(3)^{672}f(4).
$$

If, next week, somebody asks the same question about $2021$ that is congruent to $2$ modulo $3$, and the answer will be $f(3)^{673}f(2)$ instead.
