If you travel to Peru in high season (July) you need to buy your bus tickets at least one month in advance if you want to get VIP seats and Suites.
Yeah. The first flight from Lima to Cusco is at 5 am. Arrive in Cusco at 6.20 am. From the airport to the Poroy train station takes about 45 minutes by car. And there are direct services to Aguas Calientes (Machu Picchu Pueblo) such as the luxurious Belmond Hiram Bingham that departs at 9 AM and arrives at its destination at 12:30.
You can enter the Inca city at 1 or 2 PM and take advantage of the less tourists in the afternoon visiting the citadel of Machu Picchu.