HP to lay off about 27,000, profit slides 31 percent