Under construction

Still being built. Things may change

Shooting Lasers

Time limit1.5sMemory limit1024 MB

Summary
Given sensors in a strip with mirror walls, find the launch angle from (0, 0) that lights the most sensors using fewer than K wall reflections.
Level

Medium6 of 10

Topics
Math, Sorting
Solved
No attempts yet

Problem

A plane has width MM, is fixed at the bottom, and extends infinitely upward. Map the space onto a coordinate plane so that the lower-left corner is the point (0,0)(0, 0). The point xx units to the right and yy units up from (0,0)(0, 0) is (x,y)(x, y). Since the width is MM, the lines x=0x = 0 and x=Mx = M are the two side walls.

A laser launcher sits at (0,0)(0, 0). Both side walls are mirrors, so when the laser hits a wall, it reflects with the angle of incidence equal to the angle of reflection. Due to a technical limitation, the launcher cannot be turned to a direction parallel or perpendicular to the walls.

On the plane there are NN distinct lattice points, and each has a sensor. When the laser passes exactly through a sensor's coordinates, the light bulb connected to that sensor turns on. Each reflection weakens the laser, so a laser that has reflected off a mirror KK or more times is not detected by any sensor.

Given NN and the sensor coordinates, find the maximum number of bulbs that can be lit at the same time by adjusting the firing angle of the launcher.

Input

The first line contains the number of sensors NN (1≤N≤1 0001 \le N \le 1\,000), the wall width MM (2≤M≤10 0002 \le M \le 10\,000), and the number of reflections KK (1≤K≤1 0001 \le K \le 1\,000) after which the laser is too weak to be detected.

From the second line through line N+1N+1, each line gives the coordinates (x,y)(x, y) of a sensor (0<x<M0 < x < M, 0<y<10 000 0000 < y < 10\,000\,000). All sensors are on integer points, and no point is given twice.

Output

Print the maximum number of bulbs that can be lit at the same time with the launcher.

Examples2

  1. Example 1

    Input
    3 4 3
    1 3
    2 2
    3 1
    
    Expected output
    3
    
  2. Example 2

    Input
    3 5 4
    2 10
    2 15
    4 5
    
    Expected output
    3