Sorted points on the x-axis: count those within distance d of a query point, then within d of both of two points, then of either.
Sorted points on the x-axis: count those within distance d of a query point, then within d of both of two points, then of either.
Opens with the full question.