Can I stay in Cusco before I go to Machupicchu?
This depends on what type of traveler you are.
If you want to relax and enjoy scenic views of the Andes then I would recommend staying in the Sacred Valley (Ollantaytambo or Urubamba). During the day you would observe the incredible sites and cities of the Sacred Valley, including adventure activities, and then at night there isn’t a lot to do. A couple of restaurants/bars, but that’s about it.
Cusco is the main hub of the area. Think lots of culture, parties, sites, places to walk, markets to shop, things to do. It will have hotel options for all budgets and a never-ending list of things to do and see.
I wouldn’t be worried about altitude. Cusco is at 12K, Sacred Valley is at 9K, not that big of a difference. Use this article as a reference for combating altitude in Cusco: How To Combat The Altitude Of Cusco