TITLE: Lebesgue non-measurable function
QUESTION [16 upvotes]: Can we give an example of Lebesgue non-measurable function, for which set $\{x: f(x)=C\}~\forall C\in\mathbb{R}$ is measurable? Thanks.

REPLY [33 votes]: Let $S$ a non-measurable subset of $]0,+\infty[$. Define $$g(x)=\begin{cases} x\text{ if } x\in S\\-x\text{ if } x\notin S\end{cases}$$
$g^{-1}(y)$ is finite $\forall y\in \mathbb{R}$, but $\{ g\geq 0\}\setminus\ ]-\infty,0]=S$ is not measurable.