Solution (source code)

= Solution

A <divisor on an algebraic curve> is a finite formal sum $D=\sum n_pp$ with integer coefficients. Its degree is $\deg D=\sum n_p$. The <principal divisor> of a nonzero <meromorphic function> is $(f)=\sum\operatorname{ord}_p(f)p$. For a nonconstant $f$, zeros and poles are fibers over zero and infinity of the same map to the <sphere>, each of total multiplicity equal to its degree; hence $\deg(f)=0$. A nonzero constant has zero divisor.

Write $L(D)=\{f:(f)+D\geq0\}\cup\{0\}$ and $\ell(D)=\dim L(D)$. The <Riemann-Roch theorem> states
$$
\boxed{\ell(D)-\ell(K_C-D)=\deg D+1-g,}
$$
where $K_C$ is a <canonical divisor>. Taking $D=p_1+\cdots+p_{g+1}$ gives $\ell(D)=2+\ell(K_C-D)\geq2$. Constants span only one <dimension>, so there is a nonconstant $f\in L(D)$. It has no poles outside these points and at most a <simple pole> at each. Thus \b[the required nonconstant function exists], with actual poles at some nonempty subset because a <holomorphic function> on a compact connected curve is constant.