Recover cost function from profit function
I suggest that you ask yourself the following questions:


If $\tilde{z}(y;w)$ is the input demand from cost minimization, can there be any difference between $\tilde{z}\big(y(p);w\big) \equiv \hat{z} (p;w)$ and $z(p;w)$ from Hotelling's lemma and profit maximization?
Even if $\tilde{z}(y;w)$ is a correspondance rather than a function, is there any difference between $ p \hat{z} (p;w) = p \tilde{z}\big(y(p);w\big) = c(y;w) $ and $p z(p;w)$ (where the later are dot products).


Hope this helps,