Problem:
Score : 900 points

Problem Statement

In the city of Nevermore, there are 10^8 streets and 10^8 avenues, both numbered from 0 to 10^8-1.
All streets run straight from west to east, and all avenues run straight from south to north.
The distance between neighboring streets and between neighboring avenues is exactly 100 meters.

Every street intersects every avenue. Every intersection can be described by pair (x, y), where x is avenue ID and y is street ID.

There are N fountains in the city, situated at intersections (X_i, Y_i).
Unlike normal intersections, there's a circle with radius 10 meters centered at the intersection, and there are no road parts inside this circle.

The picture below shows an example of how a part of the city with roads and fountains may look like.

City governors don't like encountering more than one fountain while moving along the same road.
Therefore, every street contains at most one fountain on it, as well as every avenue.

Citizens can move along streets, avenues and fountain perimeters.
What is the shortest distance one needs to cover in order to get from intersection (x_1, y_1) to intersection (x_2, y_2)?

Constraints

0 \leq x_1, y_1, x_2, y_2 < 10^8

1 \leq N \leq 200,000

0 \leq X_i, Y_i < 10^8

X_i \neq X_j for i \neq j

Y_i \neq Y_j for i \neq j

Intersections (x_1, y_1) and (x_2, y_2) are different and don't contain fountains.

All input values are integers.

Input

Input is given from Standard Input in the following format:

x_1 y_1 x_2 y_2
N
X_1 Y_1
X_2 Y_2
:
X_N Y_N

Output

Print the shortest possible distance one needs to cover in order to get from intersection (x_1, y_1) to intersection (x_2, y_2), in meters.
Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{-11}.

Sample Input 1

1 1 6 5
3
3 2
5 3
2 4

Sample Output 1

891.415926535897938

One possible shortest path is shown on the picture below. The path starts at the blue point, finishes at the purple point and follows along the red line.

Sample Input 2

3 5 6 4
3
3 2
5 3
2 4

Sample Output 2

400.000000000000000

Sample Input 3

4 2 2 2
3
3 2
5 3
2 4

Sample Output 3

211.415926535897938

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
//------------------------------>> coding space <<------------------------------//

template< typename DATA, class CALC, DATA FAIL >
class SegmentTree {
private:
	int size__;
	Vec< DATA > data;
	
	inline int left_t(int k) { return (k << 1) + 1; }
	inline int right_t(int k) { return (k << 1) + 2; }
	inline int center(int l, int r) { return (l + r) >> 1; }
	
	DATA calc(DATA d1, DATA d2) { return CALC().calc(d1, d2); }
	
	DATA query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return FAIL;
		if (a <= l && r <= b) return data[k];
		return calc(query(a, b, left_t(k), l, center(l, r)),
					query(a, b, right_t(k), center(l, r), r));
	}
	
public:
	SegmentTree(int n, DATA ini) {
		for (size__ = 1; size__ < n; size__ <<= 1);
		data.assign(2 * size__ - 1, ini);
	}
	
	void update(int k, DATA a) {
		k += size__ - 1;
		data[k] = a;
		
		while (k > 0) {
			k = (k - 1) >> 1;
			data[k] = calc(data[left_t(k)], data[right_t(k)]);
		}
	}
	
	DATA query(int a, int b) { return query(a, b, 0, 0, size__); }
	
	int size() { return size__; }
};

template< typename T >
class MaxCalc {
public:
	inline T calc(T d1, T d2) { return max(d1, d2); }
};



int x[2], y[2], N, X[200005], Y[200005];

const int MAX_Z = (int)(1e8)-1;

void reverseX() {
	for_(i,0,2) x[i] = MAX_Z - x[i];
	for_(i,0,N) X[i] = MAX_Z - X[i];
}

void reverseY() {
	for_(i,0,2) y[i] = MAX_Z - y[i];
	for_(i,0,N) Y[i] = MAX_Z - Y[i];
}

int main() {
	cin >> x[0] >> y[0] >> x[1] >> y[1];
	cin >> N;
	for_(i,0,N) cin >> X[i] >> Y[i];
	
	if (x[0] > x[1]) reverseX();
	if (y[0] > y[1]) reverseY();
	
	Vec< int > use, yset;
	for_(i,0,N) {
		if (in_range(X[i], x[0], x[1]+1) &&
			in_range(Y[i], y[0], y[1]+1)) {
			use.push_back(i);
			yset.push_back(Y[i]);
		}	
	}
	sort(allof(use), [&](int i, int j) { return X[i] < X[j]; });
	sort(allof(yset));
	
	int m = use.size();
	double pr = 0.5 * acos(-1) * 10, base = double(x[1] - x[0] + y[1] - y[0]) * 100;
	
	cout << setprecision(15) << setiosflags(ios::fixed);
	if (m == 0) {
		cout << base << endl;
		return 0;
	}
	
	if (m == y[1]-y[0]+1 || m == x[1]-x[0]+1) {
		bool flag = true;
		for_(ii,0,m-1) {
			int i = use[ii], j = use[ii+1];
			flag &= (X[i]+1 == X[j] && Y[i]+1 == Y[j]);
		}
		
		if (flag) {
			cout << base - 20. * m + pr * (m+1) << endl;
			return 0;
		}
	}
		
	SegmentTree< int, MaxCalc< int >, 0 > seg(m, 0);
	
	for_(ii,0,m) {
		int i = use[ii];
		int yi = lower_bound(allof(yset), Y[i]) - yset.begin();
		int add = seg.query(0, yi);
		seg.update(yi, add + 1);
	}
	
	int nc = seg.query(0, m);
	cout << base - 20. * nc + pr * nc << endl;
}