Hamiltonian formulation of systems with balanced loss-gain and exactly solvable models