#include <bits/stdc++.h>   using namespace std;   inline char gc() {     static char buf[1 << 16], *S, *T;     if (S == T) {       T = (S = buf) + fread(buf, 1, 1 << 16, stdin);       if (T == S) return EOF;     }     return *S++;   }   inline int read() {     int x = 0, f = 1;     char ch = gc();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = gc();     }     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = gc();     return x * f;   }   int n, w, mxb, mxa, bel[100010], nn, cnt[350], q[350][350], qh[350], qt[350];   long long d[100010];   struct data {     int a, b;     friend bool operator<(data a, data b) { return a.b < b.b; }   } A[100010];   inline double slope(int i, int j) { return (d[i] - d[j]) * 1.0 / (j - i); }   inline void gao(int i, int x) {     while (qh[i] < qt[i] && slope(q[i][qh[i]], q[i][qh[i] + 1]) <= x) ++qh[i];   }   inline void rebuild(int id, int l, int r) {     qh[id] = 1;     qt[id] = 0;     for (int i = l; i <= r; ++i) {       while (qh[id] < qt[id] &&              slope(q[id][qt[id]], i) < slope(q[id][qt[id] - 1], q[id][qt[id]]))         --qt[id];       q[id][++qt[id]] = i;     }     gao(id, 0);   }   inline void add(int x) {     if (!x) return;     for (int i = 1; i < bel[x]; ++i) gao(i, ++cnt[i]);     int l = (bel[x] - 1) * nn + 1, r = min(bel[x] * nn, mxa), id = bel[x];     for (int i = l; i <= r; ++i) d[i] += (long long)cnt[id] * i;     for (int i = l; i <= x; ++i) d[i] += i;     cnt[id] = 0;     rebuild(id, l, r);   }   int main() {     n = read();     w = read();     for (int i = 1; i <= n; ++i)       A[i].a = read(), A[i].b = read(), mxb = max(mxb, A[i].b),       mxa = max(mxa, A[i].a);     sort(A + 1, A + n + 1);     int now = 1;     nn = sqrt(mxa);     for (int i = 1; i <= mxa; ++i) bel[i] = (i - 1) / nn + 1;     int tot = bel[mxa];     for (int i = 1; i <= tot; ++i) qh[i] = 1, q[i][++qt[i]] = min(i * nn, mxa);     int flag = 0;     for (int c = 0; c <= mxb + 1; ++c) {       while (now <= n && A[now].b < c) add(A[now].a), ++now;       long long ans = 0;       int ans1 = 0;       for (int i = 1; i <= tot; ++i) {         int x = q[i][qh[i]];         if (d[x] + (long long)x * cnt[i] > ans)           ans = d[x] + (long long)x * cnt[i], ans1 = x;       }       printf( %I64d %d n , ans + (long long)w * c * (n - now + 1), ans1);       if (c == 1) flag = ans + (long long)w * c * (n - now + 1);     }     return 0;   }   