Competitive Programming - Theory vs Practice

I hope this is not a cliched question.
But I want to ask, is it more important to do contests and learn from them or to learn theory and then do contests. I know that obviously both are important. But is it a good idea to first learn all theory, including algorithms, data structures etc. and then take part in contests or take part in contests and learn from the problems I couldn’t solve. Obviously it is not a good idea to do only contests (i think?).
So which is a better way to improve?
I had this idea that I was going to first learn all the algorithms, data structures and other things before returning back to contests but is that really a good idea?


You are mixing competitive programming with learning Data structures and Algorithms.

When you take part in contests and compete, you are improving your implementation skills, logic digging skills, thinking fast and many more.

When you learn some algorithms or data structures, it’s just staying in a limit.

To expand that, you need to participate and upsolve (as you mentioned).