Dark matter and leptogenesis from gravitational production