Code Jam Fair and Square

This is a solution to the FairAndSquare problem asked in the qualification round of Google Code Jam-2013. Please read the problem statement very carefully as the correctness of solution depends heavily on how you understand and interpret the problem statement. We present here two solutions to the problem one for the small input and the other for the large ...