Given a prime number $p$ and integer numbers $x,y$. Prove that if a number $x(p-x)y(p-y)$ is a square of an integer then $x=y$. 
Given a prime number $p>2$ and numbers $x,y \in \lbrace 1,2,...,\frac{p-1}{2}\rbrace$. Prove that if a number $x(p-x)y(p-y)$ is a square of an integer then $x=y$.

Firstly I noticed that $x$ and $p-x$ are relatively prime likewise $y$ and $p-y$. That means we have two cases, because if WLOG $x$ is a square then one of $y$ or $p-y$ is not a square  due to $x$ and $p-x$ being coprime.
$$\begin{cases}
xy = k^2 \\ 
(p-x)(p-y)=l^2
\end{cases}
$$
and
$$\begin{cases}
x(p-y) = k^2 \\ 
y(p-x)=l^2
\end{cases}$$
The first system of equations gives us after subtraction $$l^2-k^2=(l+k)(l-k)=p(p-x-y)$$ we must have that $p|x+y$
also $2\le k+l \le \sqrt{\frac{p-1}{2}}+p$ implying $l+k=p$ and $l-k=p-x-y$ yielding $k=\frac{x+y}{2}$ and now using first equation in the first system of equations we get $xy=(\frac{x+y}{2})^2$ implying $(x-y)^2=0$ and giving $x=y$ i tried to solve the second system in similar fashion but I am unable to do so. How do I proceed? Any help appreciated.
 A: WLOG, Let $x,y \leq \frac{p-1}{2}$. Clearly, $p-x,p-y<p$. So, $k^2,l^2<\frac{p-1}{2}\times p<\frac{p^2}{2}$. This implies that $k,l<\frac{p}{\sqrt{2}}$ or equivalently, $k+l<\sqrt{2}p$ and $k-l<\frac{p}{\sqrt{2}}$.
Substracting the two equations, we get that $(x-y)p=k^2-l^2$. From the inequality, we get that $p=k+l$ or $k-l=0$.
For the first:
From RMS-inequality, we have that $\frac{k+l}{2}\leq\sqrt{\frac{x(p-y)+y(p-x)}{2}}=\frac{\sqrt{(x+y)p-2xy}}{\sqrt{2}}$. This simplifies to $p^2/2\leq(x+y)p-2xy$. So, $x+y$ has to be atleast $p/2$.
Suppose $\frac{p+r}{2}= x+y$ for $0 < r < p/2$, then we have that one of $x,y$ has to be at least $r+1$, since the other is less than $\frac{p-1}{2}$. So, the product $2xy$ is at least $(p-1)(r+1)$. Therefore, $(x+y)p-2xy$ is at most $(\frac{p+r}{2})p-(p-1)(r+1)<p^2/2$, which is a contradiction for $r<p/2$. Since there is no possible $x+y$ for this inequality to hold, we can conlude that $k+l=p$ is not possible.
For the second: $k=l$. $(x-y)p=0$ and so, $x=y$.
$\mathbf{Edit:}$
The OP mentions that he has missed the case where $y$ is a square and $x(p-x)(p-y)$ is a square. This seems to be the hardest case to solve and took me quite a while.
It can be seen quite easily that if $x(p-x)(p-y)$ and $y$ are square, then we need to have $x=af^2, p-x=bg^2, p-y=abh^2, y=i^2$ for $a,b$ square free and some $f,g,h,i$. And we have the two relations: $$af^2+bg^2=p$$
$$abh^2+i^2=p$$
This reminded me a lot of the Brahmagupta identity and tried to establish something along those directions. Also, toying with some small values for such combinations gave me the feel that there was some identity involved that made any number which could be written in this form to have some factor. See this article on writing a number as sum of squares in two different ways.
So, I tried the following: $p^2=(af^2+bg^2)(abh^2+i^2)$ and applied a sort of Brahmagupta identity.
$$p^2=b((ahf)^2+(gi)^2)+a((fi)^2+(bgh)^2)$$
$$=b(ahf-gi)^2+a(fi+bgh)^2$$
$$=b(ahf+gi)^2+a(fi-bgh)^2$$
Now, all that is left is to see that this can't happen. Looking $mod(p)$, we can see that $(p-x)(p-y)$ is $xy(mod (p))$. So, $p$ divides $af^2i^2-ab^2g^2h^2$. So, $p$ divides $a(fi+bgh)(fi-bgh)$. $a<p$ and so, $p$ divides $fi+bgh$ or $fi-bgh$. Neither can be true because $p^2=b(ahf-gi)^2+a(fi+bgh)^2$ and $p^2=b(ahf+gi)^2+a(fi-bgh)^2$. So, one of them has to be zero. If not, then $a$ will be one, reducing it to an earlier case. This implies that $fi=bgh$. $b$ must divide one of the $x$ or $y$ which is not possible, so it must be that $b=1$. So, that means that $p-x=bg^2=g^2$ is a square and this reduces it to case to that was already done. This completes our proof.
$\mathbf{Remark:}$ As pointed out in a comment, it is entirely possible that none of $x,y,(p-x),(p-y)$ are squares. The general case can be done in the same way as follows. $x=gcd(a,p-y)gcd(a,y)f^2$, $p-x=gcd(b,p-y)gcd(b,y)g^2$, $p-y=gcd(a,p-y)gcd(b,p-y)h^2$ and $y=gcd(a,y)gcd(b,y)i^2$. And go into the same Brahmagupta type identity, to reduce it into the case where $a$ or $b$ is 1.
