Solution (source code)

= Solution

Because $S_1$ and $S_2$ are <isometry>[isometric],
$$
\chi(S_1)=\chi(S_2),
\qquad
\int_{S_1}K\,dA=\int_{S_2}K\,dA.
$$
The two induced orientations on their common boundary $\gamma$ are opposite. If
$$
B=\int_\gamma k_g\,ds
$$
is computed with the boundary orientation from $S_1$, then its value for $S_2$ is $-B$. Applying the <Gauss-Bonnet theorem> to the two halves gives
$$
\int_{S_1}K\,dA+B=2\pi\chi(S_1),
\qquad
\int_{S_2}K\,dA-B=2\pi\chi(S_2).
$$
The equalities above imply $B=0$. This is the <isometric halves give zero total boundary geodesic curvature> argument.

Every ambient isometry $\phi_{x,y}$ preserves the magnitude of geodesic curvature and sends $x$ to $y$. Hence $|k_g|$ is constant along the connected curve $\gamma$ by the <transitive curve symmetry makes geodesic-curvature magnitude constant>. If that constant were positive, continuity would force the signed $k_g$ to have one fixed sign, making its integral nonzero. Therefore $k_g\equiv0$. A curve has zero geodesic curvature exactly when it is a <geodesic>, so $\gamma$ is geodesic.