Language: C++

#include<iostream>
#include<vector>
#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:6:1: error: expected initializer before 'using'
    6 | using namespace std;
      | ^~~~~
a.cc:5:13: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    5 | #define dlr pair<ll,pair<ll,ll> >
      |             ^~~~
a.cc:7:19: note: in expansion of macro 'dlr'
    7 | 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:5:18: error: 'll' was not declared in this scope
    5 | #define dlr pair<ll,pair<ll,ll> >
      |                  ^~
a.cc:7:19: note: in expansion of macro 'dlr'
    7 | bool compare_by_l(dlr a, dlr b) {
      |                   ^~~
a.cc:5:21: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    5 | #define dlr pair<ll,pair<ll,ll> >
      |                     ^~~~
a.cc:7:19: note: in expansion of macro 'dlr'
    7 | 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:5:26: error: 'll' was not declared in this scope
    5 | #define dlr pair<ll,pair<ll,ll> >
      |                          ^~
a.cc:7:19: note: in expansion of macro 'dlr'
    7 | bool compare_by_l(dlr a, dlr b) {
      |                   ^~~
a.cc:5:29: error: 'll' was not declared in this scope
    5 | #define dlr pair<ll,pair<ll,ll> >
      |                             ^~
a.cc:7:19: note: in expansion of macro 'dlr'
    7 | bool compare_by_l(dlr a, dlr b) {
      |                   ^~~
a.cc:5:33: error: expected primary-expression before '>' token
    5 | #define dlr pair<ll,pair<ll,ll> >
      |                                 ^
a.cc:7:19: note: in expansion of macro 'dlr'
    7 | bool compare_by_l(dlr a, dlr b) {
      |                   ^~~
a.cc:7:23: error: 'a' was not declared in this scope
    7 | bool compare_by_l(dlr a, dlr b) {
      |                       ^
a.cc:5:13: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    5 | #define dlr pair<ll,pair<ll,ll> >
      |             ^~~~
a.cc:7:26: note: in expansion of macro 'dlr'
    7 | 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:5:18: error: 'll' was not declared in this scope
    5 | #define dlr pair<ll,pair<ll,ll> >
      |                  ^~
a.cc:7:26: note: in expansion of macro 'dlr'
    7 | bool compare_by_l(dlr a, dlr b) {
      |                          ^~~
a.cc:5:21: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    5 | #define dlr pair<ll,pair<ll,ll> >
      |                     ^~~~
a.cc:7:26: note: in expansion of macro 'dlr'
    7 | 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:5:26: error: 'll' was not declared in this scope
    5 | #define dlr pair<ll,pair<ll,ll> >
      |                          ^~
a.cc:7:26: note: in expansion of macro 'dlr'
    7 | bool compare_by_l(dlr a, dlr b) {
      |                          ^~~
a.cc:5:29: error: 'll' was not declared in this scope
    5 | #define dlr pair<ll,pair<ll,ll> >
      |                             ^~
a.cc:7:26: note: in expansion of macro 'dlr'
    7 | bool compare_by_l(dlr a, dlr b) {
      |                          ^~~
a.cc:5:33: error: expected primary-expression before '>' token
    5 | #define dlr pair<ll,pair<ll,ll> >
      |                                 ^
a.cc:7:26: note: in expansion of macro 'dlr'
    7 | bool compare_by_l(dlr a, dlr b) {
      |                          ^~~
a.cc:7:30: error: 'b' was not declared in this scope
    7 | bool compare_by_l(dlr a, dlr b) {
      |                              ^
a.cc:7:31: error: expression list treated as compound expression in initializer [-fpermissive]
    7 | bool compare_by_l(dlr a, dlr b) {
      |                               ^
a.cc:5:13: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    5 | #define dlr pair<ll,pair<ll,ll> >
      |             ^~~~
a.cc:14:19: note: in expansion of macro 'dlr'
   14 | 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:5:18: error: 'll' was not declared in this scope
    5 | #define dlr pair<ll,pair<ll,ll> >
      |                  ^~
a.cc:14:19: note: in expansion of macro 'dlr'
   14 | bool compare_by_r(dlr a, dlr b) {
      |                   ^~~
a.cc:5:21: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    5 | #define dlr pair<ll,pair<ll,ll> >
      |                     ^~~~
a.cc:14:19: note: in expansion of macro 'dlr'
   14 | 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:5:26: error: 'll' was not declared in this scope
    5 | #define dlr pair<ll,pair<ll,ll> >
      |                          ^~
a.cc:14:19: note: in expansion of macro 'dlr'
   14 | bool compare_by_r(dlr a, dlr b) {
      |                   ^~~
a.cc:5:29: error: 'll' was not declared in this scope
    5 | #define dlr pair<ll,pair<ll,ll> >
      |                             ^~
a.cc:14:19: note: in expansion of macro 'dlr'
   14 | bool compare_by_r(dlr a, dlr b) {
      |                   ^~~
a.cc:5:33: error: expected primary-expression before '>' token
    5 | #define dlr pair<ll,pair<ll,ll> >
      |                                 ^
a.cc:14:19: note: in expansion of macro 'dlr'
   14 | bool compare_by_r(dlr a, dlr b) {
      |                   ^~~
a.cc:14:23: error: 'a' was not declared in this scope
   14 | bool compare_by_r(dlr a, dlr b) {
      |                       ^
a.cc:5:13: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    5 | #define dlr pair<ll,pair<ll,ll> >
      |             ^~~~
a.cc:14:26: note: in expansion of macro 'dlr'
   14 | 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:5:18: error: 'll' was not declared in this scope
    5 | #define dlr pair<ll,pair<ll,ll> >
      |                  ^~
a.cc:14:26: note: in expansion of macro 'dlr'
   14 | bool compare_by_r(dlr a, dlr b) {
      |                          ^~~
a.cc:5:21: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    5 | #define dlr pair<ll,pair<ll,ll> >
      |                     ^~~~
a.cc:14:26: note: in expansion of macro 'dlr'
   14 | 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:5:26: error: 'll' was not declared in this scope
    5 | #define dlr pair<ll,pair<ll,ll> >
      |                          ^~
a.cc:14:26: note: in expansion of macro 'dlr'
   14 | bool compare_by_r(dlr a, dlr b) {
      |                          ^~~
a.cc:5:29: error: 'll' was not declared in this scope
    5 | #define dlr pair<ll,pair<ll,ll> >
      |                             ^~
a.cc:14:26: note: in expansion of macro 'dlr'
   14 | bool compare_by_r(dlr a, dlr b) {
      |                          ^~~
a.cc:5:33: error: expected primary-expression before '>' token
    5 | #define dlr pair<ll,pair<ll,ll> >
      |                                 ^
a.cc:14:26: note: in expansion of macro 'dlr'
   14 | bool compare_by_r(dlr a, dlr b) {
      |                          ^~~
a.cc:14:30: error: 'b' was not declared in this scope
   14 | bool compare_by_r(dlr a, dlr b) {
      |                              ^
a.cc:14:31: error: expression list treated as compound expression in initializer [-fpermissive]
   14 | bool compare_by_r(dlr a, dlr b) {
      |                               ^
a.cc: In function 'int main()':
a.cc:24:9: error: 'll' was not declared in this scope
   24 |         ll n;
      |         ^~
a.cc:25:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   25 |         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:25:16: error: 'n' was not declared in this scope; did you mean 'yn'?
   25 |         cin >> n;
      |                ^
      |                yn
a.cc:26:3: error: 'vector' was not declared in this scope
   26 |   vector<dlr > data;
      |   ^~~~~~
a.cc:26: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:5:13: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    5 | #define dlr pair<ll,pair<ll,ll> >
      |             ^~~~
a.cc:26:10: note: in expansion of macro 'dlr'
   26 |   vector<dlr > data;
      |          ^~~
/usr/include/c++/14/bits/stl_iterator.h:3013:12: note: 'std::pair' declared here
 3013 |     struct pair;
      |            ^~~~
a.cc:5:33: error: expected primary-expression b