if the dataset used to train an LLM contains a problem statement and corresponding solution code that perfectly matches the prompt, and few or no alternative solutions for the same problem, then yes, many LLMs will in fact output an exact (or almost exact) copy of the solution code in the training dataset.
Same when a specific case is vastly overrepresented.
"Almost exact copy" often including comments with author attribution.
Same with generated images, of course. Even with the watermark from the commercial image bank the original came from.
