PS: dont totally accept my ans first confirm it by an expert
See find charges b4 and after the events ,
u will find that the battery supplies an extra charge =\frac{\varepsilon CC_{0} }{2C+C_{0}}
But since there is no change in the total electrostatic energy stored by the system , all work done by battery is converted to heat
so work done by battery = charge supplied x EMF
= heat
\frac{\varepsilon^{2} CC_{0} }{2C+C_{0}}