Solution (source code)

= Solution

Take
$$
G'=(\{a,b\},\{S,A,B\},P',S),
$$
where
$$
P'=\{S\to ABA,\ A\to AB,\ B\to BA,\ A\to a,\ B\to b\}.
$$
This grammar is in <Weak Chomsky normal form>. In the original grammar, $C$ occurs only in $S\to AC$ and has the sole production $C\to BA$. Thus every use of
$$
S\to AC\to ABA
$$
is replaced in $G'$ by $S\to ABA$, while every later production is unchanged. Conversely, the ternary production can always be expanded into those two original steps. Therefore $G'$ is equivalent to $G$ in the sense of an <equivalent grammar>.