Self-evidently, Presidents Andrew Johnson and William Clinton, the only ones subjected to impeachment and trial, had been elected the last time they ran. Otherwise, the impeachment terms of the Constitution could never have applied to them. Ummm... you may know the subject "nine ways from Sunday," but Andrew Johnson was not elected. He was Veep and attained the presidency as a result of the Lincoln assassination. Clinton was and is the only elected president to be impeached.
Andrew Johnson was "elected the last time he ran" exactly as I said. He was elected Vice President, unlike Gerald Ford and Nelson Rockefeller, both of whom became Vice President without having been elected to that office.
John / Billybob