If a president and simultaneously a presidential candidate Trump would have to quit before the November vote the remainder of his presidency would of course be assumed by Pence, his VP and running mate. But what would happen to Trump's 2020 candidacy? Would Pence automatically be able to continue running in Trump's stead? That is, would the Republican have to nominate the new presidential candidate, or is the presidential candidacy constitutionally inherited by the corresponding VP candidate? Furthermore, would Pence have the standing to participate in debates as both the VP candidate against Harris and as the presidential candidate against Biden?
There isn't a single "candidacy". Each of the 50 states and DC holds an election for a slate of electors, and those electors later participate in the actual election for President and Vice President in the Electoral College.
For each state's election for electors, the ballot usually prints the name of the "candidate" for President and Vice President submitted by the party. The rules on under what circumstances the names on the ballot can be changed varies by state, and it may also depend on how close to election date it is, as it may be infeasible to change it once ballots have started being printed.
However, even if a state's ballots print the name of certain candidates for President and VP in the election for the slate of electors, that does not necessarily mean that those electors, once chosen, will necessarily have to vote for those candidates. So if a party's candidate withdraws too close to the election for the ballots to be changed, or withdraws after the election but before the Electoral College votes, the party's leadership will probably instruct all of the electors of that party (i.e. electors in the states that that party's candidate for President won in) to vote for a new ticket of President and VP in the Electoral College.
Whether the electors will or can follow those instructions is a little tricky. Some states have laws requiring electors to pledge to vote for the Presidential and VP candidates that won in that state, and I am not sure whether the parties can change the Presidential and VP candidates after the election. This would vary by state. In some states, the pledge requirement has no penalty for violation; in some states, there is a fine; and in some states, the state will replace an elector who does not vote for the pledged candidate. (And the Supreme Court ruled in Chiafalo v. Washington (2020) that it is legal for states to fine and/or replace faithless electors.) Again, you would need to look at the specific state's law to see if there is an exception for if the Presidential/VP candidate withdraws.
As for debates, as a commenter noted, they are run by the Commission on Presidential Debates, a private corporation, so it would be completely up to that corporation to decide who would be invited to which debates.