Solution (source code)

= Solution
{c}

Apply the local bound from condition (1) separately to $f$ and $-f$. For any $a\in X$ and $\varepsilon>0$, there are $r_+,r_->0$ such that
$$
d(x,a)<r_+\implies f(x)<f(a)+\varepsilon,\qquad d(x,a)<r_-\implies -f(x)<-f(a)+\varepsilon.
$$
With $\delta=\min\{r_+,r_-\}$, both inequalities hold when $d(x,a)<\delta$, so
$$
f(a)-\varepsilon<f(x)<f(a)+\varepsilon.
$$
This is exactly <continuity> at $a$. Since $a$ was arbitrary, $f$ is <continuous> on $X$: <upper semicontinuity> of $f$ and of $-f$ is equivalent to simultaneous <upper semicontinuity> and <lower semicontinuity> of $f$.