Solution (source code)

= Solution

A <divisor> on a compact connected <Riemann surface> is a finite formal sum $D=\sum_pn_pp$ with integer coefficients; its degree is $\sum_pn_p$. A <canonical divisor> is the divisor of zeros and poles of a nonzero meromorphic differential. Two divisors are linearly equivalent when their difference is the divisor of a nonzero <meromorphic function>. Such <principal divisors> have degree zero, but equal degree does not generally imply <linear equivalence of divisors>.

For example take distinct points $p,q$ on a genus-one surface. If $p-q$ were principal, its function would define a degree-one meromorphic map to the sphere, since it has just one <simple pole>. A degree-one map between compact <Riemann surfaces> is a biholomorphism, contradicting their different genera. Thus these degree-one divisors are not equivalent.

Define $L(D)=\{f\text{ meromorphic}: (f)+D\ge0\}\cup\{0\}$ and $\ell(D)=\dim_{\mathbb C}L(D)$. The <Riemann-Roch theorem> states
$$
\ell(D)-\ell(K-D)=\deg D+1-g.
$$
Since all holomorphic functions on the compact surface are constant, $\ell(0)=1$. Setting $D=0$ gives $\ell(K)=g$. Multiplication by a fixed meromorphic differential identifies $L(K)$ with holomorphic differentials, so their dimension is $g$. Setting $D=K$ then gives
$$
\boxed{\dim H^0(S,\Omega^1)=g,\qquad\deg K=2g-2.}
$$
For $g=2$, choose a nonzero holomorphic differential, whose effective <canonical divisor> has degree two. Since $\ell(K)=2$, $L(K)$ contains a nonconstant <meromorphic function>. Its pole divisor is bounded by that effective $K$, proving \b[existence of a nonconstant function with total pole multiplicity at most two].