Striker Othmane Maamma has come off the bench to score the decisive goal as Montpellier won 2-1 at Toulouse to move off the bottom of the French league.