The Rotating Camera
A warehouse floor is a flat plane with integer coordinates. A security camera is
mounted at the point (cx, cy), and n objects lie on the floor, each at an
integer point. Objects are tiny and never hide one another.
The camera sits on a swivel and can be turned to face any direction in the plane,
not just whole-degree directions. Its lens has a field of view exactly θ
degrees wide. Once the camera is turned, the bearing of an object is the
direction of the ray from the camera to that object. The camera sees an object if
its bearing lies inside the field of view or exactly on either of its two
edges. In other words, the field of view is a closed angular sector of width
θ with its apex at the camera. With θ = 360 the sector is the whole plane.
An object lying exactly at the camera's position (cx, cy) has no bearing, and
the camera always sees it, whichever way it faces.
The guard wants to turn the camera so that it sees as many objects as possible at the same moment. Find that maximum number.
Input
The first line contains two integers n and θ (1 ≤ n ≤ 10^5,
0 ≤ θ ≤ 360): the number of objects and the width of the field of view in
degrees.
The second line contains two integers cx and cy, the camera's position.
Each of the next n lines contains two integers x_i and y_i, the position
of the i-th object. Several objects may share a position, and any number of
them may lie exactly at the camera's position.
All coordinates satisfy -10^9 ≤ cx, cy, x_i, y_i ≤ 10^9.
For θ < 360 the test data also guarantees the following. Take any two objects
A and B that are not at the camera's position, and let φ be the angle,
measured in degrees in [0, 360), through which the ray towards A must be
turned counterclockwise to reach the ray towards B. Then either φ = θ
exactly, or |φ − θ| ≥ 10^-6. Exact equality can and does happen (for example,
the bearings towards (1, 0) and (1, 1) from (0, 0) are exactly 45
degrees apart), but you never have to resolve a difference smaller than 10^-6
degrees. So computing bearings in double precision and comparing them with a
small tolerance, such as 10^-9 radians, is safe.
Output
Print one integer: the largest number of objects the camera can see at once.
Notes
In the first example the camera is at (1, 1), and θ = 90. Seen from the
camera, the objects at (4, 1), (3, 3) and (1, 4) lie due east, northeast
and due north. If the field of view runs from east to north, the first and the
third of them lie exactly on its edges, so all three are seen. The object at
(1, 1) is at the camera's position and is always seen, which gives 4. No turn
of the camera sees four objects that are not at its position.
In the second example the camera is at (-2, 3). The objects at (3, 2),
(2, 4) and (4, 5) have bearings of about 348.7, 14.0 and 18.4 degrees
counterclockwise from east. A 60-degree field of view that starts slightly
south of east covers all three. Remember that a field of view may cross the
due-east direction.