#include #include #include std::vector V[200010],save; long long int sum[200010]; int main() { int a,b,c; scanf("%d%d%d",&a,&b,&c); for(int i=1;i<=a;i++) { int d,e; scanf("%d%d",&d,&e); V[e].push_back(d); } for(int i=1;i<=b;i++) std::sort(V[i].begin(),V[i].end()); for(int i=1;i<=b;i++) { if(V[i].size()>=1) { std::reverse(V[i].begin(),V[i].end()); save.push_back(V[i][0]+c); for(int j=1;j