You have to stay in Cuzco (+ maybe get used to the height) and start from there to Machu Picchu (the train ride to Machu Picchu takes around 1.5-2h oneway + bus ride uphill). I did the trip the other way round (coming from the South, stayed in Cuzco with trip to Machu Picchu) and continued via Lima. I arrived in the morning in Lima and left in the late evening (I used an airport shuttle. I strongly believe that the airport shuttle also drives to the hotels in Lima). It's not worth while to stay longer in Lima for sightseeing and Lima is too far away from Machu Picchu in order to use it as base.
Full report with pictures (Machu Picchu, Cuzco, etc.)