\(A=x^2-4xy+4y^2+x^2+2x+1+2018\)
\(A=\left(x-2y\right)^2+\left(x+1\right)^2+2018\ge2018\)
\(A_{min}=2018\) khi \(\left\{{}\begin{matrix}x=-1\\y=-\frac{1}{2}\end{matrix}\right.\)
\(B=-\left(4x^2+4xy+y^2\right)-\left(x^2-6x+9\right)+2029\)
\(B=-\left(2x+y\right)^2-\left(x-3\right)^2+2029\le2029\)
\(B_{max}=2029\) khi \(\left\{{}\begin{matrix}x=3\\y=-6\end{matrix}\right.\)