Constrained Style Learning from Imperfect Demonstrations under Task Optimality