Language: C++

#include "bits/stdc++.h"
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/11/22  Problem: AOJ 2376 / Link: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2376  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */
typedef long double ld;
const ld EPS = 1e-12;
typedef long double ld;
const ld PI = acos(-1.0);
bool eq(ld a, ld b) { return abs(a - b) < EPS; }
typedef complex<ld> Point;
typedef vector<Point> Polygon;

namespace std
{
	bool operator < (const Point& a, const Point& b)
	{
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
// 点の入力
Point input_point() {
	ld x, y;
	cin >> x >> y;
	return Point(x, y);
}
const ld eps = 1e-9, pi = acos(-1.0);

// 誤差つき等号判定
bool eq(ld a, ld b) {
	return (abs(a - b) < eps);
}

struct Line
{
	Point a, b;
	Line(Point p, Point q) :a(p), b(q) {};
	Line(ld x1, ld y1, ld x2, ld y2) :a(Point(x1, y1)), b(Point(x2, y2)) {};
};

LL N;

LL ans = 0LL;
ld gety(const Line &line, int X) {
	ld y1 = line.a.imag();
	ld y2 = line.b.imag();
	ld x1 = line.a.real();
	ld x2 = line.b.real();

	return (y2 - y1)*(x2 - X) / (X - x1);
}


int calc(Line &a, Line &b, int X) {// [X,X+1]
	int res = 0;
	if (a.a.imag() <= X&&X <= a.b.imag() && b.a.imag() <= X&&b.b.imag()) {
		ld ya1 = gety(a, X);
		ld ya2 = gety(a, X + 1);
		ld yb1 = gety(b, X);
		ld yb2 = gety(b, X + 1);
		int yh = ceil<int>(max({ ya1,ya2,yb1,yb2 }));
		int yl= floor<int>(min({ya1,ya2,yb1,yb2}));
		res += abs(yh - yl);

	}
	return res;
}


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

	while (cin >> N, N) {
		vector<Point> ps(N + 1);
		FOR(i, 0, N) {
			ps[i] = input_point();
		}
		ps[N] = ps[0];
		vector<Line> lines(N);
		FOR(i, 0, N) {
			lines[i] = Line(ps[i], ps[i + 1]);
		}

		ans = 0;
		FOR(x, -2000, 2000) {
			//[x,x+1]で数え上げる
			//　この区間でsort
			auto mysort = [&](const Line &a, const Line &b) {
				ld ya = max(gety(a, x), gety(a, x + 1));
				ld yb = max(gety(b, x), gety(b, x + 1));
				return (ya > yb);
			};
			sort(lines.begin(), lines.end(), mysort);
			for (int i = 0; i < N; i += 2) {
				ans += calc(lines[i], lines[i + 1], x);
			}

		}



		cout << ans << "\n";
	}

	return 0;
}

Compiler output:
a.cc:59:6: error: redefinition of 'bool eq(ld, ld)'
   59 | bool eq(ld a, ld b) {
      |      ^~
a.cc:39:6: note: 'bool eq(ld, ld)' previously defined here
   39 | bool eq(ld a, ld b) { return abs(a - b) < EPS; }
      |      ^~
In file included from /usr/include/c++/14/bits/stl_tempbuf.h:61,
                 from /usr/include/c++/14/bits/stl_algo.h:69,
                 from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_construct.h: In instantiation of 'void std::_Construct(_Tp*, _Args&& ...) [with _Tp = Line; _Args = {}]':
/usr/include/c++/14/bits/stl_uninitialized.h:643:18:   required from 'static _ForwardIterator std::__uninitialized_default_n_1<_TrivialValueType>::__uninit_default_n(_ForwardIterator, _Size) [with _ForwardIterator = Line*; _Size = long unsigned int; bool _TrivialValueType = false]'
  643 |                 std::_Construct(std::__addressof(*__cur));
      |                 ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_uninitialized.h:712:20:   required from '_ForwardIterator std::__uninitialized_default_n(_ForwardIterator, _Size) [with _ForwardIterator = Line*; _Size = long unsigned int]'
  710 |       return __uninitialized_default_n_1<__is_trivial(_ValueType)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  711 |                                          && __can_fill>::
      |                                          ~~~~~~~~~~~~~~~~
  712 |         __uninit_default_n(__first, __n);
      |         ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_uninitialized.h:779:44:   required from '_ForwardIterator std::__uninitialized_default_n_a(_ForwardIterator, _Size, allocator<_Tp>&) [with _ForwardIterator = Line*; _Size = long unsigned int; _Tp = Line]'
  779 |     { return std::__uninitialized_default_n(__first, __n); }
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1720:36:   required from 'void std::vector<_Tp, _Alloc>::_M_default_initialize(size_type) [with _Tp = Line; _Alloc = std::allocator<Line>; size_type = long unsigned int]'
 1720 |           std::__uninitialized_default_n_a(this->_M_impl._M_start, __n,
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1721 |                                            _M_get_Tp_allocator());
      |                                            ~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:558:9:   required from 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = Line; _Alloc = std::allocator<Line>; size_type = long unsigned int; allocator_type = std::allocator<Line>]'
  558 |       { _M_default_initialize(__n); }
      |         ^~~~~~~~~~~~~~~~~~~~~
a.cc:109:23:   required from here
  109 |                 vector<Line> lines(N);
      |                                     ^
/usr/include/c++/14/bits/stl_construct.h:119:7: error: no matching function for call to 'Line::Line()'
  119 |       ::new((void*)__p) _Tp(std::forward<_Args>(__args)...);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:67:9: note: candidate: 'Line::Line(ld, ld, ld, ld)'
   67 |         Line(ld x1, ld y1, ld x2, ld y2) :a(Point(x1, y1)), b(Point(x2, y2)) {};
      |         ^~~~
a.cc:67:9: note:   candidate expects 4 arguments, 0 provided
a.cc:66:9: note: candidate: 'Line::Line(Point, Point)'
   66 |         Line(Point p, Point q) :a(p), b(q) {};
      |         ^~~~
a.cc:66:9: note:   candidate expects 2 arguments, 0 provided
a.cc:63:8: note: candidate: 'constexpr Line::Line(const Line&)'
   63 | struct Line
      |        ^~~~
a.cc:63:8: note:   candidate expects 1 argument, 0 provided
a.cc:63:8: note: candidate: 'constexpr Line::Line(Line&&)'
a.cc:63:8: note:   candidate expects 1 argument, 0 provided