Answer
$1.02\;\rm cm$
Work Step by Step
We know that the compressed distance of the spring is given by
$$F_{sp}=kx$$
where $k$ is the spring constant and $x$ is the compressed distance from the spring's equilibrium point.
Thus,
$$x=\dfrac{F_{sp}}{k}\tag 1$$
Now we need to find the spring force which is equal in magnitude and opposite in direction to the force exerted on the spring by the piston.
$$F_{piston}=|F_{sp}|=\Delta PA=(P_2-P_1)A$$
where $\Delta P$ is the change in the pressure of the gas, $P_1=P_a$, and $P_2$ is the final gas pressure.
Plugging into (1);
$$x=\dfrac{(P_2-P_1)A}{k}\tag 2$$
So, we have to find the pressure $P$ when the gas temperature is raised to 100$^\circ$C
Assuming that the gas sealed inside the cylinder is an ideal gas, so
$$\dfrac{P_1V_1}{T_1}=\dfrac{P_2V_2}{T_2}$$
Noting that $V_1=AL$ where $L$ is the length of the cylinder before the gas pushes the piston, while $V_2=A(L+x)$ where $x$ is the extra distance moved by the piston due to the air pressure which is at the same time is the compressed distance by the spring.
$$\dfrac{P_1 \color{red}{\bf\not} AL}{T_1}=\dfrac{P_2\color{red}{\bf\not} A(L+x)}{T_2}$$
$$\dfrac{P_1 L}{T_1}=\dfrac{P_2 (L+x)}{T_2}$$
Solving for $P_2$;
$$\dfrac{P_1 LT_2}{T_1(L+x)}= P_2 $$
Plugging into (2) and solving for $x$;
$$x=\left[\dfrac{P_1 LT_2}{T_1(L+x)}-P_1\right]\dfrac{ A}{k} $$
$$x=\left[\dfrac{ LT_2}{T_1(L+x)}-1\right]\dfrac{ P_1 A}{k} $$
Noting that $P_1=P_a$
$$x=\left[\dfrac{ LT_2-T_1(L+x)}{T_1(L+x)} \right]\dfrac{ P_aA}{k} $$
$$x(L+x)=\left[ LT_2-T_1(L+x) \right]\dfrac{ P_aA}{T_1k} $$
$$x(L+x)=\left[ LT_2-T_1 L -T_1x \right]\dfrac{ P_aA}{T_1k} $$
$$x(L+x)=\left[ L(T_2-T_1 ) -T_1x \right]\dfrac{ P_aA}{T_1k} $$
$$x(L+x)= L(T_2-T_1 ) \dfrac{ P_aA}{T_1k} -\dfrac{ P_aA}{ k} x $$
$$xL+x^2+\dfrac{ P_aA}{ k} x = \dfrac{ P_aA L(T_2-T_1 )}{T_1k} $$
$$ x^2+\left[\dfrac{ P_aA}{ k} +L\right] x - \dfrac{ P_aA L(T_2-T_1 )}{T_1k} =0\tag 3$$
Now we need to find $L$, so
$$P_1V_1=nRT_1$$
Hence,
$$\overbrace{P_1}^{P_a} AL=nRT_1$$
$$L=\dfrac{nRT_1}{P_a A }$$
Plugging into (3);
$$ x^2+\left[\dfrac{ P_aA}{ k} +\dfrac{nRT_1}{P_a A }\right] x - \dfrac{nR\color{red}{\bf\not} T_1}{\color{red}{\bf\not} P_a\color{red}{\bf\not} A } \dfrac{ \color{red}{\bf\not} P_a\color{red}{\bf\not} A (T_2-T_1 )}{\color{red}{\bf\not} T_1k} =0 $$
$$ x^2+\left[\dfrac{ P_a^2A^2+nRT_1 k}{ kP_a A} \right] x -\left[\dfrac{nR (T_2-T_1)}{ k} \right]=0 $$
Plugging the known;
$$ x^2+\\
\left[\dfrac{ (1.013\times 10^5)^2(10\times 10^{-4})^2+(0.004)(8.31)(20+273)(1500)}{ (1500)(1.013\times 10^5)(10\times 10^{-4})} \right] x -\\
\left[\dfrac{(0.004)(8.31)(100-20)}{ (1500)} \right]=0 $$
Using any software calculator, so
$$x=0.010196\;{\rm m},\;\;\;\;\;\;{\rm Or,}\;\;\;\;\;\; x=-0.173872\;\rm m$$
And since $x$ here is considered as length, it can't be negative. So we have to dismiss the negative root.
Therefore,
$$x=\color{red}{\bf1.02}\;\rm cm$$