\[ \boxed { {\frac {{\rm d}^{2}}{{\rm d}{x}^{2}}}y \left ( x \right ) +2\,y \left ( x \right ) {\frac {\rm d}{{\rm d}x}}y \left ( x \right ) +f \left ( x \right ) \left ( {\frac {\rm d}{{\rm d}x}}y \left ( x \right ) + \left ( y \left ( x \right ) \right ) ^{2} \right ) -g \left ( x \right ) =0} \]
Mathematica: cpu = 0.325541 (sec), leaf count = 35 \[ \text {DSolve}\left [f(x) \left (y'(x)+y(x)^2\right )-g(x)+y''(x)+2 y(x) y'(x)=0,y(x),x\right ] \]
Maple: cpu = 0.609 (sec), leaf count = 63 \[ \left \{ y \left ( x \right ) ={\it ODESolStruc} \left ( {\it \_b} \left ( {\it \_a} \right ) ,[ \left \{ {{\rm e}^{\int \!f \left ( {\it \_a} \right ) \,{\rm d}{\it \_a}}} \left ( {\it \_b} \left ( {\it \_a} \right ) \right ) ^{2}+{{\rm e}^{\int \!f \left ( {\it \_a} \right ) \,{\rm d}{\it \_a}}}{\frac {\rm d}{{\rm d}{\it \_a}}}{\it \_b} \left ( {\it \_a} \right ) -\int \!{{\rm e}^{\int \!f \left ( {\it \_a} \right ) \,{\rm d}{\it \_a}}}g \left ( {\it \_a} \right ) \,{\rm d}{\it \_a}+{ \it \_C1}=0 \right \} , \left \{ {\it \_a}=x,{\it \_b} \left ( {\it \_a} \right ) =y \left ( x \right ) \right \} , \left \{ x={\it \_a},y \left ( x \right ) ={\it \_b} \left ( {\it \_a} \right ) \right \} ] \right ) \right \} \]