I've never had a problem in Cusco, but my wife did. I did have a headache at Lake Titicaca though after too much walking on my arrival day. Luckily my guide gave me a pill that helped.
Rapid ascent to heights exceeding about 8,000 above sea level can cause oxygen saturation of hemoglobin in the body to decrease. Breathing and heart rate increase immediately, and the heart beats faster. For most people, that's the worst of it since their bodies adapt and the concentration of red blood cells increase. For others, that feeling of breathlessness soon leads to a pounding headache, nausea and vertigo.
What can you do to try to prevent this, or at least make it more tolerable?