JavaScript (Node.js), 61 bytes
N=>eval('for(k=n=0;n++<N;)for(c=e=N%n||n;c<=e+N-n;)k+=c*c++')
-2 by Polichinelle.
Iteratively calculates sum, which is shorter than direct calculation.
N=>eval('for(k=n=0;n++<N;)for(c=e=N%n||n;c<=e+N-n;)k+=c*c++')
-2 by Polichinelle.
Iteratively calculates sum, which is shorter than direct calculation.