A geometric inequality in the Heisenberg group and its applications to stable solutions of semilinear problems