Solution (source code)

= Solution

Choose a normalized set-theoretic section $s:H\to E$ of $\pi$, so $s(1)=1$. Define the <extension cocycle>
$$
\phi(h,k)=s(h)s(k)s(hk)^{-1}\in M.
$$
Associativity of $s(h)s(k)s(l)$ gives, in multiplicative notation for $M$,
$$
\phi(h,k)\phi(hk,l)
=(h\cdot\phi(k,l))\phi(h,kl),
$$
which is exactly the <two-cocycle> identity. Thus $\phi$ represents the class of the <group extension> in $H^2(H,M)$.