\(D=\left(x^2+y^2+1-2xy+2x-2y\right)+\frac{1}{2}\left(4y^2-4y+1\right)+\frac{4039}{2}\)
\(=\left(x-y+1\right)^2+\frac{1}{2}\left(2y-1\right)^2+\frac{4039}{2}\ge\frac{4039}{2}\)
\(D_{min}=\frac{4039}{2}\) khi \(\left\{{}\begin{matrix}x=-\frac{1}{2}\\y=\frac{1}{2}\end{matrix}\right.\)