6. On graph paper, a polygon with a perimeter of 2014 is drawn, with its sides running along the grid lines. What is the maximum area it can have?
Solution. First, consider the extreme verticals and horizontals. Moving from them inward does not allow reducing the perimeter, but it decreases the area. Therefore, the rectangle has the largest area. If A and B are the lengths of its sides, then $A + B = 1007$.

Now, among different rectangles with a perimeter of 2014, we need to find the rectangle with the largest value of the area $AB$. Since $4AB = (A + B)^2 - (A - B)^2 = 1007^2 - (A - B)^2$, to achieve the maximum value of the area $AB$, we need to choose A and B so that their difference is as small as possible. Since the sum of A and B is odd, they cannot be equal. Therefore, the smallest possible value of $A - B = 1$. Considering $A + B = 1007$, we find $A = 504, B = 503$, and $AB = \mathbf{253512}$.

## Criteria.

A complete solution consists of two parts: (1) proving that rectangles are better than other shapes and (2) proving that the best rectangle is a square.

If (1) is stated but not proven, the problem is not solved (max. 2 points). If (2) is stated but not proven, the problem is solved with a deficiency (5 points). As proof, the analysis of the quadratic function or a clear reference to the isoperimetric inequality is considered.

Only the answer (or the answer with the indication that it is obtained for a square) - 1 point.