SPOJ Find Maximum Rectangle and Square in N