solution for the first large input of fair and square