Cade Cunningham led the Pistons with 40 points as they ended a three-game skid with a 117-102 win over the Dallas Mavericks.