(1) He is leaving not just the institute, but also mathematics.
(2) He is not leaving just the institute, but also mathematics.
Does the second sentence imply that he is not going to leave any of them, so he is staying? At first glance they have the same meaning for me.
The second sentence seems to me merely a slightly more difficult to parse version of the first. It doesn’t imply he’s not leaving when it has the ‘just’ and ‘but’ conjunction. Without ‘but…’, maybe it could be made to mean he’s not leaving. But that phrase makes it clear he’s leaving, just takes a few milliseconds longer to figure out what.