Kinetic energy = (1/2) (mass) x (speed²)
If the ball was launched in the horizontal direction,
then its total kinetic energy was
(1/2) x (0.005 kg) x (5 m/s)²
= (0.0025 x 25) (kg-m²/sec²)
= 0.0625 Joule .
And that would be the amount of energy stored in the spring.
If the ball was launched at some angle above the horizontal, then
it had some vertical speed too. Its total kinetic energy was then
some greater number, and there was more energy stored in
the spring.