Let x1 & x2 be the extensions in the spring with spring cosntant k1 & k2 respectively.
(a) in equilibrium
k1x1=(m1+m2)g
x1=(m1+m2)gk1=(2+1)101500=0.02m
k2x2=m2g
x2=m2gk2=1×10500=0.02m
Total potential energy, P=12k1x21+12k2x22
P=121500.(0.02)2+12500.(0.02)2=0.4J
Hence, potential energy is 0.4J
(b) When pulling, spring in series pull together.
k=k1k2k1+k2=1500×5001500+500=375Nm2
Potential energy, P=12kx2=12×375×0.082=1.2J
Hence, Potential energy is 1.2J