Yes that agrees with what I was imagining. But how can you translate it into H and O molecules?

We're aware that when the 'box' is at the bottom, and you're reducing its density to make it float:
X joules of electrical energy is used, which goes towards
Y joules of chemical energy and
Z joules of work lifting the column of fluid above it.

Does X = Y + Z + losses? Conservation of energy says yes, but we're not allowed to rely on that. If we rely on that law then the whole system is automatically, and uninterestingly unworkable without any analysis.

From Paul's calculations which I checked too, it doesn't appear to add up right.