Solution (source code)

= Solution

Recognize that $z^2=(x^2-y^2)+2ixy$ and $e^{-z}=e^{-x}(\cos y-i\sin y)$. Their product has exactly the specified real part. Its imaginary part is
$$
v_0=e^{-x}[2xy\cos y-(x^2-y^2)\sin y].
$$
One can also recover it directly from the <Cauchy-Riemann equations>. Differentiating the specified real part gives
$$
u_x=e^{-x}[(2x-x^2+y^2)\cos y+2y(1-x)\sin y].
$$
Integration of $v_y=u_x$ gives $v=v_0+h(x)$; the other equation $v_x=-u_y$ then forces $h'(x)=0$. Thus the most general answer on a connected domain is
$$
\boxed{f(z)=z^2e^{-z}+iC,\qquad C\in\mathbb R.}
$$
Indeed the difference of any two <analytic functions> with the same real part has zero real part; its two <Cauchy-Riemann equations> force its imaginary part to be constant. This proves that no further analytic freedom is missing.