Question: > 
> Let $n,m,k,l$ be positive integers and $p$ and odd prime with $0 \leq n,m,k,l \leq p-1$ and $$n+m \equiv k+l \pmod{p}, \quad n^2+m^2 \equiv k^2+l^2 \pmod{p}.$$ Prove that $\{m,n\} =\{k,l\}$.
> 
> 
> 

We can rearrange the third condition to get $(n-l)(n+l) \equiv (k-m)(k+m) \pmod{p}$. How do we continue from here?

Answer: 
This holds true in any field in which $2$ is invertible. Suppose 

$$a+b=c+d \tag{1} $$

$$a^2+b^2=c^2+d^2 \tag{2} $$

Square $(1)$, subtract $(2)$, then divide by $2$ to get

$$ ab=cd \tag{3} $$

This means we have an equality of polynomials

$$(x-a)(x-b)=(x-c)(x-d) \tag{4}$$

So both $\{a,b\}$ and $\{c,d\}$ are the roots of this polynomial.

There are two key ideas here:

* To know how to get from $(1)$ and $(2)$ to $(3)$, be familiar with the relationship between elementary symmetric polynomials and power symmetric polynomials (at least the first couple of each type).
* To know to combine $(1)$ and $(3)$ to $(4)$, know Vieta's formulas.

(A field is a number system with all the usual operations and properties - addition, multiplication, associativity, commutativity, distributivity, etc. - with the property that all nonzero elements have multiplicative inverses.)
First, observe that $n^2 + 2mn + m^2 \equiv (n+m)^2 \equiv (k+l)^2 \equiv k^2 + 2kl + l^2$, so $kl \equiv mn$ (since $p$ is odd, 2 is a unit).

If $k \equiv 0$, then $0 \equiv kl \equiv mn$. Without loss of generality we have $m \equiv 0$, and thus $n \equiv l$. The claim follows then from $0 \le m,n,k,l \le p-1$.

Otherwise, let $k \not\equiv 0$. This means $k$ is a unit, and we can find $a$ in $\mathbb{F}\_p$ with $m \equiv ak$ (choose e.g. $a = k^{-1} m$). It follows that $kl \equiv akn$, and thus $l \equiv an$ (by multiplying both sides with $k^{-1}$). Furthermore, $k + an \equiv k + l \equiv n + m \equiv n + ak$.

If $a \equiv 1$, then we immediately have $l \equiv n$ and $m \equiv k$, and the claim follows as before from $0 \le m,n,k,l \le p-1$.

Else, we get $k \equiv n$ and thus $l \equiv an \equiv ak \equiv m$. As before, $\{ k,l \} = \{ m,n \}$.