Solution (source code)

= Solution

When the Hamiltonians agree, exactness of the one-form gives
$$
\sum_i p_i\,dq_i-\sum_iP_i\,dQ_i=dG,
\qquad L-\mathcal L=\frac{dG}{dt}.
$$
The <action> argument of part b then proves canonicity. Equivalently, exterior differentiation preserves the symplectic two-form. For a time-dependent transformation, \b[the <exact differential> must supply the full <action> identity]; a fixed-time check alone would not establish that the new <Hamiltonian> equals the old one without a time-dependent correction.