The song at the beginning of Assassination Classroom episode 40 starts from 0:06 when Karma gasps, and stops playing at 0:58, then the theme song "Bye Bye Yesterday" starts.
What's the song at the beginning called?
解き明かされる謎 Tokiakasareru Nazo
A quick note... On Youtube this claims to be from the Second Season OST, which i could not find on Amazon or in fact any of the usual places i go for track lists. there is a version on the First Season OST (track 19 not 2) which is a slower version of the same thing but is not what you're looking for. Sorry i couldnt find you a purchase link but hopefully this will help you in some way.