Once Upon a Time in China
A new computer game, "Once Upon a Time in China," is about to be released. For now, we can enjoy the demo version. The game revolves around a young man who learns the art of kung fu and visits various bandit hideouts to defeat the bad guys and seize their stolen money. The young man's kung fu mastery is represented by a non-negative integer.
In the game, there are N bandit hideouts. Each hideout i is characterized by three values: Q_i, S_i, and M_i. The value Q_i is the minimum level of kung fu mastery required for the young man to successfully rob the bandits at hideout i. If his mastery level is below Q_i, he should avoid that hideout. The value S_i represents the amount of money (in yuan) he can take from hideout i if his mastery level is exactly Q_i.
If his kung fu mastery is higher, he can extract more money. Specifically, if his mastery level K falls within the range from Q_i to Q_i·M_i inclusive, he will take an amount equal to S_i·(K/Q_i) from the bandits. If his mastery level exceeds Q_i·M_i, he will take exactly S_i·M_i, as there is no more money to be gained.
However, there's a challenge. The young man must learn kung fu from Master Zen, who charges 1 yuan for each hour of training. As the student's level increases, more training hours are required to further improve his skills. To increase his level from X_1 to X_2, he needs A·(X_2^2-X_1^2) hours of training.
Master Zen only conducts training in whole hours and allows the young man to pay later, after he has used his skills.
Given that the young man starts with no kung fu skills (i.e., his level is 0) and no money, determine the maximum possible profit he can achieve. This profit is the difference between the money taken from the bandits and the amount spent on training.
Input
The first line contains the numbers N (1 ≤ N ≤ 10000) and A (0 ≤ A ≤ 10, with up to 3 decimal places).
Each of the next N lines contains the numbers Q_i, S_i, and M_i (1 ≤ Q_i, S_i ≤ 1000, 1 ≤ M_i ≤ 10. The numbers M_i, S_i, and Q_i are integers).
Output
Output a single number representing the maximum profit the young man can achieve. Your answer should be accurate to within 0.000001 (1e-6).