Let $m$ be Lebesgue measure and $a \in R$. Suppose that $f : R \to R$ is integrable, and $\int_a^xf(y) \, dy = 0$ for all $x$. Then $f = 0$ a.e.

You need the characterization of measurable sets:

Let $G \subset \Bbb{R}^k$ a bounded set. Then the following are equivalent:

  1. $G$ is Lebesgue measurable.

  2. There exist $B, N \subset \Bbb{R}^k$ such that $G = B \cup N$, $B$ is Borel, $N$ has zero Lebesgue measure.

Now, to conclude your exercize call $G= \{ x : f(x) >0\}$ and write $G=\bigcup_n (G \cap [-n,n])$ as a union of bounded measurable sets. Use the characterization to write $G \cap [-n,n] = B_n \cup N_n$. Finally $$\int_{G \cap [-n,n]} f = \int_{B_n} f = 0$$ So $f=0$ a.e. in $G \cap [-n,n]$. Since $n$ is arbitrary, you have $f=0$ a.e. in $G$.

Do the same thing with $H=\{ x : f(x) <0\}$ and you are done.