Language: C++

#include <bits/stdc++.h>

#define PB          push_back
#define PF          push_front
#define MP          make_pair
#define FI          first
#define SE          second
#define SIZE( A )   int( ( A ).size( ) )
#define ALL( A )    ( A ).begin( ), ( A ).end( )
#define ALLR( A )   ( A ).rbegin( ), ( A ).rend( )

using namespace std;

typedef long long           ll;
typedef unsigned long long  ull;
typedef long double         lf;
typedef pair< int, int >    pii;
typedef pair< ll, ll >      pll;
typedef vector< bool >      vb;
typedef vector< lf >        vd;
typedef vector< ll >        vll;
typedef vector< int >       vi;
typedef vector< pii >       vpii;

const int MAXN = int( 2e5 )+10;
const int MOD  = int( 360 );
const int oo   = INT_MAX;
lf PI = acos(-1.0);
lf C = 5.0*PI;

int x[2],y[2],n, cnt;
pii p[ MAXN ];
double ans;

int CeilIndex(vector<int> &v, int l, int r, int key) {
    while (r-l > 1) {
    int m = l + (r-l)/2;
    if (v[m] >= key)
        r = m;
    else
        l = m;
    }

    return r;
}

int LongestIncreasingSubsequenceLength(vector<int> &v) {
    if (v.size() == 0)
        return 0;

    vector<int> tail(v.size(), 0);
    int length = 1; // always points empty slot in tail

    tail[0] = v[0];
    for (size_t i = 1; i < v.size(); i++) {
        if (v[i] < tail[0])
            // new smallest value
            tail[0] = v[i];
        else if (v[i] > tail[length-1])
            // v[i] extends largest subsequence
            tail[length++] = v[i];
        else
            // v[i] will become end candidate of an existing subsequence or
            // Throw away larger elements in all LIS, to make room for upcoming grater elements than v[i]
            // (and also, v[i] would have already appeared in one of LIS, identify the location and replace it)
            tail[CeilIndex(tail, -1, length-1, v[i])] = v[i];
    }

    return length;
}

bool cmp( const pii &a, const pii &b ) {
  return a.FI < b.FI;
}

int main( ) {

  #ifdef LOCAL
    freopen( "input", "r", stdin );
    //freopen( "output", "w", stdout );
  #else
    //freopen( "input", "r", stdin );
    //freopen( "output", "w", stdout );
    ios_base::sync_with_stdio( 0 );
    cin.tie( 0 );
  #endif
  cout << fixed << setprecision(15);
  cin >> x[0] >> y[0] >> x[1] >> y[1] >> n;
  for( int i = 0; i < n; ++i ) {
    int x,y; cin >> x >> y;
    p[i] = make_pair( x,y );
  }
  sort( p, p+n, cmp );
  if( x[0] > x[1] ) {
    swap( x[0],x[1] );
    swap( y[0],y[1] );
  }
  ans = (x[1]-x[0]) + abs(y[1]-y[0]);
  ans *= 100;
  cnt = 0;
  if( x[0] == x[1] ) {
    auto it = lower_bound( p, p+n, make_pair(x[0],min(y[0],y[1]) );
    if( it != p+n ) {
      ans -= 20;
      cnt += 2;
    }
  }
  else if( y[0] == y[1] ) {
    auto it = lower_bound( p, p+n, make_pair(x[0],y[0]) );
    if( it != p+n ) {
      ans -= 20;
      cnt += 2;
    }
  }
  else {
    if( y[0] < y[1] ) {
      int i = 0, cur = 0;
      for( ; i < n; ++i ) {
        if( p[i].FI >= x[0] && p[i].SE >= y[0] ) break;
      }
      if( i != n ) {
        int sz = n-i;
        vector<int> lista;
        bool flag = false;
        for( int j = 0; i < n; ++j, ++i ) {
          if( y[0] <= p[i].SE && p[i].SE <= y[1] ) {
            flag = true;
            lista.PB(p[i].SE);
          }
        }
        if(flag)
          cnt = LongestIncreasingSubsequenceLength( lista );
      }
    }
    else {
      int i = 0, cur = 0;
      for( ; i < n; ++i ) {
        if( p[i].FI >= x[0] && p[i].SE <= y[0] ) break;
      }
      if( i != n ) {
        int sz = n-i;
        vector<int> lista;
        bool flag = false;
        for( int j = 0; i < n; ++j, ++i ) {
          if( y[1] <= p[i].SE && p[i].SE <= y[0] ) {
            flag = true;
            lista.PB(-p[i].SE);
          }
        }
        if( flag )
          cnt = LongestIncreasingSubsequenceLength( lista );
      }
    }
    if( cnt == min(x[0]-x[1], abs(y[0]-y[1]))+1 ) {
      ans -= 20;
      --cnt;
      ans += 2*C;
    }
    ans -= 20*cnt;
  }
  cout << ans + cnt*C << '\n';
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:102:67: error: expected ')' before ';' token
  102 |     auto it = lower_bound( p, p+n, make_pair(x[0],min(y[0],y[1]) );
      |                          ~                                        ^
      |                                                                   )