A function $f:\Bbb R\to\Bbb R^*$ ($\Bbb R^*$ is the reals together with $\pm\infty$) is upper semicontinuous at $y$ if
$f(y)\neq +\infty$ and $f(y) \geq \limsup\limits_{x\to y} f(x)$. Let $a \in \Bbb R^*$.
Prove that $\{ x: f(x) < a \}$ is an open set. Prove that $\{ x: f(x) = a \}$ is a Borel set.
Suppose that $f$ is upper semicontinous; then for each $x_0\in\Bbb R$ and $\epsilon>0$ there is a $\delta>0$ such that $f(x)\le f(x_0)+\epsilon$ whenever $|x-x_0|<\delta$. Fix $a\in\Bbb R^*$, and let $L=\{x:f(x)<a\}$; we wish to show that $L$ is open. Let $x_0\in L$ be arbitrary. Let $\epsilon=\frac12(a-f(x_0))$; $x_0\in L$, so $f(x_0)<a$, and $\epsilon>0$. Can you finish the argument from there? I've completed it but left it spoiler-protected.
For the second result, let $E=\{x:f(x)=a\}$. Observe that
$$E=\bigcap_{n\in\Bbb N}\{x:f(x)<a+2^{-n}\}\cap\Big(\Bbb R\setminus\{x:f(x)<a\}\Big)\;,$$
and apply the first part of the problem.