First of all you must know that battery doesn't provide charge.
It accepts charge at lower potential and places it at a higher potential.
Lets take a 10 volt battery connected across a 10uf capacitor. Charge on capacitor will be 100uc. energy provided by battery is 1000uJ energy stored in the capacitor is 500uj. Now we connect the charged capacitor in the opposite way to the battery. Now final potential Energyu is still 500uJ (change in potential energy of capacitor is zero), but energy supplied by battery is 1000uj