Solution (source code)

= Solution

For $H=H(p)$, <Hamilton's equations> give
$$
p(t)=P,
\qquad
q(t)=Q+tH'(P).
$$
Thus $P=p$ and $Q=q-tH'(p)$. The <Poisson bracket> is $\{Q,P\}=1$, so the transformation is canonical for every $t$. A type-2 generator is
$$
\boxed{F_2(q,P,t)=qP-tH(P)}.
$$
Indeed $p=\partial_qF_2=P$, $Q=\partial_PF_2=q-tH'(P)$, and the transformed Hamiltonian is $K=0$, as expected because $Q,P$ are constants of motion.