Use circle method detect the condition $N=\sum_{i=1}^k \frac{m_i(m_i+1)}{2}$ to derive $r(N)=\int_0^1 f^k(\alpha) e(-N\alpha)$, where $f(\alpha)=\sum_{n\leq N} e(\alpha \frac{m_i(m_i+1)}{2} )=\int_{major arcs}+\int_{minor arcs}$by Dirichlet approximating lemm. Writing $f(\alpha)=\sum_{m\leq N} e( (\frac{a}{q}+\lambda) \frac{m(m+1)}{2} )$ and $m = qt + s$ with $s \leq q,\frac{1-s}{q} \leq t \leq\frac{N-s}{q}$.$$f(\alpha)=\sum_{m\leq N}e( (\frac{a} {q}+\lambda) \frac{(qt + s)(qt + s+1)}{2} )=\sum_{s\leq q}e(\frac{a}{q}\cdot \frac{s(s+1)}{2})\times \sum_{\frac{1-s}{q} \leq t \leq\frac{N-s}{q}}e(\lambda \frac{(qt + s)(qt + s+1)}{2} ).$$since $ \sum_{\frac{1-s}{q} \leq t \leq\frac{N-s}{q}}e(\lambda \frac{(qt + s)(qt + s+1)}{2} )=\frac{1}{q}\sum_{m\le N}e(\lambda \frac{m(m+1)}{2})+o(1),$ we have $f(\alpha)=\frac{c_q(a)}{q}\sum_{m\leq N}e(\lambda \frac{m(m+1)}{2})+o(q)$ with $c_q(a)=\sum_{s\leq q}e(\frac{a(\frac{s(s+1)}{2})}{q})$ bounded by $\ll q^{1/2}$. Eventually we have $r(N)=\sigma(N,P)J(N)+errorterm$. Here $P$ is the upper bound for $q$ in the arcs division( that is, major arcs: $\cup_{q\le P}\cup_{(a,q)=1,a\leq q} M(a,q)$, with $M(a,q)=[\frac{a}{q}-\frac{1}{qQ},\frac{a}{q}+\frac{1}{qQ}] $.minor arcs:$[\frac{1}{Q},1+\frac{1}{Q}]-$major arcs), and could be taken $log^A N$ for any $A$,$\sigma(N,P)=\sum_{a\leq q,(a,q)=1}(\frac{c_q(a)}{q})^ke(-\frac{aN}{q})$,and $J(N)=\int_{-\frac{1}{qQ}}^{\frac{1}{qQ}}(\sum_{m\le N}e(\lambda \frac{m(m+1)}{2}))^ke(-N \lambda)d \lambda$.