You're assuming that management cares about having good software more than it cares about replacing developers with a machine.
Assuming management has the ability to tell the difference and not just count lines of code or commits.
and if this trend will continue the good ones increasingly aren't going to be working either. hopefully they realize they are getting themselves there by cooperating
How to separate them if the code is already mixed?
this assumes it's easy to differentiate between the two groups.