One question that's implied in several of our discussions so far is, do we want cs50.SE to exist independently of the basic standards of conduct in effect generally on Stack Exchange? In many situations, the "correct" community moderation action to take depends on whether helping the user solve their problem takes priority over cultivating quality and standards on the site.
Since this resource is provided at no cost to us by Stack Exchange, I think it's only basic respect that we should at least try to cultivate quality and conform to basic standards, in the context of our host network. And that means using the tools we're given, including votes and flags. It's possible to be friendly while criticizing or downvoting, as well as effective; it just takes practice and care.
So, with that long wind-up out of the way, here's what I would have done.
I would have removed the link (or any other code dump) in its entirety, without choosing the "right" snippet. For one thing, it's really important in either of these contexts (SE user and cs50 student) to get used to identifying where in your code something has gone wrong. The concept of an MCVE is incredibly powerful for anyone who codes, in practically any context, and the act of putting together an MCVE is itself a great debugging exercise that helps people understand their own and other people's code. It's important to engage users in conversation about this and encourage them - by exerting some pressure to conform to basic community standards in a friendly manner - to develop skills in this area.
On the other hand, although you and I are more likely to be able to identify an appropriate snippet more quickly than someone with less experience, we also run the risk of identifying the wrong snippet - especially when the question is unclear or important details are left unstated. This has the potential to solicit answers that actually have nothing to do with the solution the user needs, but appear to solve the problem as presented by us, the editors. It also (I believe) crosses a line between neutral editing and taking active control over content. To some extent, the composition of the relevant snippet is subjective, and imposing the editor's choice of snippet takes some agency from the asker. Compared to the challenge of the course itself, asking users to put just a little effort into writing a good question is hardly demanding.
Having edited to remove the code dump, I would leave a comment on the post to explain the reason for the edit and ask the user to choose their own snippet. In my experience moderating the subreddit, most users are happy to do this once they're given the reminder (although the fact that on the subreddit I'm removing their post completely instead of editing it is probably an added incentive).
As far as the two-questions-in-one problem, different network sites seem to have different attitudes. I don't see too much of an issue with it here; although it's always better to have one question and one answer, both the code issue and the gdb issue are raised in pursuit of solving the same problem. The gdb questions are directly related to the code, and plenty of high-quality posts contain questions within them incidental to the main question. As long as people don't go crazy asking questions about different problem sets in the same post, or a laundry list of errors/bugs that have nothing to do with each other, I don't mind.