CF607E Cross Sum

Description

Genos has been given $ n $ distinct lines on the Cartesian plane. Let ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF607E/828bd1f150735aa8c65c79525d1418ab3058d668.png) be a list of intersection points of these lines. A single point might appear multiple times in this list if it is the intersection of multiple pairs of lines. The order of the list does not matter. Given a query point $ (p,q) $ , let ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF607E/887c79cacd151e1b1341a67c48b05ad1977a6a94.png) be the corresponding list of distances of all points in ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF607E/828bd1f150735aa8c65c79525d1418ab3058d668.png) to the query point. Distance here refers to euclidean distance. As a refresher, the euclidean distance between two points $ (x_{1},y_{1}) $ and $ (x_{2},y_{2}) $ is ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF607E/86b2aa253cbc7f8f2ad97ad58bb4a22991d5ff81.png). Genos is given a point $ (p,q) $ and a positive integer $ m $ . He is asked to find the sum of the $ m $ smallest elements in ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF607E/887c79cacd151e1b1341a67c48b05ad1977a6a94.png). Duplicate elements in ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF607E/887c79cacd151e1b1341a67c48b05ad1977a6a94.png) are treated as separate elements. Genos is intimidated by Div1 E problems so he asked for your help.

Input Format

N/A

Output Format

N/A

Explanation/Hint

In the first sample, the three closest points have distances ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF607E/03e1c4be79c9981c15945694583ed8d2e2085b66.png) and ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF607E/d62dafca248b736710e5c1ac832c2ae727a7ca37.png). In the second sample, the two lines $ y=1000x-1000 $ and ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF607E/faf029c89031cc072ce6f3860dca6bca047834e2.png) intersect at $ (2000000,1999999000) $ . This point has a distance of ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF607E/e834978c95cd4c06fee17dcf9f08db5c1d7a9312.png) from $ (-1000,-1000) $ . In the third sample, the three lines all intersect at the point $ (1,1) $ . This intersection point is present three times in ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF607E/828bd1f150735aa8c65c79525d1418ab3058d668.png) since it is the intersection of three pairs of lines. Since the distance between the intersection point and the query point is $ 2 $ , the answer is three times that or $ 6 $ .