Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"


template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef cc_hash_table<int, int, hash<int > > ht;


#define int long long 
#define  st first
#define  nd second

const int M = 1e8;
const int  maxn = 2e5+5;
const int  inf =  1e12;

// 1 base indexing build(1,1,n);
struct Data
{
	//Use required attributes 
	//Default Values
	int  lo ; 
	int  lazy_inc;
	int  lazy_ass;
	Data() {
	  lazy_inc = lazy_ass=0;
	  lo = inf;
	}
};

#define lnode 2*node
#define rnode 2*node + 1

struct SegTree
{
	int N;
	vector<Data> st;

	void init(int n)
	{
		N = n;
		st.resize(4 * N + 5);
	}

	//Write reqd merge functions
	void merge1(Data &cur, Data &l, Data &r)
	{
        cur.lo = min(l.lo , r.lo);
	}

	//Handle lazy propagation appriopriately
	void propagate(int node, int L, int R)
	{
		if(L != R)
		{
			st[lnode].lazy_ass   +=   st[node].lazy_ass;
			st[rnode].lazy_ass   +=   st[node].lazy_ass;

			st[lnode].lazy_inc   +=   st[node].lazy_inc;
			st[rnode].lazy_inc   +=   st[node].lazy_inc;
		}
        if(st[node].lazy_ass){
            st[node].lo =  st[node].lazy_ass + L +1 ;
            st[node].lazy_ass=0;
		}
		if(st[node].lazy_inc){
			st[node].lo +=st[node].lazy_inc;
            st[node].lazy_inc=0;
		}
	}
 
	void build(int node, int L, int R)
	{
		if(L==R)
		{
			st[node].lo= L-1;
			return;
		}
		int M=(L + R)/2;
		build(lnode, L, M);
		build(rnode, M + 1, R);
		merge1(st[node], st[lnode], st[rnode]);
	}

	Data Query(int node, int L, int R, int i, int j)
	{
		propagate(node, L, R);
		if(j<L || i>R){
			return Data();
		}
		if(i<=L && R<=j)
			return st[node];
		int M = (L + R)/2;
		Data left = Query(lnode, L, M, i, j);
		Data right= Query(rnode, M + 1, R, i, j);
		Data cur;
		merge1(cur, left, right);
		return cur;
	}

	Data pQuery(int node, int L, int R, int pos)
	{
		return Query(node,L,R,pos,pos);
	}

	void Update(int node, int L, int R, int i, int j, int val) /// assignment of L-i
	{

		propagate(node, L, R);
		if(j<L || i>R)
			return;
		if(i<=L && R<=j)
		{
			st[node].lazy_ass = val;
			propagate(node, L, R);
			return;
		}
		int M = (L + R)/2;
		Update(lnode, L, M, i, j, val);
		Update(rnode, M + 1, R, i, j, val);
		merge1(st[node], st[lnode], st[rnode]);
	}
    void Update2(int node, int L,int R,int i , int j,int val){
        propagate(node, L, R);
		if(j<L || i>R)
			return;
		if(i<=L && R<=j)
		{
			st[node].lazy_inc += val;
			propagate(node, L, R);
			return;
		}
		int M = (L + R)/2;
		Update2(lnode, L, M, i, j,val);
		Update2(rnode, M + 1, R, i, j,val);
		merge1(st[node], st[lnode], st[rnode]);
	}
	void pUpdate(int node, int L, int R, int pos, int val)
	{
		Update(node,L,R,pos,pos,val);
	}

	Data query(int pos)
	{
		return pQuery(1, 1, N, pos);
	}

	Data query(int l, int r)
	{
		return Query(1, 1, N, l, r);
	}

	void update(int pos, int val)
	{
		pUpdate(1, 1, N, pos, val);
	}

	void update(int l, int r, int val)
	{
		Update(1, 1, N, l, r, val);
	}
	void update2(int l ,int r)
	{
		Update2(1,1,N,l,r);
	}
};

int32_t main(){

  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int h , w ; 
  cin >> h >> w ;
  SegTree t;
  t.init(w);
  t.build(1,1,w);
  for(int i = 0 ; i < h ; i++){
     int l , r ; 
	 cin >> l >> r ; 
	 if(l==1 and r==w){
		 t.update(l,r,inf);
	 }
	 else if(l==1){
		 t.update(l,r,inf);
		 t.update2(r+1,w);
	 }
	 else{
	 
	 t.update2(1,l-1);
	 if(r!=w){
		 t.update2(r+1,w);
	 }	 
	 int n = (t.query(l-1)).lo;
     t.update(l,r,n-l);
	 
	 
	 }

	 int ans = t.query(1,w).lo;
	 if(ans<inf){
		 cout << ans ;
	 }
	 else{
		 cout << -1;
	 }
	 cout << "\n";
  }    
  
}



Compiler output:
a.cc: In member function 'void SegTree::update2(long long int, long long int)':
a.cc:181:24: error: no matching function for call to 'SegTree::Update2(int, int, long long int&, long long int&, long long int&)'
  181 |                 Update2(1,1,N,l,r);
      |                 ~~~~~~~^~~~~~~~~~~
a.cc:140:10: note: candidate: 'void SegTree::Update2(long long int, long long int, long long int, long long int, long long int, long long int)'
  140 |     void Update2(int node, int L,int R,int i , int j,int val){
      |          ^~~~~~~
a.cc:140:10: note:   candidate expects 6 arguments, 5 provided