As promised, here are some (nested) hints for Codeforces Round #682 (Div. 2).
1438A - Специфичные вкусы Андре
Hint 1
Hint 1
Hint 1
Hint 1
I wasn't able to solve E and F. If you did, you may want to add your hints in the comments.
Also, please send a feedback if the hints are unclear or if they spoil the solution too much.