Language: C++

#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

struct M {
  using T = array<lint, 3>; // min, max, sum
  using U = array<lint, 2>; // linear function
  static T op(const T& a, const T& b) { return T{min(a[0], b[0]), max(a[1], b[1]), a[2] + b[2]}; }
  static constexpr T e() { return T{numeric_limits<lint>::max(), numeric_limits<lint>::min(), 0}; }
  static void ap(T& a, const U& g, int k) { for (int i = 0; i < 3; i++) a[i] = g[0] * a[i] + (i == 2 ? k : 1) * g[1]; if (g[0] < 0) swap(a[0], a[1]); }
  static void ap(U& f, const U& g) { f[0] *= g[0]; f[1] = g[0] * f[1] + g[1]; }
  static constexpr U id() { return U{1, 0}; }
};

template<class M> struct ST {
  using T = typename M::T;
  using U = typename M::U;
  int n, h;
  V<T> t;
  V<U> u;
  V<> k;

  ST(int n) : n(n), h(max(8 * sizeof(int) - __builtin_clz(n - 1), 1U)) {
    t.assign(2 * n, M::e());
    u.assign(n, M::id());
    k.assign(2 * n, 1);
    for (int i = n - 1; i; i--) k[i] = k[2 * i] + k[2 * i + 1];
  }

  void _ap(int i, const U& f) {
    M::ap(t[i], f, k[i]);
    if (i < n) M::ap(u[i], f);
  }

  void build() {
    for (int i = n - 1; i; i--) t[i] = M::op(t[2 * i], t[2 * i + 1]);
  }

  T get(int l, int r) {
    set(l, r, M::id());
    T resl = M::e(), resr = M::e();
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) resl = M::op(resl, t[l++]);
      if (r & 1) resr = M::op(t[--r], resr);
    }
    return M::op(resl, resr);
  }

  void push() {
    for (int i = 1; i < n; i++) {
      _ap(2 * i, u[i]);
      _ap(2 * i + 1, u[i]);
      u[i] = M::id();
    }
  }

  void set(int l, int r, const U& f) {
    // V<> p, pl, pr;
    // int i = l + n;
    // while (!(i & 1)) i >>= 1;
    // while (i >>= 1) pl.push_back(i);
    // i = r + n;
    // while (!(i & 1)) i >>= 1;
    // while (i >>= 1) pr.push_back(i);
    // merge(pl.begin(), pl.end(), pr.begin(), pr.end(), back_inserter(p), greater<int>());
    // p.erase(unique(p.begin(), p.end()), p.end());
    // for (auto itr = p.rbegin(); itr != p.rend(); ++itr) {
    //   _ap(2 * *itr, u[*itr]);
    //   _ap(2 * *itr + 1, u[*itr]);
    //   u[*itr] = M::id();
    // }

    for (int i = h; i; i--) {
      int j = (l + n) >> i;
      if (j){
      _ap(2 * j, u[j]);
      _ap(2 * j + 1, u[j]);
      u[j] = M::id();
      }
      // if (j == r >> i) continue;
      j = (r + n - 1) >> i;
      if (!j) continue;
      _ap(2 * j, u[j]);
      _ap(2 * j + 1, u[j]);
      u[j] = M::id();
    }

    // stack<int> s;
    // int i = l + n;
    // while (!(i & 1)) i >>= 1;
    // while (i >>= 1) s.push(i);
    // i = r + n;
    // while (!(i & 1)) i >>= 1;
    // while (i >>= 1) s.push(i);
    // for (int i = l + n; i >>= 1;) s.push(i);
    // for (int i = r + n - 1; i >>= 1;) s.push(i);
    // while (!s.empty()) {
    //   int i = s.top(); s.pop();
    //   _ap(2 * i, u[i]);
    //   _ap(2 * i + 1, u[i]);
    //   u[i] = M::id();
    // }
    for (int i = l + n, j = r + n; i < j; i >>= 1, j >>= 1) {
      if (i & 1) _ap(i++, f);
      if (j & 1) _ap(--j, f);
    }
    for (l += n; !(l & 1);) l >>= 1;
    while (l >>= 1) t[l] = M::op(t[2 * l], t[2 * l + 1]);
    for (r += n; !(r & 1);) r >>= 1;
    while (r >>= 1) t[r] = M::op(t[2 * r], t[2 * r + 1]);
  }
};

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, q; cin >> n >> q;
  ST<M> st(n);
  for (int i = 0; i < n; i++) st.t[i + n].fill(numeric_limits<int>::max());
  st.build();
  for (int i = 0; i < q; i++) {
    int t; cin >> t;
    if (t) {
      int l, r; cin >> l >> r, r++;
      cout << st.get(l, r)[0] << '\n';
    } else {
      int l, r, x; cin >> l >> r >> x, r++;
      st.set(l, r, M::U{0, x});
    }
  }
}


Compiler output:
a.cc: In constructor 'ST<M>::ST(int)':
a.cc:27:26: error: no matching function for call to 'max(long unsigned int, unsigned int)'
   27 |   ST(int n) : n(n), h(max(8 * sizeof(int) - __builtin_clz(n - 1), 1U)) {
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:27:26: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'unsigned int')
   27 |   ST(int n) : n(n), h(max(8 * sizeof(int) - __builtin_clz(n - 1), 1U)) {
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:27:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   27 |   ST(int n) : n(n), h(max(8 * sizeof(int) - __builtin_clz(n - 1), 1U)) {
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~