Language: C++

#include<iostream>
#include<vector>
#include<utility>
#include<cmath>
typedef long long ll
#define dlr pair<ll,pair<ll,ll> > 
using namespace std;
bool compare_by_l(dlr a, dlr b) {
    if(a.second.first != b.second.first){
        return a.second.first < b.second.first;
    }else{
        return a.first < b.first;
    }
}
bool compare_by_r(dlr a, dlr b) {
    if(a.second.second != b.second.second){
        return a.second.second < b.second.second;
    }else{
        return a.first < b.first;
    }
}


int main(){
	ll n;
  	cin >> n;
  vector<dlr > data;
  for(ll i =0;i<n;++i){
    ll l,r;
    cin >>l>>r;
    data.push_back(dlr(r-l,pair<ll,ll>(l,r)));
  }
  sort(data.begin(),data.end());
  ll ml,mr;
  ml = data.back().second.first;
  mr = data.back().second.second;
  data.pop_back();
  sort(data.begin(),data.end(),compare_by_l);
  ll ans = 0;
  ll sl,sr;
  sl = data.back().second.first;
  sort(data.begin(),data.end(),compare_by_r);
  sr = data.back().second.second;
  ans = mr-ml+1+sr-sl+1;
  cout << ans<<endl;
  return 0;
}

    

Compiler output:
a.cc:7:1: error: expected initializer before 'using'
    7 | using namespace std;
      | ^~~~~
a.cc:6:13: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    6 | #define dlr pair<ll,pair<ll,ll> >
      |             ^~~~
a.cc:8:19: note: in expansion of macro 'dlr'
    8 | bool compare_by_l(dlr a, dlr b) {
      |                   ^~~
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:3013:12: note: 'std::pair' declared here
 3013 |     struct pair;
      |            ^~~~
a.cc:6:18: error: 'll' was not declared in this scope
    6 | #define dlr pair<ll,pair<ll,ll> >
      |                  ^~
a.cc:8:19: note: in expansion of macro 'dlr'
    8 | bool compare_by_l(dlr a, dlr b) {
      |                   ^~~
a.cc:6:21: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    6 | #define dlr pair<ll,pair<ll,ll> >
      |                     ^~~~
a.cc:8:19: note: in expansion of macro 'dlr'
    8 | bool compare_by_l(dlr a, dlr b) {
      |                   ^~~
/usr/include/c++/14/bits/stl_iterator.h:3013:12: note: 'std::pair' declared here
 3013 |     struct pair;
      |            ^~~~
a.cc:6:26: error: 'll' was not declared in this scope
    6 | #define dlr pair<ll,pair<ll,ll> >
      |                          ^~
a.cc:8:19: note: in expansion of macro 'dlr'
    8 | bool compare_by_l(dlr a, dlr b) {
      |                   ^~~
a.cc:6:29: error: 'll' was not declared in this scope
    6 | #define dlr pair<ll,pair<ll,ll> >
      |                             ^~
a.cc:8:19: note: in expansion of macro 'dlr'
    8 | bool compare_by_l(dlr a, dlr b) {
      |                   ^~~
a.cc:6:33: error: expected primary-expression before '>' token
    6 | #define dlr pair<ll,pair<ll,ll> >
      |                                 ^
a.cc:8:19: note: in expansion of macro 'dlr'
    8 | bool compare_by_l(dlr a, dlr b) {
      |                   ^~~
a.cc:8:23: error: 'a' was not declared in this scope
    8 | bool compare_by_l(dlr a, dlr b) {
      |                       ^
a.cc:6:13: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    6 | #define dlr pair<ll,pair<ll,ll> >
      |             ^~~~
a.cc:8:26: note: in expansion of macro 'dlr'
    8 | bool compare_by_l(dlr a, dlr b) {
      |                          ^~~
/usr/include/c++/14/bits/stl_iterator.h:3013:12: note: 'std::pair' declared here
 3013 |     struct pair;
      |            ^~~~
a.cc:6:18: error: 'll' was not declared in this scope
    6 | #define dlr pair<ll,pair<ll,ll> >
      |                  ^~
a.cc:8:26: note: in expansion of macro 'dlr'
    8 | bool compare_by_l(dlr a, dlr b) {
      |                          ^~~
a.cc:6:21: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    6 | #define dlr pair<ll,pair<ll,ll> >
      |                     ^~~~
a.cc:8:26: note: in expansion of macro 'dlr'
    8 | bool compare_by_l(dlr a, dlr b) {
      |                          ^~~
/usr/include/c++/14/bits/stl_iterator.h:3013:12: note: 'std::pair' declared here
 3013 |     struct pair;
      |            ^~~~
a.cc:6:26: error: 'll' was not declared in this scope
    6 | #define dlr pair<ll,pair<ll,ll> >
      |                          ^~
a.cc:8:26: note: in expansion of macro 'dlr'
    8 | bool compare_by_l(dlr a, dlr b) {
      |                          ^~~
a.cc:6:29: error: 'll' was not declared in this scope
    6 | #define dlr pair<ll,pair<ll,ll> >
      |                             ^~
a.cc:8:26: note: in expansion of macro 'dlr'
    8 | bool compare_by_l(dlr a, dlr b) {
      |                          ^~~
a.cc:6:33: error: expected primary-expression before '>' token
    6 | #define dlr pair<ll,pair<ll,ll> >
      |                                 ^
a.cc:8:26: note: in expansion of macro 'dlr'
    8 | bool compare_by_l(dlr a, dlr b) {
      |                          ^~~
a.cc:8:30: error: 'b' was not declared in this scope
    8 | bool compare_by_l(dlr a, dlr b) {
      |                              ^
a.cc:8:31: error: expression list treated as compound expression in initializer [-fpermissive]
    8 | bool compare_by_l(dlr a, dlr b) {
      |                               ^
a.cc:6:13: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    6 | #define dlr pair<ll,pair<ll,ll> >
      |             ^~~~
a.cc:15:19: note: in expansion of macro 'dlr'
   15 | bool compare_by_r(dlr a, dlr b) {
      |                   ^~~
/usr/include/c++/14/bits/stl_iterator.h:3013:12: note: 'std::pair' declared here
 3013 |     struct pair;
      |            ^~~~
a.cc:6:18: error: 'll' was not declared in this scope
    6 | #define dlr pair<ll,pair<ll,ll> >
      |                  ^~
a.cc:15:19: note: in expansion of macro 'dlr'
   15 | bool compare_by_r(dlr a, dlr b) {
      |                   ^~~
a.cc:6:21: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    6 | #define dlr pair<ll,pair<ll,ll> >
      |                     ^~~~
a.cc:15:19: note: in expansion of macro 'dlr'
   15 | bool compare_by_r(dlr a, dlr b) {
      |                   ^~~
/usr/include/c++/14/bits/stl_iterator.h:3013:12: note: 'std::pair' declared here
 3013 |     struct pair;
      |            ^~~~
a.cc:6:26: error: 'll' was not declared in this scope
    6 | #define dlr pair<ll,pair<ll,ll> >
      |                          ^~
a.cc:15:19: note: in expansion of macro 'dlr'
   15 | bool compare_by_r(dlr a, dlr b) {
      |                   ^~~
a.cc:6:29: error: 'll' was not declared in this scope
    6 | #define dlr pair<ll,pair<ll,ll> >
      |                             ^~
a.cc:15:19: note: in expansion of macro 'dlr'
   15 | bool compare_by_r(dlr a, dlr b) {
      |                   ^~~
a.cc:6:33: error: expected primary-expression before '>' token
    6 | #define dlr pair<ll,pair<ll,ll> >
      |                                 ^
a.cc:15:19: note: in expansion of macro 'dlr'
   15 | bool compare_by_r(dlr a, dlr b) {
      |                   ^~~
a.cc:15:23: error: 'a' was not declared in this scope
   15 | bool compare_by_r(dlr a, dlr b) {
      |                       ^
a.cc:6:13: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    6 | #define dlr pair<ll,pair<ll,ll> >
      |             ^~~~
a.cc:15:26: note: in expansion of macro 'dlr'
   15 | bool compare_by_r(dlr a, dlr b) {
      |                          ^~~
/usr/include/c++/14/bits/stl_iterator.h:3013:12: note: 'std::pair' declared here
 3013 |     struct pair;
      |            ^~~~
a.cc:6:18: error: 'll' was not declared in this scope
    6 | #define dlr pair<ll,pair<ll,ll> >
      |                  ^~
a.cc:15:26: note: in expansion of macro 'dlr'
   15 | bool compare_by_r(dlr a, dlr b) {
      |                          ^~~
a.cc:6:21: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    6 | #define dlr pair<ll,pair<ll,ll> >
      |                     ^~~~
a.cc:15:26: note: in expansion of macro 'dlr'
   15 | bool compare_by_r(dlr a, dlr b) {
      |                          ^~~
/usr/include/c++/14/bits/stl_iterator.h:3013:12: note: 'std::pair' declared here
 3013 |     struct pair;
      |            ^~~~
a.cc:6:26: error: 'll' was not declared in this scope
    6 | #define dlr pair<ll,pair<ll,ll> >
      |                          ^~
a.cc:15:26: note: in expansion of macro 'dlr'
   15 | bool compare_by_r(dlr a, dlr b) {
      |                          ^~~
a.cc:6:29: error: 'll' was not declared in this scope
    6 | #define dlr pair<ll,pair<ll,ll> >
      |                             ^~
a.cc:15:26: note: in expansion of macro 'dlr'
   15 | bool compare_by_r(dlr a, dlr b) {
      |                          ^~~
a.cc:6:33: error: expected primary-expression before '>' token
    6 | #define dlr pair<ll,pair<ll,ll> >
      |                                 ^
a.cc:15:26: note: in expansion of macro 'dlr'
   15 | bool compare_by_r(dlr a, dlr b) {
      |                          ^~~
a.cc:15:30: error: 'b' was not declared in this scope
   15 | bool compare_by_r(dlr a, dlr b) {
      |                              ^
a.cc:15:31: error: expression list treated as compound expression in initializer [-fpermissive]
   15 | bool compare_by_r(dlr a, dlr b) {
      |                               ^
a.cc: In function 'int main()':
a.cc:25:9: error: 'll' was not declared in this scope
   25 |         ll n;
      |         ^~
a.cc:26:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   26 |         cin >> n;
      |         ^~~
      |         std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:26:16: error: 'n' was not declared in this scope; did you mean 'yn'?
   26 |         cin >> n;
      |                ^
      |                yn
a.cc:27:3: error: 'vector' was not declared in this scope
   27 |   vector<dlr > data;
      |   ^~~~~~
a.cc:27:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:6:13: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    6 | #define dlr pair<ll,pair<ll,ll> >
      |             ^~~~
a.cc:27:10: note: in expansion of macro 'dlr'
   27 |   vector<dlr > data;
      |          ^~~
/usr/include/c++/14/bits/stl_iterator.h:3013:12: note: 'std::pair' declared here
 3013 |     struct pair;
      |            ^~~~
a.cc:6:33: error: expected primary-expression b