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 =  1e13;

// 1 base indexing build(1,1,n);
struct Data
{
	//Use required attributes 
	//Default Values
	int  lo ; 
	int l , r;
	int  lazy_inc;
	int  lazy_ass;
	bool clazy_inc;
	bool clazy_ass;
	Data() {
	  lazy_inc = lazy_ass=0;
	  clazy_inc = clazy_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);
		cur.lazy_ass = l.lazy_ass;
	}

	//Handle lazy propagation appriopriately
	void propagate(int node, int L, int R)
	{

		
		if(st[node].clazy_ass){
             
			 st[lnode].lazy_ass = st[node].lazy_ass;
			 st[lnode].lo = st[lnode].l + st[node].lazy_ass+1;
			 st[lnode].clazy_ass =1;
			 st[lnode].clazy_inc=0;
			 st[lnode].lazy_inc = 0;

			 st[rnode].lazy_ass = st[node].lazy_ass;
			 st[rnode].clazy_ass = 1;
			 st[rnode].clazy_inc = 0;
			 st[rnode].lazy_inc = 0;
			 st[rnode].lo = st[rnode].l + st[node].lazy_ass +1;
			 
	
			
		}
		else if(st[node].clazy_inc){
             
			 st[lnode].lazy_inc += st[node].lazy_inc;
			 st[lnode].clazy_inc = 1;
			 st[lnode].lo+=st[node].lazy_inc;

			 st[rnode].lazy_inc += st[node].lazy_inc;
			 st[rnode].lo+=st[node].lazy_inc;
	         st[rnode].clazy_inc = 1;		 
		}

			 
		
		st[node].lazy_ass = 0;
		st[node].lazy_inc = 0 ;
		st[node].clazy_ass = 0 ;
		st[node].clazy_inc = 0;
		
	}
 
	void build(int node, int L, int R)
	{
		if(L==R)
		{
			st[node].lo= L-1;
			st[node].l = L;
			st[node].r = R;
			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)
	{
		
		if(j<L || i>R){
			return Data();
		}
		if(i<=L && R<=j)
			return st[node];
		propagate(node, L, R);
		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
	{

		
		if(j<L || i>R)
			return;
		if(i<=L && R<=j)
		{
			st[node].clazy_ass=1;
			st[node].lazy_ass = val;
			st[node].clazy_inc = 0;
			st[node].lazy_inc = 0 ;
			st[node].lo = val + L + 1;
			return;
		}
		propagate(node, L, R);
		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){
		if(j<L || i>R)
			return;
		if(i<=L && R<=j)
		{
			st[node].clazy_inc =1;
			st[node].lazy_inc += val;
			st[node].lazy_ass +=val;
			st[node].lo += val;
			return;
		}
		propagate(node, L, R);
		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,int val)
	{
		Update2(1,1,N,l,r,1);
	}
};

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,1);
	 }
	 else{
	 
	 t.update2(1,l-1,1);
	 if(r!=w){
		 t.update2(r+1,w,1);
	 }	 
	 int n = (t.query(l-1)).lo;
     t.update(l,r,n-l);
	 
	 }

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



Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.