The Hamiltonian is KE + PE
The Lagrangian is KE - PE
Imagine a Lagrangian as the difference of two terms,
Term 1 the generalized velocities vi
Term 2 the generalized coordinates xi,
then L(vi,qi) = KE(vi) - PE(qi) is the Lagrangian.