Solution (source code)

= Solution

Let $V(t)$ be the total variation of $f$ on $[0,t]$. The <Jordan decomposition of a function of bounded variation> is
$$
g(t)=\frac{V(t)+f(t)}2,
\qquad
h(t)=\frac{V(t)-f(t)}2.
$$
For $s<t$, the inequality $V(t)-V(s)\geq|f(t)-f(s)|$ shows that both increments are nonnegative, so $g,h$ are nondecreasing and $f=g-h$. Right-continuity of the <finite variation> function $f$ implies right-continuity of $V$, and hence of $g,h$.