Language: C++

#include<iostream>
#include<vector>
#include<utility>
#include<cmath>
using namespace std;
typedef long long ll
#define dlr pair<ll,pair<ll,ll> > 
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:8:1: error: expected initializer before 'bool'
    8 | bool compare_by_l(dlr a, dlr b) {
      | ^~~~
a.cc:7:18: error: 'll' was not declared in this scope
    7 | #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:7:26: error: 'll' was not declared in this scope
    7 | #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:7:29: error: 'll' was not declared in this scope
    7 | #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:7:31: error: template argument 1 is invalid
    7 | #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:7:31: error: template argument 2 is invalid
    7 | #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:7:33: error: template argument 1 is invalid
    7 | #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:7:33: error: template argument 2 is invalid
    7 | #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:7:18: error: 'll' was not declared in this scope
    7 | #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:7:26: error: 'll' was not declared in this scope
    7 | #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:7:29: error: 'll' was not declared in this scope
    7 | #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:7:31: error: template argument 1 is invalid
    7 | #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:7:31: error: template argument 2 is invalid
    7 | #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:7:33: error: template argument 1 is invalid
    7 | #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:7:33: error: template argument 2 is invalid
    7 | #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: In function 'bool compare_by_r(int, int)':
a.cc:16:10: error: request for member 'second' in 'a', which is of non-class type 'int'
   16 |     if(a.second.second != b.second.second){
      |          ^~~~~~
a.cc:16:29: error: request for member 'second' in 'b', which is of non-class type 'int'
   16 |     if(a.second.second != b.second.second){
      |                             ^~~~~~
a.cc:17:18: error: request for member 'second' in 'a', which is of non-class type 'int'
   17 |         return a.second.second < b.second.second;
      |                  ^~~~~~
a.cc:17:36: error: request for member 'second' in 'b', which is of non-class type 'int'
   17 |         return a.second.second < b.second.second;
      |                                    ^~~~~~
a.cc:19:18: error: request for member 'first' in 'a', which is of non-class type 'int'
   19 |         return a.first < b.first;
      |                  ^~~~~
a.cc:19:28: error: request for member 'first' in 'b', which is of non-class type 'int'
   19 |         return a.first < b.first;
      |                            ^~~~~
a.cc: In function 'int main()':
a.cc:25:9: error: 'll' was not declared in this scope
   25 |         ll n;
      |         ^~
a.cc:26:16: error: 'n' was not declared in this scope; did you mean 'yn'?
   26 |         cin >> n;
      |                ^
      |                yn
a.cc:7:33: error: template argument 2 is invalid
    7 | #define dlr pair<ll,pair<ll,ll> >
      |                                 ^
a.cc:27:10: note: in expansion of macro 'dlr'
   27 |   vector<dlr > data;
      |          ^~~
a.cc:27:14: error: template argument 1 is invalid
   27 |   vector<dlr > data;
      |              ^
a.cc:27:14: error: template argument 2 is invalid
a.cc:28:9: error: expected ';' before 'i'
   28 |   for(ll i =0;i<n;++i){
      |         ^~
      |         ;
a.cc:28:15: error: 'i' was not declared in this scope
   28 |   for(ll i =0;i<n;++i){
      |               ^
a.cc:29:7: error: expected ';' before 'l'
   29 |     ll l,r;
      |       ^~
      |       ;
a.cc:30:11: error: 'l' was not declared in this scope
   30 |     cin >>l>>r;
      |           ^
a.cc:30:14: error: 'r' was not declared in this scope
   30 |     cin >>l>>r;
      |              ^
a.cc:31:10: error: request for member 'push_back' in 'data', which is of non-class type 'int'
   31 |     data.push_back(dlr(r-l,pair<ll,ll>(l,r)));
      |          ^~~~~~~~~
a.cc:7:33: error: template argument 2 is invalid
    7 | #define dlr pair<ll,pair<ll,ll> >
      |                                 ^
a.cc:31:20: note: in expansion of macro 'dlr'
   31 |     data.push_back(dlr(r-l,pair<ll,ll>(l,r)));
      |                    ^~~
a.cc:33:13: error: request for member 'begin' in 'data', which is of non-class type 'int'
   33 |   sort(data.begin(),data.end());
      |             ^~~~~
a.cc:33:26: error: request for member 'end' in 'data', which is of non-class type 'int'
   33 |   sort(data.begin(),data.end());
      |                          ^~~
a.cc:33:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   33 |   sort(data.begin(),data.end());
      |   ^~~~
      |   sqrt
a.cc:34:5: error: expected ';' before 'ml'
   34 |   ll ml,mr;
      |     ^~~
      |     ;
a.cc:35:3: error: 'ml' was not declared in this scope
   35 |   ml = data.back().second.first;
      |   ^~
a.cc:35:13: error: request for member 'back' in 'data', which is of non-class type 'int'
   35 |   ml = data.back().second.first;
      |             ^~~~
a.cc:36:3: error: 'mr' was not declared in this scope
   36 |   mr = data.back().second.second;
      |   ^~
a.cc:36:13: error: request for member 'back' in 'data', which is of non-class type 'int'
   36 |   mr = data.back().second.second;
      |             ^~~~
a.cc:37:8: error: request for member 'pop_back' in 'data', which is of non-class type 'int'
   37 |   data.pop_back();
      |        ^~~~~~~~
a.cc:38:13: error: request for member 'begin' in 'data', which is of non-class type 'int'
   38 |   sort(data.begin(),data.end(),compare_by_l);
      |             ^~~~~
a.cc:38:26: error: request for member 'end' in 'data', which is of non-class type 'int'
   38 |   sort(data.begin(),data.end(),compare_by_l);
      |                          ^~~
a.cc:38:32: error: 'compare_by_l' was not declared in this scope; did you mean 'compare_by_r'?
   38 |   sort(data.begin(),data.end(),compare_by_l);
      |                                ^~~~~~~~~~~~
      |                                compare_by_r
a.cc:39:5: error: expected ';' before 'ans'
   39 |   ll ans = 0;
      |     ^~~~
      |     ;
a.cc:40:5: error: expected ';' before 'sl'
   40 |   ll sl,sr;
      |     ^~~
      |     ;
a.cc:41:3: error: 'sl' was not declared in this scope
   41 |   sl = data.back().second.first;
      |   ^~
a.cc:41:13: error: request for member 'back' in 'data', which is of non-class type 'int'
   41 |   sl = data.back().second.first;
      |             ^~~~
a.cc:42:13: error: request for member 'begin' in 'data', which is of non-class type 'int'
   42 |   sort(data.begin(),data.end(),compare_by_r);
      |             ^~~~~
a.cc:42:26: error: request for member 'end' in 'data', which is of non-class type 'int'
   42 |   sort(data.begin(),data.end(),compare_by_r);
      |                          ^~~
a.cc:43:3: error: 'sr' was not declared in this scope
   43 |   sr = data.back().second.second;
      |   ^~
a.cc:43:13: error: request for member 'back' in 'data', which is of non-class type 'int'
   43 |   sr = data.back().second.second;
      |             ^~~~
a.cc:44:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   44 |   ans = mr-ml+1+sr-sl+1;
      |   ^~~
      |   abs