Let $f:\mathbb{R}\to\mathbb{R}$ be a differentiable function such that the set $A:=\{x\in\mathbb{R};f'(x)\not\in\{1,-1\}\}$ has measure $0$. Does this imply that $f'$ is constant?
Context: I was thinking about a question whose author probably meant "continuously differentiable curves" instead of just "differentiable curves", but I wanted to think about the general case. I don't know anything about functions with discontinuous derivative so I have no idea if the answer will be yes or no.
Edit: As Christian Remling mentions in the comments, here is another answer which implies that if $f'$ was not constant, then the measure of $A$ would be greater than $0$. Also, as mentioned by Mateusz Kwaśnicki below, a paper was devoted to proving this result.