Solution (source code)

= Solution

For an oriented surface normal $N$ and a unit-speed curve tangent $T$, take signed <geodesic curvature> $k_g=(dT/ds)\cdot(T\times N)$. This convention uses boundary orientation with the region on the right; reversing to the usual left-hand boundary convention reverses both orientation and the corresponding curvature convention. With positive orientation consistent this way, the <Gauss-Bonnet theorem> for a region $D$ with piecewise smooth boundary is
$$
\boxed{\int_DK\,dA+\int_{\partial D}k_g\,ds+\sum\text{exterior turning angles}=2\pi\chi(D).}
$$
For a disk with smooth boundary there are no corner terms and $\chi(D)=1$. Stating the signed convention is necessary to reproduce the sign in part (ii).