Language: C++

#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define ALL(x) (x).begin(),(x).end()
#define C(x) cout << #x << " : " << x
#define scanf scanf_s

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;

template<typename Monoid, typename AA>
class SegTree {
public:
	Monoid* tree;
	AA* calc;
	bool* lazy;
	size_t size;
	int32 i;
	size_t hight = 0;
	//?????????????????????
	SegTree(size_t length) {
		--length;
		size = length;
		if (size & 0xffff0000) { size = size & 0xffff0000;hight += 16; }
		if (size & 0xff00ff00) { size = size & 0xff00ff00;hight += 8; }
		if (size & 0xf0f0f0f0) { size = size & 0xf0f0f0f0;hight += 4; }
		if (size & 0xcccccccc) { size = size & 0xcccccccc;hight += 2; }
		if (size & 0xaaaaaaaa) { size = size & 0xaaaaaaaa;hight += 1; }
		if (length) { size <<= 1;hight += 1; }
		else { size = 1;hight = 0; }
		++length;
		tree = (Monoid *)calloc(size << 1, sizeof(Monoid));
		calc = (AA *)calloc(size << 1, sizeof(AA));
		lazy = (bool *)calloc(size << 1, sizeof(bool));
	}
	//?????????
	void set() {
		size <<= 1;
		for (i = 0;i < size;++i) {
			tree[i].set();
			calc[i].set();
			lazy[i] = false;
		}
		size >>= 1;
	}
	//calc[begin,end)???data???????????????????¨????
	void update(size_t begin, size_t end, AA &data) {
		begin += size;end += size - 1;
		size_t left, right;
		for (i = hight;i > 0;--i) {
			left = begin >> i;
			right = end >> i;
			if (lazy[left]) {
				calc[left * 2] = lazy[left * 2] ? calc[left * 2] * calc[left] : calc[left];
				calc[left * 2 + 1] = lazy[left * 2 + 1] ? calc[left * 2 + 1] * calc[left] : calc[left];
				lazy[left] = false; lazy[left * 2] = true; lazy[left * 2 + 1] = true;
			}
			if (lazy[right]) {
				calc[right * 2] = lazy[right * 2] ? calc[right * 2] * calc[right] : calc[right];
				calc[right * 2 + 1] = lazy[right * 2 + 1] ? calc[right * 2 + 1] * calc[right] : calc[right];
				lazy[right] = false; lazy[right * 2] = true; lazy[right * 2 + 1] = true;
			}
		}
		for (left = begin, right = end + 1;left < right;left >>= 1, right >>= 1) {
			if (left & 1) {
				calc[left] = lazy[left] ? calc[left] * data : data;
				lazy[left] = true;
				++left;
			}
			if (right & 1) {
				--right;
				calc[right] = lazy[right] ? calc[right] * data : data;
				lazy[right] = true;
			}
		}
		for (begin >>= 1, end >>= 1;begin < end;begin >>= 1, end >>= 1) {
			tree[begin] = (lazy[begin * 2] ? tree[begin * 2] * calc[begin * 2] : tree[begin * 2]) + (lazy[begin * 2 + 1] ? tree[begin * 2 + 1] * calc[begin * 2 + 1] : tree[begin * 2 + 1]);
			tree[end] = (lazy[end * 2] ? tree[end * 2] * calc[end * 2] : tree[end * 2]) + (lazy[end * 2 + 1] ? tree[end * 2 + 1] * calc[end * 2 + 1] : tree[end * 2 + 1]);
		}
		for (;begin;begin >>= 1) {
			tree[begin] = (lazy[begin * 2] ? tree[begin * 2] * calc[begin * 2] : tree[begin * 2]) + (lazy[begin * 2 + 1] ? tree[begin * 2 + 1] * calc[begin * 2 + 1] : tree[begin * 2 + 1]);
		}
	}
	//[begin,end)??????????????????
	Monoid range(size_t begin, size_t end) {
		Monoid retL, retR;
		begin += size;end += size - 1;
		size_t left, right;
		for (i = hight;i > 0;--i) {
			left = begin >> i;
			right = end >> i;
			if (lazy[left]) {
				calc[left * 2] = lazy[left * 2] ? calc[left * 2] * calc[left] : calc[left];
				calc[left * 2 + 1] = lazy[left * 2 + 1] ? calc[left * 2 + 1] * calc[left] : calc[left];
				lazy[left] = false; lazy[left * 2] = true; lazy[left * 2 + 1] = true;
			}
			if (lazy[right]) {
				calc[right * 2] = lazy[right * 2] ? calc[right * 2] * calc[right] : calc[right];
				calc[right * 2 + 1] = lazy[right * 2 + 1] ? calc[right * 2 + 1] * calc[right] : calc[right];
				lazy[right] = false; lazy[right * 2] = true; lazy[right * 2 + 1] = true;
			}
		}
		++end;
		for (;begin < end;(++begin) >>= 1, end >>= 1) {
			if (begin & 1) {
				if (lazy[begin]) {
					retL = retL + (tree[begin] * calc[begin]);
				}
				else {
					retL = retL + tree[begin];
				}
			}
			if (end & 1) {
				if (lazy[--end]) {
					retR = retR + (tree[end] * calc[end]);
				}
				else {
					retR = retR + tree[end];
				}
			}
		}
		return retL + retR;
	}
};

struct MIN {
	int32 e;
	MIN() { set(); }
	MIN(int32 x) { e = x; }
	void set() { e = 2147483647; }
	MIN operator+(MIN &other);
	MIN operator*(MIN &other);
};
MIN MIN::operator+(MIN &other) {
	return e < other.e ? MIN(e) : MIN(other.e);
}
MIN MIN::operator*(MIN &other) {
	return other;
}

int main() {
	int32 n, q;
	cin >> n >> q;
	SegTree<MIN,MIN> t(n);
	t.set();
	bool c;
	int32 x, y;
	MIN z;
	rep(i, 0, q) {
		cin >> c;
		if (c) {
			cin >> x >> y;
			
			printf("%d\n", t.range(x, y + 1).e);
		}
		else {
			cin >> x >> y >> z.e;
			t.update(x, y + 1, z);
			
		}
	}
	/*
	rep(i, 1, 8) {
		C(t.tree[i].e);
		C(t.calc[i].e);
		C(t.lazy[i]);
		cout << endl;
	}
	*/
	return 0;
}

Compiler output:
a.cc: In instantiation of 'Monoid SegTree<Monoid, AA>::range(size_t, size_t) [with Monoid = MIN; AA = MIN; size_t = long unsigned int]':
a.cc:174:26:   required from here
  174 |                         printf("%d\n", t.range(x, y + 1).e);
      |                                        ~~~~~~~^~~~~~~~~~
a.cc:127:53: error: no match for 'operator+' (operand types are 'MIN' and 'MIN')
  127 |                                         retL = retL + (tree[begin] * calc[begin]);
      |                                                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:154:5: note: candidate: 'MIN MIN::operator+(MIN&)' (near match)
  154 | MIN MIN::operator+(MIN &other) {
      |     ^~~
a.cc:154:5: note:   conversion of argument 1 would be ill-formed:
a.cc:127:68: error: cannot bind non-const lvalue reference of type 'MIN&' to an rvalue of type 'MIN'
  127 |                                         retL = retL + (tree[begin] * calc[begin]);
      |                                                       ~~~~~~~~~~~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:48,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)'
  627 |     operator+(typename reverse_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:627:5: note:   template argument deduction/substitution failed:
a.cc:127:53: note:   'MIN' is not derived from 'const std::reverse_iterator<_Iterator>'
  127 |                                         retL = retL + (tree[begin] * calc[begin]);
      |                                                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)'
 1798 |     operator+(typename move_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1798:5: note:   template argument deduction/substitution failed:
a.cc:127:53: note:   'MIN' is not derived from 'const std::move_iterator<_IteratorL>'
  127 |                                         retL = retL + (tree[begin] * calc[begin]);
      |                                                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3598 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3598:5: note:   template argument deduction/substitution failed:
a.cc:127:53: note:   'MIN' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
  127 |                                         retL = retL + (tree[begin] * calc[begin]);
      |                                                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3616 |     operator+(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3616:5: note:   template argument deduction/substitution failed:
a.cc:127:53: note:   mismatched types 'const _CharT*' and 'MIN'
  127 |                                         retL = retL + (tree[begin] * calc[begin]);
      |                                                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3635 |     operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3635:5: note:   template argument deduction/substitution failed:
a.cc:127:53: note:   'MIN' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
  127 |                                         retL = retL + (tree[begin] * calc[begin]);
      |                                                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
 3652 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3652:5: note:   template argument deduction/substitution failed:
a.cc:127:53: note:   'MIN' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
  127 |                                         retL = retL + (tree[begin] * calc[begin]);
      |                                                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)'
 3670 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3670:5: note:   template argument deduction/substitution failed:
a.cc:127:53: note:   'MIN' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
  127 |                                         retL = retL + (tree[begin] * calc[begin]);
      |                                                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3682 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3682:5: note:   template argument deduction/substitution failed:
a.cc:127:53: note:   'MIN' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
  127 |                                         retL = retL + (tree[begin] * calc[begin]);
      |                                                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
 3689 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3689:5: note:   template argument deduction/substitution failed:
a.cc:127:53: note:   'MIN' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
  127 |                                         retL = retL + (tree[begin] * calc[begin]);
      |                                                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
 3696 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3696:5: note:   template argument deduction/substitution failed:
a.cc:127:53: note:   'MIN' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
  127 |                                         retL = retL + (tree[begin] * calc[begin]);
      |                                                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3719:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
 3719 |     operator+(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3719:5: note:   template argument deduction/substitution failed:
a.cc:127:53: note:   mismatched types 'const _CharT*' and 'MIN'
  127 |                                         retL = retL + (tree[begin] * calc[begin]);
      |                                                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3726:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
 3726 |     operator+(_CharT __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3726:5: note:   template argument deduction/substitution failed:
a.cc:127:53: note:   'MIN' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
  127 |