It seems that something is wrong with round #196 div1 D problem.
This problem's statement and samples are inconsistent at the moment. According to the statement, the answer is YES or NO. But the first sample's output is 5. It was correct till today's afternoon when eventually sample tests' output changed and my solution(which outputs YES or NO only) started receiving WA1(some other people have the same problem).
I hope it will be fixed.
Thanks in regards.