Solution (source code)

= Solution

For a regular <Lagrangian> define $p_i=\partial L/\partial\dot q_i$ and $H=\sum_i p_i\dot q_i-L$. Its differential is
$$
dH=\sum_i\dot q_i\,dp_i-\sum_i\frac{\partial L}{\partial q_i}\,dq_i
-\frac{\partial L}{\partial t}\,dt.
$$
The <velocity> differentials cancel. Using $\partial L/\partial q_i=\dot p_i$ and comparing independent coefficients gives
$$
\boxed{\dot q_i=H_{p_i},\quad\dot p_i=-H_{q_i},\quad H_t=-L_t.}
$$
The last equality concerns explicit partial derivatives in their respective natural variables; it does not assert that total time derivatives are always negatives.