To improve, just upsolving problems is not enough. You also need to ask yourself at what point you diverged from the intended solution, or what you could've done differently to arrive at the intended solution.
I made a video editorial discussing my train of thoughts involved for solving D. Learning to Paint from last CodeTON Round. The video talks about how you can spot patterns in problems and use them to your advantage for future problems.
Youtube Link : https://youtu.be/EGp72-5MV8U?si=1l9kq1SFQ_qhFRro
If you need any help (for this problem only), you can ask on my Discord Server or on the Twitter thread. In case you are interested, you can also checkout my youtube channel