Problem: E: Do You Divide It? / Do you want to chop it up?

story

Mr. T has been terribly troubled by the problem of plane figures in programming contests he has participated in in the past, and has had a strong grudge against plane figures ever since.

Above all, I have mixed feelings about polygons drawn on a two-dimensional plane, so when I see a polygon, I can't help but chop it up.

When Mr. T chops a polygon, he covers the polygon with a plate with slits at intervals of 0.5 width parallel to the y-axis, and chops and discards the invisible part with the slits.

However, Mr. T does not like unilateral killing, so in order to leave the buds of recurrence in the polygon, care should be taken to make the total area of ​​the figures remaining after chopping as large as possible.

Let's find the area of ​​the figure that remains after Mr. T chops it.

problem

The two-dimensional plane has an infinite length slit in the y-axis direction, and the visible part and the invisible part are switched every 0.5 in the x-axis direction.

As shown in the figure below, a polygon consisting of N vertices continues to translate in the positive x-axis direction on this plane.

<image>

Output the area of ​​the visible part at the moment when the visible part of the polygon becomes the largest.

Input format

Give N in the first line. In the i-th line of the following N lines, the i-th vertex coordinates (x_i, y_i) in the counterclockwise direction of the polygon are given.

The following can be assumed.

* All inputs are integers
* 3 ≤ N ≤ 100, −10 ^ 3 ≤ x_i, y_i ≤ 10 ^ 3
* Given polygons do not share edges or vertices with anything other than adjacent line segments.
* The three consecutive vertices of a given polygon are not on the same straight line



Output format

Output the visible area in one line at the moment when the visible part of the given polygon becomes the largest. Absolute error and relative error are allowed up to 10 ^ {-5}.

Input example 1


6
0 0
-1 -2
3 -2
2 0
3 2
-1 2


Output example 1


6.000000000

Input example 2


Five
0 0
twenty two
4 -2
4 2
twenty two


Output example 2


6.50000000





Example

Input

6
0 0
-1 -2
3 -2
2 0
3 2
-1 2


Output

6.000000000

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define sz(s) ((int)(s.size()))

typedef complex<double> P;

typedef vector<P> poly;

typedef pair<P, P> L;

const double EPS = 1e-9;

double cross(const P &a, const P &b) { return imag(conj(a) * b); }
double dot(const P &a, const P &b) { return real(conj(a) * b); }

int ccw(P a, P b, P c) {
	double d = cross(b -= a, c -= a);
	return d > EPS ? 1 : d<-EPS ? -1 : dot(b, c) < -EPS ? 2 : norm(b) + EPS < norm(c) ? -2 : 0;
}

#define DI(l) ((l).second - (l).first)
#define CCW(l, a) ccw((l).first, (l).second, (a))

bool intersectSS(const L &s, const L &t) { return CCW(s, t.first)*CCW(s, t.second)<=0 && CCW(t, s.first)*CCW(t, s.second) <= 0; }
P crosspoint(const L &l, const L &m) {
	P a = DI(l), b = DI(m);
	double A  = cross(a, b), B = cross(a, l.second - m.first);
	return m.first + B / A * b;
}

double signed_area(const poly &v) {
	double res = 0;
	rep(i, sz(v)) res += cross(v[i], v[(i+1)%sz(v)]);
	return res * 0.5;
}



vector<P> v;
double calc(double x) {
	L a(P(x, -1e3), P(x, 1e3)), b(P(x+0.5, -1e3), P(x+0.5, 1e3));

	vector<double> ap, bp;
	rep(i, sz(v)) {
		L l = L(v[i], v[(i+1)%sz(v)]);
		if (!(intersectSS(l, a) && intersectSS(l, b))) continue;
		ap.push_back(imag(crosspoint(l, a)));
		bp.push_back(imag(crosspoint(l, b)));
	}
	sort(ap.begin(), ap.end());
	sort(bp.begin(), bp.end());
	assert(sz(ap) % 2 == 0);
	double S = 0;
	rep(i, sz(ap)/2) {
		S +=  (ap[i*2 + 1] - ap[i*2] + bp[i*2 + 1] - bp[i*2]) * 0.5 * 0.5;
	}
	return S;
}
int main(int argc, char *argv[]) {
	int N;
	cin >> N;
	rep(i, N) {
		double x, y;
		cin >> x >> y;
		v.push_back(P(x, y));
	}

	double s0 = 0, s1 = 0;
	for(double x = -1e3; x <= 1e3; x += 1) {
		s0 += calc(x);
	}
	for(double x = -1e3 - 0.5; x <= 1e3; x += 1) {
		s1 += calc(x);
	}

	printf("%.20f\n", max(s0, s1));
}