Showing that if $f$ is surjective, then $m\geq n$ holds (where $m$ and $n$ are the number of elements in the domain and codomain respectively)
For each $y\in Y$, let $N(y)$ be the number of elements in $X$ that are mapped to $y$.
Then $\sum_{y\in Y} N(y) = |X|$ because every element of $X$ is mapped to some element of $Y$ and the fibers of $f$ partition $X$.
If $f$ is surjective, then $N(y)\ge 1$ for all $y \in Y$. Therefore $$ |Y|=\sum_{y\in Y} 1 \le \sum_{y\in Y} N(y) = |X| $$
If $f$ is injective, then $N(y)\le 1$ for all $y \in Y$. Therefore $$ |Y|=\sum_{y\in Y} 1 \ge \sum_{y\in Y} N(y) = |X| $$