Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef double ld;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

template< typename Monoid, typename OperatorMonoid = Monoid >
struct LazySegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;
  using G = function< Monoid(Monoid, OperatorMonoid) >;
  using H = function< OperatorMonoid(OperatorMonoid, OperatorMonoid) >;

  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);
  }

  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]);
    }
  }

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

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

  inline void recalc(int k) {
    while(k >>= 1) data[k] = f(reflect(2 * k + 0), reflect(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) {
    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) {
    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, reflect(l++));
      if(r & 1) R = f(reflect(--r), R);
    }
    return f(L, R);
  }

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

  template< typename C >
  int find_subtree(int a, const C &check, Monoid &M, bool type) {
    while(a < sz) {
      propagate(a);
      Monoid nxt = type ? f(reflect(2 * a + type), M) : f(M, reflect(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, reflect(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, reflect(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(reflect(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(reflect(--b), R);
        if(check(nxt)) return find_subtree(b, check, R, true);
        R = nxt;
      }
    }
    return -1;
  }
};

int main(){
	init();
	ll N,M;cin>>N>>M;
	vector<ll>data(N+1,0);
	for(int i=0;i<M;i++){
		ll l,r;cin>>l>>r;
		l--;r--;
		data[l]++;
		data[r+1]--;
	}
	vector<ll>sum(N+2,0);
	for(int i=0;i<N;i++){
		sum[i+1]=sum[i]+data[i];
	}
	ll ans=0;
	for(auto&&i:sum){
		if(i==M)ans++;
	}
	cout<<ans<<endl;
}


Compiler output:
a.cc:57:13: error: 'function' does not name a type; did you mean 'union'?
   57 |   using F = function< Monoid(Monoid, Monoid) >;
      |             ^~~~~~~~
      |             union
a.cc:58:13: error: 'function' does not name a type; did you mean 'union'?
   58 |   using G = function< Monoid(Monoid, OperatorMonoid) >;
      |             ^~~~~~~~
      |             union
a.cc:59:13: error: 'function' does not name a type; did you mean 'union'?
   59 |   using H = function< OperatorMonoid(OperatorMonoid, OperatorMonoid) >;
      |             ^~~~~~~~
      |             union
a.cc:64:9: error: 'F' does not name a type
   64 |   const F f;
      |         ^
a.cc:65:9: error: 'G' does not name a type
   65 |   const G g;
      |         ^
a.cc:66:9: error: 'H' does not name a type
   66 |   const H h;
      |         ^
a.cc:71:32: error: 'F' does not name a type
   71 |   LazySegmentTree(int n, const F f, const G g, const H h,
      |                                ^
a.cc:71:43: error: 'G' does not name a type
   71 |   LazySegmentTree(int n, const F f, const G g, const H h,
      |                                           ^
a.cc:71:54: error: 'H' does not name a type
   71 |   LazySegmentTree(int n, const F f, const G g, const H h,
      |                                                      ^
a.cc: In constructor 'LazySegmentTree<Monoid, OperatorMonoid>::LazySegmentTree(int, int, int, int, const Monoid&, OperatorMonoid)':
a.cc:73:9: error: class 'LazySegmentTree<Monoid, OperatorMonoid>' does not have any field named 'f'
   73 |       : f(f), g(g), h(h), M1(M1), OM0(OM0) {
      |         ^
a.cc:73:15: error: class 'LazySegmentTree<Monoid, OperatorMonoid>' does not have any field named 'g'
   73 |       : f(f), g(g), h(h), M1(M1), OM0(OM0) {
      |               ^
a.cc:73:21: error: class 'LazySegmentTree<Monoid, OperatorMonoid>' does not have any field named 'h'
   73 |       : f(f), g(g), h(h), M1(M1), OM0(OM0) {
      |                     ^