If a spring of spring constant k extends by x on loading due to an applied force F, then the energy stored by the spring is
F22x
F22k
2xF2
2F2k
We have F=kx and U=kx22.
Therefore,
U=F22k