No energy can be gained by electrolysis and recombination.
You need to learn Thermodynamics. It takes exactly as much energy to split a liter of water into hydrogen and oxygen as is given off when the two gasses are recombined, if the process is 100% efficient. No process is 100% efficient, so it actually takes more energy in practice than is released in recombination. Therefore, splitting water into hydrogen and oxygen and recombining them can never generate net energy.
