Solution (source code)

= Solution

For a nonconstant holomorphic map $f:X\to Y$ of degree $d$ between compact <Riemann surfaces>, <Riemann-Hurwitz formula> is $2g_X-2=d(2g_Y-2)+\sum_p(e_p-1)$. Triangulate $Y$ with branch values as vertices and lift the triangulation: faces and edges lift $d$ times, while the vertex deficit is exactly the ramification sum. Comparing Euler characteristics proves the formula.