On the best Hardy constant for quasi-arithmetic means and homogeneous deviation means