code:
#include<bits/extc++.h>
using namespace std;
int n,w,k;
using P = std::pair<int, int>;
vector<P>je;
vector<P>::iterator it;
int main(){
cin>>n>>w>>k;
for(int i=1;i<=n;i++){
int a,b;
cin>>a>>b;
je.push_back({a,b});
}
sort(je.begin() + 1, je.begin() + n + 1,
[](const P& a, const P& b) { return a.second < b.second; });
for(it=je.begin();it!=je.end();it++){
printf("%d %d\n",it->first,it->second);
}
int ans=0;
while(k--){
it=je.end()-1;
ans+=it->second;
je.erase(it);
}
cout<<ans<<' '<<je.size();
}
/*
input:
4 10 1
9 10
10 1
3 5
5 20
*/