Programming contests are useful for some students in some contexts, but they're harmful to other students in other contexts.
Contests are useful for students who already self-identify as programmers and, are motivated by competition, and enjoy the high-stress environment of a competition. But like you said, the skills acquired by participating in programming contests aren't always useful outside of that environment. I'll also note that your examples are all very math-oriented, so the contests might be geared towards students with a more mathematical background.
But they're less useful for students who are not motivated by competition. Notably, students from under-represented groups or who don't self-identify as programmers are less likely to participate in these, and requiring them to participate can actually discourage them from pursuing computer science.
So, while programming competitions might be one small part of a course, I'd recommend balancing it with other activities that might help other types of students, and pointing out the problems with "competition code" that you mentioned in your question.
I'd also recommend focusing on "hackathons" or "game jams" more than competitions. These have the fun and motivation of a competition, but it's more of a collaborative / cooperative environment. This can be beneficial to students regardless of whether they already self-identify as programmers.