For Japan, to prevent split imposed by the Soviet 'dibs' doctrine, the USA/Brits would have to conquer the whole of the Japanese islands before the USSR has landed any troops. Unless the USA was prepared to incur even more casualties by 'rushing', this will be difficult. As it was, Operation Downfall pretty near brought down the American government over all of the dead and maimed US troops. Do not forget, at the time, the involvement of the Russians in Japan was encouraged so that they could have some of the casualties. The only way I see this working would be a slightly stronger Germany/Axis group for a little bit longer, keeping the Soviets distracted. The Romanians, українська армія свободи (Free Ukrainians), and Hungarians could have been supported better so they fought cohesively a bit longer for Germany. If you want a deus ex machina solution, perhaps the atomic bomb projects could have had a bit more early success, so that they were available in 1946 to force a quicker surrender by Japan rather than in 1948 when there was no war to use them upon.
For Germany, we would need a better Russian outcome, so that their armies get to the greater Brandenburg area at the same time as the Western Allies, or even a little bit sooner. Maybe Germany committed fewer atrocities, so the Russian reprisals were lessened? Maybe the Free French / Brits / USA did more bad things to enrage the Germans? Whatever it is, some dynamic would have to change so that the Germans did not deploy over 85% of their resources in the Eastern defense. It is clear that, other than local pockets, the Eastern-front Germans fought to the last man, fanatically giving ground as slowly as possible, while the Western-Front Germans seemed to give ground quickly, offering only token resistance (by comparison). Clearly, the German army knew which of their opponents they wanted occupying the Fatherland, once it was obvious that they could not prevail.