Problem:
Hanbunko
Twin siblings, Yae and Joe, received a rice cracker as a snack from their mother. The rice cracker is shaped like a convex polygon and has slits on all the diagonals to make it easier to break.
They want to split the rice cracker into two pieces, but since they are not strong enough, they can only do so by clamping their hands on both sides of one of the diagonals. They started to think about which diagonal line they should divide the rice cracker into two so that it would be closest to Hanbunko and the difference between their shares would be the smallest.
Wreate a program which reads the information about the shape of the rice cracker represented by the convex polygon and finds the smallest difference between the two people's shares. The difference between two people's shares is expressed as the absolute value of the difference in their areas when the rice cracker is divided into two along one diagonal line.
Input
The input is given in the following form.
$N$
$x_1$ $y_1$
$x_2$ $y_2$
:
$x_N$ $y_N$
The first line gives the number of vertices of the convex polygon $N$ ($4 \leq N \leq 60,000$). In the following $N$ lines, the coordinates $x_i$, $y_i$ ($0 \leq x_i,y_i \leq 100,000,000$) of the vertices of the convex polygon are given as integers. The vertices of the convex polygon are given in such an order that the adjacent vertices are visited in a counterclockwise direction.
Output
Output the minimum difference between the two shares as a real number in a line. The error must not exceed plus or minus 0.0001.
Sample Input and Output
Sample Input 1
4
0 0
1 0
1 1
0 1
Sample Output 1
0.0
Sample Input 2
4
0 0
1 0
1 2
0 1
Sample Output 2
0.5000

Submitted solutions:

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
	int N;
	cin>>N;
	ll x[N*2+1],y[N*2+1];
	for(int i=1;i<=N;i++){
		cin>>x[i]>>y[i];
		x[i+N]=x[i];
		y[i+N]=y[i];
	}
	ll all=0;
	for(int i=2;i<N;i++){
		ll a1=x[i]-x[1],a2=y[i]-y[1];
		ll b1=x[i+1]-x[1],b2=y[i+1]-y[1];
		all+=abs(a1*b2-a2*b1);
	}
	int place=2;
	ll ans=2e18;
	ll now=0;
	for(int i=1;i<=N;i++){
		while(true){
			if(now*2>all){
				ans=min(ans,abs(all-now*2));
				break;
			}
			ll a1=x[place]-x[i],a2=y[place]-y[i];
			ll b1=x[place+1]-x[i],b2=y[place+1]-y[i];
			now+=abs(a1*b2-a2*b1);
			if(now*2>all){
				ans=min(ans,abs(all-now*2));
				now-=abs(a1*b2-a2*b1);
				ans=min(ans,abs(all-now*2));
				break;
			}
			place++;
		}
		ll A1=x[i+1]-x[i],A2=y[i+1]-y[i],B1=x[place]-x[i],B2=y[place]-y[i];
		now-=abs(A1*B2-A2*B1);
	}
	long double answer=ans;
	answer/=2;
	cout<<fixed<<setprecision(15)<<answer<<endl;
}
accuracy: 1
time_ms: 20
memory_kb: 5392
final_rank: 10

code_snippet: #include <bits/stdc++.h>
using namespace std;
using Point = complex<long double>;
long double cross(Point x, Point y) { return x.real() * y.imag() - x.imag() * y.real(); }
int main() {
    int n;
    cin >> n;
    vector<Point> p(n);
    for (int i = 0; i < n; i++) {
        long double x, y;
        cin >> x >> y;
        p[i] = {x, y};
    }
    // 全体の面積を求めておく
    long double s = 0;
    for (int i = 1; i < n - 1; i++) {
        // p[i+1]-p[i]とp[0]-p[i]の面積
        s += abs(cross(p[i + 1] - p[i], p[0] - p[i])) / 2.0;
    }
    // 尺取り法
    long double ans = 1e50;
    int l = 0, r = 0;
    long double x = 0, y = s;
    while (true) {
        // 面積が小さいならrを増やす
        if (x < y) {
            if (r == n - 1) break;
            // l,r,(r+1)の三角形の面積を求める
            long double a = abs(cross(p[r] - p[l], p[r + 1] - p[l])) / 2;
            x += a;
            y -= a;
            r++;
            ans = min(ans, abs(x - y));
        }
        // 面積が大きいならlを増やす
        else {
            // l,(l+1),rの三角形の面積を求める
            long double a = abs(cross(p[l] - p[r], p[l + 1] - p[r])) / 2;
            x -= a;
            y += a;
            l++;
            ans = min(ans, abs(x - y));
        }
    }
    printf("%.4Lf\n", ans);
}
accuracy: 1
time_ms: 30
memory_kb: 4956
final_rank: 13

code_snippet: #include <bits/stdc++.h>
using namespace std;
using Point = complex<double>;
double cross(Point x, Point y) { return x.real() * y.imag() - x.imag() * y.real(); }
int main() {
    int n;
    cin >> n;
    vector<Point> p(n);
    for (int i = 0; i < n; i++) {
        double x, y;
        cin >> x >> y;
        p[i] = {x, y};
    }
    // 全体の面積を求めておく
    double s = 0;
    for (int i = 1; i < n - 1; i++) {
        // p[i+1]-p[i]とp[0]-p[i]の面積
        s += abs(cross(p[i + 1] - p[i], p[0] - p[i])) / 2.0;
    }
    // 尺取り法
    double ans = 1e50;
    int l = 0, r = 0;
    double x = 0, y = s;
    while (true) {
        // 面積が小さいならrを増やす
        if (x < y) {
            if (r == n - 1) break;
            // l,r,(r+1)の三角形の面積を求める
            double a = abs(cross(p[r] - p[l], p[r + 1] - p[l])) / 2;
            x += a;
            y -= a;
            r++;
            ans = min(ans, abs(x - y));
        }
        // 面積が大きいならlを増やす
        else {
            // l,(l+1),rの三角形の面積を求める
            double a = abs(cross(p[l] - p[r], p[l + 1] - p[r])) / 2;
            x -= a;
            y += a;
            l++;
            ans = min(ans, abs(x - y));
        }
    }
    printf("%.4lf\n", ans);
}
accuracy: 0.6666666666666666
time_ms: 30
memory_kb: 3708
final_rank: 17

code_snippet: #include <bits/stdc++.h>
using namespace std; 
/*#include <atcoder/all>
using namespace atcoder;
using mint = modint;*/
//long long型=int64_tという認識で大丈夫です。
//#define int long long
#define ll long long
#define ull unsigned long long
#define vec vector
#define vi vector<int>
#define vll vector<ll>
#define pq priority_queue
#define pb push_back
#define rep(i, l, r) for(ll i=(ll)(l); i<(ll)(r); i++)
#define ld long double

const ll INF = 2e9;
const ll inf = 5e18;
const ld ep = 1e-15;

struct Edge {
    int to;
    ll cost;
};

struct SEdge {
    int to;
    pair<ll, ll> cost;
};

template<class T>
using spq = priority_queue<T, vec<T>, greater<T>>; 

const vector<ll> di = {-1, 0, 1, 0}, dj = {0, -1, 0, 1};

template<class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T, class U> 
istream &operator>>(istream &is, pair<T, U> &p) {
    is >> p.first >> p.second;
    return is;
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << p.first << " " << p.second;
    return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
    for(auto &x : v) {
        is >> x;
    }
    return is;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for(int i = 0; i < (int)v.size(); i++) {
        if(i != (int)v.size() - 1)
            os << v[i] << " ";
        else
            os << v[i];
    }
    return os;
}

template <class T>
bool jf(pair<T, T> a, pair<T, T> b) {
    if(a.second > b.second) return false;
    else return true;
}

using S = ll;

S op(S a, S b){ return max(a, b); }
S e(){ return 0;}

ld tri(ld x1, ld y1, ld x2, ld y2, ld x3, ld y3) {
    return abs((x1 - x3) * (y2 - y3) - (x2 - x3) * (y1 - y3)) / 2;
}

signed main(){
    int n; cin >> n;
    vec<ld> x(n), y(n); rep(i, 0, n) cin >> x[i] >> y[i];
    /*rep(i, 1, n) {x[i] -= x[0], y[i] -= y[0];}
    x[0] = 0, y[0] = 0;*/
    vec<ld> z(n + 1); z[0] = 0; z[1] = 0;
    rep(i, 1, n - 1) {
        z[i + 1] = z[i] + tri(x[i], y[i], x[i + 1], y[i + 1], x[0], y[0]);
    }
    z[n] = z[n - 1];
    int pos = 1;
    ld ans = inf;
    ld cnt = 0;
    rep(i, 0, n) {
        rep(j, pos, 2 * n) {
            if(cnt + tri(x[i], y[i], x[(j - 1) % n], y[(j - 1) % n], x[j % n], y[j % n]) > z[n] / 2) {
                pos = j;
                break;
            }
            cnt += tri(x[i], y[i], x[(j - 1) % n], y[(j - 1) % n], x[j % n], y[j % n]);
            if(j == 2 * n - 1) {
                pos = 2 * n;
                break;
            }
        }
        chmin(ans, z[n] - 2 * cnt);
        cnt -= tri(x[i], y[i], x[(i + 1) % n], y[(i + 1) % n], x[(pos - 1) % n], y[(pos - 1) % n]);
    }
    cout << fixed << setprecision(15) << ans << endl;
}
accuracy: 1
time_ms: 40
memory_kb: 5936
final_rank: 14

code_snippet: #include <bits/stdc++.h>
using namespace std;

#define int long long
signed main(){
    int n;
    cin >> n;
    deque<pair<int,int>> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i].first >> a[i].second;
    }
    auto c = [&](int t,int b,int c){
        pair<int,int> x,y;  
        x = {a[b].first - a[t].first,a[b].second - a[t].second};
        y = {a[c].first - a[t].first,a[c].second - a[t].second};
        return abs(x.first * y.second - x.second * y.first);
    };
    long double ans = 1000000000000000000;
    long double sum = 0;
    for(int i = 2;i < n;i++){
        sum += c(0,i - 1,i);
    }
    int now = 1;
    long double it = sum / 2;
    long double cou = 0;
    for(int i = 0;i < n - 1;i++){
        while(now + 1 < n && cou + c(i,now,now + 1) <= it){
            cou += c(i,now,now + 1);
            now++;
        }
        ans = min(ans,abs(cou - (sum - cou)));
        if(now + 1 < n){
            int p = cou + c(i,now,now + 1);
            ans = min(ans,abs(p - (sum - p)));
        }
        cou -= c(i,i + 1,now);
    }
    cout << fixed << setprecision(2) << (long double)ans / (long double)2.0 << endl;
}
accuracy: 1
time_ms: 20
memory_kb: 4420
final_rank: 9

code_snippet: #line 1 "0445.test.cpp"
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/problems/0445"
#define ERROR 0.0001

#line 2 "/home/zawatin/compro/cp-documentation/Src/Template/IOSetting.hpp"

#line 2 "/home/zawatin/compro/cp-documentation/Src/Template/TypeAlias.hpp"

#include <cstdint>
#include <cstddef>

namespace zawa {

using i16 = std::int16_t;
using i32 = std::int32_t;
using i64 = std::int64_t;
using i128 = __int128_t;

using u8 = std::uint8_t;
using u16 = std::uint16_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;

using usize = std::size_t;

} // namespace zawa
#line 4 "/home/zawatin/compro/cp-documentation/Src/Template/IOSetting.hpp"

#include <iostream>
#include <iomanip>

namespace zawa {

void SetFastIO() {
    std::cin.tie(nullptr)->sync_with_stdio(false);
}

void SetPrecision(u32 dig) {
    std::cout << std::fixed << std::setprecision(dig);
}

} // namespace zawa
#line 2 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Polygon.hpp"

#line 2 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Point.hpp"

#line 2 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Zahlen.hpp"

#line 4 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Zahlen.hpp"

#include <cassert>

namespace zawa {

namespace geometryZ2 {

using Zahlen = i64;

namespace internal {

constexpr i32 positive{1};
constexpr i32 zero{0};
constexpr i32 negative{-1};

} // namespace internal

constexpr i32 Sign(Zahlen value) {
    if (value < 0) return internal::negative;
    if (value > 0) return internal::positive;
    return internal::zero;
}

constexpr bool Positive(Zahlen value) {
    return Sign(value) == internal::positive;
}

constexpr bool Zero(Zahlen value) {
    return Sign(value) == internal::zero;
}

constexpr bool Negative(Zahlen value) {
    return Sign(value) == internal::negative;
}

constexpr Zahlen Abs(Zahlen value) {
    return (value > 0 ? value : -value);
}

constexpr Zahlen Square(Zahlen value) {
    return value * value;
}

} // namespace geometryZ2

} // namespace zawa
#line 5 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Point.hpp"

#line 8 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Point.hpp"

namespace zawa {

namespace geometryZ2 {

class Point {
private:
    Zahlen x_{}, y_{};
    static constexpr u32 origin{0};
    static constexpr u32 firstQuadrant{1};
    static constexpr u32 secondQuadrant{1};
    static constexpr u32 thirdQuadrant{1};
    static constexpr u32 forthQuadrant{1};

    u32 area() const {
        if (x_ == 0 and y_ == 0) return origin;
        if (x_ > 0 and y_ >= 0) return firstQuadrant;
        if (x_ <= 0 and y_ > 0) return secondQuadrant;
        if (x_ < 0 and y_ <= 0) return thirdQuadrant;
        return forthQuadrant;
    }
public:
    /* constructor */
    Point() = default;
    Point(const Point& p) : x_{p.x()}, y_{p.y()} {}
    Point(Zahlen x, Zahlen y) : x_{x}, y_{y} {}

    /* getter setter */
    Zahlen& x() {
        return x_;
    }
    const Zahlen& x() const {
        return x_;
    }
    Zahlen& y() {
        return y_;
    }
    const Zahlen& y() const {
        return y_;
    }

    /* operator */
    Point& operator=(const Point& p) {
        x() = p.x();
        y() = p.y();
        return *this;
    }
    Point& operator+=(const Point& p) {
        x() += p.x();
        y() += p.y();
        return *this;
    }
    friend Point operator+(const Point& p0, const Point& p1) {
        return Point{p0} += p1;
    }
    Point& operator-=(const Point& p) {
        x() -= p.x();
        y() -= p.y();
        return *this;
    }
    friend Point operator-(const Point& p0, const Point& p1) {
        return Point{p0} -= p1;
    }
    Point& operator*=(Zahlen k) {
        x() *= k;
        y() *= k;
        return *this;
    }
    friend Point operator*(const Point& p, Zahlen k) {
        return Point{p} *= k;
    }
    friend Point operator*(Zahlen k, const Point& p) {
        return Point{p} *= k;
    }
    Point& operator/=(Zahlen k) {
        assert(k);
        assert(x() % k == 0);
        assert(y() % k == 0);
        x() /= k;
        y() /= k;
        return *this;
    }
    friend Point operator/(const Point& p, Zahlen k) {
        return Point{p} /= k;
    }
    friend bool operator==(const Point& p0, const Point& p1) {
        return p0.x() == p1.x() and p0.y() == p1.y();
    }
    friend bool operator!=(const Point& p0, const Point& p1) {
        return p0.x() != p1.x() or p0.y() != p1.y();
    }
    friend bool operator<(const Point& p0, const Point& p1) {
        if (p0.x() != p1.x()) return p0.x() < p1.x();
        else return p0.y() < p1.y();
    }
    friend bool operator<=(const Point& p0, const Point& p1) {
        return (p0 < p1) or (p0 == p1);
    }
    friend bool operator>(const Point& p0, const Point& p1) {
        if (p0.x() != p1.x()) return p0.x() > p1.x();
        else return p0.y() > p1.y();
    }
    friend bool operator>=(const Point& p0, const Point& p1) {
        return (p0 > p1) or (p0 == p1);
    }
    friend std::istream& operator>>(std::istream& is, Point& p) {
        is >> p.x() >> p.y();
        return is;
    }
    friend std::ostream& operator<<(std::ostream& os, const Point& p) {
        os << '(' << p.x() << ',' << p.y() << ')';
        return os;
    }

    /* member function */
    Zahlen normSquare() const {
        return Square(x()) + Square(y());
    }

    /* friend function */
    friend Zahlen Dot(const Point& p0, const Point& p1) {
        return p0.x() * p1.x() + p0.y() * p1.y();
    }
    friend Zahlen Cross(const Point& p0, const Point& p1) {
        return p0.x() * p1.y() - p0.y() * p1.x();
    }
    friend bool ArgComp(const Point& p0, const Point& p1) {
        if (p0.area() != p1.area()) return p0.area() < p1.area();
        Zahlen cross{Cross(p0, p1)};
        return (!Zero(cross) ? Positive(cross) : p0.normSquare() < p1.normSquare());
    }
};
using Vector = Point;

} // namespace geometryZ2

} // namespace zawa
#line 2 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Relation.hpp"

#line 5 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Relation.hpp"

namespace zawa {

namespace geometryZ2 {

enum RELATION {
    // p0 -> p1 -> p2の順で直線上に並んでいる
    ONLINE_FRONT        = -2,
    // (p1 - p0) -> (p2 - p0)が時計回りになっている
    CLOCKWISE           = -1,
    // p0 -> p2 -> p1の順で直線上に並んでいる
    ON_SEGMENT          =  0,
    // (p1 - p0) -> (p2 - p0)が反時計回りになっている
    COUNTER_CLOCKWISE   = +1,
    // p2 -> p0 -> p1、またはp1 -> p0 -> p2の順で直線上に並んでいる
    ONLINE_BACK         = +2
};

RELATION Relation(const Point& p0, const Point& p1, const Point& p2) {
    Point a{p1 - p0}, b{p2 - p0};
    if (Positive(Cross(a, b))) return COUNTER_CLOCKWISE;
    if (Negative(Cross(a, b))) return CLOCKWISE;
    if (Negative(Dot(a, b))) return ONLINE_BACK;
    if (a.normSquare() < b.normSquare()) return ONLINE_FRONT;
    return ON_SEGMENT;
};

} // namespace geometryZ2

} // namespace zawa
#line 6 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Polygon.hpp"

#include <algorithm>
#line 9 "/home/zawatin/compro/cp-documentation/Src/GeometryZ2/Polygon.hpp"
#include <iterator>
#include <vector>

namespace zawa {

namespace geometryZ2 {

class Polygon {
private:
    std::vector<Point> data_;
public:
    usize size() const {
        return data_.size(); 
    }

    /* constructor */
    Polygon() = default;
    Polygon(const Polygon& polygon) : data_{polygon.data_} {}
    Polygon(const std::vector<Point>& data) : data_{data} {}
    Polygon(usize n) : data_{n} {
        assert(n >= static_cast<usize>(3));
    }

    /* operator */
    Polygon& operator=(const Polygon& polygon) {
        data_ = polygon.data_;
        return *this;
    }
    Point& operator[](usize i) {
        assert(i < size());
        return data_[i];
    }
    const Point& operator[](usize i) const {
        assert(i < size());
        return data_[i];
    }
    friend std::istream& operator>>(std::istream& is, Polygon& polygon) {
        for (size_t i{} ; i < polygon.size() ; i++) {
            is >> polygon[i];
        }
        return is;
    }
    friend std::ostream& operator<<(std::ostream& os, const Polygon& polygon) {
        for (usize i{} ; i < polygon.size() ; i++) {
            std::cout << polygon[i] << (i + 1 == polygon.size() ? "" : " ");
        }
        return os;
    }

    /* member function */
    void pushBack(const Point& p) {
        data_.push_back(p);
    }
    void emplaceBack(Zahlen x, Zahlen y) {
        data_.emplace_back(x, y);
    }
    void orderRotate(usize i) {
        assert(i < size());
        std::rotate(data_.begin(), data_.begin() + i, data_.end());
    }
    void normalForm() {
        auto index{std::distance(data_.begin(), std::min_element(data_.begin(), data_.end()))};
        orderRotate(index);
    }
    Polygon normalFormed() const {
        Polygon res{*this};
        res.normalForm();
        return res;
    }
    bool isConvex() const {
        assert(size() >= static_cast<usize>(3));
        for (usize i{} ; i < size() ; i++) {
            if (Relation(data_[i], data_[i+1==size()?0:i+1], data_[i+2>=size()?i+2-size():i+2])
                    == CLOCKWISE) {
                return false;
            }
        }
        return true;
    }
    Zahlen areaTwice() const {
        assert(size() >= static_cast<usize>(3));
        Zahlen res{};
        for (usize i{1} ; i < size() ; i++) {
            res += Cross(data_[i] - data_[0], data_[i+1==size()?0:i+1] - data_[0]);
        }
        return res;
    }
    Polygon subtriangle(usize i, usize j, usize k) const {
        assert(i < size());
        assert(j < size());
        assert(k < size());
        return Polygon{std::vector<Point>{ data_[i], data_[j], data_[k] }};
    }
};

}

} // namespace zawa
#line 6 "0445.test.cpp"

using namespace zawa;
using namespace geometryZ2;

int main() {
    SetFastIO();
    SetPrecision(6);
    int n; std::cin >> n;
    Polygon p(n);
    std::cin >> p;
    Zahlen total{p.areaTwice()};
    Zahlen area{};
    Zahlen ans{total};
    int r{};
    for (int l{} ; l < n ; l++) {
        while (area * 2 < total) {
            area += p.subtriangle(l, r, r+1==n?0:r+1).areaTwice();
            r = (r+1==n?0:r+1);
        }
        ans = std::min(ans, std::abs(area * 2 - total));
        if (l == r) r++;
        else area -= p.subtriangle(l, l+1==n?0:l+1, r).areaTwice();
    }
    std::cout << ans / 2.0 << '\n';
}
accuracy: 1
time_ms: 10
memory_kb: 4132
final_rank: 1

code_snippet: #include<bits/stdc++.h>
#define overload(a,b,c,d,...) d
#define rep1(a) for(ll _=0;_<a;++_)
#define rep2(i,a) for(ll i=0;i<a;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep(...) overload(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__)
#define rrep1(i,a) for(ll i=(ll)a-1;i>=0;--i)
#define rrep2(i,a,b) for(ll i=(ll)b-1;i>=(ll)a;--i)
#define rrep(...) overload(__VA_ARGS__,rrep2,rrep1)(__VA_ARGS__)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define eb emplace_back
#define pb push_back
using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
template<typename T,typename U>inline bool chmin(T&a,const U&b){return (a>b?a=b,true:false);}
template<typename T,typename U>inline bool chmax(T&a,const U&b){return (a<b?a=b,true:false);}
static constexpr ll inf=numeric_limits<ll>::max()/2;
ll calc(ll x1,ll y1,ll x2,ll y2,ll x3,ll y3){
    return abs((x1-x3)*(y2-y3)-(x2-x3)*(y1-y3));
}
int main(){
    ll n;cin>>n;
    vector<ll>x(n),y(n);
    rep(i,n)cin>>x[i]>>y[i];
    ll area=0;
    rep(i,1,n-1){
        area+=calc(x[0],y[0],x[i],y[i],x[i+1],y[i+1]);
    }
    ll j=1;
    ll ans=inf;
    ll sum=0;
    rep(i,n){
        while(sum*2<=area){
            sum+=calc(x[i],y[i],x[j],y[j],x[(j+1)%n],y[(j+1)%n]);
            chmin(ans,abs(area-2*sum));
            j++;
            j%=n;
        }
        sum-=calc(x[i],y[i],x[(i+1)%n],y[(i+1)%n],x[j],y[j]);
        chmin(ans,abs(area-sum*2));
    }
    cout<<fixed<<setprecision(12)<<(double)ans/2.0<<endl;
}
accuracy: 1
time_ms: 20
memory_kb: 4136
final_rank: 6

code_snippet: #include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define cin_int(i) int i;cin>>i
#define cin_long(i) ll i;cin>>i
#define cin_arrayint(i,k)vector<int>i; for(int t=0; t<k; t++){int x; cin>>x;i.push_back(x);} 
#define cin_arraylonglong(i,k)vector<long long>i; for(int t=0; t<k; t++){long long x; cin>>x;i.push_back(x);} 
#define cin_arraydouble(i,k)vector<double>i; for(int t=0; t<k; t++){double x; cin>>x;i.push_back(x);} 
#define foreach(i,t) for(auto i:t)
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define var auto
#define List vector
#define cw(i) cout<<i<<endl;
#define HashSet unordered_set
#define Dictionary unordered_map
#define intreed() soloread<int>()
#define longread() soloread<long>()
#define all(i) i.begin(),i.end() 
const ll LINF = 1e18;
const int INF = 1e9;

class union_find
{ 
    public:
    vector<int>tree;

    union_find(int i)
    {
        tree=vector<int>(i+1,-1);
    }

    int get_root(int i)
    {
        return tree[i]<0?i:tree[i]=get_root(tree[i]);
    }

    int group_check(int i,int t)
    {
        return get_root(i)==get_root(t);
    }

    bool unite(int i,int t)
    {
        var x=get_root(i);
        var y=get_root(t);
        if(x!=y)
        {
            if(tree[x]>tree[y])
            {
                swap(x,y);
            }
            tree[x]+=tree[y];
            tree[y]=x;
        }
        return x!=y;
    }

    bool Is_top(int i)
    {
        return tree[i]<0?true:false;
    }

    int get_cnt(int x)
    {
        return tree[get_root(x)]*-1;
    }
};

template<typename T> T soloread()
{
    T i;
    cin>>i;
    return i;
}

template<typename T> vector<T> make_array(int n)
{
    var back=List<T>();
    for(int i=0; i<n; i++)
        back.push_back(soloread<T>());
    return back;
}

vector<long long> CSun(vector<long long>N,bool mode=true)
{
    if(mode==false)reverse(N.begin(),N.end());
    vector<long long>back(N.size()+1);
    back[0]=0;
    for(long long i=1; i<=N.size(); i++)
    {
        back[i]=back[i-1]+N[i-1];
    }
    return back;
}

vector<vector<bool>> bitallsearch(int N)
{
    vector<vector<bool>>back(pow(2,N),vector<bool>(N));
    for (int i = 0; i < pow(2, N); i++)
        {
            for (int t = 0; t < N; t++)
            {
                var k = (i >> t) & 1;
                if (k == 1)
                {
                    back[i][t] = true;
                }
                else
                {
                    back[i][t]=false;
                }
            }
        }
    return back;
}

void YN(bool i)
{
    if(i)
    {
        cw("Yes");
    }
    else
    {
        cw("No");
    }
}

int int_parse(char i)
{
    return (int)(i-'0');
}

int int_parse(string i)
{
    return stoi(i);
}

class Dijkstra
{
    public:
    vector<long long>dist;
    priority_queue<tuple<long long,int>,vector<tuple<long long,int>>,greater<tuple<long long,int>>>que;//コスト、頂点
    vector<vector<tuple<int,long long>>>G;//行先、コスト
    vector<int>prev;

    Dijkstra(int N)
    {
        dist=vector<long long>(N+1,LINF);
        prev=vector<int>(N+1,-1);
        for(int i=0; i<=N; i++)
        {
            G.push_back(vector<tuple<int,long long>>());
        }
        
    }

    void conect(int x,int y,long long cost,bool interactive=true)
    {
        G[x].emplace_back(make_tuple(y,cost));
        if(interactive)
        {
            G[y].emplace_back(make_tuple(x,cost));
        }
    }

    void start_Dijkstra(int start_point)
    {
        dist[start_point]=0;
        que.push(make_tuple(0,start_point));
        while (que.size()!=0)
        {
            auto now=que.top();//topでは削除されない
            que.pop();
            long long now_cost=get<0>(now);//現在の地点にいるためのコスト
            int now_point=get<1>(now);//現在の地点の番号
            if(dist[now_point]<now_cost)
            {
                continue;
            }
            for(int i=0; i<G[now_point].size(); i++)
            {
                auto next=G[now_point][i];
                long long next_cost=get<1>(next);// コスト
                int next_point=get<0>(next);//行先
                if(dist[next_point]>now_cost+next_cost)
                {
                    dist[next_point]=now_cost+next_cost;
                    que.push(make_tuple(dist[next_point],next_point));
                    prev[next_point]=now_point;
                }
            }
        }
    }

    long long get_cost(int i)
    {
        return dist[i];
    }

    int get_prev(int i)
    {
        return prev[i];
    }

    void reset_dist()
    {
        int N=dist.size();
        dist=vector<long long>(N,LINF);
    }


};



class BFS
{ 
    public:
    vector<int>dist;
    queue<int>que;
    vector<vector<int>>G;

    BFS(int N)
    {
        dist=vector<int>(N+1,-1);
        for(int i=0; i<=N; i++)
        {
            G.push_back(vector<int>());
        }
    }

    void conect(int x,int y)
    {
        G[x].push_back(y);
        G[y].push_back(x);
    }

    vector<int> start_bfs(int i)
    {
        que.push(i);
        var back=vector<int>();
        back.push_back(i);
        dist[i]=0;
        while (que.size()!=0)
        {
            var t=que.front();
            que.pop();
            for(int w=0; w<G[t].size(); w++)
            {
                if(dist[G[t][w]]==-1)
                {
                    que.push(G[t][w]);
                    back.push_back(G[t][w]);
                    dist[G[t][w]] = dist[t] + 1;
                }
            }
        }
        return back;
    }


};

ll get_area(ll x1,ll y1,ll x2,ll y2,ll x3,ll y3)
{
    return abs((x3-x1)*(y2-y1)-(y3-y1)*(x2-x1));
}

int main(){
    int n; cin>>n;
    vector<int> x(n),y(n);
    //入力をする
    for(int i=0; i<n; i++)
    {
        int a,b; cin>>a>>b;
        x[i]=a;
        y[i]=b;
    }

    ll ans=ll(1e18)+20;

    ll S_all=0;
    for(int i=1;i<n-1;i++)S_all+=get_area(x[0],y[0],x[i],y[i],x[i+1],y[i+1]);

    deque<int> q;
    rep(i,3)q.emplace_back(i);
    ll now=get_area(x[0],y[0],x[1],y[1],x[2],y[2]);
    for(;;){
        //左端はqの左端
        //「足してギリ半分以上」になるまで伸ばす
        int l=q.front();
        if(l>=n)break;
        while(now*2<S_all){
            int r=q.back();
            now+=get_area(x[l],y[l],x[r%n],y[r%n],x[(r+1)%n],y[(r+1)%n]);
            r++;
            q.emplace_back(r);
        }
        ans=min(ans,2*now-S_all);
        int r=q.back();
        now-=get_area(x[l],y[l],x[(l+1)%n],y[(l+1)%n],x[r%n],y[r%n]);
        q.pop_front();
    }
    cout << fixed << setprecision(10);
    cout << ans/2.0 << endl;
}
accuracy: 1
time_ms: 20
memory_kb: 3760
final_rank: 3

code_snippet: #include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define vi vector<int>
#define pll pair<ll,ll>
using namespace std;
using ll = long long;

ll cross(const pll &a, const pll &b){
	return a.first * b.second - a.second * b.first;
}
ll dot(const pll &a, const pll &b){
	return a.first * b.first + a.second * b.second;
}
pll sub(const pll &a, const pll &b){
	return { a.first - b.first, a.second - b.second };
}
int main(){
	int n;
	cin >> n;
	vector<pll> ps(n);
	rep(i, n) cin >> ps[i].first >> ps[i].second;
	ps.insert(ps.end(), ps.begin(), ps.end());
	auto calc = [&](int i, int j, int k) -> ll {
		return abs(cross(sub(ps[j], ps[i]), sub(ps[k], ps[i])));
	};
	ll all_area = 0;
	rep(i, n){
		all_area += calc(0, i, i+1);
	}
	ll cur = 0;
	ll ans = 1e18;
	int right = 0;
	for(int left = 0; left <= n; left++){
		while(right < n*2 && (cur+calc(left, right, right+1))*2 <= all_area){
			cur += calc(left, right, right+1);
			right++;
		}
		ans = min(ans, all_area - cur*2);
		ans = min(ans, (cur+calc(left,right,right+1))*2 - all_area);
		if(left == right){
			right++;
			cur = 0;
			continue;
		}
		cur -= calc(left, left+1, right);
	}
	printf("%.3lf\n", (double)ans / 2);
}
accuracy: 1
time_ms: 20
memory_kb: 5752
final_rank: 11

code_snippet: #include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define rep2(i, l, r) for(int i = int(l); i < int(r); i++)
#define repr(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define repr2(i, l, r) for(int i = int(r) - 1; i >= int(l); i--)

struct P{
    lint x, y;
};

lint triangle_2S(P p1, P p2, P p3){
    p2.x -= p1.x;
    p2.y -= p1.y;
    p3.x -= p1.x;
    p3.y -= p1.y;
    
    return abs(p2.x * p3.y - p3.x * p2.y);
}

int main(){
    int n;
    cin >> n;
    P points[n];
    rep(i, n){
        cin >> points[i].x;
        cin >> points[i].y;
    }
    
    lint all_2S = 0;
    rep2(i, 1, n - 1){
        all_2S += triangle_2S(points[0], points[i], points[i + 1]);
    }
    
    int p = 0, q = 0;
    lint now_2S = 0;
    lint min_diff = all_2S;
    while(p < n * 2){
        if(now_2S * 2 < all_2S){
            int q2 = q + 1;
            
            now_2S += triangle_2S(points[p % n], points[q % n], points[q2 % n]);
            q = q2;
        }else{
            int p2 = p + 1;
            
            now_2S -= triangle_2S(points[p % n], points[p2 % n], points[q % n]);
            p = p2;
        }
        
        min_diff = min(min_diff, abs(now_2S * 2 - all_2S));
        
//        cout << p << " " << q << " " << now_2S << endl;
    }
    
    cout << fixed << setprecision(5) << min_diff / 2.0 << endl;
}
accuracy: 1
time_ms: 20
memory_kb: 4380
final_rank: 8

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;

template<class T> struct point{
    T x, y;
    point(): x(0), y(0){}
    point(T a, T b): x(a), y(b){}
    point& operator += (const point& rhs) {x += rhs.x, y += rhs.y; return *this;}
    point& operator -= (const point& rhs) {x -= rhs.x, y -= rhs.y; return *this;}
    point& operator *= (const T& rhs) {x *= rhs, y *= rhs; return *this;}
    point& operator /= (const T& rhs) {x /= rhs, y /= rhs; return *this;}
    point operator +() const { return *this; }
    point operator -() const { return point() - *this; }
    friend point operator + (const point& lhs, const point& rhs) {return point(lhs) += rhs;}
    friend point operator - (const point& lhs, const point& rhs) {return point(lhs) -= rhs;}
    friend point operator * (const point& lhs, const T& rhs) {return point(lhs) *= rhs;}
    friend point operator * (const T& lhs, const point& rhs) {return point(rhs) *= lhs;}
    friend point operator / (const point& lhs, const T& rhs) {return point(lhs) /= rhs;}
    friend T operator * (const point& lhs, const point& rhs) {return lhs.x * rhs.x + lhs.y * rhs.y;}
    friend T operator ^ (const point& lhs, const point& rhs) {return lhs.x * rhs.y - lhs.y * rhs.x;}
    friend istream& operator >> (istream& os, point& rhs) noexcept {
        os >> rhs.x >> rhs.y;
        return os;
    }
    friend constexpr ostream& operator << (ostream &os, const point& rhs) noexcept {
        return os << '('<< rhs.x << ',' << rhs.y << ')';
    }
    double norm(){return sqrt(x * x + y * y);}
    T norm2(){return x * x + y * y;}
    int orthant(){//第何象限かのベクトルを返す(0,0は0象限とする)
        if(x == 0 && y == 0)return 0;
        if(y > 0)return (x > 0 ? 1 : 2);
        return (x > 0 ? 4 : 3);
    }
    //偏角ソート->ベクトルの大きさの小さい順の優先度
    friend bool operator < (point &lhs, point &rhs){
        int lo = lhs.orthant(), ro = rhs.orthant();
        if(lo != ro)return (lo < ro);
        T cv = (lhs ^ rhs);
        if(cv != 0)return (cv > 0);
        return (lhs.norm2() < rhs.norm2());
    }
};

int main(){
    int n;
    cin >> n;
    vector<point<ll>> p(n);
    for(auto &&pos:p)cin >> pos;
    p.resize(2 * n);
    for(int i = 0; i < n; i++)p[i + n] = p[i];
    ll S = 0, T = 0, ans = 1ll << 62;
    for(int i = 0; i < n; i++){
        S += (p[i] ^ p[i + 1]);
    }
    for(int l = 0, r = 1; l < n; l++){
        while(2 * T <= S){
            ans = min(ans, abs(2 * T - S));
            T += abs((p[r] - p[l]) ^ (p[r + 1] - p[l]));
            r++;
        }
        ans = min(ans, abs(2 * T - S));
        T -= abs((p[l] - p[r]) ^ (p[l + 1] - p[r]));
    }
    printf("%.15lf\n", double(ans) / 2);
}
accuracy: 1
time_ms: 20
memory_kb: 5752
final_rank: 11

code_snippet: #include<bits/stdc++.h>
using namespace std;

long long int Area(long long int x1,long long int y1,long long int x2,long long int y2,long long int x3,long long int y3){
  long long int X2 = x2-x1;
  long long int Y2 = y2-y1;
  long long int X3 = x3-x1;
  long long int Y3 = y3-y1;
  long long int Ans = abs(X2*Y3-Y2*X3)*4;
  return Ans;
}

int main(){
  int N;
  cin >> N;
  vector<long long int> X(N),Y(N);
  for(int i=0;i<N;i++) cin >> X[i] >> Y[i];
  long long int S = 0;
  for(int i=1;i<N-1;i++) S += Area(X[0],Y[0],X[i],Y[i],X[i+1],Y[i+1]);
  long long int a = S/2;
  int l = 1;
  long long int Sl = 0;
  long long int Sr = Area(X[0],Y[0],X[1],Y[1],X[2],Y[2]);
  long long int ans = 2000000000000000000;
  ans = min(ans,abs(S-Sl));
  ans = min(ans,abs(S-Sr));
  for(int i=0;i<N;i++){
    for(;;){
      if(Sl-a <= 0 && Sr-a >= 0){
        if(Sl != 0) ans = min(ans,abs(Sl-a));
        if(Sr != 0) ans = min(ans,abs(Sr-a));
        break;
      }
      if(Sl-a >= 0 && Sr-a <= 0){
        if(Sl != 0) ans = min(ans,abs(Sl-S));
        if(Sr != 0) ans = min(ans,abs(Sr-S));
        break;
      }
      int nl = l+1;
      if(nl >= N) nl -= N;
      Sl += Area(X[i],Y[i],X[l],Y[l],X[nl],Y[nl]);
      Sr += Area(X[i],Y[i],X[nl],Y[nl],X[(nl+1)%N],Y[(nl+1)%N]);
      l = nl;
    }
    Sl -= Area(X[i],Y[i],X[(i+1)%N],Y[(i+1)%N],X[l],Y[l]);
    Sr -= Area(X[i],Y[i],X[(i+1)%N],Y[(i+1)%N],X[(l+1)%N],Y[(l+1)%N]);
  }
  cout << ans/4;
  if(ans%4 == 0) cout << endl;
  else if(ans%4 == 1) cout << ".25" << endl;
  else if(ans%4 == 2) cout << ".5" << endl;
  else cout << ".75" << endl;
}
accuracy: 1
time_ms: 20
memory_kb: 3940
final_rank: 4

code_snippet: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <cstdint>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <fstream>
#include <cmath>
#include <limits>
#include <chrono>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
#include <cassert>
#include <random>
#pragma warning (disable: 4996)
using namespace std;

using ll = long long;


int main() {
	ll n;
	cin >> n;
	vector<ll> x(3*n);
	vector<ll> y(3*n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		x[i + n] = x[i];
		y[i + n] = y[i];
		x[i + n*2] = x[i];
		y[i + n*2] = y[i];
	}
	vector<long double> ac(3*n-1);
	for (int i = 0; i < 3*n-1; i++) {
		ac[i] = ((long double)x[i] - (long double)x[i + 1]) * ((long double)y[i] + (long double)y[i + 1]);
	}
	vector<long double> tc(3 * n);
	for (int i = 0; i < 3 * n - 1; i++) {
		tc[i + 1] = tc[i] + ac[i];
	}
	long double s = abs(tc[n]);
	s /= (long double)2;
	long double zans = s;
	for (int i = 0; i < n; i++) {
		ll ok = i;
		ll ng = i + n;
		while (ng - ok > 1) {
			ll mid = (ok + ng) / 2;
			if (abs(tc[mid]-tc[i] + ((long double)x[mid] - (long double)x[i]) * ((long double)y[mid] + (long double)y[i])) <= s)ok = mid;
			else ng = mid;
		}
		zans = min({ zans,abs(abs(tc[ok] - tc[i] + ((long double)x[ok] - (long double)x[i]) * ((long double)y[ok] + (long double)y[i])) - s), abs(abs(tc[ng] - tc[i] + ((long double)x[ng] - (long double)x[i]) * ((long double)y[ng] + (long double)y[i])) - s) });

	}
	cout <<fixed << setprecision(40)<< zans << endl;
}
accuracy: 1
time_ms: 30
memory_kb: 11192
final_rank: 16

code_snippet: #include <bits/stdc++.h>
#include <iomanip>
#include <limits>
using namespace std;
const long long MOD1 = 1000000007;
const long long MOD2 = 998244353;
typedef long long ll;
typedef pair<long long, long long> P;
const long long INF = 1e16;
template <typename T>
void input_arr(vector<T>& A, ll N) {
	for (ll i = 0; i < N; i++) {
		cin >> A[i];
	}
}
template <typename T, typename Q>
void input_arr(vector<pair<T, Q>>& A, ll N) {
	for (ll i = 0; i < N; i++) {
		cin >> A[i].first >> A[i].second;
	}
}
template <typename T>
void input_arr(vector<vector<T>>& A, ll H, ll W) {
	for (ll i = 0; i < H; i++) {
		for (ll j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
}
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
class Point {
public:
    long double x;
    long double y;

    Point(long double x = 0, long double y = 0) : x(x), y(y) {}

    Point operator+(Point p) { return Point(x + p.x, y + p.y); }
    Point operator-(Point p) { return Point(x - p.x, y - p.y); }
    Point operator*(long double a) { return Point(a * x, a * y); }
    Point operator/(long double a) { return Point(x / a, y / a); }

    long double abs() { return sqrt(norm()); }
    long double norm() { return x * x + y * y; }

    bool operator<(const Point& p) const {
        return x != p.x ? x < p.x : y < p.y;
    }
    bool operator==(const Point& p) const {
        return fabs(x - p.x) < (1e-10) && fabs(y - p.y) < (1e-10);
    }
};
typedef Point Vector;
struct Segment {
    Point A;
    Point B;
};
typedef Segment Line;
class Circle {
public:
    Point C;
    long double r;
    Circle(Point C = Point(), long double r = 0.0) : C(C), r(r) {}
};
typedef vector<Point> Polygon;
long double dot(Vector A, Vector B) {
    return A.x * B.x + A.y * B.y;
}
long double cross(Vector A, Vector B) {
    return A.x * B.y - A.y * B.x;
}
long double Area(Polygon S) {
    if (S.size() < 3) return 0;
    long double ans = 0;
    Point O = S[0];
    for (ll i = 1; i + 1 < S.size(); i++) {
        Point A = S[i], B = S[i + 1];
        Vector C = A - O;
        Vector D = B - O;
        long double area = cross(C, D);
        ans += area;
    }
    return ans / 2;
}
int main() {
    ll N; cin >> N;
    Polygon S(N); 
    for (ll i = 0; i < N; i++) cin >> S[i].x >> S[i].y;
    long double area = Area(S);
    long double ans = area;
    ll pos1 = 0, pos2 = 0;
    long double sum = 0;
    while (true) {
        Polygon A = { S[pos1], S[pos2], S[(pos2 + 1) % N] };
        long double area2 = Area(A);
        ans = min(ans, abs(sum + area2 - (area - sum - area2)));
        if (2 * (sum + area2) <= area) {
            sum += area2;
            pos2 = (pos2 + 1) % N;
        }
        else {
            Polygon B = { S[pos1], S[(pos1 + 1) % N], S[pos2] };
            long double area3 = Area(B);
            sum -= area3;
            pos1 = (pos1 + 1) % N;
            if (pos1 == 0) break;
        }
    }
    cout << fixed << setprecision(12) << ans << endl;
}
accuracy: 1
time_ms: 40
memory_kb: 6868
final_rank: 15

code_snippet: #include <bits/stdc++.h>
#include <iomanip>
#include <limits>
using namespace std;
const long long MOD1 = 1000000007;
const long long MOD2 = 998244353;
typedef long long ll;
typedef pair<long long, long long> P;
const long long INF = 1e18;
template <typename T>
void input_arr(vector<T>& A, ll N) {
	for (ll i = 0; i < N; i++) {
		cin >> A[i];
	}
}
template <typename T, typename Q>
void input_arr(vector<pair<T, Q>>& A, ll N) {
	for (ll i = 0; i < N; i++) {
		cin >> A[i].first >> A[i].second;
	}
}
template <typename T>
void input_arr(vector<vector<T>>& A, ll H, ll W) {
	for (ll i = 0; i < H; i++) {
		for (ll j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
}
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
class Point {
public:
    double x;
    double y;

    Point(double x = 0, double y = 0) : x(x), y(y) {}

    Point operator+(Point p) { return Point(x + p.x, y + p.y); }
    Point operator-(Point p) { return Point(x - p.x, y - p.y); }
    Point operator*(double a) { return Point(a * x, a * y); }
    Point operator/(double a) { return Point(x / a, y / a); }

    double abs() { return sqrt(norm()); }
    double norm() { return x * x + y * y; }

    bool operator<(const Point& p) const {
        return x != p.x ? x < p.x : y < p.y;
    }
    bool operator==(const Point& p) const {
        return fabs(x - p.x) < (1e-10) && fabs(y - p.y) < (1e-10);
    }
};
typedef Point Vector;
struct Segment {
    Point A;
    Point B;
};
typedef Segment Line;
class Circle {
public:
    Point C;
    double r;
    Circle(Point C = Point(), double r = 0.0) : C(C), r(r) {}
};
typedef vector<Point> Polygon;
double dot(Vector A, Vector B) {
    return A.x * B.x + A.y * B.y;
}
double cross(Vector A, Vector B) {
    return A.x * B.y - A.y * B.x;
}
double Area(Polygon S) {
    if (S.size() < 3) return 0;
    double ans = 0;
    Point O = S[0];
    for (ll i = 1; i + 1 < S.size(); i++) {
        Point A = S[i], B = S[i + 1];
        Vector C = A - O;
        Vector D = B - O;
        double area = cross(C, D) * 0.5;
        ans += area;
    }
    return ans;
}
int main() {
    ll N; cin >> N;
    Polygon S(N); 
    for (ll i = 0; i < N; i++) cin >> S[i].x >> S[i].y;
    double area = Area(S);
    double ans = (double)INF;
    ll j = 0;
    double sum = 0;
    for (ll i = 0; i < N; i++) {
        while (sum < area / 2) {
            Polygon a = { S[i], S[j + 1], S[j + 2] };
            sum += Area(a);
            j++;
        }
        ans = min(ans, abs(area - 2 * sum));
        S.push_back(S[i]);
        Polygon b = { S[i], S[i + 1], S[j + 1] };
        sum -= Area(b);
    }
    cout << fixed << setprecision(12) << ans << endl;
}
accuracy: 0.6666666666666666
time_ms: 30
memory_kb: 4716
final_rank: 19

code_snippet: #include <bits/stdc++.h>
#include <iomanip>
#include <limits>
using namespace std;
const long long MOD1 = 1000000007;
const long long MOD2 = 998244353;
typedef long long ll;
typedef pair<long long, long long> P;
const long long INF = 1e18;
template <typename T>
void input_arr(vector<T>& A, ll N) {
	for (ll i = 0; i < N; i++) {
		cin >> A[i];
	}
}
template <typename T, typename Q>
void input_arr(vector<pair<T, Q>>& A, ll N) {
	for (ll i = 0; i < N; i++) {
		cin >> A[i].first >> A[i].second;
	}
}
template <typename T>
void input_arr(vector<vector<T>>& A, ll H, ll W) {
	for (ll i = 0; i < H; i++) {
		for (ll j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
}
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
class Point {
public:
    double x;
    double y;

    Point(double x = 0, double y = 0) : x(x), y(y) {}

    Point operator+(Point p) { return Point(x + p.x, y + p.y); }
    Point operator-(Point p) { return Point(x - p.x, y - p.y); }
    Point operator*(double a) { return Point(a * x, a * y); }
    Point operator/(double a) { return Point(x / a, y / a); }

    double abs() { return sqrt(norm()); }
    double norm() { return x * x + y * y; }

    bool operator<(const Point& p) const {
        return x != p.x ? x < p.x : y < p.y;
    }
    bool operator==(const Point& p) const {
        return fabs(x - p.x) < (1e-10) && fabs(y - p.y) < (1e-10);
    }
};
typedef Point Vector;
struct Segment {
    Point A;
    Point B;
};
typedef Segment Line;
class Circle {
public:
    Point C;
    double r;
    Circle(Point C = Point(), double r = 0.0) : C(C), r(r) {}
};
typedef vector<Point> Polygon;
double dot(Vector A, Vector B) {
    return A.x * B.x + A.y * B.y;
}
double cross(Vector A, Vector B) {
    return A.x * B.y - A.y * B.x;
}
double Area(Polygon S) {
    if (S.size() < 3) return 0;
    double ans = 0;
    Point O = S[0];
    for (ll i = 1; i + 1 < S.size(); i++) {
        Point A = S[i], B = S[i + 1];
        Vector C = A - O;
        Vector D = B - O;
        double area = cross(C, D) * 0.5;
        ans += area;
    }
    return ans;
}
int main() {
    ll N; cin >> N;
    Polygon S(N); 
    for (ll i = 0; i < N; i++) cin >> S[i].x >> S[i].y;
    double area = Area(S);
    double ans = (double)INF;
    ll j = 0;
    double sum = 0;
    for (ll i = 0; i < N; i++) {
        while (sum < area / 2) {
            Polygon a = { S[i], S[j + 1], S[j + 2] };
            sum += Area(a);
            j++;
        }
        ans = min(ans, abs(area - 2 * sum));
        S.push_back(S[i]);
        Polygon b = { S[i], S[i + 1], S[j + 1] };
        sum -= Area(b);
    }
    cout << fixed << setprecision(12) << ans << endl;
}
accuracy: 0.6666666666666666
time_ms: 30
memory_kb: 4748
final_rank: 20

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vc = vector<T>;
template<class T> using vvc = vc<vc<T>>;
template<class T> using vvvc = vc<vvc<T>>;
template<class T> using vvvvc = vvc<vvc<T>>;
template<class T> using PQ = priority_queue<T>;
template<class T> using invPQ = priority_queue<T, vector<T>, greater<T>>;
using IP = pair<int, int>;
using LP = pair<ll, ll>;
#define all(x) begin(x), end(x)
#define allr(x) rbegin(x), rend(x)
#define rep(i, n) for (int i = 0; (i) < (int)(n); i++)
#define rep3(i, m, n) for (int i = (m); (i) < (int)(n); i++)
#define repr(i, n) for (int i = (n) - 1; (i) >= 0; i--)
#define rep3r(i, m, n) for (int i = (n) - 1; (i) >= (int)(m); i--)
template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return 1; } return 0; }

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int N;
    cin >> N;
    vc<long long> x(N), y(N);
    rep (i, N) cin >> x[i] >> y[i];

    vc<long long> s(N+1);
    rep (i, N) {
        s[i+1] = (x[i]*y[(i+1)%N] - y[i]*x[(i+1)%N]);
    }
    rep (i, N) s[i+1] += s[i];

    long long ans = s[N];

    rep (i, N-2) {
        int l = i + 2, r = N;
        if (i < 2) r -= 2 - i;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            if ((s[mid] - s[i] + (x[mid]*y[i] - y[mid]*x[i])) * 2 - s[N] >= 0) r = mid;
            else l = mid;
        }
        chmin(ans, abs(s[N] - (s[l] - s[i] + (x[l]*y[i] - y[l]*x[i])) * 2));
        if (r < N) chmin(ans, abs(s[N] - (s[r] - s[i] + (x[r]*y[i] - y[r]*x[i])) * 2));
    }

    printf("%.10f\n", (double)ans/2);
}
accuracy: 1
time_ms: 10
memory_kb: 4392
final_rank: 2

code_snippet: #ifdef LOGX
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;

/*---------macro---------*/
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define unless(x) if(!(x))
#define until(x) while(!(x))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define mybit(i,j) (((i)>>(j))&1)

/*---------type/const---------*/
const int big=1000000007;
//const int big=998244353;
const double EPS=1e-8; //適宜変える
typedef long long ll;
typedef unsigned long long ull;
typedef std::string::const_iterator state; //構文解析
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const char newl='\n';
struct{
    constexpr operator int(){return -int(1e9)-10;}
    constexpr operator ll(){return -ll(1e18)-10;}
}neginf;
struct{
    constexpr operator int(){return int(1e9)+10;}
    constexpr operator ll(){return ll(1e18)+10;}
    constexpr auto operator -(){return neginf;}
}inf;

/*---------debug---------*/
#ifdef LOGX
#include <template/debug.hpp>
#else
#define dbg(...) ;
#define dbgnewl ;
#define prt(x) ;
#define _prt(x) ;
#endif

/*---------function---------*/
template<typename T> T max(const std::vector<T> &a){T ans=a[0];for(T elem:a){ans=max(ans,elem);}return ans;}
template<typename T> T min(const std::vector<T> &a){T ans=a[0];for(T elem:a){ans=min(ans,elem);}return ans;}
template<typename T,typename U> bool chmin(T &a,const U b){if(a>b){a=b;return true;}return false;}
template<typename T,typename U> bool chmax(T &a,const U b){if(a<b){a=b;return true;}return false;}
bool valid(int i,int j,int h,int w){return (i>=0 && j>=0 && i<h && j<w);}
template<class T,class U>T expm(T x,U y,const ll mod=big){T res=1;while(y){if(y&1)(res*=x)%=mod;(x*=x)%=mod;y>>=1;}return res;}
template<class T,class U>T exp(T x,U y){T res=1;while(y){if(y&1)res*=x;x*=x;y>>=1;}return res;}



int main(){
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(nullptr);
    std::cout << fixed << setprecision(10);
/*------------------------------------*/
    
    int n;
    cin >> n;
    vector<complex<ll>> vec(n);
    rep(i,n){
        int a,b;
        cin >> a >> b;
        vec[i]={a,b};
    }
    auto MOD=[&](int i){
        return (i%n+n)%n;
    };
    auto calc=[&](int i,int j,int k){
        i=MOD(i);
        j=MOD(j);
        k=MOD(k);
        auto a=vec[i]-vec[k],b=vec[j]-vec[k];
        return abs(a.real()*b.imag()-a.imag()*b.real());
    };
    
    ll ans=inf;
    ll A=0,B=0;
    rep(i,n-1){
        B+=calc(0,i,i+1);
    }

    int j=1;
    rep(i,n){
        while(A<B){
            ans=min(ans,abs(A-B));
            A+=calc(i,j,j+1);
            B-=calc(i,j,j+1);
            j++;
        }
        ans=min(ans,abs(A-B));
        A-=calc(i,i+1,j);
        B+=calc(i,i+1,j);
        ans=min(ans,abs(A-B));
    }
    cout << ans/2.0 << newl;
}
accuracy: 1
time_ms: 20
memory_kb: 4188
final_rank: 7

code_snippet: #ifdef LOGX
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;

/*---------macro---------*/
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define unless(x) if(!(x))
#define until(x) while(!(x))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define mybit(i,j) (((i)>>(j))&1)

/*---------type/const---------*/
const int big=1000000007;
//const int big=998244353;
const double EPS=1e-8; //適宜変える
typedef long long ll;
typedef unsigned long long ull;
typedef std::string::const_iterator state; //構文解析
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const char newl='\n';
struct{
    constexpr operator int(){return -int(1e9)-10;}
    constexpr operator ll(){return -ll(1e18)-10;}
}neginf;
struct{
    constexpr operator int(){return int(1e9)+10;}
    constexpr operator ll(){return ll(1e18)+10;}
    constexpr auto operator -(){return neginf;}
}inf;

/*---------debug---------*/
#ifdef LOGX
#include <template/debug.hpp>
#else
#define dbg(...) ;
#define dbgnewl ;
#define prt(x) ;
#define _prt(x) ;
#endif

/*---------function---------*/
template<typename T> T max(const std::vector<T> &a){T ans=a[0];for(T elem:a){ans=max(ans,elem);}return ans;}
template<typename T> T min(const std::vector<T> &a){T ans=a[0];for(T elem:a){ans=min(ans,elem);}return ans;}
template<typename T,typename U> bool chmin(T &a,const U b){if(a>b){a=b;return true;}return false;}
template<typename T,typename U> bool chmax(T &a,const U b){if(a<b){a=b;return true;}return false;}
bool valid(int i,int j,int h,int w){return (i>=0 && j>=0 && i<h && j<w);}
template<class T,class U>T expm(T x,U y,const ll mod=big){T res=1;while(y){if(y&1)(res*=x)%=mod;(x*=x)%=mod;y>>=1;}return res;}
template<class T,class U>T exp(T x,U y){T res=1;while(y){if(y&1)res*=x;x*=x;y>>=1;}return res;}



int main(){
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(nullptr);
    std::cout.precision(10);
/*------------------------------------*/
    
    int n;
    cin >> n;
    vector<complex<ll>> vec(n);
    rep(i,n){
        int a,b;
        cin >> a >> b;
        vec[i]={a,b};
    }
    auto MOD=[&](int i){
        return (i%n+n)%n;
    };
    auto calc=[&](int i,int j,int k){
        i=MOD(i);
        j=MOD(j);
        k=MOD(k);
        auto a=vec[i]-vec[k],b=vec[j]-vec[k];
        return abs(a.real()*b.imag()-a.imag()*b.real());
    };
    
    ll ans=inf;
    ll A=0,B=0;
    rep(i,n-1){
        B+=calc(0,i,i+1);
    }

    int j=1;
    rep(i,n){
        while(A<B){
            ans=min(ans,abs(A-B));
            A+=calc(i,j,j+1);
            B-=calc(i,j,j+1);
            j++;
        }
        ans=min(ans,abs(A-B));
        A-=calc(i,i+1,j);
        B+=calc(i,i+1,j);
        ans=min(ans,abs(A-B));
    }
    cout << (ans>>1) << '.' << (ans&1 ? 5:0) << newl;
}
accuracy: 1
time_ms: 20
memory_kb: 4124
final_rank: 5

code_snippet: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
using Real = double;
using Point = complex< double >;
using Polygon = vector< Point >;
const Real EPS = 1e-6, PI = acos(-1);
constexpr int COUNTER_CLOCKWISE = +1;
constexpr int CLOCKWISE = -1;
constexpr int ONLINE_BACK = +2;  // c-a-b
constexpr int ONLINE_FRONT = -2; // a-b-c
constexpr int ON_SEGMENT = 0;    // a-c-b

Point operator*(const Point &p, const Real &d) {
    return Point(real(p) * d, imag(p) * d);
}

Point operator/(const Point &p, const Real &d) {
    return Point(real(p) / d, imag(p) / d);
}

istream &operator>>(istream &is, Point &p) {
    Real a, b; is >> a >> b;
    p = Point(a, b);
    return is;
}

ostream &operator<<(ostream &os, const Point &p) {
    return os << fixed << setprecision(10) << real(p) << " " << imag(p);
}

namespace std {
    bool operator<(const Point &a, const Point &b) {
        return a.real() != b.real() ? a.real() < b.real() : a.imag() < b.imag();
    }
}

// 符号
inline int sign(const Real &r) {
    return r <= -EPS ? -1 : r >= EPS ? 1 : 0;
}

// a = b ? 
inline bool equals(const Real &a, const Real &b) {
    return sign(a - b) == 0;
}


// 単位ベクトル
Point unitVec(const Point &a){ return a / abs(a); }

// 法線ベクトル 半時計周り
Point normVec(const Point &a){ return a * Point(0, 1); }
//Point normVec(const Point &a){ return a * Point(0,-1); }

// 内積
Real dot(const Point &a, const Point &b) {
    return (a.real() * b.real() + a.imag() * b.imag());
}

// 外積
Real cross(const Point &a, const Point &b) {
    return (a.real() * b.imag() - a.imag() * b.real());
}

Point rotate(const Point &p, const Real &theta) {
    return Point(cos(theta) * p.real() - sin(theta) * p.imag(),
                 sin(theta) * p.real() + cos(theta) * p.imag());
}

Real Radian_To_Degree(const Real &radian){ return radian * 180.0 / PI; }
Real Degree_To_Radian(const Real &degree){ return degree * PI / 180.0; }

struct Line {
    Point a, b;
    Line() = default;
    Line(Point a, Point b) : a(a), b(b) {}

    // Ax + By = C
    Line(Real A, Real B, Real C) {
        if(equals(A, 0)) {
            a = Point(0, C / B), b = Point(1, C / B);
        }else if(equals(B,0)) {
            b = Point(C / A, 0), b = Point(C / A, 1);
        }else{
            a = Point(0, C / B), b = Point(C / A, 0);
        }
    }

    friend ostream &operator<<(ostream &os, Line &p) {
        return os << p.a << " " << p.b;
    }

    friend istream &operator>>(istream &is, Line &a) {
        return is >> a.a >> a.b;
    }
};

struct Segment : Line {
    Segment() = default;
    Segment(Point a, Point b) : Line(a, b) {}
};

struct Circle {
    Point p;
    Real r;
    Circle() = default;
    Circle(Point p, Real r) : p(p), r(r) {}

    friend ostream &operator<<(ostream &os, Circle &c) {
        return os << c.p << " " << c.r;
    }

    friend istream &operator>>(istream &is, Circle &c) {
        return is >> c.p >> c.r;
    }
};

// 直線lに点pから引いた垂線の足を求める
Point projection(const Line &l, const Point &p) {
    Real t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
    return l.a + (l.a - l.b) * t;
}

Point projection(const Segment &l, const Point &p) {
    Real t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
    return l.a + (l.a - l.b) * t;
}

// 直線lに関して点pと対称な点を求める
Point reflection(const Line &l, const Point &p) {
    return p + (projection(l, p) - p) * 2.0;
}

// 点の回転方向
// 点aを基準に点b,cの位置関係
int ccw(const Point &a, Point b, Point c) {
    b = b - a, c = c - a;
    if(sign(cross(b, c)) == +1) return COUNTER_CLOCKWISE; // 反時計回り
    if(sign(cross(b, c)) == -1) return CLOCKWISE;         // 時計回り
    if(sign(dot(b, c)) == -1) return ONLINE_BACK;         // c - a - b
    if(norm(b) < norm(c)) return ONLINE_FRONT;            // a - b - c
    return ON_SEGMENT;                                    // a - c - b
}

// 2直線の直交判定
bool is_orthogonal(const Line &a, const Line &b) {
    return equals(dot(a.b - a.a, b.b - b.a), 0);
}

// 2直線の平行判定
bool is_parallel(const Line &a, const Line &b) {
    return equals(cross(a.b - a.a, b.b - b.a), 0);
}

// 線分の交差判定
bool is_intersect_ss(const Segment &s, const Segment &t) {
    return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
           ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}

// 直線の交差判定
bool is_intersect_ll(const Line &l, const Line &m) {
    Real A = cross(l.b - l.a, m.b - m.a);
    Real B = cross(l.b - l.a, l.b - m.a);
    if(equals(abs(A), 0) && equals(abs(B), 0)) return true;
    return !is_parallel(l, m);
}

// 線分に点が乗っているか
bool is_intersect_sp(const Segment &s, const Point &p) {
    return ccw(s.a, s.b, p) == ON_SEGMENT;
}

// 点と点の距離
Real distance_pp(const Point &p1, const Point &p2) {
    return sqrt(pow(real(p1)-real(p2), 2) + pow(imag(p1)-imag(p2), 2));
}

// 点と直線の距離
Real distance_lp(const Line &l, const Point &p) {
    return abs(p - projection(l, p));
}

// 直線と直線の距離
Real distance_ll(const Line &l, const Line &m) {
    return is_intersect_ll(l, m) ? 0 : distance_lp(l, m.a);
}

// 点と線分の距離
Real distance_sp(const Segment &s, const Point &p) {
    Point r = projection(s, p);
    if(is_intersect_sp(s, r)) return abs(r - p);
    return min(abs(s.a - p), abs(s.b - p));
}

// 線分と線分の距離
Real distance_ss(const Segment &a, const Segment &b) {
    if(is_intersect_ss(a, b)) return 0;
    return min({distance_sp(a, b.a), distance_sp(a, b.b), distance_sp(b, a.a), distance_sp(b, a.b)});
}

// 交点
Point cross_point_ll(const Line &l, const Line &m) {
    Real A = cross(l.b - l.a, m.b - m.a);
    Real B = cross(l.b - l.a, l.b - m.a);
    if(equals(abs(A), 0) && equals(abs(B), 0)) return m.a;
    return m.a + (m.b - m.a) * B / A;
}

// 円と円の位置関係
int intersect(Circle c1, Circle c2) {
    if(c1.r < c2.r) swap(c1, c2);
    Real d = abs(c1.p - c2.p);
    if(c1.r + c2.r < d) return 4;
    if(equals(c1.r + c2.r, d)) return 3;
    if(c1.r - c2.r < d) return 2;
    if(equals(c1.r - c2.r, d)) return 1;
    return 0;
}

bool is_convex(const Polygon &p){
    for(int i = 0; i < p.size(); i++){
        if(ccw(p[(i + p.size() - 1) % p.size()], p[i], p[(i + 1) % p.size()]) == -1) return false;
    }
    return true;
}

enum { OUT, ON, IN };
int contains(const Polygon &Q, const Point &p){
    bool in = false;
    for(int i = 0; i < Q.size(); i++){
        Point a = Q[i] - p, b = Q[(i + 1) % Q.size()] - p;
        if(a.imag() > b.imag()) swap(a, b);
        if(a.imag() <= 0 && 0 < b.imag() && cross(a, b) < 0) in = !in;
        if(cross(a, b) == 0 && dot(a, b) <= 0) return ON;
    }
    return in ? IN : OUT;
}

Polygon convex_hull(Polygon &p, bool strict = true){
    int n = (int)p.size(), k = 0;
    if(n <= 2) return p;
    sort(p.begin(), p.end());
    Polygon ch(2 * n);
    for(int i = 0; i < n; ch[k++] = p[i++]){
        while(k >= 2 && cross(ch[k - 1] - ch[k - 2], p[i] - ch[k - 1]) < 0) --k;
    }
    for(int i = n - 2, t = k + 1; i >= 0; ch[k++] = p[i--]){
        while(k >= t && cross(ch[k - 1] - ch[k - 2], p[i] - ch[k - 1]) < 0) --k;
    }
    ch.resize(k - 1);
    return ch;
}

Real convex_diameter(const Polygon &p){
    int n = (int)p.size();
    int is = 0, js = 0;
    for(int i = 1; i < n; i++){
        if(p[i].imag() > p[is].imag()) is = i;
        if(p[i].imag() < p[js].imag()) js = i;
    }
    Real maxdis = norm(p[is] - p[js]);
    int maxi, maxj, i, j;
    i = maxi = is;
    j = maxj = js;
    do {
        if(cross(p[(i + 1) % n] - p[i], p[(j + 1) % n] - p[j]) >= 0){
            j = (j + 1) % n;
        }else{
            i = (i + 1) % n;
        }

        if(norm(p[i] - p[j]) > maxdis){
            maxdis = norm(p[i] - p[j]);
            maxi = i;
            maxj = j;
        }

    }while(i != is || j != js);
    return sqrt(maxdis);
}

Polygon convex_cut(const Polygon &U, Line l){
    Polygon ret;
    for(int i = 0; i < U.size(); i++){
        Point now = U[i], nxt = U[(i + 1) % U.size()];
        if(ccw(l.a, l.b, now) != -1) ret.push_back(now);
        if(ccw(l.a, l.b, now) * ccw(l.a, l.b, nxt) < 0){
            ret.push_back(cross_point_ll(Line(now, nxt), l));
        }
    }
    return ret;
}

Real ClosetPair(Polygon& ps){
    if(ps.size() <= 1) throw (0);
    sort(begin(ps), end(ps));

    auto compare_y = [&](const Point &a, const Point &b) {
        return a.imag() < b.imag();
    };
    Polygon beet(ps.size());
    const double INF = 1e18;

    function< double(int, int) > rec = [&](int left, int right) {
        if(right - left <= 1) return INF;
        int mid = (left + right) >> 1;
        auto x = ps[mid].real();
        auto ret = min(rec(left, mid), rec(mid, right));
        inplace_merge(begin(ps) + left, begin(ps) + mid, begin(ps) + right, compare_y);
        int ptr = 0;
        for(int i = left; i < right; i++) {
            if(fabs((ps[i].real()) - x) >= ret) continue;
            for(int j = 0; j < ptr; j++) {
                auto luz = ps[i] - beet[ptr - j - 1];
                if(luz.imag() >= ret) break;
                ret = min(ret, abs(luz));
            }
            beet[ptr++] = ps[i];
        }
        return ret;
    };
    return rec(0, (int) ps.size());
}

pair< Point, Point > cross_point_cc(const Circle &c1, const Circle &c2) {
    Real d = abs(c1.p - c2.p);
    Real a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d));
    Real t = atan2(c2.p.imag() - c1.p.imag(), c2.p.real() - c1.p.real());
    Point p1 = c1.p + Point(cos(t + a) * c1.r, sin(t + a) * c1.r);
    Point p2 = c1.p + Point(cos(t - a) * c1.r, sin(t - a) * c1.r);
    return {p1, p2};
}

const int BOTTOM = 0;
const int LEFT   = 1;
const int RIGHT  = 2;
const int TOP    = 3;

class endPoint {
    public:
        Point p;
        int seg; // id of Point
        int st; // kind of Point
        endPoint(){}
        endPoint(Point inp, int inseg, int inst):p(inp),seg(inseg),st(inst){}
        bool operator<(const endPoint &ep)const {
            if(p.imag() == ep.p.imag()) return st < ep.st;
            else return p.imag() < ep.p.imag();
        }
};

endPoint EP[220000];
int Manhattan_Intersections(vector< Segment > s){
    int n = s.size();
    double hoge;

    for(int i = 0, k = 0; i < n; i++){
        if(s[i].a.imag() == s[i].b.imag()){
            if(s[i].a.real() > s[i].b.real()){
                hoge = s[i].a.real();
                s[i].a.real(s[i].b.real());
                s[i].b.real(hoge);
            }
        }else if(s[i].a.imag() > s[i].b.imag()){
            hoge = s[i].a.imag();
            s[i].a.imag(s[i].b.imag());
            s[i].b.imag(hoge);
        }

        if(s[i].a.imag() == s[i].b.imag()){
            EP[k++] = endPoint(s[i].a, i, LEFT);
            EP[k++] = endPoint(s[i].b, i, RIGHT);
        }else{
            EP[k++] = endPoint(s[i].a, i, BOTTOM);
            EP[k++] = endPoint(s[i].b, i, TOP);
        }
    }

    sort(EP, EP + 2 * n);
    set<int> BT;
    BT.insert(1000000001);
    int cnt = 0;
    for(int i = 0; i < 2 * n; i++){
        if(EP[i].st == TOP) BT.erase(EP[i].p.real());
        else if(EP[i].st == BOTTOM) BT.insert(EP[i].p.real());
        else if(EP[i].st == LEFT){
            set<int>::iterator b = lower_bound(BT.begin(), BT.end(), s[EP[i].seg].a.real());
            set<int>::iterator e = upper_bound(BT.begin(), BT.end(), s[EP[i].seg].b.real());
            cnt += distance(b, e);
        }
    }

    return cnt;
}

// 内接円
Circle Inscribed_Circle(const Point& a, const Point& b, const Point& c){
    double A = abs(b - c), B = abs(c - a), C = abs(a - b);
    Point x = Point((a * A + b * B + c * C) / (A + B + C));
    double r = distance_sp(Segment(a,b),x);
    return Circle(x, r);
}

// 外接円
Circle Circumscribed_Circle(const Point& a, const Point& b, const Point& c){
    Point m1((a+b)/2.0), m2((b+c)/2.0);
    Point v((b-a).imag(), (a-b).real()), w((b-c).imag(), (c-b).real());
    Line s(m1, Point(m1+v)), t(m2, Point(m2+w));
    const Point x = cross_point_ll(s, t);
    return Circle(x, abs(a-x));
}

pair< Point, Point > cross_point_cl(const Circle &c, const Line &l) {
    Point pr = projection(l, c.p);
    if(equals(abs(pr - c.p), c.r)) return {pr, pr};
    Point e = (l.b - l.a) / abs(l.b - l.a);
    auto k = sqrt(norm(c.r) - norm(pr - c.p));
    return {pr - e * k, pr + e * k};
}

// 点pを通る円の接線
pair<Point,Point> tangent_cp(const Circle &c, const Point &p) {
    return cross_point_cc(c, Circle(p, sqrt(norm(c.p - p) - c.r * c.r)));
}

// 二つの円の共通接線
vector< Line > tangent_cc(Circle c1, Circle c2){
    vector< Line > ret;
    if(c1.r < c2.r) swap(c1,c2);
    double g = norm(c1.p-c2.p);
    if(equals(g,0.0)) return ret;
    Point u = (c2.p-c1.p)/sqrt(g);
    Point v = rotate(u, PI * 0.5);
    for(int s:{-1,1}){
        double h = (c1.r+ s*c2.r)/sqrt(g);
        if(equals(1- h*h, 0)){
            ret.emplace_back(c1.p+u*c1.r, c1.p+(u+v)*c1.r);
        }else if(1-h*h > 0){
            Point uu = u*h, vv = v*sqrt(1-h*h);
            ret.emplace_back(c1.p+(uu+vv)*c1.r, c2.p-(uu+vv)*c2.r*s);
            ret.emplace_back(c1.p+(uu-vv)*c1.r, c2.p-(uu-vv)*c2.r*s);
        }
    }
    return ret;
}

Real area_poly_c(const Polygon &p, const Circle &c) {
    if(p.size() < 3) return 0.0;
    function< Real(Circle, Point, Point) > cross_area = [&](const Circle &c, const Point &a, const Point &b) {
        Point va = c.p - a, vb = c.p - b;
        Real f = cross(va, vb), ret = 0.0;
        if(equals(f, 0.0)) return ret;
        if(max(abs(va), abs(vb)) < c.r + EPS) return f;
        if(distance_sp(Segment(a, b), c.p) > c.r - EPS) return c.r * c.r * arg(vb * conj(va));
        auto u = cross_point_cl(c, Segment(a, b));
        vector< Point > tot{a, u.first, u.second, b};
        for(int i = 0; i + 1 < tot.size(); i++) {
            ret += cross_area(c, tot[i], tot[i + 1]);
        }
        return ret;
    };
    Real A = 0;
    for(int i = 0; i < p.size(); i++) {
        A += cross_area(c, p[i], p[(i + 1) % p.size()]);
    }
    return A;
}

Real area_cc(const Circle &c1, const Circle &c2) {
    Real d = abs(c1.p - c2.p);
    if(c1.r + c2.r <= d + EPS) return 0.0;
    if(d <= fabs(c1.r - c2.r) + EPS) {
        Real r = min(c1.r, c2.r);
        return r * r * PI;
    }
    Real rc = (d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
    Real theta = acos(rc / c1.r);
    Real phi = acos((d - rc) / c2.r);
    return (c1.r * c1.r*theta + c2.r*c2.r*phi - d*c1.r*sin(theta));
}

Real area(const Polygon &p){
    Real A = 0;
    for(int i = 0; i < p.size(); i++){
        A += cross(p[i], p[(i + 1) % p.size()]);
    }
    return A * 0.5;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);

    int N; cin >> N;
    Polygon p(N);
    rep(i,N) cin >> p[i];
    
    vector< Real > sum(N, 0);
    rep(i,N-1) sum[i + 1] += sum[i] + cross(p[i], p[i + 1]);

    int r = 0;
    Real AREA = area(p) * 2.0;
    Real ans = AREA;
    rep(l,N){
        r = max(r, l);
        while(r < N) {
            Real T = sum[r] - sum[l] + cross(p[r], p[l]);
            Real diff = AREA - 2.0 * T;
            ans = min(ans, abs(diff));
            if(diff <= 0) break;
            r++;
        }
    }
    cout.precision(17);
    cout << ans * 0.5 << endl;
}
accuracy: 0.6666666666666666
time_ms: 10
memory_kb: 9576
final_rank: 18