Solution (source code)

= Solution

A <divisor on an algebraic curve> is a finite formal sum
$$
D=\sum_{p\in C}n_pp,\qquad n_p\in\mathbb Z.
$$
Its <degree of a divisor> is $\deg D=\sum_pn_p$. It is an <effective divisor>, written $D\geq0$, when every $n_p\geq0$.

A <meromorphic differential on a Riemann surface> is a one-form represented in every local <holomorphic> coordinate $t$ by $a(t)\,dt$, where $a$ is a <meromorphic function>. Under a coordinate change $t=t(u)$, its coefficient becomes $a(t(u))t'(u)$, so these expressions agree on overlapping charts. Since $t'(u)$ is a nonvanishing <holomorphic function> for a valid coordinate change, the order of a zero or <pole> of the differential is independent of coordinate. Equivalently, for a fixed nonconstant <meromorphic function> $h$, any such differential can be written $f\,dh$ with $f$ meromorphic.

A <canonical divisor> is the <divisor on an algebraic curve>
$$
K=(\eta)=\sum_{p\in C}\operatorname{ord}_p(\eta)p
$$
of a nonzero <meromorphic differential on a Riemann surface> $\eta$. If $\eta'=f\eta$, then $(\eta')=(\eta)+(f)$, so all <canonical divisors> are related by <linear equivalence of divisors>. Their degree is
$$
\boxed{\deg K=2g-2.}
$$

The <Riemann-Roch theorem> states that, for every <divisor on an algebraic curve> $D$ and any <canonical divisor> $K$ on the nonsingular <projective curve> $C$ of <genus> $g$,
$$
\boxed{\ell(D)-\ell(K-D)=\deg D+1-g,}
\qquad
\ell(D)=\dim_{\mathbb C}\mathcal L(D).
$$
The term $\ell(K-D)$ measures the failure of the naive count of conditions on <meromorphic functions>.