Mahmud vs Ridwan (Hard)

Limits: 1s, 512 MB

Mahmud is playing a game with Ridwan. He (Mahmud) will be given N cartesian points by Ridwan. Mahmud can connect two points by drawing a line. Now there is a condition, he cannot draw a line which is already parallel to previously drawn lines. For each created line he will earn D$. Now Mahmud wants your help to find out what will be his maximum possible earning?


This is a companion discussion topic for the original entry at https://toph.co/p/mahmud-vs-ridwan-hard