I wrote my solution after I watched editorial.
Now I know that many things can go wrong and when I get WA first time didn’t really feel anything.
But I started to double-check the answers with accepted solutions (ex. solutions in python)
I checked answers on my local system from K = 2 X = 2, to K = 1000000 X = 1000000
and it was the same answer as the accepted solution.
Anyone is for hunting the bug?
Thank you in advance!
Lukas
Solution: https://www.codechef.com/viewsolution/39810198
IRINGWO