Could hydrogen liberated from water provide lifting energy which exceeds the energy it took to liberate it from water I was thinking about Hydrogen balloons and that large ones which are used for weather balloons which sometimes go up to 100,000 ft (approx 30km). Then I was wondering, how much potential energy has the balloon gained with the balloon and the weight it carries to get up to 100,000 ft. It seems the object would have a lot of potential energy at that height. If the object was rolled down a ramp from that height, it would generate a lot of energy going down a 30km height ramp. Then how much energy was used to get it to lift, to produce the hydrogen in the first place?
So my question is, could there be any situation where the potential energy the balloon and its cargo gained exceed the energy it took to make the hydrogen in the first place? Then, if so, how could a cycle be set up where the lifting energy of the hydrogen is used to liberate more hydrogen and produce energy.
Here is another idea, what if the balloon started at the bottom of the ocean, a Electrolysis device is separating hydrogen and oxygen from the water down there. A balloon collects the hydrogen and oxygen and pulls upwards. The balloon is attached to a string which it pulls up and turns a pully (wheel) at the bottom as it goes up. Could the rotation of the wheel gain more energy than the cost to extract the hydrogen. I guess the weight of the string would be a factor to consider as well.
My thought is that all of this is very unlikely, as it seems like a perpetual motion device, as the hydrogen and oxygen could be re-combined and it would fall back downwards as water and the cycle would be repeated. The question would be, where does the energy come from? it has to come from somewhere, so this seems very unlikely. I cannot think of where the energy comes from.
But can anyone work out the calculations even for a very basic calculation?
 A: I haven't done the calculations, but I doubt that this scheme would generate net energy. As was pointed out, electrolysis uses a lot of energy. However, after the H2 and O2 rises up the water column, you could get some of the energy back with a fuel cell that would convert the hydrogen and oxygen back to water and supply additional electric power, but inefficiencies at each stage would have to be made up from the energy gained by the rising gases in the column of water.
To show that there has to be a net overall loss of energy, consider the following modification to your problem.  Imagine a long vertical pipe filled with water. Now instead of electrolysis, let's say you instead use an air pump to inflate a balloon near the bottom of the water filled pipe.  This takes work which goes into lifting the column of water up such that the surface of the water rises enough to allow for the volume of the ballon.  Once the ballon has risen through the water column the water level will go back to it's former position. That fall in water level is the source of the energy that the rising ballon could generate.  So there is no free lunch or perpetual motion machine here - inefficiencies at each stage will insure that there is a net loss of energy.
By the way, I do not know this for a fact, but by this thought experiment, I would predict that electrolysis of water under high pressure would take more energy than under lower pressure.  I say this because the electrolysis is effectively inflating a balloon against the pressure of the water - which will thus take more energy at high pressure.
A: The answers stated so far has neglected to take into account the pressure factor. (@George comment). When you try to do any chemical process, you need to pay the energy to overcome the entropy of the system and not only the potential, this is why we consider the free energy of something and not the potential energy. 
If you don't consider that, you can replace water with theoretical chemical, let's call it amazingume, which has similar properties of water except that it is easy to do electrolysis to. You still won't get that desired free energy since you'll have to pay the energy of putting the amazingume elements in the atmospheric pressure.
A: You are correct, they absolutely would constitute perpetual motion devices. A wide variety of schemes like this can be constructed, which all falter on the basis that they violate the first law of thermodynamics - that is, the total energy of a closed system (which both proposals are, though it may not be immediately apparent) is conserved.
Regarding water electrolysis, the massive amount of energy you would be putting in to the reaction $2\mathrm{H_{2}O} \rightarrow 2\mathrm{H_{2}} + \mathrm{O_{2}}$ would find very little representation in the buoyancy of the hydrogen balloon. A mixture of $\mathrm{H}_{2}$ and $\mathrm{O}_{2}$ is quite thermodynamically unstable with respect to $\mathrm{H_{2}O}$, which is the reason why $\mathrm{H}_{2}$ combusts so vigorously, however this thermodynamic instability that you've invested so much energy in contributes nothing to the lifting force of the balloon, which is simply an unrelated consequence of hydrogen just happening to have a lower molecular mass than air.
A: Without going into calculations, one can look at analogues.
There exists the analogue of the hydroelectric power. Essentially power from the sun transfers water from a lower gravitational potential to a higher, in the mountains, and the return of the water to the oceans releases gravitational energy; the sun directly by evaporation from the ocean surface and indirectly by wind energy, temperature, and atmospheric circulations in general.
Thus, what is necessary for your model to work with positive energy results is power outside the system. Solar panels providing electrolysis current would do the job and no perpetual motion is involved, the power will again come from the sun to change the gravitational potential energy of some mass. 
It is not worth it economically, imo: why not use the electricity directly?
Edit
Anybody who has observed the sea bottom has seen bubbles  rise from seaweed and corrals, and speed to the surface. There is kinetic energy in the buoyancy so the question has merrit. 
To find the energy  balance sheet for a process that uses solar energy for electrolysis at some depth, builds up a hydrogen balloon at some ocean depth  ( and why not a second oxygen balloon?), releases it and attempts to recover energy from the kinetic energy of the buoyant balloon needs calculations. In principle the electrolytic energy can be recovered at surface. The kinetic energy of the bubble is the energy of the water falling to fill in the vacuum left from the rising balloon. 
The question of energy conservation boils down to "where does buoyant kinetic energy come from". Somebody has done the work. From gravity, because the falling mass is larger than the rising mass.
A: I think there is a gravitational separator used in mining operations that results in enough hydrogen to run an entire  mine.  This system features an accelerated Venturi effect and deep mine shafts.
