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:4:2: error: invalid preprocessing directive #typedef
    4 | #typedef long long ll
      |  ^~~~~~~
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: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:31: error: template argument 1 is invalid
    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:31: error: template argument 2 is invalid
    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: template argument 1 is invalid
    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: template argument 2 is invalid
    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: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: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:31: error: template argument 1 is invalid
    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:31: error: template argument 2 is invalid
    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: template argument 1 is invalid
    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: template argument 2 is invalid
    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: In function 'bool compare_by_l(int, int)':
a.cc:8:10: error: request for member 'second' in 'a', which is of non-class type 'int'
    8 |     if(a.second.first != b.second.first){
      |          ^~~~~~
a.cc:8:28: error: request for member 'second' in 'b', which is of non-class type 'int'
    8 |     if(a.second.first != b.second.first){
      |                            ^~~~~~
a.cc:9:18: error: request for member 'second' in 'a', which is of non-class type 'int'
    9 |         return a.second.first < b.second.first;
      |                  ^~~~~~
a.cc:9:35: error: request for member 'second' in 'b', which is of non-class type 'int'
    9 |         return a.second.first < b.second.first;
      |                                   ^~~~~~
a.cc:11:18: error: request for member 'first' in 'a', which is of non-class type 'int'
   11 |         return a.first < b.first;
      |                  ^~~~~
a.cc:11:28: error: request for member 'first' in 'b', which is of non-class type 'int'
   11 |         return a.first < b.first;
      |                            ^~~~~
a.cc: At global scope:
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: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:31: error: template argument 1 is invalid
    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:31: error: template argument 2 is invalid
    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: template argument 1 is invalid
    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: template argument 2 is invalid
    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: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: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:31: error: template argument 1 is invalid
    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:31: error: template argument 2 is invalid
    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: template argument 1 is invalid
    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: template argument 2 is invalid
    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: In function 'bool compare_by_r(int, int)':
a.cc:15:10: error: request for member 'second' in 'a', which is of non-class type 'int'
   15 |     if(a.second.second != b.second.second){
      |          ^~~~~~
a.cc:15:29: error: request for member 'second' in 'b', which is of non-class type 'int'
   15 |     if(a.second.second != b.second.second){
      |                             ^~~~~~
a.cc:16:18: error: request for member 'second' in 'a', which is of non-class type 'int'
   16 |         return a.second.second < b.second.second;
      |                  ^~~~~~
a.cc:16:36: error: request for member 'second' in 'b', which is of non-class type 'int'
   16 |         return a.second.second < b.second.second;
      |                                    ^~~~~~
a.cc:18:18: error: request for member 'first' in 'a', which is of non-class type 'int'
   18 |         return a.first < b.first;
      |                  ^~~~~
a.cc:18:28: error: request for member 'first' in 'b', which is of non-class type 'int'
   18 |         return a.first < b.first;
      |                            ^~~~~
a.cc: In function 'int main()':
a.cc:24:9: error: 'll' was not declared in this scope
   24 |         ll n;
      |         ^~
a.cc:25:16: error: 'n' was not declared in this scope; did you mean 'yn'?
   25 |         cin >> n;
      |                ^
      |                yn
a.cc:5:33: error: template argument 2 is invalid
    5 | #define dlr pair<ll,pair<ll,ll> >
      |                                 ^
a.cc:26:10: note: in expansion of macro 'dlr'
   26 |   vector<dlr > data;
      |          ^~~
a.cc:26:14: error: template argument 1 is invalid
   26 |   vector<dlr > data;
      |              ^
a.cc:26:14: error: template argument 2 is invalid
a.cc:27:9: error: expected ';' before 'i'
   27 |   for(ll i =0;i<n;++i){
      |         ^~
      |         ;
a.cc:27:15: error: 'i' was not declared in this scope
   27 |   for(ll i =0;i<n;++i){
      |