Solution (source code)

= Solution

A <Riemannian metric> is a smooth positive definite symmetric bilinear form $g_q$ on each <tangent space>. The inverse form on the cotangent space defines the kinetic <Hamiltonian>
$$
H(q,p)=\tfrac12g_q^{-1}(p,p)=\tfrac12g^{ij}(q)p_ip_j.
$$
It is smooth and satisfies $H(q,ap)=a^2H(q,p)$. With the canonical <symplectic form> $\Omega=\sum_i dq^i\wedge dp_i$, define $\iota_{X_H}\Omega=dH$. This gives Hamilton's equations
$$
\dot q^i=\partial_{p_i}H=g^{ij}p_j,\qquad\dot p_i=-\partial_{q^i}H.
$$
Thus $p_i=g_{ij}\dot q^j$. Differentiating the inverse metric yields $\dot p_i=\tfrac12\partial_i g_{jk}\dot q^j\dot q^k$. Differentiating $p_i=g_{ij}\dot q^j$ and substituting gives
$$
\ddot q^i+\Gamma^i_{jk}\dot q^j\dot q^k=0.
$$
Therefore the projections of the <Hamiltonian> integral curves are affinely parametrized geodesics, and lifting a <geodesic> by its metric covector gives a <Hamiltonian> integral curve.

For the <Killing vector field> define the fibrewise linear <function> $f(q,p)=p(Y_q)=p_iY^i(q)$. Along the lifted <geodesic> it equals $g(\dot q,Y)$. Metric compatibility and the <geodesic equation> give
$$
\frac d{dt}g(\dot q,Y)=g(\dot q,\nabla_{\dot q}Y)=\tfrac12(\mathcal L_Yg)(\dot q,\dot q)=0.
$$
Thus \b[$f$ is conserved]. Equivalently the cotangent lift of the <isometry> flow preserves $H$, and its generator has <Hamiltonian> $f$, so their <Poisson bracket> vanishes.

For the final two metrics write $s=\ell(x)+m(y)$, restricting to an <open set> where the printed tensors are smooth nondegenerate metrics. Their inverse forms give
$$
H_1=\frac{p_x^2+p_y^2}{2s},\qquad
H_2=\frac{m(y)p_x^2-\ell(x)p_y^2}{2s}=m(y)H_1-\frac12p_y^2.
$$
Along the $H_1$ flow, $H_1$ is constant, while
$$
\dot y=p_y/s,\qquad \dot p_y=\frac{m'(y)}{2s^2}(p_x^2+p_y^2)=\frac{m'(y)H_1}{s}.
$$
Hence
$$
\boxed{\frac{dH_2}{dt}=m'(y)\frac{p_y}{s}H_1-p_y\frac{m'(y)H_1}{s}=0}.
$$
This is the <Liouville metric geodesic integral>, a quadratic conserved quantity. It does not require a <Killing vector field>; it arises from the separated metric coefficients. When both printed metrics are Riemannian, their positivity in particular requires $s>0$, $m>0$ and $\ell<0$; the calculation also applies wherever the corresponding inverse tensors are defined.