Problem:
B: 三角形足し算
問題
長さ $N$ の数列 $A = (a_1, ..., a_N)$ があり、値は最初全て $0$ である。
数列 $A$ に対して、以下で説明するクエリを $Q$ 回行う。
二つの正整数 $l$, $k$ が与えられる。$0 \leq i < k$ を満たす各整数 $i$ に対して $a_{l+i}$ に $i+1$ を加算する。
$Q$ 回のクエリを順に処理した後の数列 $A$ を出力せよ。
入力形式
入力は $Q + 1$ 行で与えられる。
$N$ $Q$
$l_1$ $k_1$
$l_2$ $k_2$
...
$l_Q$ $k_Q$
$1$ 行目には、数列の長さ $N$ とクエリの数 $Q$ が空白区切りで与えられる。
続く $Q$ 行には、各 $l$ と $k$ が空白区切りで与えられる。$l_i$ 及び $k_i$ はそれぞれ $i$ 番目のクエリの $l$ 及び $k$ を表す。
制約
入力は全て整数で与えられる
$1 \leq N \leq 2 \times 10^5$
$1 \leq Q \leq 2 \times 10^5$
$2 \leq l_i + k_i  \leq N + 1$ ($1\leq i\leq Q$)
$1 \leq l_i$ ($1\leq i\leq Q$)
$1 \leq k_i$ ($1\leq i\leq Q$)
出力形式
クエリを処理し終えた後の $A$ の各要素を、$1$ 番目から順番に半角スペース区切りで一行に出力せよ。
入力例1
4 1
2 3
出力例1
0 1 2 3
このクエリにおいて、$A$ の添字 $2 \leq i < 2+3$ の部分が変化する。
まず $a_2$ に $1$ 加算する。
次に $a_3$ に $2$ 加算する。
最後に $a_4$ に $3$ 加算する。
結果、できる数列は $(0, 1, 2, 3)$ である。
入力例2
8 3
1 2
2 4
3 6
出力例2
1 3 3 5 7 4 5 6
入力例3
10 15
1 2
2 3
3 2
3 2
3 2
3 2
3 2
4 3
5 3
5 2
5 2
5 2
7 2
8 2
9 2
出力例3
1 3 7 14 6 11 4 3 3 2
ここにそのような例を載せることはできませんが、オーバーフローには注意してください。

Submitted solutions:

code_snippet: #pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using lint = long long;
using ull = unsigned long long;
using ld = long double;
using int128 = __int128_t;
#define all(x) (x).begin(), (x).end()
#define EPS 1e-8
#define uniqv(v) v.erase(unique(all(v)), v.end())
#define OVERLOAD_REP(_1, _2, _3, name, ...) name
#define REP1(i, n) for (auto i = std::decay_t<decltype(n)>{}; (i) != (n); ++(i))
#define REP2(i, l, r) for (auto i = (l); (i) != (r); ++(i))
#define rep(...) OVERLOAD_REP(__VA_ARGS__, REP2, REP1)(__VA_ARGS__)
#define log(x) cout << x << endl
#define logfixed(x) cout << fixed << setprecision(10) << x << endl;
#define logy(bool)         \
  if (bool) {              \
    cout << "Yes" << endl; \
  } else {                 \
    cout << "No" << endl;  \
  }

ostream &operator<<(ostream &dest, __int128_t value) {
  ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(ios_base::badbit);
    }
  }
  return dest;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < (int)v.size(); i++) {
    os << v[i] << (i + 1 != (int)v.size() ? " " : "");
  }
  return os;
}

template <typename T>
ostream &operator<<(ostream &os, const set<T> &set_var) {
  for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
    os << *itr;
    ++itr;
    if (itr != set_var.end()) os << " ";
    itr--;
  }
  return os;
}

template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &map_var) {
  for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
    os << itr->first << " -> " << itr->second << "\n";
  }
  return os;
}

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}

void out() { cout << '\n'; }
template <class T, class... Ts>
void out(const T &a, const Ts &...b) {
  cout << a;
  (cout << ... << (cout << ' ', b));
  cout << '\n';
}

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &in : v) is >> in;
  return is;
}

inline void in(void) { return; }
template <typename First, typename... Rest>
void in(First &first, Rest &...rest) {
  cin >> first;
  in(rest...);
  return;
}

template <typename T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

vector<lint> dx8 = {1, 1, 0, -1, -1, -1, 0, 1};
vector<lint> dy8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<lint> dx4 = {1, 0, -1, 0};
vector<lint> dy4 = {0, 1, 0, -1};

#pragma endregion

template <class S,
          auto op,
          auto e,
          class F,
          auto mapping,
          auto composition,
          auto id>
struct lazy_segtree {
 private:
  unsigned int seg_bit_ceil(unsigned int n) {
    unsigned int x = 1;
    while (x < (unsigned int)(n)) x *= 2;
    return x;
  }

 public:
  static_assert(std::is_convertible_v<decltype(op), std::function<S(S, S)>>,
                "op must work as S(S, S)");
  static_assert(std::is_convertible_v<decltype(e), std::function<S()>>,
                "e must work as S()");
  static_assert(
      std::is_convertible_v<decltype(mapping), std::function<S(F, S)>>,
      "mapping must work as F(F, S)");
  static_assert(
      std::is_convertible_v<decltype(composition), std::function<F(F, F)>>,
      "compostiion must work as F(F, F)");
  static_assert(std::is_convertible_v<decltype(id), std::function<F()>>,
                "id must work as F()");
  lazy_segtree() : lazy_segtree(0) {}
  explicit lazy_segtree(int n) : lazy_segtree(std::vector<S>(n, e())) {}
  explicit lazy_segtree(const std::vector<S> &v) : _n(int(v.size())) {
    size = (int)seg_bit_ceil((unsigned int)(_n));
    log = __builtin_ctz((unsigned int)size);
    d = std::vector<S>(2 * size, e());
    lz = std::vector<F>(size, id());
    for (int i = 0; i < _n; i++) d[size + i] = v[i];
    for (int i = size - 1; i >= 1; i--) {
      update(i);
    }
  }

  void set(int p, S x) {
    assert(0 <= p && p < _n);
    p += size;
    for (int i = log; i >= 1; i--) push(p >> i);
    d[p] = x;
    for (int i = 1; i <= log; i++) update(p >> i);
  }

  S get(int p) {
    assert(0 <= p && p < _n);
    p += size;
    for (int i = log; i >= 1; i--) push(p >> i);
    return d[p];
  }

  S prod(int l, int r) {
    assert(0 <= l && l <= r && r <= _n);
    if (l == r) return e();

    l += size;
    r += size;

    for (int i = log; i >= 1; i--) {
      if (((l >> i) << i) != l) push(l >> i);
      if (((r >> i) << i) != r) push((r - 1) >> i);
    }

    S sml = e(), smr = e();
    while (l < r) {
      if (l & 1) sml = op(sml, d[l++]);
      if (r & 1) smr = op(d[--r], smr);
      l >>= 1;
      r >>= 1;
    }

    return op(sml, smr);
  }

  S all_prod() { return d[1]; }

  void apply(int p, F f) {
    assert(0 <= p && p < _n);
    p += size;
    for (int i = log; i >= 1; i--) push(p >> i);
    d[p] = mapping(f, d[p]);
    for (int i = 1; i <= log; i++) update(p >> i);
  }
  void apply(int l, int r, F f) {
    assert(0 <= l && l <= r && r <= _n);
    if (l == r) return;

    l += size;
    r += size;

    for (int i = log; i >= 1; i--) {
      if (((l >> i) << i) != l) push(l >> i);
      if (((r >> i) << i) != r) push((r - 1) >> i);
    }

    {
      int l2 = l, r2 = r;
      while (l < r) {
        if (l & 1) all_apply(l++, f);
        if (r & 1) all_apply(--r, f);
        l >>= 1;
        r >>= 1;
      }
      l = l2;
      r = r2;
    }

    for (int i = 1; i <= log; i++) {
      if (((l >> i) << i) != l) update(l >> i);
      if (((r >> i) << i) != r) update((r - 1) >> i);
    }
  }

  template <bool (*g)(S)>
  int max_right(int l) {
    return max_right(l, [](S x) { return g(x); });
  }
  template <class G>
  int max_right(int l, G g) {
    assert(0 <= l && l <= _n);
    assert(g(e()));
    if (l == _n) return _n;
    l += size;
    for (int i = log; i >= 1; i--) push(l >> i);
    S sm = e();
    do {
      while (l % 2 == 0) l >>= 1;
      if (!g(op(sm, d[l]))) {
        while (l < size) {
          push(l);
          l = (2 * l);
          if (g(op(sm, d[l]))) {
            sm = op(sm, d[l]);
            l++;
          }
        }
        return l - size;
      }
      sm = op(sm, d[l]);
      l++;
    } while ((l & -l) != l);
    return _n;
  }

  template <bool (*g)(S)>
  int min_left(int r) {
    return min_left(r, [](S x) { return g(x); });
  }
  template <class G>
  int min_left(int r, G g) {
    assert(0 <= r && r <= _n);
    assert(g(e()));
    if (r == 0) return 0;
    r += size;
    for (int i = log; i >= 1; i--) push((r - 1) >> i);
    S sm = e();
    do {
      r--;
      while (r > 1 && (r % 2)) r >>= 1;
      if (!g(op(d[r], sm))) {
        while (r < size) {
          push(r);
          r = (2 * r + 1);
          if (g(op(d[r], sm))) {
            sm = op(d[r], sm);
            r--;
          }
        }
        return r + 1 - size;
      }
      sm = op(d[r], sm);
    } while ((r & -r) != r);
    return 0;
  }

 private:
  int _n, size, log;
  std::vector<S> d;
  std::vector<F> lz;

  void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); }
  void all_apply(int k, F f) {
    d[k] = mapping(f, d[k]);
    if (k < size) lz[k] = composition(f, lz[k]);
  }
  void push(int k) {
    all_apply(2 * k, lz[k]);
    all_apply(2 * k + 1, lz[k]);
    lz[k] = id();
  }
};

class RangeLinearAddRangeSum {
 private:
  static constexpr long long INF = 8e18;
  static constexpr int INFI = int(1e9) + 10;

  struct S {
    long long sum;
    int l, r;
  };
  struct F {
    long long a, b;
  };

  static S op(S a, S b) {
    return S{a.sum + b.sum, min(a.l, b.l), max(a.r, b.r)};
  }
  static S e() {
    return S{0, INFI, -INFI};
  }

  static S mapping(F f, S s) {
    return {s.sum + (f.a * (s.l + s.r - 1) + f.b * 2) * (s.r - s.l) / 2, s.l, s.r};
  }

  static F composition(F f, F g) {
    return {f.a + g.a, f.b + g.b};
  }

  static F id() {
    return F{0, 0};
  }

  lazy_segtree<S, op, e, F, mapping, composition, id> seg;

 public:
  RangeLinearAddRangeSum(const vector<long long> &v) {
    int n = int(v.size());
    vector<S> tmp(n);
    for (int i = 0; i < n; i++) {
      tmp[i].l = i;
      tmp[i].r = i + 1;
      tmp[i].sum = v[i];
    }
    seg = lazy_segtree<S, op, e, F, mapping, composition, id>(tmp);
  }

  void set(int i, S x) {
    seg.set(i, x);
  }
  S get(int i) {
    return seg.get(i);
  }
  S all_prod() {
    return seg.all_prod();
  }
  S prod(int l, int r) {
    return seg.prod(l, r);
  }
  void apply(int l, int r, F f) {
    seg.apply(l, r, F{f.a, f.b - f.a * get(l).l});
  }
  void apply(int i, F f) {
    seg.apply(i, F{f.a, f.b - f.a * get(i).l});
  }

  template <bool (*g)(S)>
  int max_right(int l) {
    return seg.max_right(l, [](S x) { return g(x); });
  }
  template <bool (*g)(S)>
  int min_left(int r) {
    return seg.min_left(r, [](S x) { return g(x); });
  }
};
int main() {
  cin.tie(0)->sync_with_stdio(0);
  int n, q;
  in(n, q);
  vector<long long> v(n);
  RangeLinearAddRangeSum seg(v);

  rep(i, q) {
    int l, k;
    in(l, k);
    l--;
    seg.apply(l, l + k, {1, 1});
  }

  vector<long long> res(n);
  rep(i, n) {
    res[i] = seg.get(i).sum;
  }

  out(res);
}
accuracy: 1
time_ms: 150
memory_kb: 20168
final_rank: 16

code_snippet: #include <vector>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cassert>
#include <limits>

constexpr int bit_ceil_log(unsigned int n) {
    int x = 0;
    while ((1 << x) < (unsigned int)(n)) x++;
    return x;
}

template <typename T>
struct linear_add_range_sum {
  private:
    struct node {
        T sum, lza, lzb;
        long long isum;
        int sz;
        node(int i = -1, T v = 0) : sum(v), lza(0), lzb(0), isum(i == -1 ? 0 : i), sz(i == -1 ? 0 : 1) {}
    };

    int _n, size, log;
    std::vector<node> nd;

    void all_apply(int k, T a, T b) {
        nd[k].sum += nd[k].isum * a + nd[k].sz * b;
        if (k < size) nd[k].lza += a, nd[k].lzb += b;
    }

    void push(int k) {
        all_apply(2 * k, nd[k].lza, nd[k].lzb);
        all_apply(2 * k + 1, nd[k].lza, nd[k].lzb);
        nd[k].lza = nd[k].lzb = 0;
    }

    void pull(int k) {
        nd[k].sum = nd[k * 2].sum + nd[k * 2 + 1].sum;
    }
  
  public:
    linear_add_range_sum() : linear_add_range_sum(0) {}
    linear_add_range_sum(int n) : linear_add_range_sum(std::vector<T>(n, 0)) {}
    linear_add_range_sum(const std::vector<T>& v) : _n(int(v.size())) {
        log = bit_ceil_log((unsigned int)_n);
        size = 1 << log;
        nd = std::vector<node>(2 * size);
        for (int i = 0; i < size; i++) nd[size + i] = node(i < _n ? i : -1, i < _n ? v[i] : 0);
        for (int i = size - 1; i >= 1; i--) {
            nd[i].sz = nd[2 * i].sz + nd[2 * i + 1].sz;
            nd[i].isum = nd[2 * i].isum + nd[2 * i + 1].isum;
            nd[i].sum = nd[2 * i].sum + nd[2 * i + 1].sum;
        }
    }
    
    void set(int p, T x) {
        assert(0 <= p && p < _n);
        int P = p;
        p += size;
        for (int i = log; i >= 1; i--) push(p >> i);
        nd[p] = node(P, x);
        for (int i = 1; i <= log; i++) pull(P >> i);
    }

    T get(int p) {
        assert(0 <= p && p < _n);
        p += size;
        T a = 0, b = 0;
        for (int i = log; i >= 1; i--) a += nd[p >> i].lza, b += nd[p >> i].lzb;
        return nd[p].sum + nd[p].isum * a + b;
    }

    void apply(int l, int r, T a, T b) {
        assert(0 <= l && l <= r && r <= _n);
        if (l == r) return;
        l += size;
        r += size;
        {
            int l2 = l, r2 = r;
            while (l < r) {
                if (l & 1) all_apply(l++, a, b);
                if (r & 1) all_apply(--r, a, b);
                l >>= 1;
                r >>= 1;
            }
            l = l2;
            r = r2;
        }
        for (int i = 1; i <= log; i++) {
            if (((l >> i) << i) != l) pull(l >> i);
            if (((r >> i) << i) != r) pull((r - 1) >> i);
        }
    }

    // [l, r)のsum
    T prod(int l, int r) {
        assert(0 <= l && l <= r && r <= _n);
        if (l == r) return 0;
        l += size;
        r += size;
        for (int i = log; i >= 1; i--) {
            if (((l >> i) << i) != l) push(l >> i);
            if (((r >> i) << i) != r) push((r - 1) >> i);
        }
        T res = 0;
        while (l < r) {
            if (l & 1) res += nd[l++].sum;
            if (r & 1) res += nd[--r].sum;
            l >>= 1;
            r >>= 1;
        }
        return res;
    }
};

#include <iostream>

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int N, Q;
    std::cin >> N >> Q;
    linear_add_range_sum<long long> seg(N);

    for (int i = 0; i < Q; i++) {
        int l, k;
        std::cin >> l >> k;
        l--;
        seg.apply(l, l + k, 1, -l + 1);
    }

    for (int i = 0; i < N; i++) {
        std::cout << seg.get(i) << (i + 1 == N ? "\n" : " ");
    }
}
accuracy: 1
time_ms: 70
memory_kb: 25164
final_rank: 17

code_snippet: #include <bits/stdc++.h>
using namespace std;

template<typename OpMonoid>
struct lazy_segtree {
    using S = typename OpMonoid::S;
    using F = typename OpMonoid::F;
    lazy_segtree() : lazy_segtree(0) {}
    lazy_segtree(int _n) : lazy_segtree(vector<S>(_n, OpMonoid::e())) {}
    lazy_segtree(const vector<S> &v) { init(v); }
    void set(const vector<S> &v) { init(v); }
    void set(int p, const S &x) {
        assert(0 <= p && p < n);
        p += sz;
        inner_push(p);
        d[p] = x;
        inner_update(p);
    }
    void apply(int p, const F &f) {
        assert(0 <= p && p < n);
        p += sz;
        inner_push(p);
        d[p] = OpMonoid::mapping(f, d[p]);
        inner_update(p);
    }
    void apply(int l, int r, const F &f) {
        assert(0 <= l && l <=r && r <= n);
        l += sz;
        r += sz;
        for (int i = log; i >= 1; i--) {
            if (((l >> i) << i) != l) push(l >> i);
            if (((r >> i) << i) != r) push((r - 1) >> i);
        }
        int l2 = l, r2 = r;
        while (l < r) {
            if (l & 1) all_apply(l++, f);
            if (r & 1) all_apply(--r, f);
            l >>= 1;
            r >>= 1;
        }
        l = l2, r = r2;
        for (int i = 1; i <= log; i++) {
            if (((l >> i) << i) != l) update(l >> i);
            if (((r >> i) << i) != r) update((r - 1) >> i);
        }
    }
    S get(int p) {
        assert(0 <= p && p < n);
        p += sz;
        inner_push(p);
        return d[p];
    }
    S prod(int l, int r) {
        assert(0 <= l && l <=r && r <= n);
        l += sz;
        r += sz;
        for (int i = log; i >= 1; i--) {
            if (((l >> i) << i) != l) push(l >> i);
            if (((r >> i) << i) != r) push((r - 1) >> i);
        }
        S pl = OpMonoid::e(), pr = OpMonoid::e();
        while (l < r) {
            if (l & 1) pl = OpMonoid::op(pl, d[l++]);
            if (r & 1) pr = OpMonoid::op(d[--r], pr);
            l >>= 1;
            r >>= 1;
        }
        return OpMonoid::op(pl, pr);
    }
    S all_prod() const { return d[1]; }
private:
    int n, log, sz;
    vector<S> d;
    vector<F> lz;
    void init(const vector<S> &v) {
        n = v.size();
        log = 1;
        while ((1 << log) < n) log++;
        sz = 1 << log;
        d = vector<S>(2 * sz, OpMonoid::e());
        lz = vector<F>(sz, OpMonoid::id());
        for (int i = 0; i < n; i++) d[i + sz] = v[i];
        for (int i = sz - 1; i >= 1; i--) update(i);
    }
    void update(int p) {
        d[p] = OpMonoid::op(d[2 * p], d[2 * p + 1]);
    }
    void all_apply(int p, const F &f) {
        d[p] = OpMonoid::mapping(f, d[p]);
        if (p < sz) lz[p] = OpMonoid::comp(f, lz[p]);
    }
    void push(int p) {
        all_apply(2 * p, lz[p]);
        all_apply(2 * p + 1, lz[p]);
        lz[p] = OpMonoid::id();
    }
    void inner_update(int p) {
        for (int i = 1; i <= log; i++) update(p >> i);
    }
    void inner_push(int p) {
        for (int i = log; i >= 1; i--) push(p >> i);
    }
};

template<typename T>
struct range_arithmetic_add_range_sum {
    static constexpr int inf = numeric_limits<int>::max() / 2;
    struct S {
        T sm;
        int l, r;
        T sum() const { return sm; }
        S() : S(0, inf, -inf) {}
        S(T x, int p) : S(x, p, p + 1) {}
        S(T _sm, int _l, int _r) : sm(_sm), l(_l), r(_r) {}
    };
    static S op(const S&a, const S &b) {
        S c;
        c.sm = a.sum() + b.sum();
        c.l = min(a.l, b.l);
        c.r = max(a.r, b.r);
        return c;
    }
    static S e() {
        return S();
    }
    struct F {
        T a, b;
        F() : F(0, 0) {}
        F(T _a, T _b) : a(_a), b(_b) {}
    };
    static F comp(const F &f, const F &g) {
        return F(f.a + g.a, f.b + g.b);
    }
    static F id() {
        return F();
    }
    static S mapping(const F &f, const S &x) {
        S y;
        y.sm = x.sm + (f.a * (x.l + x.r - 1) + f.b * 2) * (x.r - x.l) / 2;
        y.l = x.l;
        y.r = x.r;
        return y;
    }
};

using M = range_arithmetic_add_range_sum<long long>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, Q;
    cin >> N >> Q;
    lazy_segtree<M> seg(N);
    for (int i = 0; i < N; i++) {
        seg.set(i, M::S(0, i));
    }
    while (Q--) {
        int l, k;
        cin >> l >> k;
        l--;
        seg.apply(l, l + k, M::F(1, 1 - l));
    }
    for (int i = 0; i < N; i++) {
        cout << seg.get(i).sum() << " \n"[i + 1 == N];
    }
}
accuracy: 1
time_ms: 150
memory_kb: 18556
final_rank: 15

code_snippet: #include <bits/stdc++.h>


using namespace std;
//make -f ../makefile SRC=
/*
prefix sum for AP
*/


//------------------------------------------------------------------------------
bool DEBUG = false;
const int INF = 1000000000;

const int MAX_N = 200000 + 5;
static int64_t vect[MAX_N];

//------------------------------------------------------------------------------
void solve(int N)
{
    //--------------------------------------------------------------------------
    // base cases:
    //--------------------------------------------------------------------------
    // init:
    //--------------------------------------------------------------------------
    // compute:
    for (int i=1; i<N+1; ++i) vect[i] += vect[i-1];
    for (int i=1; i<N+1; ++i) vect[i] += vect[i-1];

    for (int i=1; i<N; ++i) printf("%ld ", vect[i]);
    printf("%ld\n", vect[N]);
}

//------------------------------------------------------------------------------
void test()
{

}

//------------------------------------------------------------------------------
int main()
{
    //test(); return 0;
    //DEBUG = true;
    //--------------------------------------------------------------------------
    int N, Q, K, L, num;
    num = scanf("%d %d ", &N, &Q);
    for (int i=0; i<N+5; ++i) vect[i] = 0;
    for (int q=0; q<Q; ++q)
    {
        num = scanf("%d %d ", &K, &L);
        vect[K]++;
        vect[K+L] -= L+1;
        vect[K+L+1] += L;
    }
    solve(N);
    //--------------------------------------------------------------------------
    return 0;
}
//------------------------------------------------------------------------------
accuracy: 1
time_ms: 30
memory_kb: 5128
final_rank: 3

code_snippet: #include <bits/stdc++.h>


using namespace std;
//make -f ../makefile SRC=
/*
prefix sum for AP
*/


//------------------------------------------------------------------------------
bool DEBUG = false;
const int INF = 1000000000;

const int MAX_N = 200000 + 5;
static int vect[MAX_N];

//------------------------------------------------------------------------------
void solve(int N)
{
    //--------------------------------------------------------------------------
    // base cases:
    //--------------------------------------------------------------------------
    // init:
    //--------------------------------------------------------------------------
    // compute:
    for (int i=1; i<N+1; ++i) vect[i] += vect[i-1];
    for (int i=1; i<N+1; ++i) vect[i] += vect[i-1];

    for (int i=1; i<N; ++i) printf("%d ", vect[i]);
    printf("%d\n", vect[N]);
}

//------------------------------------------------------------------------------
void test()
{

}

//------------------------------------------------------------------------------
int main()
{
    //test(); return 0;
    //DEBUG = true;
    //--------------------------------------------------------------------------
    int N, Q, K, L, num;
    num = scanf("%d %d ", &N, &Q);
    for (int i=0; i<N+5; ++i) vect[i] = 0;
    for (int q=0; q<Q; ++q)
    {
        num = scanf("%d %d ", &K, &L);
        vect[K]++;
        vect[K+L] -= L+1;
        vect[K+L+1] += L;
    }
    solve(N);
    //--------------------------------------------------------------------------
    return 0;
}
//------------------------------------------------------------------------------
accuracy: 0.38235294117647056
time_ms: 20
memory_kb: 4008
final_rank: 20

code_snippet: #define _CRT_SECURE_NO_WARNINGS
#pragma GCC target "no-avx"

#if USE_MP
#include <boost/multiprecision/cpp_int.hpp>
#endif
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#if defined _DEBUG
//#include "TestCase.h"
//#include "Util.h"
#endif

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tlll;
typedef tuple<int, int, int> tiii;

using ai2 = array<int, 2>;
using ai3 = array<int, 3>;
using ai4 = array<int, 4>;
using al2 = array<ll, 2>;
using al3 = array<ll, 3>;
using al4 = array<ll, 4>;
using ad2 = array<ld, 2>;
using ad3 = array<ld, 3>;
using ad4 = array<ld, 4>;

inline void Yes(bool upper = false) { cout << (upper ? "YES" : "Yes") << "\n"; }
inline void No(bool upper = false) { cout << (upper ? "NO" : "No") << "\n"; }

inline ll DivCeil(ll nume, ll deno)
{
	assert(deno != 0);
	if (deno < 0) { nume = -nume; deno = -deno; }
	if (nume < 0) return -(-nume / deno);
	else return (nume + deno - 1) / deno;
}
inline ll DivFloor(ll nume, ll deno)
{
	assert(deno != 0);
	if (deno < 0) { nume = -nume; deno = -deno; }
	if (nume < 0) return -((-nume + deno - 1) / deno);
	else return nume / deno;
}
inline ll DivRound(ll nume, ll deno)
{
	assert(deno != 0);
	if (deno < 0) { nume = -nume; deno = -deno; }
	if (nume < 0) return -((-nume + deno / 2) / deno);
	else return (nume + deno / 2) / deno;
}

template <typename T, int S>
auto MakeVecImpl(queue<int>& size, const T& ini)
{
	if constexpr (S == 1)
	{
		return vector<T>(size.front(), ini);
	}
	else
	{
		int fsize = size.front();
		size.pop();
		return vector(fsize, MakeVecImpl<T, S - 1>(size, ini));
	}
}

template <typename T, int S>
auto MakeVec(const array<int, S>& size, const T ini = T())
{
	queue<int> qsize;
	for (const auto v : size) qsize.push(v);
	return MakeVecImpl<T, S>(qsize, ini);
}
int d4[][2] =
{
	{0,-1},
	{0,1},
	{-1,0},
	{1,0},
};
int d8[][2] =
{
	{-1,-1},
	{0,-1},
	{1,-1},

	{-1,0},
	{1,0},

	{-1,1},
	{0,1},
	{1,1},
};
vector<array<int, 2>> Neighbor2(int y, int x)
{
	vector<array<int, 2>> ret;
	ret.push_back({ y, x + 1 });
	ret.push_back({ y + 1, x });
	return ret;
}
vector<array<int, 2>> Neighbor4(int y, int x)
{
	vector<array<int, 2>> ret;
	ret.push_back({ y, x - 1 });
	ret.push_back({ y, x + 1 });
	ret.push_back({ y - 1, x });
	ret.push_back({ y + 1, x });
	return ret;
}
vector<array<int, 2>> Neighbor6(int y, int x)
{
	vector<array<int, 2>> ret;
	const int ofs = (y & 1); // 1 - (y & 1); //

	ret.push_back({ y, x - 1 });
	ret.push_back({ y, x + 1 });

	ret.push_back({ y - 1, x - 1 + ofs });
	ret.push_back({ y - 1, x + ofs });

	ret.push_back({ y + 1, x - 1 + ofs });
	ret.push_back({ y + 1, x + ofs });

	return ret;
}
vector<array<int, 2>> Neighbor8(int y, int x)
{
	vector<array<int, 2>> ret;
	ret.push_back({ y - 1, x - 1 });
	ret.push_back({ y - 1, x });
	ret.push_back({ y - 1, x + 1 });

	ret.push_back({ y, x - 1 });
	ret.push_back({ y, x + 1 });

	ret.push_back({ y + 1, x - 1 });
	ret.push_back({ y + 1, x });
	ret.push_back({ y + 1, x + 1 });
	return ret;
}

vector<int> DecompDigit(ull val)
{
	if (val == 0)
		return { 0 };

	vector<int> ret;
	while (val)
	{
		ret.emplace_back(val % 10);
		val /= 10;
	}
	reverse(ret.begin(), ret.end());
	return ret;
}


#define PI 3.14'159'265'358'979l
long double R2D = 180 / PI;
long double D2R = PI / 180;

static const ll Mod = 1'000'000'007;
static const ll Mod9 = 998244353;// 1000000007;
static const ll INF64 = 4'500000'000000'000000;// 10000000000000000;
static const int INF32 = 2'000'000'000;

random_device rd;
//mt19937 mt(rd());
mt19937 mt(0);
#if USE_MP
using mpint = boost::multiprecision::cpp_int;
#endif

const double EPS = 1e-10;

struct Solver
{
	void Run()
	{
		int N, Q;
		cin >> N >> Q;
		vector<ll> A(N + 2);
		while (Q--) {
			int l, k;
			cin >> l >> k;
			l--;
			A[l]++;
			A[l + k] -= k + 1;
			A[l + k + 1] += k;
		}
		for (int i = 1; i < A.size(); i++) A[i] += A[i - 1];
		for (int i = 1; i < A.size(); i++) A[i] += A[i - 1];
		for (int i = 0; i < N; i++) {
			if (i) cout << ' ';
			cout << A[i];
		}
		cout << "\n";
	}
};

int main()
{
	std::cin.tie(nullptr); //★インタラクティブ注意★
	std::ios_base::sync_with_stdio(false);
	int T = 1;
	//cin >> T;
	while (T--)
	{
		Solver S;
		S.Run();
	}

	return 0;
}

/// 値渡しになっていないか?
/// 入力を全部読んでいるか? 途中でreturnしない
/// 32bitで収まるか? 10^5数えるとき
/// modは正しいか?
/// multisetでcountしていないか?
accuracy: 1
time_ms: 30
memory_kb: 4660
final_rank: 2

code_snippet: #define _CRT_SECURE_NO_WARNINGS
#pragma GCC target "no-avx"

#if USE_MP
#include <boost/multiprecision/cpp_int.hpp>
#endif
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#if defined _DEBUG
//#include "TestCase.h"
//#include "Util.h"
#endif

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tlll;
typedef tuple<int, int, int> tiii;

using ai2 = array<int, 2>;
using ai3 = array<int, 3>;
using ai4 = array<int, 4>;
using al2 = array<ll, 2>;
using al3 = array<ll, 3>;
using al4 = array<ll, 4>;
using ad2 = array<ld, 2>;
using ad3 = array<ld, 3>;
using ad4 = array<ld, 4>;

inline void Yes(bool upper = false) { cout << (upper ? "YES" : "Yes") << "\n"; }
inline void No(bool upper = false) { cout << (upper ? "NO" : "No") << "\n"; }

inline ll DivCeil(ll nume, ll deno)
{
	assert(deno != 0);
	if (deno < 0) { nume = -nume; deno = -deno; }
	if (nume < 0) return -(-nume / deno);
	else return (nume + deno - 1) / deno;
}
inline ll DivFloor(ll nume, ll deno)
{
	assert(deno != 0);
	if (deno < 0) { nume = -nume; deno = -deno; }
	if (nume < 0) return -((-nume + deno - 1) / deno);
	else return nume / deno;
}
inline ll DivRound(ll nume, ll deno)
{
	assert(deno != 0);
	if (deno < 0) { nume = -nume; deno = -deno; }
	if (nume < 0) return -((-nume + deno / 2) / deno);
	else return (nume + deno / 2) / deno;
}

template <typename T, int S>
auto MakeVecImpl(queue<int>& size, const T& ini)
{
	if constexpr (S == 1)
	{
		return vector<T>(size.front(), ini);
	}
	else
	{
		int fsize = size.front();
		size.pop();
		return vector(fsize, MakeVecImpl<T, S - 1>(size, ini));
	}
}

template <typename T, int S>
auto MakeVec(const array<int, S>& size, const T ini = T())
{
	queue<int> qsize;
	for (const auto v : size) qsize.push(v);
	return MakeVecImpl<T, S>(qsize, ini);
}
int d4[][2] =
{
	{0,-1},
	{0,1},
	{-1,0},
	{1,0},
};
int d8[][2] =
{
	{-1,-1},
	{0,-1},
	{1,-1},

	{-1,0},
	{1,0},

	{-1,1},
	{0,1},
	{1,1},
};
vector<array<int, 2>> Neighbor2(int y, int x)
{
	vector<array<int, 2>> ret;
	ret.push_back({ y, x + 1 });
	ret.push_back({ y + 1, x });
	return ret;
}
vector<array<int, 2>> Neighbor4(int y, int x)
{
	vector<array<int, 2>> ret;
	ret.push_back({ y, x - 1 });
	ret.push_back({ y, x + 1 });
	ret.push_back({ y - 1, x });
	ret.push_back({ y + 1, x });
	return ret;
}
vector<array<int, 2>> Neighbor6(int y, int x)
{
	vector<array<int, 2>> ret;
	const int ofs = (y & 1); // 1 - (y & 1); //

	ret.push_back({ y, x - 1 });
	ret.push_back({ y, x + 1 });

	ret.push_back({ y - 1, x - 1 + ofs });
	ret.push_back({ y - 1, x + ofs });

	ret.push_back({ y + 1, x - 1 + ofs });
	ret.push_back({ y + 1, x + ofs });

	return ret;
}
vector<array<int, 2>> Neighbor8(int y, int x)
{
	vector<array<int, 2>> ret;
	ret.push_back({ y - 1, x - 1 });
	ret.push_back({ y - 1, x });
	ret.push_back({ y - 1, x + 1 });

	ret.push_back({ y, x - 1 });
	ret.push_back({ y, x + 1 });

	ret.push_back({ y + 1, x - 1 });
	ret.push_back({ y + 1, x });
	ret.push_back({ y + 1, x + 1 });
	return ret;
}

vector<int> DecompDigit(ull val)
{
	if (val == 0)
		return { 0 };

	vector<int> ret;
	while (val)
	{
		ret.emplace_back(val % 10);
		val /= 10;
	}
	reverse(ret.begin(), ret.end());
	return ret;
}


#define PI 3.14'159'265'358'979l
long double R2D = 180 / PI;
long double D2R = PI / 180;

static const ll Mod = 1'000'000'007;
static const ll Mod9 = 998244353;// 1000000007;
static const ll INF64 = 4'500000'000000'000000;// 10000000000000000;
static const int INF32 = 2'000'000'000;

random_device rd;
//mt19937 mt(rd());
mt19937 mt(0);
#if USE_MP
using mpint = boost::multiprecision::cpp_int;
#endif

const double EPS = 1e-10;

template <typename DATA, typename LAZY>
struct LazySegmentTree
{
	LazySegmentTree(size_t size,
		DATA unit,
		LAZY identity,
		function<DATA(DATA, DATA)> dataMergeFunc,
		function<DATA(LAZY, DATA)> evaluationFunc,
		function<LAZY(LAZY, LAZY)> lazyMergeFunc
	) : e(unit),
		I(identity),
		mergeData(dataMergeFunc),
		evaluate(evaluationFunc),
		mergeLazy(lazyMergeFunc),
		Norg(size)
	{
		// 2べきのサイズを求める
		N = 1;
		while (N < size) N <<= 1;

		// 領域確保
		data.resize(2 * N - 1, e);
		lazy.resize(2 * N - 1, I);

		// 伝搬
		for (int i = N - 2; i >= 0; i--)
			data[i] = mergeData(data[i * 2 + 1], data[i * 2 + 2]);
	}
	LazySegmentTree(const vector<DATA>& vec,
		DATA unit,
		LAZY identity,
		function<DATA(DATA, DATA)> dataMergeFunc,
		function<DATA(LAZY, DATA)> evaluationFunc,
		function<LAZY(LAZY, LAZY)> lazyMergeFunc
	) : e(unit),
		I(identity),
		mergeData(dataMergeFunc),
		evaluate(evaluationFunc),
		mergeLazy(lazyMergeFunc),
		Norg(vec.size())
	{
		// 2べきのサイズを求める
		N = 1;
		while (N < vec.size()) N <<= 1;

		// 領域確保
		data.resize(2 * N - 1, e);
		lazy.resize(2 * N - 1, I);

		// vecをコピーして伝搬
		copy(vec.begin(), vec.end(), data.begin() + N - 1);
		for (int i = N - 2; i >= 0; i--)
			data[i] = mergeData(data[i * 2 + 1], data[i * 2 + 2]);
	}

	// 区間評価
	DATA Fold(size_t l, size_t r)
	{
		return Fold(l, r, 0, 0, N);
	}

	// 区間更新
	void Update(size_t l, size_t r, LAZY val)
	{
		Update(l, r, 0, 0, N, val);
	}

#pragma region binary search
	// セグメント木上の二分探索
	// 区間[l, r)について、IsOKになる最大のrを求める
	size_t MaxRight(size_t l, function<bool(DATA)> IsOK)
	{
		vector<bool> isEvaluated(data.size());
		auto LazyEvalToRoot = [this, &isEvaluated](size_t idx) {	// 根に向かって未反映のノードを探し、自分まで辿る
			size_t cur = idx;
			vector<size_t> target;
			while (!isEvaluated[cur]) {
				target.emplace_back(cur);
				if (cur == 0) break;
				cur = (cur - 1) >> 1;
			}
			for (int i = target.size() - 1; i >= 0; i--) {
				LazyEval(target[i]);
				isEvaluated[target[i]] = true;
			}
			};

		// [l, l+1)でも満たさない場合は即終了
		LazyEvalToRoot(l + N - 1);
		if (!IsOK(data[l + N - 1])) return l;

		// 二分探索
		size_t maxR = N;
		size_t curIdx = l + N - 1;
		size_t curR = l + 1;
		DATA curVal = data[curIdx];
		DATA prvVal = e;
		size_t step = 2;

		size_t nxtR, nxtIdx;
		DATA nxtVal;

		// 葉から上へ
		while (maxR > curR)
		{
			// 自分が左部分木なら[l, l+step)のstepを増やしていくイメージ
			if (IsLeft(curIdx))
			{
				nxtR = curR + step - (step >> 1);
				nxtIdx = (curIdx - 1) >> 1;	// 親
				LazyEvalToRoot(nxtIdx);
				nxtVal = mergeData(prvVal, data[nxtIdx]);
				if (IsOK(nxtVal))
				{
					curIdx = nxtIdx;
					curR = nxtR;
					// prvValはまだ更新しない lが同じでstepが大きいものを試すため
					curVal = nxtVal;
				}
				else
				{
					// 次のノードの左部分木から下りていく
					step >>= 2;
					nxtR = curR + step;
					nxtIdx = (curIdx + 1) * 2 + 1;
					break;
				}
			}
			// 自分が右部分木なら[l, l+step)に[l+step, l+step*2)を継ぎ足すイメージ
			else
			{
				nxtR = curR + step;
				nxtIdx = (curIdx + 1) >> 1;	// 隣の親
				LazyEvalToRoot(nxtIdx);
				nxtVal = mergeData(curVal, data[nxtIdx]);
				if (IsOK(nxtVal))
				{
					curIdx = nxtIdx;
					curR = nxtR;
					prvVal = curVal;
					curVal = nxtVal;
				}
				else
				{
					// 次のノードからから下りていく
					step >>= 1;
					nxtR = curR + step;
					nxtIdx = curIdx + 1;
					break;
				}

			}
			step <<= 1;
		}
		// OKのまま右端まで来てたら終了
		if (maxR == curR)
			return min(curR, Norg);

		// 下へ(prv~はもう使わない)
		while (nxtR > curR)
		{
			LazyEvalToRoot(nxtIdx);
			nxtVal = mergeData(curVal, data[nxtIdx]);
			if (IsOK(nxtVal))
			{
				curIdx = nxtIdx;
				curVal = nxtVal;
				curR = nxtR;

				// 次のノードの左部分木へ
				step >>= 1;
				nxtR = curR + step;
				nxtIdx = (curIdx + 1) * 2 + 1;
			}
			else
			{
				// 自分の左部分木へ
				step >>= 1;
				nxtR = curR + step;
				nxtIdx = nxtIdx * 2 + 1;
			}
		}
		return min(curR, Norg);
	}

	// セグメント木上の二分探索
	// 区間[l, r)について、IsOKになる最小のlを求める
	size_t MinLeft(size_t r, function<bool(DATA)> IsOK)
	{
		r = min(r, Norg);

		vector<bool> isEvaluated(data.size());
		auto LazyEvalToRoot = [this, &isEvaluated](size_t idx) {	// 根に向かって未反映のノードを探し、自分まで辿る
			size_t cur = idx;
			vector<size_t> target;
			while (!isEvaluated[cur]) {
				target.emplace_back(cur);
				if (cur == 0) break;
				cur = (cur - 1) >> 1;
			}
			for (int i = target.size() - 1; i >= 0; i--) {
				LazyEval(target[i]);
				isEvaluated[target[i]] = true;
			}
			};

		// [r-1, r)でも満たさない場合は即終了
		LazyEvalToRoot(r - 1 + N - 1);
		if (!IsOK(data[r - 1 + N - 1])) return r;

		// 二分探索
		size_t minL = 0;
		size_t curIdx = r - 1 + N - 1;
		size_t curL = r - 1;
		DATA curVal = data[curIdx];
		DATA prvVal = e;
		size_t step = 2;

		size_t nxtL, nxtIdx;
		DATA nxtVal;

		// 葉から上へ
		while (minL < curL)
		{
			// 自分が右部分木なら[r-step, r)のstepを増やしていくイメージ
			if (IsRight(curIdx))
			{
				nxtL = curL - step + (step >> 1);
				nxtIdx = (curIdx - 1) >> 1;	// 親
				LazyEvalToRoot(nxtIdx);
				nxtVal = mergeData(data[nxtIdx], prvVal);
				if (IsOK(nxtVal))
				{
					curIdx = nxtIdx;
					curL = nxtL;
					// prvValはまだ更新しない rが同じでstepが大きいものを試すため
					curVal = nxtVal;
				}
				else
				{
					// 前のノードの右部分木から下りていく
					step >>= 2;
					nxtL = curL - step;
					nxtIdx = (curIdx - 1) * 2 + 2;
					break;
				}
			}
			// 自分が左部分木なら[r-step, r)に[r-step*2, r-step)を継ぎ足すイメージ
			else
			{
				nxtL = curL - step;
				nxtIdx = ((curIdx - 1) >> 1) - 1;	// 隣の親
				LazyEvalToRoot(nxtIdx);
				nxtVal = mergeData(data[nxtIdx], curVal);
				if (IsOK(nxtVal))
				{
					curIdx = nxtIdx;
					curL = nxtL;
					prvVal = curVal;
					curVal = nxtVal;
				}
				else
				{
					// 前のノードからから下りていく
					step >>= 1;
					nxtL = curL - step;
					nxtIdx = curIdx - 1;
					break;
				}

			}
			step <<= 1;
		}
		// OKのまま左端まで来てたら終了
		if (minL == curL)
			return minL;

		// 下へ(prv~はもう使わない)
		while (nxtL < curL)
		{
			LazyEvalToRoot(nxtIdx);
			nxtVal = mergeData(curVal, data[nxtIdx]);
			if (IsOK(nxtVal))
			{
				curIdx = nxtIdx;
				curVal = nxtVal;
				curL = nxtL;

				// 前のノードの右部分木へ
				step >>= 1;
				nxtL = curL - step;
				nxtIdx = (curIdx - 1) * 2 + 2;
			}
			else
			{
				// 自分の右部分木へ
				step >>= 1;
				nxtL = curL - step;
				nxtIdx = nxtIdx * 2 + 2;
			}
		}
		return curL;
	}
#pragma endregion
private:
#pragma region primitive data
	size_t N;								// 2べき化したサイズ	
	size_t Norg;							// 元のサイズ
	DATA e;									// 実データの単位元
	LAZY I;									// 遅延評価の恒等写像
	vector<DATA> data;						// 実データ
	vector<LAZY> lazy;						// 遅延評価値
	function<DATA(DATA, DATA)> mergeData;	// 取得時のマージ演算
	function<DATA(LAZY, DATA)> evaluate;	// lazy -> dataの反映
	function<LAZY(LAZY, LAZY)> mergeLazy;	// lazyを下のlazyにマージする操作
#pragma endregion

#pragma region implementation
	// 区間評価(本体)
	DATA Fold(size_t queryL, size_t queryR,
		size_t nodeIdx, size_t nodeL, size_t nodeR
	)
	{
		// 遅延評価
		LazyEval(nodeIdx);

		// かすりもしない
		if (queryL >= nodeR || queryR <= nodeL) return e;

		// 完全に覆われる
		if (queryL <= nodeL && queryR >= nodeR) return data[nodeIdx];

		// 部分的に覆われる
		size_t nodeM = (nodeL + nodeR) / 2;
		return mergeData(
			Fold(queryL, queryR, 2 * nodeIdx + 1, nodeL, nodeM),
			Fold(queryL, queryR, 2 * nodeIdx + 2, nodeM, nodeR)
		);
	}

	// 区間更新(本体)
	void Update(size_t queryL, size_t queryR,
		size_t nodeIdx, size_t nodeL, size_t nodeR,
		LAZY val
	)
	{
		LazyEval(nodeIdx);

		// かすりもしない
		if (queryL >= nodeR || queryR <= nodeL) return;

		// 完全に覆われる
		if (queryL <= nodeL && queryR >= nodeR) {
			lazy[nodeIdx] = mergeLazy(val, lazy[nodeIdx]);
			LazyEval(nodeIdx);
			return;
		}

		// 部分的に覆われる
		size_t nodeM = (nodeL + nodeR) / 2;
		Update(queryL, queryR, 2 * nodeIdx + 1, nodeL, nodeM, val);
		Update(queryL, queryR, 2 * nodeIdx + 2, nodeM, nodeR, val);
		data[nodeIdx] = mergeData(data[2 * nodeIdx + 1], data[2 * nodeIdx + 2]);
	}

	// 遅延評価
	void LazyEval(size_t idx)
	{
		data[idx] = evaluate(lazy[idx], data[idx]);

		// 一段落とす
		if (idx < N - 1)
		{
			lazy[idx * 2 + 1] = mergeLazy(lazy[idx], lazy[idx * 2 + 1]);
			lazy[idx * 2 + 2] = mergeLazy(lazy[idx], lazy[idx * 2 + 2]);
		}

		lazy[idx] = I;
	}
#pragma endregion
	inline bool IsLeft(size_t idx) const { return (idx & 1) == 1; }
	inline bool IsRight(size_t idx) const { return (idx & 1) == 0; }
};

struct Data
{
	ll val;
	size_t size;
};
	
using Lazy = ll;
	
Data MergeData(Data a, Data b)
{
	return { a.val + b.val, a.size + b.size };
}
	
Data Evaluate(Lazy l, Data a)
{
	a.val += l * a.size;
	return a;
}
	
Lazy MergeLazy(Lazy a, Lazy b)
{
	return a + b;
}
	 
const Data unit{ 0, 1 };
const Lazy Identity = 0;

struct Solver
{
	void Run()
	{
		int N, Q;
		cin >> N >> Q;

		LazySegmentTree<Data, Lazy> st(N+1, unit, Identity, MergeData, Evaluate, MergeLazy );
		while (Q--) {
			int l, k;
			cin >> l >> k;
			l--;
			st.Update(l, l + k, 1);
			st.Update(l + k, l + k + 1, -k);
		}

		ll a = 0;
		for (int i = 0; i < N; i++) {
			a += st.Fold(i, i + 1).val;
			if (i)
				cout << ' ';
			cout << a;
		}
		cout << "\n";
	}
};

int main()
{
	std::cin.tie(nullptr); //★インタラクティブ注意★
	std::ios_base::sync_with_stdio(false);
	int T = 1;
	//cin >> T;
	while (T--)
	{
		Solver S;
		S.Run();
	}

	return 0;
}

/// 値渡しになっていないか?
/// 入力を全部読んでいるか? 途中でreturnしない
/// 32bitで収まるか? 10^5数えるとき
/// modは正しいか?
/// multisetでcountしていないか?
accuracy: 1
time_ms: 360
memory_kb: 15496
final_rank: 18

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define rep(i, s, f) for(long long i = s; i <= f; i++)

template<typename T>
struct dualsegtree {
 
    dualsegtree(int siz, T _id) :  id(_id) {
        n = 1;
        while(n < siz) n <<= 1;
        dat.resize(n*2, id);
    }

    private: 

    
        int n;
        vector<T> dat;
        T id;
       

        void eval(int k, int len) {
            if(len == 1) return;
            dat[k << 1] = op(dat[k << 1], dat[k]);
            dat[(k << 1) + 1] = op(dat[(k << 1) + 1], dat[k]);
            dat[k] = id;
        }


        void update(int a, int b, T e, int l, int r, int k) {//[a, b) := 今見ている区間  [l, r) := クエリ区間
            eval(k, b-a);
            if(b <= l || r <= a) return;
            if(l <= a && b <= r) {
                dat[k] = op(dat[k], e);
                eval(k, b-a);
                return;
            }
            int mid = (a+b)>>1;
            update(a, mid, e, l, r, k<<1);
            update(mid, b, e, l, r, (k<<1)+1);
        }

        T query(int pos) {
            int a = 1;
            int b = n+1;
            int k = 1;
            while(1) {
                eval(k, b-a);
                if(b-a == 1) {
                    return dat[k];
                }
                int mid = (a+b)>>1;
                if(mid <= pos) {
                    k = (k << 1) + 1;
                    a = mid;
                }
                else {
                    k <<= 1;
                    b = mid;
                }  
            }
        }


    public: 

        void set(int pos, T val) {
            dat[pos+n-1] = val;
        }

        void init() {

        }

        void change(int l, int r, T x) {
            update(1, n+1, x, l, r+1, 1);
        }

        T get(int pos) {
            return query(pos);
        }

};


struct Monoid {
    ll a, d;
    Monoid():a(0), d(0){}
    Monoid(ll _a, ll _d) : a(_a), d(_d) {}
    friend Monoid op(const Monoid& l, const Monoid& r) {//monoid * monoid
        return Monoid(l.a + r.a, l.d + r.d);
    }

};
using E = Monoid;

Monoid id(0, 0);

int main() {
    ll N, Q;
    cin >> N >> Q;
    dualsegtree<Monoid> seg(N+1, id);
    rep(i,1,N)seg.set(i, id);
    seg.init();
    rep(qi, 1, Q) {
        ll l, k;
        cin >> l >> k;
        seg.change(l, l + k - 1, Monoid(2-l, 1));
    }

    rep(i,1,N) {
        auto [a,d] = seg.get(i);
        cout << a + (i-1) * d;
        if(i != N) cout << " ";}
    cout << endl;
    
}
accuracy: 1
time_ms: 150
memory_kb: 11316
final_rank: 11

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define rep(i, s, f) for(long long i = s; i <= f; i++)

template<typename T>
struct dualsegtree {
    dualsegtree(int siz) {
        n = 1;
        while(n < siz) n <<= 1;
        dat.resize(n*2);
    }

    private: 
        struct E {
            T a, d;
            E():a(0), d(0){}
            E(T _a, T _d) : a(_a), d(_d) {}
        };

        int n;
        vector<E> dat;
        E id = E(0, 0); 

        E fe(const E& l, const E& r) {//作用素の合成
            return E(l.a + r.a, l.d + r.d);
        }


        void eval(int k, int len) {
            if(dat[k].a == 0 && dat[k].d == 0) return;
            if(len == 1) return;
            dat[k << 1] = fe(dat[k << 1], dat[k]);
            dat[(k << 1) + 1] = fe(dat[(k << 1) + 1], E(dat[k].a + (len >> 1) * dat[k].d, dat[k].d));
            dat[k] = id;
        }


        void update(int a, int b, E e, int l, int r, int k) {//[a, b) := 今見ている区間  [l, r) := クエリ区間
            eval(k, b-a);
            if(b <= l || r <= a) return;
            if(l <= a && b <= r) {
                dat[k] = fe(dat[k], e);
                eval(k, b-a);
                return;
            }
            int mid = (a+b)>>1;
            update(a, mid, e, l, r, k<<1);
            update(mid, b,  E(e.a + (mid - a)*e.d, e.d), l, r, (k<<1)+1);
        }

        T query(int pos) {
            int a = 1;
            int b = n+1;
            int k = 1;
            while(1) {
                eval(k, b-a);
                if(b-a == 1) {
                    return dat[k].a;
                }
                int mid = (a+b)>>1;
                if(mid <= pos) {
                    k = (k << 1) + 1;
                    a = mid;
                }
                else {
                    k <<= 1;
                    b = mid;
                }  
            }
        }


    public: 

        void set(int pos, T val) {
            dat[pos+n-1].a = val;
        }

        void init() {

        }

        void change(int l, int r, T a, T d) {
            if(l != 1) {
                a = a - (l-1) * d;
                update(1, n+1, E(-a, -d), 1, l, 1);//左端を1に合わせる為に、打ち消すaddをする。
            } 
            update(1, n+1, E(a, d), 1, r+1, 1);
        }

        T get(int pos) {
            return query(pos);
        }

};


int main() {
    ll N, Q;
    cin >> N >> Q;
    dualsegtree<ll> seg(N+1);
    rep(i,1,N)seg.set(i, 0);
    seg.init();
    rep(qi, 1, Q) {
        ll l, k;
        cin >> l >> k;
        seg.change(l, l + k - 1, 1, 1);
    }

    rep(i,1,N) {cout << seg.get(i);if(i != N) cout << " ";}
    cout << endl;
    
}
accuracy: 1
time_ms: 160
memory_kb: 11320
final_rank: 12

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define rep(i, n) for (ll i = 0; i < (ll) (n); i++)

int main() {

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    ll N, Q;
    cin >> N >> Q;
    vll A(N, 0);
    vll B(N,0);
    rep(i, Q) {
        ll L, K;
        cin >> L >> K;
        L--;
        A[L]++;
        if (L + K < N){
            A[L + K]--;
            B[L+K]-=K;
        }
    }
    rep(i, N - 1)A[i + 1] += A[i];
    rep(i,N)A[i]+=B[i];
    rep(i, N - 1)A[i + 1] += A[i];
    rep(i,N)cout<<A[i]<<" \n"[i==N-1];
}
accuracy: 1
time_ms: 30
memory_kb: 6248
final_rank: 5

code_snippet: #include <bits/stdc++.h>
using namespace std;

int main() {
    int n, q;
    cin >> n >> q;
    vector<long long> imos_range(n + 2), imos_l_sum(n + 2);
    for (int i = 0; i < q; i++) {
        int l, k;
        cin >> l >> k;
        imos_range[l]++;
        imos_range[l + k]--;
        imos_l_sum[l] += l;
        imos_l_sum[l + k] -= l;
    }
    for (int i = 1; i <= n; i++) {
        imos_range[i] += imos_range[i - 1];
        imos_l_sum[i] += imos_l_sum[i - 1];
        cout << imos_range[i] * (i + 1) - imos_l_sum[i];
        if (i < n) cout << ' ';
    }
    cout << '\n';
}
accuracy: 1
time_ms: 70
memory_kb: 6284
final_rank: 9

code_snippet: #include <bits/stdc++.h>

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef long long lint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef char chr;
typedef string str;

#define REP(i, n) for (int i=0;i<(int)n;i++)
#define ALL(x) x.begin() x.begin()
#define SEP " "
#define YES cout << "Yes" << endl
#define NO cout << "NO" << endl
#define OUT(x) cout << x << endl
#define OUTF(x) cout << fixed << setprecision(10) << x << endl
#define SIZE(v) v.size()
#define PB push_back
#define MP make_pair
#define MT make_typle

const double pi = 3.141592653589793238;

const int large_a = 65;
const int small_a = 97;

const int INF = 2147483647;
const int INT_INF = 2147483647;

const int dy[4] = {-1, 0, 1, 0};
const int dx[4] = {0, 1, 0, -1};

template<class T> inline void print_vec(const vector<T>& v) {
	int last = SIZE(v);
	REP(i, last) {
		cout << v[i];
		if(i != last-1) cout << SEP;
	}
	cout << endl;
}

int main() {
	int n,q;
	cin >> n >> q;
	vector<ll> v(n+2),b(n+2);
	for(int i=0;i<q;i++){
		int l,k;
		cin >> l >> k;
		v[l]++;
		v[l+k]--;
		b[l]-=l-1;
		b[l+k]+=l-1;
	}
	for(int i=1;i<n+1;i++){
		v[i]+=v[i-1];
		b[i]+=b[i-1];
	}
	for(int i=1;i<n+1;i++){
		v[i]*=i;
	}
	for(int i=1;i<n;i++){
		cout << v[i]+b[i] << " ";
	}
	cout << v[n]+b[n] << endl;


}
accuracy: 1
time_ms: 70
memory_kb: 6244
final_rank: 7

code_snippet: #include<cstdio>
#include<iostream>
using namespace std;

unsigned long long ans[200002];
unsigned long long dp[200002];

int main(){
    unsigned long long n,q,i,j;
    unsigned long long l,k;

    scanf("%llu %llu", &n, &q);
    
    for(i=1;i<=n;i++){
        ans[i] = 0;
        dp[i] = 0;
    }

    for(i=0;i<q;i++){
        scanf("%llu %llu", &l, &k);
        dp[l-1] += -1;
        dp[l+k-1] += 1;
        ans[l+k-1] += k;
    }

    for(i=n;i>=2;i--){
        if(dp[i]==0)continue;
        
        dp[i-1] = dp[i-1] + dp[i];
        ans[i-1] = (ans[i] - dp[i]) + ans[i-1];
    }
    
    for(i=1;i<=n;i++){
        printf("%llu", ans[i]);
        if(i!=n){
            printf(" ");
        }
    }
    printf("\n");

    return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 6348
final_rank: 6

code_snippet: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)

using namespace std;
using ll = long long;
using P = pair<int,int>;
const int mod = 998244353;
const int inf = (1<<30);

const int dy[4] = {-1,0,0,1};
const int dx[4] = {0,-1,1,0};

int main(){
    int n,q;cin>>n>>q;
    vector<pair<long long,long long>> A(n+2);
    vector<long long> D(n+2);
    for(int i = 0; q > i; i++){
           long long l,k;cin>>l>>k;
           l--;
           A[l].first++;
           A[l+k].second+=k; 
           D[l+k]++;
    }
    long long nw = 0;
    long long ans = 0;
    for(int i = 0; n > i; i++){
           if(A[i].first){
                nw += A[i].first;    
           }
           if(A[i].second){
               ans -= A[i].second;
               nw -= D[i];
           }
           ans += nw;
           cout << ans<< " \n"[i+1==n];
    }
   
}
accuracy: 1
time_ms: 70
memory_kb: 7828
final_rank: 10

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    int n, q;
    cin >> n >> q;
    vector<long long> imos(n + 2, 0), ans(n + 2, 0);
    for (int i = 0; i < q; i++) {
        int l, k;
        cin >> l >> k;
        imos[l]++;
        imos[l + k]--;
        ans[l + k] -= k;
    }
    for (int i = 0; i < n; i++) {
        imos[i + 1] += imos[i];
    }
    for (int i = 0; i < n; i++) {
        ans[i + 1] += ans[i] + imos[i + 1];
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i + 1];
        if (i < n - 1) cout << ' ';
    }
    cout << '\n';
}
accuracy: 1
time_ms: 70
memory_kb: 6252
final_rank: 8

code_snippet: /* -*- coding: utf-8 -*-
 *
 * 3165.cc: Triangle Addition
 */

#include<cstdio>
#include<vector>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

typedef long long ll;

template <typename T>
struct SegTreeSumDelay {
  int e2;
  vector<T> nodes, das, dbs;
  vector<int> ls;
  T defv;
  SegTreeSumDelay() {}

  void init(int n, T _defv) {
    defv = _defv;
    for (e2 = 1; e2 < n; e2 <<= 1);
    nodes.assign(e2 * 2, defv);
    das.assign(e2 * 2, 0);
    dbs.assign(e2 * 2, 0);
    ls.assign(e2 * 2, 1);
    for (int j = e2 - 2; j >= 0; j--) ls[j] = ls[j * 2 + 1] + ls[j * 2 + 2];
  }

  T &geti(int i) { return nodes[e2 - 1 + i]; }
  void seti(int i, T v) { geti(i) = v; }

  void setall() {
    for (int j = e2 - 2; j >= 0; j--)
      nodes[j] = nodes[j * 2 + 1] + nodes[j * 2 + 2];
  }

  T __sigma(T a, T b, int dx) {
    // sigma_{x=0}^(dx-1) (ax+b)
    return a * dx * (dx - 1) / 2 + b * dx;
  }

  void __update(int k) {
    if (das[k] > 0 || dbs[k] > 0) {
      int k0 = k * 2 + 1, k1 = k0 + 1;
      ll a = das[k], b0 = dbs[k], b1 = b0 + a * ls[k0];
      nodes[k0] += __sigma(a, b0, ls[k0]);
      nodes[k1] += __sigma(a, b1, ls[k1]);
      das[k0] += a, das[k1] += a;
      dbs[k0] += b0, dbs[k1] += b1;
      das[k] = dbs[k] = 0;
    }
  }

  void updateall() {
    for (int j = 0; j < e2 - 1; j++) __update(j);
  }

  void add_range(int r0, int r1, T v, int k, int i0, int i1) {
    if (r1 <= i0 || i1 <= r0) return;
    if (r0 <= i0 && i1 <= r1) {
      T b = v + (i0 - r0);
      nodes[k] += __sigma(1, b, ls[k]);
      das[k]++, dbs[k] += b;
      return;
    }

    __update(k);

    int im = (i0 + i1) / 2;
    int k0 = k * 2 + 1, k1 = k0 + 1;
    add_range(r0, r1, v, k0, i0, im);
    add_range(r0, r1, v, k1, im, i1);
    nodes[k] = nodes[k0] + nodes[k1];
  }
  void add_range(int r0, int r1, T v) { add_range(r0, r1, v, 0, 0, e2); }
};

/* global variables */

SegTreeSumDelay<ll> st;

/* subroutines */

/* main */

int main() {
  int n, qn;
  scanf("%d%d", &n, &qn);

  st.init(n, 0);

  while (qn--) {
    int l, k;
    scanf("%d%d", &l, &k), l--;
    st.add_range(l, l + k, 1);
  }

  st.updateall();

  for (int i = 0; i < n; i++)
    printf("%lld%c", st.geti(i), (i + 1 < n) ? ' ' : '\n');

  return 0;
}
accuracy: 1
time_ms: 140
memory_kb: 16924
final_rank: 13

code_snippet: #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using ll=long long;
using ld=long double;
ll ILL=9167167167167167167;
const int INF=2100000000;
const ll mod=998244353;
#define rep(i,a) for (ll i=0;i<a;i++)
#define all(p) p.begin(),p.end()
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> ll LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> ll UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
void yneos(bool a){if(a) cout<<"Yes\n"; else cout<<"No\n";}
template<class T> void vec_out(vector<T> &p){for(int i=0;i<(int)(p.size());i++){if(i) cout<<" ";cout<<p[i];}cout<<"\n";}


void solve();
// oddloop
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t=1;
	//cin>>t;
	rep(i,t) solve();
}

void solve(){
	int N,Q;
	cin>>N>>Q;
	vector<ll> A(N+3),B(N+3);
	rep(i,Q){
		int l,k;
		cin>>l>>k;
		B[l]++;
		B[l+k]-=k+1;
		B[l+k+1]+=k;
	}
	rep(i,N){
		if(i) cout<<" ";
		B[i+1]+=B[i];
		A[i+1]=B[i+1]+A[i];
		cout<<A[i+1];
	}
	cout<<"\n";
}
accuracy: 1
time_ms: 20
memory_kb: 6272
final_rank: 4

code_snippet: #include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef long double ld ;
typedef pair<ll,ll> P ;
typedef tuple<ll,ll,ll> TP ;
#define chmin(a,b) a = min(a,b)
#define chmax(a,b) a = max(a,b)
#define bit_count(x) __builtin_popcountll(x)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / gcd(a,b) * b
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define rrep(i,a,b) for(int i = a ; i < b ; i++)
#define endl "\n"

template<typename S , typename M>
struct LazySegmentTree{
    private :
        int n , _n ;
        using FS = function<S(S,S)> ;
        using FM = function<M(M,M)> ;
        using FA = function<S(S,M)> ;
        FS fs ;
        FM fm ;
        FA fa ;
        S es ;
        M em ;
        vector<S> dat ;
        vector<M> lazy ;
        
        // 各セグメントに左端値, 右端値を持たせる
        void build(){
            int id = 0 ;
            for(int i = n ; i > 0 ; i = i / 2){
                for(int j = 0 ; j < n ; j += i){
                    dat[id].lef = j ;
                    dat[id].rig = j + i ;
                    id++ ;
                }
            }
        }
        void eval(int k , int l , int r){
            if(lazy[k] == em) return ;
            int len = (r - l) / 2 ;
            if(k < n - 1) {
                lazy[2 * k + 1] = fm(lazy[2 * k + 1] , {lazy[k].a,lazy[k].b}) ;
                lazy[2 * k + 2] = fm(lazy[2 * k + 2] , {lazy[k].a,lazy[k].a*len+lazy[k].b}) ;
            }
            dat[k] = fa(dat[k],lazy[k]) ;
            lazy[k] = em ;
        }
        void apply(int a , int b , int k , int l , int r , M x){
            eval(k,l,r) ;
            if(r <= a || b <= l) return ;
            if(a <= l && r <= b) {
                lazy[k] = fm(lazy[k],{x.a,x.a*(l-a)+x.b}) ;
                eval(k,l,r) ;
                return ;
            }
            apply(a,b,2*k+1,l,(l+r)/2,x) ;
            apply(a,b,2*k+2,(l+r)/2,r,x) ;
            dat[k] = fs(dat[2*k+1],dat[2*k+2]) ;
        }
        S prod(int a , int b , int k , int l , int r) {
            eval(k,l,r) ;
            if(r <= a || b <= l) return es ;
            if(a <= l && r <= b) return dat[k] ;
            S lef = prod(a,b,2*k+1,l,(l+r)/2) ;
            S rig = prod(a,b,2*k+2,(l+r)/2,r) ;
            return fs(lef,rig) ;
        }
    
    public :
        LazySegmentTree(int n_ , FS fs_ , S es_ , S ee_ , FM fm_ , M em_ , FA fa_) : fs(fs_) , fm(fm_) , fa(fa_) , es(es_) , em(em_) {
            _n = n_ ;
            n = 1 ;
            while(n_ > n) n *= 2 ;
            dat.resize(2 * n - 1,ee_) ;
            lazy.resize(2 * n - 1,em) ;
            build() ;
        }
        void apply(int a , int b , M x) { apply(a,b,0,0,n,x) ; }
        S prod(int a , int b) { return prod(a,b,0,0,n) ; }
};

namespace monoid{
    ll linf = 1e16 ;
    int inf = 1e8 ;

    // モノイド
    struct S{
        ll sum ;
        int lef , rig ;
    };

    // S*S->Sにおける演算の定義
    function<S(S,S)> fs = [](S x , S y) -> S {
        return S{
            x.sum + y.sum,
            x.lef,
            y.rig
        };
    };
    
    // Sの単位元
    S es = {0,inf,-inf} ;

    // Sの初期化単位元
    S ee = {0,0,0} ;

    // 作用モノイド
    struct M{
        ll a , b ;
        bool operator == (M x) { return a == x.a && b == x.b ; }
    };

    // M*M->Mにおける演算の定義1
    function<M(M,M)> fm = [](M x , M y) -> M {
        return M{
            x.a + y.a,
            x.b + y.b
        };
    };

    // Mの単位元
    M em = {0,0} ;

    // S*M->Sにおける演算の定義
    function<S(S,M)> fa = [](S x , M y) -> S {
        int len = (x.rig - x.lef) ;
        int lef = x.lef ;
        return S{
            x.sum + len * (len - 1) / 2 * y.a + len * y.b ,
            x.lef,
            x.rig,
        };
    };
};
using namespace monoid ;

// default
// S    : sum(区間和) , lef(区間左端値), rig(区間右端値) 
// M    : (a,b) -> ax + b のモノイド
// apply: 区間等差数列加算
// prod : sum(区間和), min(区間最小値), max(区間最大値)

int n , q ;

int main(){
    cin >> n >> q ;
    LazySegmentTree<S,M> segtree(n,fs,es,ee,fm,em,fa) ;
    rep(i,q){
        int l , r ;
        cin >> l >> r ;
        l-- ;
        segtree.apply(l,l+r,{1,1}) ;
    }
    rep(i,n) {
        if(i == n - 1) cout << segtree.prod(i,i+1).sum << endl ;
        else cout << segtree.prod(i,i+1).sum << " " ;
    }
}
accuracy: 1
time_ms: 310
memory_kb: 19608
final_rank: 19

code_snippet: // #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

#define CONSTANTS
// #define CAST_MINT_TO_LL
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

constexpr long long INF = 1e18;
// constexpr long long INF = LONG_LONG_MAX;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr long double EPS = 1e-10;
constexpr long double PI = M_PI;

using ll = long long; using ull = unsigned long long; using ld = long double; using pll = pair<ll, ll>; using pii = pair<int, int>; using pli = pair<ll, int>; using pil = pair<int, ll>; using vvl = vector<vector<ll>>; using vvi = vector<vector<int>>; using vvpll = vector<vector<pll>>; using vvpli = vector<vector<pli>>; using vvpil = vector<vector<pil>>;
#define name4(i, a, b, c, d, e, ...) e
#define rep(...) name4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(i, a) for (ll i = 0, _aa = a; i < _aa; i++)
#define rep2(i, a, b) for (ll i = a, _bb = b; i < _bb; i++)
#define rep3(i, a, b, c) for (ll i = a, _bb = b; (c > 0 && a <= i && i < _bb) or (c < 0 && a >= i && i > _bb); i += c)
#define rrep(i, a, b) for (ll i=(a); i>(b); i--)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define ALL(A) A.begin(), A.end()
#define UNIQUE(A) sort(ALL(A)), A.erase(unique(ALL(A)), A.end())
#define elif else if
#define tostr to_string
#ifndef CONSTANTS
constexpr ll INF = 1e18; constexpr int MOD = 1000000007; constexpr ld EPS = 1e-10; constexpr ld PI = M_PI;
#endif
template<int mod> struct ModInt { int x; ModInt() : x(0) {} ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator++() { x++; if (x == mod) x = 0; return *this; } ModInt &operator--() { if (x == 0) x = mod; x--; return *this; } ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; } ModInt &operator-=(const ModInt &p) { if((x += mod - p.x) >= mod) x -= mod; return *this; } ModInt &operator*=(const ModInt &p) { x = (int) (1LL * x * p.x % mod); return *this; } ModInt &operator/=(const ModInt &p) { *this *= p.inv(); return *this; } ModInt operator++(int) { ModInt result = *this; ++*this; return result; } ModInt operator--(int) { ModInt result = *this; --*this; return result; } ModInt operator-() const { return ModInt(-x); } ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inv() const { int a = x, b = mod, u = 1, v = 0, t; while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return ModInt(u); } ModInt pow(int64_t n) const { ModInt ret(1), mul(x); while(n > 0) { if(n & 1) ret *= mul; mul *= mul; n >>= 1; } return ret; } friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); } static int get_mod() { return mod; }
#ifdef CAST_MINT_TO_LL
operator ll() const { return x; }
#endif
}; using mint = ModInt<MOD>;
template<typename T> vector<vector<T>> list2d(int N, int M, T init) { return vector<vector<T>>(N, vector<T>(M, init)); } template<typename T> vector<vector<vector<T>>> list3d(int N, int M, int L, T init) { return vector<vector<vector<T>>>(N, vector<vector<T>>(M, vector<T>(L, init))); } template<typename T> vector<vector<vector<vector<T>>>> list4d(int N, int M, int L, int O, T init) { return vector<vector<vector<vector<T>>>>(N, vector<vector<vector<T>>>(M, vector<vector<T>>(L, vector<T>(O, init)))); }
template<typename T=ll> vector<T> LIST(ll N) { vector<T> A(N); rep(i, N) { cin >> A[i]; } return A; }
void print() { cout << '\n'; } template<typename T> void print(T out) { cout << out << '\n'; } template<typename T1, typename T2> void print(const pair<T1, T2> &p) { cout << p.first << ' ' << p.second << '\n'; } template<typename T1, typename T2, typename T3> void print(const tuple<T1, T2, T3> &tp) { cout << get<0>(tp) << ' ' << get<1>(tp) << ' ' << get<2>(tp) << '\n'; } template<typename T1, typename T2, typename T3, typename T4> void print(const tuple<T1, T2, T3, T4> &tp) { cout << get<0>(tp) << ' ' << get<1>(tp) << ' ' << get<2>(tp) << ' ' << get<3>(tp) << '\n'; } template<typename T1, typename T2> void print(const vector<pair<T1, T2>> &V) { for (auto& p : V) print(p); } template<typename T> void print(const vector<T> &V) { rep(i, V.size()) { cout << V[i]; if (i != V.size()-1) cout << ' '; } cout << '\n'; } template<typename T, size_t SZ> void print(const array<T, SZ> &arr) { rep(i, arr.size()) { cout << arr[i]; if (i != arr.size()-1) cout << ' '; } cout << '\n'; } template<typename T, size_t SZ> void print(const vector<array<T, SZ>> &V) { for (auto& arr : V) print(arr); } template<typename T> void print(const deque<T> &que) { vector<T> V(ALL(que)); print(V); } template<typename T> void print(const set<T> &se) { vector<T> V(ALL(se)); print(V); }
#define debug(x) (cout << #x << ": ", print(x));
void Yes() { print("Yes"); } void No() { print("No"); } void YES() { print("YES"); } void NO() { print("NO"); }
ll toint(string s) { assert(s.size() < 20); ll res = 0; for (char &c : s) { res *= 10; res += c - '0'; } return res; } int toint(char num) { return num - '0'; }
char tochar(int num) { return '0' + num; }
template<typename T> T ceil(T a, T b) { if (a >= 0) return (a+b-1) / b; else return a / b; }
template<typename T> T modulo(T a, T b) { return ((a % b) + b) % b; }
template<typename T> pair<T, T> divmod(T a, T b) { T d = a / b; T m = a % b; return {d, m}; }
template<typename T> bool chmin(T &x, T y) { return (y < x) ? x = y, true : false; }
template<typename T> bool chmax(T &x, T y) { return (y > x) ? x = y, true : false; }
template<typename T> T sum(const vector<T> &A) { return accumulate(ALL(A), (T)0); } template<typename key, typename val> val sum(const map<key, val> &mp) { val res = 0; for (auto& [k, v] : mp) res += v; return res; }
template<typename T> T min(const vector<T> &A) { return *min_element(ALL(A)); } template<typename key, typename val> val min(const map<key, val> &mp) { val res = numeric_limits<val>::max(); for (auto& [k, v] : mp) chmin(res, v); return res; }
template<typename T> T max(const vector<T> &A) { return *max_element(ALL(A)); } template<typename key, typename val> val max(const map<key, val> &mp) { val res = numeric_limits<val>::min(); for (auto& [k, v] : mp) chmax(res, v); return res; }
ll pow(ll x, ll n) { ll res = 1; rep(_, n) res *= x; return res; } ll pow(int x, ll n) { return pow((ll)x, n); } ll pow(ll x, int n) { return pow(x, (ll)n); } ll pow(int x, int n) { return pow((ll)x, (ll)n); } ll pow(ll x, ll n, int mod) { x %= mod; ll res = 1; while (n > 0) { if (n & 1) { res = (res * x) % mod; } x = (x * x) % mod; n >>= 1; } return res; }
int popcount(ll S) { return __builtin_popcountll(S); }
int bit_length(ll x) { return x != 0 ? floor(log2((ld)x))+1 : 0; }
template<typename T> int bisect_left(const vector<T> &A, T val, int lo=0) { return lower_bound(A.begin()+lo, A.end(), val) - A.begin(); } template<typename T> int bisect_right(const vector<T> &A, T val, int lo=0) { return upper_bound(A.begin()+lo, A.end(), val) - A.begin(); }
template<typename T> map<T, ll> Counter(const vector<T> &A) { map<T, ll> res; for (T a : A) { res[a]++; } return res; } template<typename T> vector<ll> Counter(const vector<T> &A, int mx) { vector<ll> res(mx+1); for (T a : A) { res[a]++; } return res; } map<char, ll> Counter(const string &S) { map<char, ll> res; for (char c : S) { res[c]++; } return res; }
template<typename F> ll bisearch_min(ll mn, ll mx, const F &func) { ll ok = mx; ll ng = mn; while (ng+1 < ok) { ll mid = (ok+ng) / 2; if (func(mid)) { ok = mid; } else { ng = mid; } } return ok; } template<typename F> ll bisearch_max(ll mn, ll mx, const F &func) { ll ok = mn; ll ng = mx; while (ok+1 < ng) { ll mid = (ok+ng) / 2; if (func(mid)) { ok = mid; } else { ng = mid; } } return ok; }
template<typename T1, typename T2> pair<vector<T1>, vector<T2>> zip(const vector<pair<T1, T2>> &A) { int N = A.size(); pair<vector<T1>, vector<T2>> res = {vector<T1>(N), vector<T2>(N)}; rep(i, N) { res.first[i] = A[i].first; res.second[i] = A[i].second; } return res; } template<typename T1, typename T2, typename T3> tuple<vector<T1>, vector<T2>, vector<T3>> zip(const vector<tuple<T1, T2, T3>> &A) { int N = A.size(); tuple<vector<T1>, vector<T2>, vector<T3>> res = {vector<T1>(N), vector<T2>(N), vector<T3>(N)}; rep(i, N) { get<0>(res)[i] = get<0>(A[i]); get<1>(res)[i] = get<1>(A[i]); get<2>(res)[i] = get<2>(A[i]); } return res; }
template<typename T> struct Compress { int N; vector<T> dat; Compress(vector<T> A) { sort(A.begin(), A.end()); A.erase(unique(A.begin(), A.end()), A.end()); N = A.size(); dat = A; } int zip(T x) { return bisect_left(dat, x); } T unzip(int x) { return dat[x]; } int operator[](T x) { return zip(x); } int size() { return dat.size(); } vector<ll> zip(const vector<T> &A) { int M = A.size(); vector<ll> res(M); rep(i, M) res[i] = zip(A[i]); return res; } };
template<typename T> vector<pair<T, int>> RLE(const vector<T> &A) { if (A.empty()) return {}; int N = A.size(); vector<pair<T, int>> res; T cur = A[0]; int cnt = 1; rep(i, 1, N) { if (A[i] == A[i-1]) { cnt++; } else { res.pb({cur, cnt}); cnt = 1; cur = A[i]; } } res.pb({cur, cnt}); return res; } vector<pair<char, int>> RLE(const string &S) { if (S.empty()) return {}; int N = S.size(); vector<pair<char, int>> res; char cur = S[0]; int cnt = 1; rep(i, 1, N) { if (S[i] == S[i-1]) { cnt++; } else { res.pb({cur, cnt}); cnt = 1; cur = S[i]; } } res.pb({cur, cnt}); return res; }
template<typename T> bool mul_overflow(T x, T y) { T z; return __builtin_mul_overflow(x, y, &z); }
vector<ll> split(const string &S, char separator) { int N = S.size(); vector<ll> res; string cur; rep(i, N) { if (S[i] == separator) { res.eb(toint(cur)); cur = ""; } else { cur += S[i]; } } if (cur.size()) res.eb(toint(cur)); return res; }
string to_string(const string &S) { return S; } string to_string(char c) { return {c}; }
template<typename T> string join(const vector<T> &A, char separator=0) { int N = A.size(); string res; rep(i, N) { res += tostr(A[i]); if (separator != 0 and i != N-1) res += separator; } return res; }
template<typename T> vector<T> sorted(vector<T> A, bool reverse=false) { sort(ALL(A)); if (reverse) std::reverse(ALL(A)); return A; } string sorted(string S, bool reverse=false) { sort(ALL(S)); if (reverse) std::reverse(ALL(S)); return S; }
template<typename T> vector<T> reversed(vector<T> A) { reverse(ALL(A)); return A; } string reversed(string S) { reverse(ALL(S)); return S; }
template<typename Mint> struct ModTools { int MAX; vector<Mint> _fact, _factinv, inv; ModTools(int mx) : MAX(++mx) { _fact.resize(MAX); _factinv.resize(MAX); inv.resize(MAX); _fact[0] = _fact[1] = 1; rep(i, 2, MAX) { _fact[i] = _fact[i-1]*(Mint)i; } _factinv[MAX-1] = (Mint)1/_fact[MAX-1]; rep(i, MAX-2, -1, -1) { _factinv[i] = _factinv[i+1]*(Mint)(i+1); } rep(i, MAX-1, 0, -1) { inv[i] = _factinv[i]*_fact[i-1]; } } Mint div(Mint a, int b) { return a*inv[b]; } Mint fact(int x) { assert(x < MAX); return _fact[x]; } Mint factinv(int x) { assert(x < MAX); return _factinv[x]; } Mint nCr(int n, int r) { if (n < r or r < 0) return 0; r = min(r, n-r); Mint num = _fact[n]; Mint den = _factinv[r] * _factinv[n-r]; return num * den; } Mint nHr(int n, int r) { assert(r+n-1 < MAX); return nCr(r+n-1, r); } Mint nPr(int n, int r) { if (n < r or r < 0) return 0; return _fact[n] * _factinv[n-r]; } Mint double_factorial(int n) { if (n%2 == 0) { int k = n/2; return Mint(2).pow(k)*fact(k); } else { int k = (n+1)/2; return fact(2*k)/Mint(2).pow(k)/fact(k); } } };
template<typename T> vector<vector<T>> permutations(const vector<T> &A, int N=-1) { if (N == -1) N = A.size(); int M = A.size(); assert(N <= M); vector<vector<T>> comb; rep(bit, 1<<M) { if (popcount(bit) != N) continue; vector<T> res; rep(i, M) { if (bit>>i & 1) { res.pb(A[i]); } } comb.pb(res); } vector<vector<T>> res; for (auto &perm : comb) { sort(ALL(perm)); do { res.pb(perm); } while (next_permutation(ALL(perm))); } return res; }
template<typename T> vector<vector<T>> combinations(const vector<T> &A, int N) { int M = A.size(); vector<vector<T>> res; auto rec = [&](auto&& f, vector<T> &cur, ll x, ll n) -> void { if (n == N) { res.pb(cur); return; } rep(i, x, M) { cur.pb(A[i]); f(f, cur, i+1, n+1); cur.pop_back(); } }; vector<T> cur; rec(rec, cur, 0, 0); return res; }
ll nC2(ll n) { if (n < 2) return 0; return n*(n-1)/2; }
template<typename T> T factorial(int x) { T res = 1; for (int i=1; i<=x; i++) res *= i; return res; }
struct UnionFind { int n, groupcnt; vector<int> par, rank, sz; vector<bool> tree; UnionFind(int n) : n(n) { par.assign(n, 0); rank.assign(n, 0); sz.assign(n, 1); tree.assign(n, true); rep(i, n) par[i] = i; groupcnt = n; } UnionFind() {} void resize(int _n) { n = _n; par.assign(n, 0); rank.assign(n, 0); sz.assign(n, 1); tree.assign(n, true); rep(i, n) par[i] = i; groupcnt = n; } int find(int x) { if (par[x] == x) { return x; } else { par[x] = find(par[x]); return par[x]; } } int merge(int a, int b) { int x = find(a); int y = find(b); if (x == y) { tree[x] = false; return x; } if (!tree[x] or !tree[y]) { tree[x] = tree[y] = false; } groupcnt--; if (rank[x] < rank[y]) { par[x] = y; sz[y] += sz[x]; return y; } else { par[y] = x; sz[x] += sz[y]; if (rank[x] == rank[y]) { rank[x]++; } return x; } } bool same(int a, int b) { return find(a) == find(b); } ll size(int x) { return sz[find(x)]; } int size() { return groupcnt; } bool is_tree(int x) { return tree[find(x)]; } set<int> get_roots() { set<int> res; rep(i, n) { res.insert(find(i)); } return res; } };
const vector<pii> dir4 = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
#define directions dir4
ll gridtoid(ll i, ll j, ll W) { return i*W+j; }
pll idtogrid(ll id, ll W) { return divmod(id, W); }
template<typename _Key, typename _Tp> struct defaultdict : map<_Key, _Tp> { const _Tp init; defaultdict() : init(_Tp()) {}; defaultdict(_Tp init) : init(init) {} _Tp& operator[](const _Key& k) { if (this->count(k)) { return map<_Key, _Tp>::operator[](k); } else { return map<_Key, _Tp>::operator[](k) = init; } } _Tp& operator[](_Key&& k) { if (this->count(k)) { return map<_Key, _Tp>::operator[](k); } else { return map<_Key, _Tp>::operator[](k) = init; } } };
ll gcd(ll a, ll b) { return __gcd(a, b); } template<typename T> T gcd(const vector<T> &A) { T res = 0; for (auto a : A) res = gcd(res, a); return res; }
ll lcm(ll x, ll y) { return x/gcd(x, y)*y; } template<typename T> T lcm(const vector<T> &A) { T res = 1; for (auto a : A) res = lcm(res, a); return res; }
template<typename T> vector<pair<T, int>> factorize(T n) { vector<pair<T, int>> ret; for (T i=2; i*i<=n; i++) { int cnt = 0; while (n % i == 0) { n /= i; cnt++; } if (cnt) ret.emplace_back(i, cnt); } if (n > 1) ret.emplace_back(n, 1); return ret; }
template<typename T> vector<T> divisors(T n) { vector<T> res; for (T i=1; i*i<=n; i++) { if (n%i == 0) { res.eb(i); if (n/i != i) res.eb(n/i); } } return res; }
ll isqrt(ll n, bool ceil=false) { ll ok = 0; ll ng = 3037000500; while (ng - ok > 1) { ll m = ok + (ng - ok) / 2; if (m * m <= n) { ok = m; } else { ng = m; } } if (ceil and ok*ok != n) ok++; return ok; }
template<typename T> struct Accumulate { vector<T> acc; int N; Accumulate(int N) : N(N) { acc.resize(N); } Accumulate(const vector<T> &A) : N(A.size()), acc(A) { build(); } void set(int i, T a) { acc[i] = a; } void add(int i, T a) { acc[i] += a; } void build() { rep(i, N-1) { acc[i+1] += acc[i]; } acc.insert(acc.begin(), 0); } T query(int l, int r) { assert(0 <= l and l <= N and 0 <= r and r <= N); return acc[r]-acc[l]; } T get(int i) { return query(i, i+1); } T operator[](int i) { return query(i, i+1); } ll bisearch_fore(int l, int r, ll x) { if (l > r) return -1; ll l_sm = query(0, l); int ok = r + 1; int ng = l - 1; while (ng+1 < ok) { int mid = (ok+ng) / 2; if (query(0, mid+1) - l_sm >= x) { ok = mid; } else { ng = mid; } } if (ok != r+1) { return ok; } else { return -1; } } ll bisearch_back(int l, int r, ll x) { if (l > r) return -1; ll r_sm = query(0, r+1); int ok = l - 1; int ng = r + 1; while (ok+1 < ng) { int mid = (ok+ng) / 2; if (r_sm - query(0, mid) >= x) { ok = mid; } else { ng = mid; } } if (ok != l-1) { return ok; } else { return -1; } } };
template<typename T> struct BIT { int sz; vector<T> tree; BIT(int n) { n++; sz = 1; while (sz < n) { sz *= 2; } tree.resize(sz); } T sum(int i) { T s = 0; i++; while (i > 0) { s += tree[i-1]; i -= i & -i; } return s; } void add(int i, T x) { i++; while (i <= sz) { tree[i-1] += x; i += i & -i; } } T query(int l, int r) { return sum(r-1) - sum(l-1); } T get(int i) { return query(i, i+1); } void update(int i, T x) { add(i, x - get(i)); } T operator[](int i) { return query(i, i+1); } void print(int n) { rep(i, n) { cout << query(i, i+1); if (i == n-1) cout << endl; else cout << ' '; } } ll bisearch_fore(int l, int r, ll x) { if (l > r) return -1; ll l_sm = sum(l-1); int ok = r + 1; int ng = l - 1; while (ng+1 < ok) { int mid = (ok+ng) / 2; if (sum(mid) - l_sm >= x) { ok = mid; } else { ng = mid; } } if (ok != r+1) { return ok; } else { return -1; } } ll bisearch_back(int l, int r, ll x) { if (l > r) return -1; ll r_sm = sum(r); int ok = l - 1; int ng = r + 1; while (ok+1 < ng) { int mid = (ok+ng) / 2; if (r_sm - sum(mid-1) >= x) { ok = mid; } else { ng = mid; } } if (ok != l-1) { return ok; } else { return -1; } } };
template<typename Monoid, typename F> struct SegmentTree { int sz; vector<Monoid> seg; const F f; const Monoid M1; SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) { sz = 1; while(sz < n) sz <<= 1; seg.assign(2 * sz, M1); } SegmentTree(const F f, const Monoid &M1) : f(f), M1(M1) {} void resize(int n) { sz = 1; while(sz < n) sz <<= 1; seg.resize(2 * sz, M1); } void clear() { seg.clear(); } void set(int k, const Monoid &x) { seg[k+sz] = x; } void build() { for(int k = sz - 1; k > 0; k--) { seg[k] = f(seg[2*k], seg[2*k+1]); } } void build(const vector<Monoid> &A) { int n = A.size(); resize(n); rep(i, n) set(i, A[i]); build(); } void update(int k, const Monoid &x) { k += sz; seg[k] = x; while(k >>= 1) { seg[k] = f(seg[2*k], seg[2*k+1]); } } Monoid query(int a, int b) { Monoid L = M1, R = M1; for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) { if(a & 1) L = f(L, seg[a++]); if(b & 1) R = f(seg[--b], R); } return f(L, R); } Monoid operator[](const int &k) const { return seg[k+sz]; } Monoid all() { return seg[1]; } void print(int n) { for (int i=0; i<n; i++) { cout << query(i, i+1); if (i == n-1) cout << endl; else cout << ' '; } } template<typename C> int find_subtree(int a, const C &check, Monoid &M, bool type) { while(a < sz) { Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]); if(check(nxt)) a = 2 * a + type; else M = nxt, a = 2 * a + 1 - type; } return a - sz; } template<typename C> int find_first(int a, const C &check) { Monoid L = M1; if(a <= 0) { if(check(f(L, seg[1]))) return find_subtree(1, check, L, false); return -1; } int b = sz; for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) { if(a & 1) { Monoid nxt = f(L, seg[a]); if(check(nxt)) return find_subtree(a, check, L, false); L = nxt; ++a; } } return -1; } template<typename C> int find_last(int b, const C &check) { Monoid R = M1; if(b >= sz) { if(check(f(seg[1], R))) return find_subtree(1, check, R, true); return -1; } int a = sz; for(b += sz; a < b; a >>= 1, b >>= 1) { if(b & 1) { Monoid nxt = f(seg[--b], R); if(check(nxt)) return find_subtree(b, check, R, true); R = nxt; } } return -1; } }; template<typename Monoid, typename F> SegmentTree<Monoid, F> get_segment_tree(int N, const F& f, const Monoid& M1) { return {N, f, M1}; } template<typename Monoid, typename F> SegmentTree<Monoid, F> get_segment_tree(const F& f, const Monoid& M1) { return {f, M1}; }
const string digits = "0123456789";
const string ascii_lowercase = "abcdefghijklmnopqrstuvwxyz";
const string ascii_uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string zfill(string str, int len) { string zeros; int n = str.size(); rep(i, len-n) zeros += '0'; return zeros+str; }
string bin(ll x) { string res; while (x) { if (x & 1) { res += '1'; } else { res += '0'; } x >>= 1; } reverse(ALL(res)); if (res == "") res += '0'; return res; }

void solve() {
    ll N, Q;
    cin >> N >> Q;
    
    vector<ll> imos(N);
    rep(i, Q) {
        ll l, k;
        cin >> l >> k;
        l--;
        ll r = l + k;
        imos[l]++;
        if (r < N) {
            imos[r] -= r - l + 1;
        }
        if (r+1 < N) {
            imos[r+1] += r - l;
        }
    }

    rep(_, 2) {
        rep(i, 1, N) {
            imos[i] += imos[i-1];
        }
    }
    print(imos);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    // single test case
    solve();

    // multi test cases
    // int T;
    // cin >> T;
    // while (T--) solve();

    return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 4572
final_rank: 1

code_snippet: // #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vvl = vector<vector<ll>>;
using vvi = vector<vector<int>>;
using vvpll = vector<vector<pll>>;
#define name4(i, a, b, c, d, e, ...) e
#define rep(...) name4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(i, a) for (ll i = 0, _aa = a; i < _aa; i++)
#define rep2(i, a, b) for (ll i = a, _bb = b; i < _bb; i++)
#define rep3(i, a, b, c) for (ll i = a, _bb = b; (c > 0 && a <= i && i < _bb) or (c < 0 && a >= i && i > _bb); i += c)
#define rrep(i, a, b) for (ll i=(a); i>(b); i--)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define ALL(A) A.begin(), A.end()
#define UNIQUE(A) sort(ALL(A)), A.erase(unique(ALL(A)), A.end())
#define elif else if
#define tostr to_string
constexpr ll INF = 1e18;
// constexpr ll INF = LONG_LONG_MAX;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;

template<typename T> vector<vector<T>> list2d(int N, int M, T init) { return vector<vector<T>>(N, vector<T>(M, init)); }
template<typename T> vector<vector<vector<T>>> list3d(int N, int M, int L, T init) { return vector<vector<vector<T>>>(N, vector<vector<T>>(M, vector<T>(L, init))); }
template<typename T> vector<vector<vector<vector<T>>>> list4d(int N, int M, int L, int O, T init) { return vector<vector<vector<vector<T>>>>(N, vector<vector<vector<T>>>(M, vector<vector<T>>(L, vector<T>(O, init)))); }

template<typename T=ll> vector<T> LIST(ll N) { vector<T> A(N); rep(i, N) cin >> A[i]; return A; }

void print() { cout << '\n'; }
template<typename T> void print(T out) { cout << out << '\n'; }
template<typename T1, typename T2> void print(pair<T1, T2> out) { cout << out.first << ' ' << out.second << '\n'; }
template<typename T> void print(const vector<T> &A) { rep(i, A.size()) { cout << A[i]; if (i != A.size()-1) cout << ' '; } cout << '\n'; }
template<typename T> void print(const deque<T> &A) { vector<T> V(A.begin(), A.end()); print(V); }
template<typename T> void print(const set<T> &S) { vector<T> A(S.begin(), S.end()); print(A); }
#define debug(x) (cout << #x << ": ", print(x));

void Yes() { print("Yes"); }
void No() { print("No"); }
void YES() { print("YES"); }
void NO() { print("NO"); }

// from common.cpp
ll toint(string s) { ll res = 0; for (char c : s) { res *= 10; res += (c - '0'); } return res; }
int toint(char num) { return num - '0'; }
char tochar(int num) { return '0' + num; }
ll floor(ll a, ll b) { if (a < 0) return (a-b+1) / b; else return a / b; }
ll ceil(ll a, ll b) { if (a >= 0) return (a+b-1) / b; else return a / b; }
ll modulo(ll a, ll b) { return ((a % b) + b) % b; }
template<typename T> pll divmod(ll a, T b) { ll d = a / b; ll m = a % b; return {d, m}; }
template<typename T> bool chmax(T &x, T y) { return (y > x) ? x = y, true : false; }
template<typename T> bool chmin(T &x, T y) { return (y < x) ? x = y, true : false; }
template<typename T> T sum(const vector<T> &A) { T res = 0; for (T a: A) res += a; return res; }
template<typename key, typename val> val sum(const map<key, val> &mp) { val res = 0; for (auto [k, v] : mp) res += v; return res; }
template<typename T> T max(const vector<T> &A) { return *max_element(ALL(A)); }
template<typename T> T min(const vector<T> &A) { return *min_element(ALL(A)); }
ll pow(int x, int n) { ll res = 1; rep(_, n) res *= x; return res; }
ll pow(int x, ll n) { ll res = 1; rep(_, n) res *= x; return res; }
ll pow(ll x, int n) { ll res = 1; rep(_, n) res *= x; return res; }
ll pow(ll x, ll n) { ll res = 1; rep(_, n) res *= x; return res; }
ll pow(ll x, ll n, int mod) { ll res = 1; while (n > 0) { if (n & 1) { res = (res * x) % mod; } x = (x * x) % mod; n >>= 1; } return res; }
int popcount(ll S) { return __builtin_popcountll(S); }
int bit_length(ll x) { return x != 0 ? floor(log2((ld)x))+1 : 0; }
template<typename T> int bisect_left(const vector<T> &A, T val, int lo=0) { return lower_bound(A.begin()+lo, A.end(), val) - A.begin(); }
template<typename T> int bisect_right(const vector<T> &A, T val, int lo=0) { return upper_bound(A.begin()+lo, A.end(), val) - A.begin(); }
template<typename T> map<T, ll> Counter(const vector<T> &A) { map<T, ll> res; for (T a : A) res[a]++; return res; }
template<typename T> vector<ll> Counter(const vector<T> &A, T mx) { vector<ll> res(mx+1); for (T a : A) { res[a]++; } return res; }
map<char, ll> Counter(const string &S) { map<char, ll> res; for (char c : S) res[c]++; return res; }
template<typename F> ll bisearch_min(ll mn, ll mx, const F &func) { ll ok = mx, ng = mn; while (ng+1 < ok) { ll mid = (ok+ng) / 2; if (func(mid)) ok = mid; else ng = mid; } return ok; }
template<typename F> ll bisearch_max(ll mn, ll mx, const F &func) { ll ok = mn, ng = mx; while (ok+1 < ng) { ll mid = (ok+ng) / 2; if (func(mid)) ok = mid; else ng = mid; } return ok; }
template<typename T1, typename T2> pair<vector<T1>, vector<T2>> zip(const vector<pair<T1, T2>> &A) { ll N = A.size(); pair<vector<T1>, vector<T2>> res = {vector<T1>(N), vector<T2>(N)}; rep(i, N) { res.first[i] = A[i].first; res.second[i] = A[i].second; } return res; }
template<typename T1, typename T2, typename T3> tuple<vector<T1>, vector<T2>, vector<T3>> zip(const vector<tuple<T1, T2, T3>> &A) { int N = A.size(); tuple<vector<T1>, vector<T2>, vector<T3>> res = {vector<T1>(N), vector<T2>(N), vector<T3>(N)}; rep(i, N) { get<0>(res)[i] = get<0>(A[i]); get<1>(res)[i] = get<1>(A[i]); get<2>(res)[i] = get<2>(A[i]); } return res; }
template<typename T> struct Compress { int N; vector<T> dat; Compress(vector<T> A) { sort(A.begin(), A.end()); A.erase(unique(A.begin(), A.end()), A.end()); N = A.size(); dat = A; } int zip(T x) { return bisect_left(dat, x); } T unzip(int x) { return dat[x]; } int operator[](T x) { return zip(x); } int size() { return dat.size(); } vector<T> zip(const vector<T> &A) { int M = A.size(); vector<T> res(M); rep(i, M) res[i] = zip(A[i]); return res; } };
template<typename T> vector<pair<T, int>> RLE(const vector<T> &A) { if (A.empty()) return {}; int N = A.size(); vector<pair<T, int>> res; T cur = A[0]; int cnt = 1; rep(i, 1, N) { if (A[i] == A[i-1]) { cnt++; } else { res.pb({cur, cnt}); cnt = 1; cur = A[i]; } } res.pb({cur, cnt}); return res; }
vector<pair<char, int>> RLE(const string &S) { if (S.empty()) return {}; int N = S.size(); vector<pair<char, int>> res; char cur = S[0]; int cnt = 1; rep(i, 1, N) { if (S[i] == S[i-1]) { cnt++; } else { res.pb({cur, cnt}); cnt = 1; cur = S[i]; } } res.pb({cur, cnt}); return res; }
bool mul_overflow(ll x, ll y) { ll z; return __builtin_mul_overflow(x, y, &z); }
vector<ll> split(const string &S, char separator) { int N = S.size(); vector<ll> res; string cur; rep(i, N) { if (S[i] == separator) { res.eb(toint(cur)); cur = ""; } else { cur += S[i]; } } if (cur.size()) res.eb(toint(cur)); return res; }
string to_string(const string &S) { return S; }
string to_string(char c) { return {c}; }
template<typename T> string join(const vector<T> &A, char separator=0) { int N = A.size(); string res; rep(i, N) { res += tostr(A[i]); if (separator != 0 and i != N-1) res += separator; } return res; }

// from combinatorics.cpp
template<int mod> struct ModInt { int x; ModInt() : x(0) {} ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; } ModInt &operator-=(const ModInt &p) { if((x += mod - p.x) >= mod) x -= mod; return *this; } ModInt &operator*=(const ModInt &p) { x = (int) (1LL * x * p.x % mod); return *this; } ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; } ModInt operator-() const { return ModInt(-x); } ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inverse() const { int a = x, b = mod, u = 1, v = 0, t; while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return ModInt(u); } ModInt pow(int64_t n) const { ModInt ret(1), mul(x); while(n > 0) { if(n & 1) ret *= mul; mul *= mul; n >>= 1; } return ret; } friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); } static int get_mod() { return mod; } };
using mint = ModInt<MOD>;
template<typename T=mint> struct ModTools { int MAX; vector<T> fact, factinv; ModTools() {}; ModTools(int mx) { build(mx); } void build(int mx) { MAX = ++mx; fact.resize(MAX); factinv.resize(MAX); fact[0] = fact[1] = 1; rep(i, 2, MAX) { fact[i] = fact[i-1] * i; } factinv[MAX-1] = (T)1 / fact[MAX-1]; rep(i, MAX-2, -1, -1) { factinv[i] = factinv[i+1] * (i+1); } } T factorial(int x) { return fact[x]; } T inverse(int x) { return factinv[x]; } T nCr(int n, int r) { if (n < r or r < 0) return 0; r = min(r, n-r); T num = fact[n]; T den = factinv[r] * factinv[n-r]; return num * den; } T nHr(int n, int r) { return nCr(r+n-1, r); } T nPr(int n, int r) { if (n < r or r < 0) return 0; return fact[n] * factinv[n-r]; } };
template<typename T> vector<vector<T>> permutations(const vector<T> &A, int N=-1) { if (N == -1) N = A.size(); int M = A.size(); vector<vector<T>> comb; rep(bit, 1<<M) { if (popcount(bit) != N) continue; vector<T> res; rep(i, M) { if (bit>>i & 1) { res.pb(A[i]); } } comb.pb(res); } vector<vector<T>> res; for (auto &perm : comb) { sort(ALL(perm)); do { res.pb(perm); } while (next_permutation(ALL(perm))); } return res; }
template<typename T> vector<vector<T>> combinations(const vector<T> &A, int N) { int M = A.size(); vector<vector<T>> res; auto rec = [&](auto&& f, vector<T> &cur, ll x, ll n) -> void { if (n == N) { res.pb(cur); return; } rep(i, x, M) { cur.pb(A[i]); f(f, cur, i+1, n+1); cur.pop_back(); } }; vector<T> cur; rec(rec, cur, 0, 0); return res; }
template<typename T> T factorial(T x) { T res = 1; for (T i=1; i<=x; i++) res *= i; return res; }

// from graph.cpp
struct UnionFind { int n, groupcnt; vector<int> par, rank, sz; vector<bool> tree; UnionFind(int n) : n(n) { par.resize(n); rank.resize(n); sz.resize(n, 1); tree.resize(n, 1); rep(i, n) par[i] = i; groupcnt = n; } UnionFind() {} void resize(int _n) { n = _n; par.resize(n); rank.resize(n); sz.resize(n, 1); rep(i, n) par[i] = i; groupcnt = n; } int find(int x) { if (par[x] == x) { return x; } else { par[x] = find(par[x]); return par[x]; } } int merge(int a, int b) { int x = find(a); int y = find(b); if (x == y) { tree[x] = false; return x; } if (!tree[x] or !tree[y]) { tree[x] = tree[y] = false; } groupcnt--; if (rank[x] < rank[y]) { par[x] = y; sz[y] += sz[x]; return y; } else { par[y] = x; sz[x] += sz[y]; if (rank[x] == rank[y]) { rank[x]++; } return x; } } bool same(int a, int b) { return find(a) == find(b); } ll size(int x) { return sz[find(x)]; } int size() { return groupcnt; } bool is_tree(int x) { return tree[find(x)]; } set<int> get_roots() { set<int> res; rep(i, n) { res.insert(find(i)); } return res; } };

// from grid.cpp
const vector<pii> directions = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
ll gridtoid(ll i, ll j, ll W) { return i*W+j; }
pll idtogrid(ll id, ll W) { return divmod(id, W); }
template<typename T> vector<vector<T>> transpose(const vector<vector<T>> &grid) { int H = grid.size(); int W = grid[0].size(); auto res = list2d(W, H, (T)0); rep(i, H) { rep(j, W) { res[j][i] = grid[i][j]; } } return res; }
vector<string> transpose(const vector<string> &grid) { int H = grid.size(); int W = grid[0].size(); vector<string> res(W, string(H, '*')); rep(i, H) { rep(j, W) { res[j][i] = grid[i][j]; } } return res; }
vector<string> rot90(const vector<string> &grid) { int H = grid.size(); int W = grid[0].size(); vector<string> res(W, string(H, '*')); rep(i, H) { rep(j, W) { res[j][H-i-1] = grid[i][j]; } } return res; }

// from mystl.cpp
template<typename _Key, typename _Tp, typename _Compare=less<_Key>, typename _Alloc=allocator<pair<const _Key, _Tp>>> struct defaultdict : public map<_Key, _Tp, _Compare, _Alloc> { const _Tp init; defaultdict() : init(_Tp()) {}; defaultdict(_Tp init) : init(init) {} _Tp& operator[](const _Key& k) { if (this->count(k)) { return map<_Key, _Tp, _Compare, _Alloc>::operator[](k); } else { return map<_Key, _Tp, _Compare, _Alloc>::operator[](k) = init; } } _Tp& operator[](_Key&& k) { if (this->count(k)) { return map<_Key, _Tp, _Compare, _Alloc>::operator[](k); } else { return map<_Key, _Tp, _Compare, _Alloc>::operator[](k) = init; } } };
template<typename _Key, typename _Compare=less<_Key>, typename _Alloc=allocator<_Key>> struct my_set : public set<_Key, _Compare, _Alloc> { _Key front() { return *this->begin(); } _Key pop_front() { auto res = this->front(); this->erase(this->begin()); return res; } _Key back() { return *this->rbegin(); } _Key pop_back() { auto res = this->back(); this->erase(prev(this->end())); return res; } };
template<typename _Key, typename _Compare=less<_Key>, typename _Alloc=allocator<_Key>> struct my_multiset : public multiset<_Key, _Compare, _Alloc> { _Key front() { return *this->begin(); } _Key pop_front() { auto res = this->front(); this->erase(this->begin()); return res; } _Key back() { return *this->rbegin(); } _Key pop_back() { auto res = this->back(); this->erase(prev(this->end())); return res; } };
template<typename _Tp, typename _Sequence=vector<_Tp>, typename _Compare=less<typename _Sequence::value_type>> struct my_priority_queue : public priority_queue<_Tp, _Sequence, _Compare> { _Tp pop() { auto res = this->top(); priority_queue<_Tp, _Sequence, _Compare>::pop(); return res; } };
template<typename _Tp, typename _Sequence=deque<_Tp>> struct my_queue : public queue<_Tp, _Sequence> { _Tp pop() { auto res = this->front(); queue<_Tp, _Sequence>::pop(); return res; } };
template<typename _Tp, typename _Alloc=std::allocator<_Tp>> struct my_deque : public deque<_Tp, _Alloc> { _Tp pop_front() { auto res = this->front(); deque<_Tp, _Alloc>::pop_front(); return res; } _Tp pop_back() { auto res = this->back(); deque<_Tp, _Alloc>::pop_back(); return res; } };

// from numbers.cpp
ll gcd(ll a, ll b) { return __gcd(a, b); }
ll lcm(ll x, ll y) { return (x * y) / gcd(x, y); }
template<typename T> vector<pair<T, int>> factorize(T n) { vector<pair<T, int>> ret; for(T i=2; i*i<=n; i++) { int cnt = 0; while(n % i == 0) { n /= i; cnt++; } if(cnt) ret.emplace_back(i, cnt); } if(n > 1) ret.emplace_back(n, 1); return ret; }
vector<ll> divisors(ll n) { vector<ll> res; for (ll i=1; i*i<=n; i++) { if (n%i == 0) { res.pb(i); if (n/i != i) res.pb(n/i); } } return res; }
ll ntod(string S, ll n) { ll res = 0, k = 1; reverse(ALL(S)); for (char &c : S) { res += k*toint(c); k *= n; } return res; }
string dton(ll num, ll n, char base='0') { string res; while (abs(num) > 0) { ll m = num % abs(n); num -= m; res += base+m; num /= n; } reverse(ALL(res)); if (res != "") { return res; } else { return res+base; } }
ll isqrt(ll n, bool ceil=false) { ll ok = 0; ll ng = 3037000500; while (ng - ok > 1) { ll m = ok + (ng - ok) / 2; if (m * m <= n) { ok = m; } else { ng = m; } } if (ceil and ok*ok != n) ok++; return ok; }
ll digit_sum(ll n) { ll res = 0; while (n > 0) { res += n % 10; n /= 10; } return res; }
ll digit_sum(string S) { ll res = 0; rep(i, S.size()) { res += toint(S[i]); } return res; }

// from segment.cpp
template<typename T> struct Accumulate { vector<T> acc; int N; Accumulate() {} Accumulate(int N) : N(N) { acc.resize(N); } Accumulate(const vector<T> &A) { N = A.size(); acc = A; build(); } void set(int i, T a) { acc[i] = a; } void build() { rep(i, N-1) { acc[i+1] += acc[i]; } acc.insert(acc.begin(), 0); } T query(int l, int r) { assert(0 <= l and l <= N and 0 <= r and r <= N); return acc[r]-acc[l]; } T get(int i) { return query(i, i+1); } T operator[](int i){ return query(i, i+1); } ll bisearch_fore(int l, int r, ll x) { if (l > r) return -1; ll l_sm = query(0, l); int ok = r + 1; int ng = l - 1; while (ng+1 < ok) { int mid = (ok+ng) / 2; if (query(0, mid+1) - l_sm >= x) { ok = mid; } else { ng = mid; } } if (ok != r+1) { return ok; } else { return -1; } } ll bisearch_back(int l, int r, ll x) { if (l > r) return -1; ll r_sm = query(0, r+1); int ok = l - 1; int ng = r + 1; while (ok+1 < ng) { int mid = (ok+ng) / 2; if (r_sm - query(0, mid) >= x) { ok = mid; } else { ng = mid; } } if (ok != l-1) { return ok; } else { return -1; } } };
template<typename T> struct BIT { int sz; vector<T> tree; BIT(int n) { n++; sz = 1; while (sz < n) { sz *= 2; } tree.resize(sz); } T sum(int i) { T s = 0; i++; while (i > 0) { s += tree[i-1]; i -= i & -i; } return s; } void add(int i, T x) { i++; while (i <= sz) { tree[i-1] += x; i += i & -i; } } T query(int l, int r) { return sum(r-1) - sum(l-1); } T get(int i) { return query(i, i+1); } void update(int i, T x) { add(i, x - get(i)); } T operator[](int i) { return query(i, i+1); } void print(int n) { rep(i, n) { cout << query(i, i+1); if (i == n-1) cout << endl; else cout << ' '; } } ll bisearch_fore(int l, int r, ll x) { if (l > r) return -1; ll l_sm = sum(l-1); int ok = r + 1; int ng = l - 1; while (ng+1 < ok) { int mid = (ok+ng) / 2; if (sum(mid) - l_sm >= x) { ok = mid; } else { ng = mid; } } if (ok != r+1) { return ok; } else { return -1; } } ll bisearch_back(int l, int r, ll x) { if (l > r) return -1; ll r_sm = sum(r); int ok = l - 1; int ng = r + 1; while (ok+1 < ng) { int mid = (ok+ng) / 2; if (r_sm - sum(mid-1) >= x) { ok = mid; } else { ng = mid; } } if (ok != l-1) { return ok; } else { return -1; } } };
template<typename Monoid, typename F> struct SegmentTree { int sz; vector<Monoid> seg; const F f; const Monoid M1; SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) { sz = 1; while(sz < n) sz <<= 1; seg.assign(2 * sz, M1); } SegmentTree(const F f, const Monoid &M1) : f(f), M1(M1) {} void resize(int n) { sz = 1; while(sz < n) sz <<= 1; seg.resize(2 * sz, M1); } void clear() { seg.clear(); } void set(int k, const Monoid &x) { seg[k+sz] = x; } void build() { for(int k = sz - 1; k > 0; k--) { seg[k] = f(seg[2*k], seg[2*k+1]); } } void build(const vector<Monoid> &A) { int n = A.size(); resize(n); rep(i, 0, n) set(i, A[i]); build(); } void update(int k, const Monoid &x) { k += sz; seg[k] = x; while(k >>= 1) { seg[k] = f(seg[2*k], seg[2*k+1]); } } Monoid query(int a, int b) { Monoid L = M1, R = M1; for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) { if(a & 1) L = f(L, seg[a++]); if(b & 1) R = f(seg[--b], R); } return f(L, R); } Monoid operator[](const int &k) const { return seg[k+sz]; } Monoid all() { return seg[1]; } void print(int n) { rep(i, n) { cout << query(i, i+1); if (i == n-1) cout << endl; else cout << ' '; } } template<typename C> int find_subtree(int a, const C &check, Monoid &M, bool type) { while(a < sz) { Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]); if(check(nxt)) a = 2 * a + type; else M = nxt, a = 2 * a + 1 - type; } return a - sz; } template<typename C> int find_first(int a, const C &check) { Monoid L = M1; if(a <= 0) { if(check(f(L, seg[1]))) return find_subtree(1, check, L, false); return -1; } int b = sz; for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) { if(a & 1) { Monoid nxt = f(L, seg[a]); if(check(nxt)) return find_subtree(a, check, L, false); L = nxt; ++a; } } return -1; } template<typename C> int find_last(int b, const C &check) { Monoid R = M1; if(b >= sz) { if(check(f(seg[1], R))) return find_subtree(1, check, R, true); return -1; } int a = sz; for(b += sz; a < b; a >>= 1, b >>= 1) { if(b & 1) { Monoid nxt = f(seg[--b], R); if(check(nxt)) return find_subtree(b, check, R, true); R = nxt; } } return -1; } }; template<typename Monoid, typename F> SegmentTree<Monoid, F> get_segment_tree(int N, const F& f, const Monoid& M1) { return {N, f, M1}; } template<typename Monoid, typename F> SegmentTree<Monoid, F> get_segment_tree(const F& f, const Monoid& M1) { return {f, M1}; }

// from strings.cpp
const string digits = "0123456789";
const string ascii_lowercase = "abcdefghijklmnopqrstuvwxyz";
const string ascii_uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string ascii_letters = ascii_lowercase + ascii_uppercase;
string replace(string str, const string& replace, const string& with) { if(!replace.empty()) { size_t pos = 0; while ((pos = str.find(replace, pos)) != string::npos) { str.replace(pos, replace.length(), with); pos += with.length(); } } return str; }
string zfill(string str, int len) { string zeros; int n = str.size(); rep(i, len-n) zeros += '0'; return zeros+str; }
string bin(ll x) { string res; while (x) { if (x & 1) res += '1'; else res += '0'; x >>= 1; } reverse(ALL(res)); if(res == "") res += '0'; return res; }

// 遅延評価セグメント木
template<typename F, typename G, typename H, typename Monoid, typename OperatorMonoid>
struct LazySegmentTree {
    int sz, height;
    vector<Monoid> data;
    vector<OperatorMonoid> lazy;
    const F f;
    const G g;
    const H h;
    const Monoid M1;
    const OperatorMonoid OM0;

    LazySegmentTree(int n, const F f, const G g, const H h,
                                    const Monoid &M1, const OperatorMonoid OM0)
            : f(f), g(g), h(h), M1(M1), OM0(OM0) {
        sz = 1;
        height = 0;
        while(sz < n) sz <<= 1, height++;
        data.assign(2 * sz, M1);
        lazy.assign(2 * sz, OM0);
    }

    LazySegmentTree(const F f, const G g, const H h,
                                    const Monoid &M1, const OperatorMonoid OM0)
            : f(f), g(g), h(h), M1(M1), OM0(OM0) {}

    void set(int k, const Monoid &x) {
        data[k + sz] = x;
    }

    void build() {
        for(int k = sz - 1; k > 0; k--) {
            data[k] = f(data[2 * k + 0], data[2 * k + 1]);
        }
    }

    void build(const vector<Monoid> &A) {
        int n = A.size();
        sz = 1;
        height = 0;
        while(sz < n) sz <<= 1, height++;
        data.assign(2 * sz, M1);
        lazy.assign(2 * sz, OM0);
        rep(i, n) set(i, A[i]);
        build();
    }

    inline void propagate(int k) {
        if(lazy[k] == OM0) return;
        lazy[2 * k + 0] = h(lazy[2 * k + 0], lazy[k]);
        lazy[2 * k + 1] = h(lazy[2 * k + 1], lazy[k]);
        data[k] = apply(k);
        lazy[k] = OM0;
    }

    inline Monoid apply(int k) {
        return lazy[k] == OM0 ? data[k] : g(data[k], lazy[k]);
    }

    inline void recalc(int k) {
        while(k >>= 1) data[k] = f(apply(2 * k + 0), apply(2 * k + 1));
    }

    inline void thrust(int k) {
        for(int i = height; i > 0; i--) propagate(k >> i);
    }

    void update(int a, int b, const OperatorMonoid &x) {
        if(a >= b) return;
        thrust(a += sz);
        thrust(b += sz - 1);
        for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
            if(l & 1) lazy[l] = h(lazy[l], x), ++l;
            if(r & 1) --r, lazy[r] = h(lazy[r], x);
        }
        recalc(a);
        recalc(b);
    }

    Monoid query(int a, int b) {
        if(a >= b) return M1;
        thrust(a += sz);
        thrust(b += sz - 1);
        Monoid L = M1, R = M1;
        for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
            if(l & 1) L = f(L, apply(l++));
            if(r & 1) R = f(apply(--r), R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) {
        return query(k, k + 1);
    }

    void update(int i, const OperatorMonoid &x) {
        update(i, i+1, x);
    }

    template<typename P=ll>
    void print(int n) {
        rep(i, n) {
            cout << (P)query(i, i+1);
            if (i == n-1) cout << '\n';
            else cout << ' ';
        }
    }

    template<typename C>
    int find_subtree(int a, const C &check, Monoid &M, bool type) {
        while(a < sz) {
            propagate(a);
            Monoid nxt = type ? f(apply(2 * a + type), M) : f(M, apply(2 * a + type));
            if(check(nxt)) a = 2 * a + type;
            else M = nxt, a = 2 * a + 1 - type;
        }
        return a - sz;
    }

    // 区間[a,N)でcheckの条件を満たすような最小位置を返す(なければ-1)
    template<typename C>
    int find_first(int a, const C &check) {
        Monoid L = M1;
        if(a <= 0) {
            if(check(f(L, apply(1)))) return find_subtree(1, check, L, false);
            return -1;
        }
        thrust(a + sz);
        int b = sz;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if(a & 1) {
                Monoid nxt = f(L, apply(a));
                if(check(nxt)) return find_subtree(a, check, L, false);
                L = nxt;
                ++a;
            }
        }
        return -1;
    }

    // 区間[0,b)でcheckの条件を満たすような最大位置を返す(なければ-1)
    template<typename C>
    int find_last(int b, const C &check) {
        Monoid R = M1;
        if(b >= sz) {
            if(check(f(apply(1), R))) return find_subtree(1, check, R, true);
            return -1;
        }
        thrust(b + sz - 1);
        int a = sz;
        for(b += sz; a < b; a >>= 1, b >>= 1) {
            if(b & 1) {
                Monoid nxt = f(apply(--b), R);
                if(check(nxt)) return find_subtree(b, check, R, true);
                R = nxt;
            }
        }
        return -1;
    }
};

template<typename F, typename G, typename H, typename T, typename E>
LazySegmentTree<F, G, H, T, E> get_lazy_segment_tree(const F& f, const G& g, const H& h, const T& ti, const E& ei) {
    return {f, g, h, ti, ei};
}

template<typename F, typename G, typename H, typename T, typename E>
LazySegmentTree<F, G, H, T, E> get_lazy_segment_tree(int N, const F& f, const G& g, const H& h, const T& ti, const E& ei) {
    return {N, f, g, h, ti, ei};
}

// 区間和取得・区間等差数列加算
// 参考：https://opt-cp.com/lazysegtree-practice/
struct Node {
    ll val, left;
    operator ll() const { return val; }
};
struct Func {
    ll cnt, sub;
    bool operator==(const Func &f) const {
        return cnt == f.cnt and sub == f.sub;
    }
};
auto f = [](const Node &a, const Node &b) -> Node { 
    return { a.val+b.val, min(a.left, b.left) };
};
auto g = [](const Node &a, const Func &b) -> Node {
    return { a.val+b.cnt*a.left+b.sub, a.left }; 
};
auto h = [](const Func &a, const Func &b) -> Func {
    return { a.cnt+b.cnt, a.sub+b.sub };
};
const Node T = {0, INF};
const Func E = {0, 0};

void solve() {
    ll N, Q;
    cin >> N >> Q;

    auto seg = get_lazy_segment_tree(N, f, g, h, T, E);
    const ll a = 1, d = 1;
    rep(i, N) {
        // 数列の先頭を初項0とした公差dの等差数列でleftを初期化
        seg.set(i, {0, i*d});
    }
    seg.build();
    rep(_, Q) {
        ll l, k;
        cin >> l >> k;
        l--;
        ll r = l+k;
        // seg.print(N);
        // 位置lを初項aとした公差dの等差数列を[l,r)に加算
        seg.update(l, r, {1, a-l*d});
    }
    seg.print(N);
    // print(seg.query(0, 3));
    // print(seg.query(6, 10));
    // print(seg.query(5, 7));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    // single test case
    solve();

    // multi test cases
    // int T;
    // cin >> T;
    // while (T--) solve();

    return 0;
}
accuracy: 1
time_ms: 120
memory_kb: 19572
final_rank: 14