Motivation: Let $k$ be a positive integer and $m=4k+1$. I want to find the necessary conditions for the following identity to hold: $$\displaystyle\sum_{i=1}^{k}\lfloor\sqrt{im}\rfloor=\frac{m^2-1}{12}$$
Since $\lfloor\sqrt{im}\rfloor\geqslant j$ is equivalent to $im>j^2-1$, where $j$ is a positive integer not exceeding $2k$, it can be shown that the left-hand side is equal to $$2k^2-\sum_{j=1}^{2k}\left\lfloor\frac{j^2}{m}\right\rfloor+\left\lfloor\frac{2k}{r}\right\rfloor$$ where $r$ is the least positive integer such that $m$ divides $r^2$.
(i) If all the prime factors $p_1,p_2,\dots$ of $m$ satisfy $p_1\equiv p_2\equiv\dots\equiv1\pmod{4}$, then $x^2\equiv-1\pmod{m}$ has a solution. Let $j'$ denotes the unique integer such that $j'\equiv xj\pmod{m}$ and $|j'|\leqslant 2k$ for each $j$. Then $$\left\lfloor\frac{j^2}{m}\right\rfloor + \left\lfloor\frac{j'^2}{m}\right\rfloor = \frac{j^2}{m} + \frac{j'^2}{m} + \epsilon_{j}$$ where $\epsilon_{j} = 0$ if $m$ divides $j^2$, and $\epsilon_{j} = -1$ if $m$ does not divide $j^2$. Since $m$ divides $j^2$ if and only if $r$ divides $j$, then it follows that $$\sum_{j=1}^{2k}\left\lfloor\frac{j^2}{m}\right\rfloor =\frac{1}{2}\sum_{j=1}^{2k}\left(\left\lfloor\frac{j^2}{m}\right\rfloor+\left\lfloor\frac{j'^2}{m}\right\rfloor\right) = \frac{1}{2}\sum_{j=1}^{2k}\left(\frac{j^2}{m}+\frac{j'^2}{m}-1\right) + \frac{1}{2}\sum_{j=1}^{2k}\left(1+\epsilon_{j}\right) =\frac{2k(k-1)}{3}+\frac{1}{2}\left\lfloor\frac{2k}{r}\right\rfloor$$ Thus the identity in the above question holds if and only if $\left\lfloor\frac{2k}{r}\right\rfloor=0$, which is equivalent to $m$ being squarefree.
(ii) If there exists a prime factor $p\equiv3\pmod{4}$ of $m$, I have no idea how to deal with it.
By using Python, I found that the identity holds for $m=245,605,637,1805,2989,6877$. For each of these $m$ and each prime factor $p$ of the form $4n+3$, there exists an integer $l$ such that $p^{2l}$ divides $m$ while $p^{2l+1}$ does not. This leads to the following question:
Question: Let $k$ be a positive integer such that $m=4k+1$ has a prime factor $p\equiv 3\pmod{4}$ with an odd exponent in the prime factorization of $m$. Equivalently, $m$ is not a sum of two square. Is it true that $$\displaystyle\sum_{i=1}^{k}\lfloor\sqrt{im}\rfloor \neq \frac{m^2-1}{12}?$$