Language: C++

#include <bits/stdc++.h>
using namespace std;

//vector…可変長、データの大きさに合わせてサイズを変える
//list…双方向リスト、要素を挿入、削除の多いとき
//forward_list
//array…固定長配列
//set…集合
//multiset
//bitset…2進数、固定長ビット列
//map…連想配列、キーと値を関連付ける
//multimap
//deque
//stack…FILO
//queue…FIFO
//priority_queue
//pair…二つの値を一組
//tuple…複数の値を一組

template<typename T>
void remove(std::vector<T>& vector, char index) {
    vector.erase(vector.begin() + index);
}

template<class T>
T ma(std::vector<T> &v) {
    T maxi = 0;
    for(auto &i:v) maxi = max(maxi, i);
    return maxi;
}

template<class T>
T mi(std::vector<T> &v) {
    T mini = 0;
    for(auto &i:v) mini = min(mini, i);
    return mini;
}

template <class T>
T pow(T x, T y, T n = numeric_limits<T>::max()) {
    if(y == 0) return 1;
    if(y % 2 == 0) return pow((x * x) % n, y / 2);
    return (x * pow(x, y - 1)) % n;
}

#define rep(i, n, m) for (int i = n; i <= m; i++)
#define Rep(i, n, m) for (int i = m; i >= 1; i--)

typedef long long ll;
typedef unsigned long long ull;

ull ans = 0;
/*
int gcd(int x, int y) {
    if (x < y) swap(x, y);
    return !y ? x : gcd(x % y, y);
}
*/
 int main() {
    ull n, m;
    cin >> n >> m;
    vector<int> L(m);
    vector<int> R(m);
    rep(i, 0, m-1) cin >> L[i] >> R[i];
    cout << endl;
    decltype(L)::iterator l = max_element(L.begin(), L.end());
    decltype(R)::iterator r = min_element(R.begin(), R.end());
  
   #include <bits/stdc++.h>
using namespace std;

//vector…可変長、データの大きさに合わせてサイズを変える
//list…双方向リスト、要素を挿入、削除の多いとき
//forward_list
//array…固定長配列
//set…集合
//multiset
//bitset…2進数、固定長ビット列
//map…連想配列、キーと値を関連付ける
//multimap
//deque
//stack…FILO
//queue…FIFO
//priority_queue
//pair…二つの値を一組
//tuple…複数の値を一組

template<typename T>
void remove(std::vector<T>& vector, char index) {
    vector.erase(vector.begin() + index);
}

template<class T>
T ma(std::vector<T> &v) {
    T maxi = 0;
    for(auto &i:v) maxi = max(maxi, i);
    return maxi;
}

template<class T>
T mi(std::vector<T> &v) {
    T mini = 0;
    for(auto &i:v) mini = min(mini, i);
    return mini;
}

template <class T>
T pow(T x, T y, T n = numeric_limits<T>::max()) {
    if(y == 0) return 1;
    if(y % 2 == 0) return pow((x * x) % n, y / 2);
    return (x * pow(x, y - 1)) % n;
}

#define rep(i, n, m) for (int i = n; i <= m; i++)
#define Rep(i, n, m) for (int i = m; i >= 1; i--)

typedef long long ll;
typedef unsigned long long ull;

ull ans = 0;
/*
int gcd(int x, int y) {
    if (x < y) swap(x, y);
    return !y ? x : gcd(x % y, y);
}
*/
 int main() {
    ull n, m;
    cin >> n >> m;
    vector<int> L(m);
    vector<int> R(m);
    rep(i, 0, m-1) cin >> L[i] >> R[i];
    cout << endl;
    decltype(L)::iterator l = max_element(L.begin(), L.end());
    decltype(R)::iterator r = min_element(R.begin(), R.end());
  
    if (*r - *l < 0) {
        cout << 0 << endl;
    } else {
        cout << *r - *l + 1 << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:88:1: error: a template declaration cannot appear at block scope
   88 | template<typename T>
      | ^~~~~~~~
a.cc:100:1: error: a template declaration cannot appear at block scope
  100 | template<class T>
      | ^~~~~~~~
a.cc:127:10: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
  127 |  int main() {
      |          ^~
a.cc:127:10: note: remove parentheses to default-initialize a variable
  127 |  int main() {
      |          ^~
      |          --
a.cc:127:10: note: or replace parentheses with braces to value-initialize a variable
a.cc:127:13: error: a function-definition is not allowed here before '{' token
  127 |  int main() {
      |             ^
a.cc:142:2: error: expected '}' at end of input
  142 | }
      |  ^
a.cc:59:13: note: to match this '{'
   59 |  int main() {
      |             ^