Problem Link : https://cses.fi/problemset/task/1636/ If you are getting TLE in your correct code, then don't get deprecated.
I have submitted several times and get frustrated.
So, here is the solution
Solution
Thanks for reading, Keep coding.
My Code