Thank you for participating in the contest! I hope you enjoyed the tasks. Here is an editorial with hints. I will upload solutions in C++ later.
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Good luck in your future contests!