https://www.ivl-projecteuler.com/overview-of-problems/25-difficulty/problem-401 takes the following derivation steps:
It needs to calculate: $$\sum_{k=1}^{n}{k^2\left\lfloor{\frac{n}{k}}\right\rfloor}.$$
It first shows that the summation can be split at an arbitrary point ($\sqrt{n}$), $$\sum_{k=1}^{\left\lfloor\sqrt{n}\right\rfloor}{k^2\left\lfloor{\frac{n}{k}}\right\rfloor}+ \sum_{k=\left\lfloor\sqrt{n}+1\right\rfloor}^{n}{k^2\left\lfloor{\frac{n}{k}}\right\rfloor}$$ Then replaces the second term with the following expression: $$\sum_{k=1}^{\left\lfloor\sqrt{n}\right\rfloor}{k^2\left\lfloor{\frac{n}{k}}\right\rfloor}+ \sum_{\ell=1}^{\left\lfloor\sqrt{n}-1\right\rfloor}{\ell\left(\sum_{k=\left\lfloor{\frac{n}{\ell+1}}\right\rfloor}^{\left\lfloor{\frac{n}{\ell}}\right\rfloor}{k^2}\right)}$$
I don't understand what kind of logic is being used to make this replacement. I tried with Hermite's identity for the floor function, but I didn't get a similar result.
As indicated in the linked page, what they're trying to do is group all of the values where $\left\lfloor{\frac{n}{k}}\right\rfloor$ are the same, calling each of these values $\ell$, starting from $\ell = 1$, and then adding the terms with each of these values from the starting value up to the last one. However, they have a small mistake in their lower bound of the bracketed summation, where the $k=\left\lfloor{\frac{n}{\ell+1}}\right\rfloor$ should be $k=\left\lfloor{\frac{n}{\ell+1}}\right\rfloor\color{red}{+1}$ instead. This is because this is for the starting point of $\left\lfloor{\frac{n}{k}}\right\rfloor=\ell$, but using their value gives
$$\left\lfloor{\frac{n}{\ell+1}}\right\rfloor\le\frac{n}{\ell+1}\;\;\to\;\;\frac{1}{\left\lfloor{\frac{n}{\ell+1}}\right\rfloor}\ge\frac{\ell+1}{n}\;\;\to\;\;\frac{n}{\left\lfloor{\frac{n}{\ell+1}}\right\rfloor}\ge \ell+1 \tag{1}\label{eq1A}$$
Also, note what they have double counts $\frac{n}{m}$ for $m \ge 2$.
To show the specified range works, we have $n = m\ell + r$ for some integers $m\gt 0$ and $0 \le r \lt \ell$. Note since $\ell \le \left\lfloor\sqrt{n}-1\right\rfloor$, then $m \ge \ell$, so $r \lt m$ (this is a primary reason for breaking up the summation at that point as they did). Thus, $k = \left\lfloor\frac{n}{\ell}\right\rfloor = \left\lfloor\frac{m\ell+r}{\ell}\right\rfloor=m+\left\lfloor\frac{r}{\ell}\right\rfloor=m$ gives that $\left\lfloor\frac{n}{m}\right\rfloor=\left\lfloor\frac{m\ell+r}{m}\right\rfloor=\ell+\left\lfloor\frac{r}{m}\right\rfloor=\ell$ works. This is the largest value for $k$ since, for $k=\left\lfloor\frac{n}{\ell}\right\rfloor=m+1$, we get $\left\lfloor\frac{n}{m+1}\right\rfloor = \left\lfloor\frac{m\ell+r}{m+1}\right\rfloor = \left\lfloor\frac{m\ell+\ell+(r-\ell)}{m+1}\right\rfloor = \ell+\left\lfloor\frac{r-\ell}{m+1}\right\rfloor \lt \ell$ (this is also shown by \eqref{eq2A} below). As indicated in \eqref{eq1A}, $k = \left\lfloor\frac{n}{\ell+1}\right\rfloor$ is too small. However, the next larger value works since
$$\left\lfloor\frac{n}{\ell+1}\right\rfloor + 1 \gt \frac{n}{\ell+1} \;\;\to\;\; \frac{1}{\left\lfloor\frac{n}{\ell+1}\right\rfloor + 1} \lt \frac{\ell+1}{n} \;\;\to\;\; \frac{n}{\left\lfloor\frac{n}{\ell+1}\right\rfloor + 1} \lt \ell+1 \tag{2}\label{eq2A}$$
With the earlier explained correction, for $\ell=1$, we have $\frac{n}{n}=\frac{n}{n-1}=\ldots=\frac{n}{\left\lfloor\frac{n}{2}\right\rfloor+1}=1$, i.e., $\left\lfloor\frac{n}{k}\right\rfloor=1$ for $\left\lfloor\frac{n}{2}\right\rfloor+1 \le k \le \left\lfloor\frac{n}{1}\right\rfloor$ (and, in general, $\left\lfloor\frac{n}{k}\right\rfloor=\ell$ for $\left\lfloor\frac{n}{\ell+1}\right\rfloor+1 \le k \le \left\lfloor\frac{n}{\ell}\right\rfloor$). Thus, the first term of the outer summation from these terms becomes
$$\sum_{k=\left\lfloor\frac{n}{2}\right\rfloor+1}^{n}k^2\left\lfloor{\frac{n}{k}}\right\rfloor = (1)\left(\sum_{k=\left\lfloor\frac{n}{2}\right\rfloor+1}^{n}k^2\right) = \sum_{\ell=1}^{1}\ell\left(\sum_{k=\left\lfloor\frac{n}{\ell+1}\right\rfloor+1}^{\left\lfloor\frac{n}{\ell}\right\rfloor}k^2\right) \tag{3}\label{eq3A}$$
Similarly, do this for $\ell = 2$ (where the smaller values of $\left\lfloor\frac{n}{3}\right\rfloor+1 \le k \le \left\lfloor\frac{n}{2}\right\rfloor$ are used), $\ell = 3$, etc., up to where the final starting value of their bracketed summation is the starting value of the overall summation, i.e., the value of $\ell$ where
$$\left\lfloor{\frac{n}{\ell+1}}\right\rfloor + 1 = \left\lfloor\sqrt{n}+1\right\rfloor \;\;\to\;\;\left\lfloor{\frac{n}{\ell+1}}\right\rfloor = \left\lfloor\sqrt{n}\right\rfloor \tag{4}\label{eq4A}$$
The linked page uses
$$\ell + 1 = \left\lfloor{\sqrt{n}}\right\rfloor \;\;\to\;\; \ell = \left\lfloor{\sqrt{n}-1}\right\rfloor \tag{5}\label{eq5A}$$
as the upper bound. However, this is not always correct. For example, with $n=13$, we get $\left\lfloor{\sqrt{13}}\right\rfloor = 3$, but $\left\lfloor\frac{13}{3}\right\rfloor=4$. The basic problem is that the appropriate cut-off, to not have any split among the $\left\lfloor\frac{n}{k}\right\rfloor$ values between the first and second overall summations, does not always occur starting at $\left\lfloor\sqrt{n}+1\right\rfloor$. As such, that should ideally be adjusted where appropriate.
Thus, with the earlier lower bound mistake mentioned corrected, we therefore now get what the linked page states, i.e.,
$$\sum_{k=\left\lfloor\sqrt{n}+1\right\rfloor}^{n}{k^2\left\lfloor{\frac{n}{k}}\right\rfloor} = \sum_{\ell=1}^{\left\lfloor\sqrt{n}-1\right\rfloor}{\ell\left(\sum_{k=\left\lfloor{\frac{n}{\ell+1}}\right\rfloor+1}^{\left\lfloor{\frac{n}{\ell}}\right\rfloor}{k^2}\right)} \tag{6}\label{eq6A}$$