Language: C++

#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define tii tuple<int,int,int>
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

ll func1(vector<pll>* a){
    int n=a.size();
    vecll vl(n),vr(n);
    ll tmpR,tmpL;
    
    tmpL=-1;
    tmpR=1000000010;
    rep(i,n){
        tmpL=max(tmpL,a[i].first);
        tmpR=min(tmpR,a[i].second);
        vl[i]=max(tmpR-tmpL+1,(ll)0);
    }
    
    tmpL=-1;
    tmpR=1000000010;
    rep3(i,n-1,0){
        tmpL=max(tmpL,a[i].first);
        tmpR=min(tmpR,a[i].second);
        vr[i]=max(tmpR-tmpL+1,(ll)0);
    }
    ll ans=0;
    rep(i,n-1){
       // cout<<vl[i]<<" "<<vr[i+1]<<endl;
        ans=max(vl[i]+vr[i+1],ans);
    }
    return ans;
}
int main(){
    int n=in();
    vector<pll> a(n);
    rep(i,n){
        ll x=lin()-1,y=lin()-1;
        a[i]=mp(x,y);
    }
    sort(ALL(a));
    cout<<func1(n,a)<<endl;
}

Compiler output:
a.cc: In function 'long long int func1(std::vector<std::pair<long long int, long long int> >*)':
a.cc:53:13: error: request for member 'size' in 'a', which is of pointer type 'std::vector<std::pair<long long int, long long int> >*' (maybe you meant to use '->' ?)
   53 |     int n=a.size();
      |             ^~~~
a.cc:60:28: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'first'
   60 |         tmpL=max(tmpL,a[i].first);
      |                            ^~~~~
a.cc:61:28: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'second'
   61 |         tmpR=min(tmpR,a[i].second);
      |                            ^~~~~~
a.cc:68:28: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'first'
   68 |         tmpL=max(tmpL,a[i].first);
      |                            ^~~~~
a.cc:69:28: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'second'
   69 |         tmpR=min(tmpR,a[i].second);
      |                            ^~~~~~
a.cc: In function 'int main()':
a.cc:87:17: error: invalid conversion from 'int' to 'std::vector<std::pair<long long int, long long int> >*' [-fpermissive]
   87 |     cout<<func1(n,a)<<endl;
      |                 ^
      |                 |
      |                 int
a.cc:87:16: error: too many arguments to function 'long long int func1(std::vector<std::pair<long long int, long long int> >*)'
   87 |     cout<<func1(n,a)<<endl;
      |           ~~~~~^~~~~
a.cc:52:4: note: declared here
   52 | ll func1(vector<pll>* a){
      |    ^~~~~