The compression ratio for Stable Diffusion is 1:25000 or more, 5B images into 5GB. I think you're overly dramatic about it. Not even a single pixel from an image. And a snippet 2-3 lines long of code, that 99.9% of the time is generic, is not worth all this scandal.
There is a distinction between learning and replicating an idea vs. the expression of it. AI is entitled to learn ideas from copyrighted works even if authors don't approve. Only expression is protected. Even API names are ok.
I think the natural balance would be to set filters that restrict replication of copyrighted code. And that's it, every kind of derivative is ok as long as it does not look overly similar to any copyrighted code. But excluding code that is generic and replicated in many sources, because that doesn't deserve to be protected and it would just stunt the model.