To keep the COM at the same position, velocity of COM is zero, so
$\frac{m_{1} \vec{v_{1}}+m_{2} \vec{v_{2}}}{m_{1}+m_{2}}$
(where $\vec{v_{1}}$ and $\vec{v_{2}}$ are velocities of particles 1 and 2 respectively.]
$\Rightarrow\, \quad m_{1} \frac{d \vec{r_{1}}}{d t}+m_{2} \frac{d \vec{r_{2}}}{d t}=0$
$\left[\because\vec{v_{1}} =\frac{d \vec{r_{1}}}{d t} \& \vec{v_{2}} =\frac{d \vec{r_{2}}}{dt}\right]$
$\Rightarrow m, d \vec{r_{1}}+m_{2}d \vec{r_{2}} =0 $[d $\vec{r_{1}}$ dnd d $\vec{r_{2}}$ represent the change in displacement of particles]
Let 2nd particle has been displaced by distance x.
$\Rightarrow\, \quad m_{1} \left(d\right)+m_{2} \left(x\right)=0 \Rightarrow x=\frac{m_{1}d}{m_{2}}$
-ve sign shows that both the particles have to move in opposite directions.
$so, \, \frac{m _{1} d}{m_{2}}$ is the distance moved by 2nd particle to keep COM at the same position.