a) \(=2\left(x-y\right)-\left(x^2-2xy+y^2\right)\)
\(=2\left(x-y\right)-\left(x-y\right)^2\)
\(=\left(x-y\right)\left(2-x+y\right)\)
b) \(x^3-x+3x^2y+3xy^2+y^3-y\)
\(=\left(x^3+y^3\right)+\left(3x^2+3xy^2\right)-\left(x+y\right)\)
\(=\left(x+y\right)\left(x^2-xy+y^2\right)+3xy\left(x+y\right)-\left(x+y\right)\)
\(=\left(x+y\right)\left(x^2-xy+y^2+3xy-1\right)\)
\(=\left(x+y\right)\left(x^2+y^2+2xy-1\right)\)