Cumulant generating function formula of heat transfer in ballistic systems with lead-lead coupling