As I understand it, if the President dies in office, the VP succeeds to the Presidency. If he then serves in that way for more than 365 days, he can only stand in his own right for one more term, rather than the normal two.
If the sitting President is reelected but dies between the election...