Baryon census in hydrodynamical simulations of galaxy clusters