1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
#include <deque>
#include <algorithm>
using namespace std;

//increase, init;
int ind=0;
deque<pair<long long,long long> > lanes;
deque<pair<long long,long long> > lanes_big;
bool compar(pair<long long,long long> val1,pair<long long,long long> val2){
	return val1.first<val2.first;
}
bool comparbig(pair<long long,long long> val1,pair<long long,long long> val2){
	return val1.first*ind+val1.second>val2.first*ind+val2.second;
}
int main() {
	ios_base::sync_with_stdio(0);
	int count;
	cin>>count;

	lanes.resize(count);
	for(int i=0;i<count;i++){
		cin>>lanes[i].first>>lanes[i].second;

	}

	//sort(lanes.begin(),lanes.end(),compar);
	for(ind=0;ind<count;ind++){
		int collected=0;
		lanes_big=deque<pair<long long,long long> >(lanes);
		sort(lanes_big.begin(),lanes_big.end(),comparbig);

		lanes_big.resize(ind+1);
		sort(lanes_big.begin(),lanes_big.end(),compar);
		//cout<<"|"<<ind;
		for(int j=0;j<=ind;j++){
			collected+=lanes_big[j].first*j+lanes_big[j].second;
			//cout<<" "<<lanes_big[j].first*j+lanes_big[j].second;
		}
		cout<<collected<<endl;
	}
	return 0;
}