Solution (source code)

= Solution

Let $e=\tfrac12(|A|^2+|B|^2)$. The time equations and the <dot product> <differentiation> rule give the local identity
$$
\partial_t e=A\cdot(\nabla\times B)-B\cdot(\nabla\times A).
$$
The <divergence of a cross product> is
$$
\nabla\cdot(A\times B)=B\cdot(\nabla\times A)-A\cdot(\nabla\times B).
$$
Combining them yields $\partial_t e+\nabla\cdot(A\times B)=0$. On a fixed bounded region with a <boundary> regular enough for the <divergence theorem>, differentiating under the <integral> and applying that theorem gives
$$
\boxed{\frac d{dt}\left[\frac12\int_V(|A|^2+|B|^2)\,dV\right]
=-\int_{\partial V}(A\times B)\cdot n\,dS.}
$$
Here $n$ is the outward <unit normal>, so the sign expresses loss of the interior quadratic quantity by outward flux. No vanishing-boundary assumption is required.