This Python code will solve the Fair and Square problem in CodeJam 2013's Qualification Round C.