Algorithm for finding 2 missing items in a stream of integers
Suppose that $x + y = A$ and $x^2 + y^2 = B$. Then
$$ xy = \frac{(x+y)^2 - (x^2+y^2)}{2} = \frac{A^2-B}{2}. $$
Consider now the polynomial
$$ (t-x)(t-y) = t^2 - (x+y)t + xy = t^2-At + \frac{A^2-B}{2}. $$
The polynomial on the right has the two roots $x,y$.

If $x + y = z + w$ and $x^2 + y^2 = z^2 + w^2$ then both $x,y$ and $z,w$ are the two roots of the same polynomial, and so $\{x,y\} = \{z,w\}$.