Take boat and dog as a system. Initially, centre of mass of the system is at rest, Since no external force is acting on the system, hence centre of mass of the system will remain stationary. Let initially distance of the centre of mass of the boat from the shore be x m.
Then, x2c.m. = \((\frac{40\times x+10\times 20}{40+10})m\)
Here, x1c.m. = distance of the C.M. of the system from the shore.
Since dog moves towards the shore, for the centre of mass of the system to be at rest, the boat has to move away from the shore. Let distance moved by the boat be ‘x’.
Then,

⇒ 50 x’ = 80 ⇒ x′ = 1.6 m.
Hence, distance of dog from the shore is (20 – 8 + 1.6)m = 13.6 m