\(M=8x^2+16x^2y+16xy^2+8y^2-5x-5y+2018\)
\(=8\left(x+y\right)^2-16xy+16x^2y+16xy^2\)\(-5\left(x+y\right)+2018\)
\(=8\left(x+y\right)^2+16xy\left(x+y-1\right)-5\left(x+y\right)+2018\)
Thay \(x+y=1\)
\(\Rightarrow M=8+16xy.\left(1-1\right)-5.1+2018\)
\(\Rightarrow M=2021\)