Sweet Earnings at Codedamn
At Codedamn's candy lab, there's a total of chocolates available for sale.
Each day, the goal is to sell chocolates, with a reward of rupee for every chocolate sold up to the goal. For any chocolates sold beyond this daily target, the reward doubles to rupees for each additional chocolate.
Given that chocolates are sold in a particular day, your task is to calculate the total earnings of the day.
Format for input
- The first line will contain a single integer , representing the number of test cases.
- For each test case, there will be two space-separated integers and — the daily sales target, and the actual number of chocolates sold.
Format for output
For every test case, print on a new line the total earnings for that day.
Constraints
Sample Test Cases (and explanation)
Case #1:
Input:
4 3 1 5 5 4 7 2 3
Output:
1 5 10 4
Explanation
Test case : The daily sales target was . Only chocolate was sold, earning rupee.
Test case : The daily sales target was . With chocolates sold, the total earnings were rupees.
Test case : The daily sales target was . Selling chocolates led to earnings of rupees for the first chocolates and an additional rupees per chocolate for the extra chocolates, making a total of rupees.
Test case : The daily sales target was . Selling chocolates resulted in earnings of rupees for the first chocolates and an additional rupees for the extra chocolate, totaling rupees.