P1369 Rectangle

Description

Given $n$ points on the plane, find an axis-aligned rectangle whose boundary contains as many points as possible.

Input Format

The first line contains an integer $n$, the number of points in the plane. Each of lines $2\sim n+1$ contains two integers, the $x$- and $y$-coordinates of a point.

Output Format

Output a single integer: the maximum number of points that can lie on the boundary of the chosen rectangle.

Explanation/Hint

Constraints and Notes - For $40\%$ of the data, $1 \le n \le 30$. - For $100\%$ of the data, $1 \le n \le 300$, and each coordinate lies in the range $[1,100]$. Translated by ChatGPT 5