The nice thing about having both pay and cost of living go up: when everything gets more expensive, it becomes that much more effective to live frugally, and you still get a net increase. For the example you gave, if you get a 40% pay increase and your cost of living goes up by 50%, that's still a net win as long as your previous cost of living started out as less than 80% of your income.
This graph shows you the percentage increase in your income after expenses for that situation, as a function of the percentage of your income you currently spend: https://www.wolframalpha.com/input/?i=graph+%28%28100*1.4+-+...