What is the potential energy of the spring?
On the left side there is a gravitational force $mg$ acts on the spring, same on for the right side. So, If force $mg$ streches the spring $x$ units then $2mg$ will strech the spring $2x$. Therefore,
$$F=kx$$
$$2mg=kx$$
$$\frac{2mg}{k}=x$$
$$U=\frac{1}{2}k{x}^{2}=\frac{1}{2}k(\frac{2mg}{k})^{2}$$
$$U=\frac{2{m}^{2}{g}^{2}}{k}$$
Is my interpretation correct?