QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#783576#9137. Ancient CountrymaspyAC ✓4712ms5228kbC++2326.4kb2024-11-26 10:45:142024-11-26 10:45:14

Judging History

你现在查看的是最新测评结果

  • [2024-11-26 10:45:14]
  • 评测
  • 测评结果:AC
  • 用时:4712ms
  • 内存:5228kb
  • [2024-11-26 10:45:14]
  • 提交

answer

#line 1 "/home/maspy/compro/library/my_template.hpp"
#if defined(LOCAL)
#include <my_template_compiled.hpp>
#else

// https://codeforces.com/blog/entry/96344
#pragma GCC optimize("Ofast,unroll-loops")
// いまの CF だとこれ入れると動かない?
// #pragma GCC target("avx2,popcnt")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i128 = __int128;
using u128 = unsigned __int128;
using f128 = __float128;

template <class T>
constexpr T infty = 0;
template <>
constexpr int infty<int> = 1'010'000'000;
template <>
constexpr ll infty<ll> = 2'020'000'000'000'000'000;
template <>
constexpr u32 infty<u32> = infty<int>;
template <>
constexpr u64 infty<u64> = infty<ll>;
template <>
constexpr i128 infty<i128> = i128(infty<ll>) * 2'000'000'000'000'000'000;
template <>
constexpr double infty<double> = infty<ll>;
template <>
constexpr long double infty<long double> = infty<ll>;

using pi = pair<ll, ll>;
using vi = vector<ll>;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vc<T>>;
template <class T>
using vvvc = vector<vvc<T>>;
template <class T>
using vvvvc = vector<vvvc<T>>;
template <class T>
using vvvvvc = vector<vvvvc<T>>;
template <class T>
using pq = priority_queue<T>;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;

#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define vvvv(type, name, a, b, c, ...) \
  vector<vector<vector<vector<type>>>> name(a, vector<vector<vector<type>>>(b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))

// https://trap.jp/post/1224/
#define FOR1(a) for (ll _ = 0; _ < ll(a); ++_)
#define FOR2(i, a) for (ll i = 0; i < ll(a); ++i)
#define FOR3(i, a, b) for (ll i = a; i < ll(b); ++i)
#define FOR4(i, a, b, c) for (ll i = a; i < ll(b); i += (c))
#define FOR1_R(a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR2_R(i, a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR3_R(i, a, b) for (ll i = (b)-1; i >= ll(a); --i)
#define overload4(a, b, c, d, e, ...) e
#define overload3(a, b, c, d, ...) d
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FOR_R(...) overload3(__VA_ARGS__, FOR3_R, FOR2_R, FOR1_R)(__VA_ARGS__)

#define FOR_subset(t, s) for (ll t = (s); t >= 0; t = (t == 0 ? -1 : (t - 1) & (s)))
#define all(x) x.begin(), x.end()
#define len(x) ll(x.size())
#define elif else if

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second

#define stoi stoll

int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(u32 x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int popcnt(u64 x) { return __builtin_popcountll(x); }
int popcnt_sgn(int x) { return (__builtin_parity(x) & 1 ? -1 : 1); }
int popcnt_sgn(u32 x) { return (__builtin_parity(x) & 1 ? -1 : 1); }
int popcnt_sgn(ll x) { return (__builtin_parity(x) & 1 ? -1 : 1); }
int popcnt_sgn(u64 x) { return (__builtin_parity(x) & 1 ? -1 : 1); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 1, 2)
int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(u32 x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(ll x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
int topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 0, 2)
int lowbit(int x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(u32 x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(ll x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
int lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }

template <typename T>
T kth_bit(int k) {
  return T(1) << k;
}
template <typename T>
bool has_kth_bit(T x, int k) {
  return x >> k & 1;
}

template <typename T>
T floor(T a, T b) {
  return a / b - (a % b && (a ^ b) < 0);
}
template <typename T>
T ceil(T x, T y) {
  return floor(x + y - 1, y);
}
template <typename T>
T bmod(T x, T y) {
  return x - y * floor(x, y);
}
template <typename T>
pair<T, T> divmod(T x, T y) {
  T q = floor(x, y);
  return {q, x - q * y};
}

template <typename T, typename U>
T SUM(const vector<U> &A) {
  T sm = 0;
  for (auto &&a: A) sm += a;
  return sm;
}

#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define LB(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define UB(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end()), x.shrink_to_fit()

template <typename T>
T POP(deque<T> &que) {
  T a = que.front();
  que.pop_front();
  return a;
}
template <typename T>
T POP(pq<T> &que) {
  T a = que.top();
  que.pop();
  return a;
}
template <typename T>
T POP(pqg<T> &que) {
  T a = que.top();
  que.pop();
  return a;
}
template <typename T>
T POP(vc<T> &que) {
  T a = que.back();
  que.pop_back();
  return a;
}

template <typename F>
ll binary_search(F check, ll ok, ll ng, bool check_ok = true) {
  if (check_ok) assert(check(ok));
  while (abs(ok - ng) > 1) {
    auto x = (ng + ok) / 2;
    (check(x) ? ok : ng) = x;
  }
  return ok;
}
template <typename F>
double binary_search_real(F check, double ok, double ng, int iter = 100) {
  FOR(iter) {
    double x = (ok + ng) / 2;
    (check(x) ? ok : ng) = x;
  }
  return (ok + ng) / 2;
}

template <class T, class S>
inline bool chmax(T &a, const S &b) {
  return (a < b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chmin(T &a, const S &b) {
  return (a > b ? a = b, 1 : 0);
}

// ? は -1
vc<int> s_to_vi(const string &S, char first_char) {
  vc<int> A(S.size());
  FOR(i, S.size()) { A[i] = (S[i] != '?' ? S[i] - first_char : -1); }
  return A;
}

template <typename T, typename U>
vector<T> cumsum(vector<U> &A, int off = 1) {
  int N = A.size();
  vector<T> B(N + 1);
  FOR(i, N) { B[i + 1] = B[i] + A[i]; }
  if (off == 0) B.erase(B.begin());
  return B;
}

// stable sort
template <typename T>
vector<int> argsort(const vector<T> &A) {
  vector<int> ids(len(A));
  iota(all(ids), 0);
  sort(all(ids), [&](int i, int j) { return (A[i] == A[j] ? i < j : A[i] < A[j]); });
  return ids;
}

// A[I[0]], A[I[1]], ...
template <typename T>
vc<T> rearrange(const vc<T> &A, const vc<int> &I) {
  vc<T> B(len(I));
  FOR(i, len(I)) B[i] = A[I[i]];
  return B;
}

template <typename T, typename... Vectors>
void concat(vc<T> &first, const Vectors &... others) {
  vc<T> &res = first;
  (res.insert(res.end(), others.begin(), others.end()), ...);
}
#endif
#line 1 "/home/maspy/compro/library/other/io.hpp"
#define FASTIO
#include <unistd.h>

// https://judge.yosupo.jp/submission/21623
namespace fastio {
static constexpr uint32_t SZ = 1 << 17;
char ibuf[SZ];
char obuf[SZ];
char out[100];
// pointer of ibuf, obuf
uint32_t pil = 0, pir = 0, por = 0;

struct Pre {
  char num[10000][4];
  constexpr Pre() : num() {
    for (int i = 0; i < 10000; i++) {
      int n = i;
      for (int j = 3; j >= 0; j--) {
        num[i][j] = n % 10 | '0';
        n /= 10;
      }
    }
  }
} constexpr pre;

inline void load() {
  memcpy(ibuf, ibuf + pil, pir - pil);
  pir = pir - pil + fread(ibuf + pir - pil, 1, SZ - pir + pil, stdin);
  pil = 0;
  if (pir < SZ) ibuf[pir++] = '\n';
}

inline void flush() {
  fwrite(obuf, 1, por, stdout);
  por = 0;
}

void rd(char &c) {
  do {
    if (pil + 1 > pir) load();
    c = ibuf[pil++];
  } while (isspace(c));
}

void rd(string &x) {
  x.clear();
  char c;
  do {
    if (pil + 1 > pir) load();
    c = ibuf[pil++];
  } while (isspace(c));
  do {
    x += c;
    if (pil == pir) load();
    c = ibuf[pil++];
  } while (!isspace(c));
}

template <typename T>
void rd_real(T &x) {
  string s;
  rd(s);
  x = stod(s);
}

template <typename T>
void rd_integer(T &x) {
  if (pil + 100 > pir) load();
  char c;
  do
    c = ibuf[pil++];
  while (c < '-');
  bool minus = 0;
  if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
    if (c == '-') { minus = 1, c = ibuf[pil++]; }
  }
  x = 0;
  while ('0' <= c) { x = x * 10 + (c & 15), c = ibuf[pil++]; }
  if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
    if (minus) x = -x;
  }
}

void rd(int &x) { rd_integer(x); }
void rd(ll &x) { rd_integer(x); }
void rd(i128 &x) { rd_integer(x); }
void rd(u32 &x) { rd_integer(x); }
void rd(u64 &x) { rd_integer(x); }
void rd(u128 &x) { rd_integer(x); }
void rd(double &x) { rd_real(x); }
void rd(long double &x) { rd_real(x); }
void rd(f128 &x) { rd_real(x); }

template <class T, class U>
void rd(pair<T, U> &p) {
  return rd(p.first), rd(p.second);
}
template <size_t N = 0, typename T>
void rd_tuple(T &t) {
  if constexpr (N < std::tuple_size<T>::value) {
    auto &x = std::get<N>(t);
    rd(x);
    rd_tuple<N + 1>(t);
  }
}
template <class... T>
void rd(tuple<T...> &tpl) {
  rd_tuple(tpl);
}

template <size_t N = 0, typename T>
void rd(array<T, N> &x) {
  for (auto &d: x) rd(d);
}
template <class T>
void rd(vc<T> &x) {
  for (auto &d: x) rd(d);
}

void read() {}
template <class H, class... T>
void read(H &h, T &... t) {
  rd(h), read(t...);
}

void wt(const char c) {
  if (por == SZ) flush();
  obuf[por++] = c;
}
void wt(const string s) {
  for (char c: s) wt(c);
}
void wt(const char *s) {
  size_t len = strlen(s);
  for (size_t i = 0; i < len; i++) wt(s[i]);
}

template <typename T>
void wt_integer(T x) {
  if (por > SZ - 100) flush();
  if (x < 0) { obuf[por++] = '-', x = -x; }
  int outi;
  for (outi = 96; x >= 10000; outi -= 4) {
    memcpy(out + outi, pre.num[x % 10000], 4);
    x /= 10000;
  }
  if (x >= 1000) {
    memcpy(obuf + por, pre.num[x], 4);
    por += 4;
  } else if (x >= 100) {
    memcpy(obuf + por, pre.num[x] + 1, 3);
    por += 3;
  } else if (x >= 10) {
    int q = (x * 103) >> 10;
    obuf[por] = q | '0';
    obuf[por + 1] = (x - q * 10) | '0';
    por += 2;
  } else
    obuf[por++] = x | '0';
  memcpy(obuf + por, out + outi + 4, 96 - outi);
  por += 96 - outi;
}

template <typename T>
void wt_real(T x) {
  ostringstream oss;
  oss << fixed << setprecision(15) << double(x);
  string s = oss.str();
  wt(s);
}

void wt(int x) { wt_integer(x); }
void wt(ll x) { wt_integer(x); }
void wt(i128 x) { wt_integer(x); }
void wt(u32 x) { wt_integer(x); }
void wt(u64 x) { wt_integer(x); }
void wt(u128 x) { wt_integer(x); }
void wt(double x) { wt_real(x); }
void wt(long double x) { wt_real(x); }
void wt(f128 x) { wt_real(x); }

template <class T, class U>
void wt(const pair<T, U> val) {
  wt(val.first);
  wt(' ');
  wt(val.second);
}
template <size_t N = 0, typename T>
void wt_tuple(const T t) {
  if constexpr (N < std::tuple_size<T>::value) {
    if constexpr (N > 0) { wt(' '); }
    const auto x = std::get<N>(t);
    wt(x);
    wt_tuple<N + 1>(t);
  }
}
template <class... T>
void wt(tuple<T...> tpl) {
  wt_tuple(tpl);
}
template <class T, size_t S>
void wt(const array<T, S> val) {
  auto n = val.size();
  for (size_t i = 0; i < n; i++) {
    if (i) wt(' ');
    wt(val[i]);
  }
}
template <class T>
void wt(const vector<T> val) {
  auto n = val.size();
  for (size_t i = 0; i < n; i++) {
    if (i) wt(' ');
    wt(val[i]);
  }
}

void print() { wt('\n'); }
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
  wt(head);
  if (sizeof...(Tail)) wt(' ');
  print(forward<Tail>(tail)...);
}

// gcc expansion. called automaticall after main.
void __attribute__((destructor)) _d() { flush(); }
} // namespace fastio
using fastio::read;
using fastio::print;
using fastio::flush;

#if defined(LOCAL)
#define SHOW(...) SHOW_IMPL(__VA_ARGS__, SHOW6, SHOW5, SHOW4, SHOW3, SHOW2, SHOW1)(__VA_ARGS__)
#define SHOW_IMPL(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define SHOW1(x) print(#x, "=", (x)), flush()
#define SHOW2(x, y) print(#x, "=", (x), #y, "=", (y)), flush()
#define SHOW3(x, y, z) print(#x, "=", (x), #y, "=", (y), #z, "=", (z)), flush()
#define SHOW4(x, y, z, w) print(#x, "=", (x), #y, "=", (y), #z, "=", (z), #w, "=", (w)), flush()
#define SHOW5(x, y, z, w, v) print(#x, "=", (x), #y, "=", (y), #z, "=", (z), #w, "=", (w), #v, "=", (v)), flush()
#define SHOW6(x, y, z, w, v, u) print(#x, "=", (x), #y, "=", (y), #z, "=", (z), #w, "=", (w), #v, "=", (v), #u, "=", (u)), flush()
#else
#define SHOW(...)
#endif

#define INT(...)   \
  int __VA_ARGS__; \
  read(__VA_ARGS__)
#define LL(...)   \
  ll __VA_ARGS__; \
  read(__VA_ARGS__)
#define U32(...)   \
  u32 __VA_ARGS__; \
  read(__VA_ARGS__)
#define U64(...)   \
  u64 __VA_ARGS__; \
  read(__VA_ARGS__)
#define STR(...)      \
  string __VA_ARGS__; \
  read(__VA_ARGS__)
#define CHAR(...)   \
  char __VA_ARGS__; \
  read(__VA_ARGS__)
#define DBL(...)      \
  double __VA_ARGS__; \
  read(__VA_ARGS__)

#define VEC(type, name, size) \
  vector<type> name(size);    \
  read(name)
#define VV(type, name, h, w)                     \
  vector<vector<type>> name(h, vector<type>(w)); \
  read(name)

void YES(bool t = 1) { print(t ? "YES" : "NO"); }
void NO(bool t = 1) { YES(!t); }
void Yes(bool t = 1) { print(t ? "Yes" : "No"); }
void No(bool t = 1) { Yes(!t); }
void yes(bool t = 1) { print(t ? "yes" : "no"); }
void no(bool t = 1) { yes(!t); }
#line 3 "main.cpp"

#line 2 "/home/maspy/compro/library/geo/base.hpp"
template <typename T>
struct Point {
  T x, y;

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

  template <typename A, typename B>
  Point(A x, B y) : x(x), y(y) {}

  template <typename A, typename B>
  Point(pair<A, B> p) : x(p.fi), y(p.se) {}

  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;
  }
  Point operator+(Point p) const { return {x + p.x, y + p.y}; }
  Point operator-(Point p) const { return {x - p.x, y - p.y}; }
  bool operator==(Point p) const { return x == p.x && y == p.y; }
  bool operator!=(Point p) const { return x != p.x || y != p.y; }
  Point operator-() const { return {-x, -y}; }
  Point operator*(T t) const { return {x * t, y * t}; }
  Point operator/(T t) const { return {x / t, y / t}; }

  bool operator<(Point p) const {
    if (x != p.x) return x < p.x;
    return y < p.y;
  }
  T dot(const Point& other) const { return x * other.x + y * other.y; }
  T det(const Point& other) const { return x * other.y - y * other.x; }

  double norm() { return sqrtl(x * x + y * y); }
  double angle() { return atan2(y, x); }

  Point rotate(double theta) {
    static_assert(!is_integral<T>::value);
    double c = cos(theta), s = sin(theta);
    return Point{c * x - s * y, s * x + c * y};
  }
  Point rot90(bool ccw) { return (ccw ? Point{-y, x} : Point{y, -x}); }
};

#ifdef FASTIO
template <typename T>
void rd(Point<T>& p) {
  fastio::rd(p.x), fastio::rd(p.y);
}
template <typename T>
void wt(Point<T>& p) {
  fastio::wt(p.x);
  fastio::wt(' ');
  fastio::wt(p.y);
}
#endif

// A -> B -> C と進むときに、左に曲がるならば +1、右に曲がるならば -1
template <typename T>
int ccw(Point<T> A, Point<T> B, Point<T> C) {
  T x = (B - A).det(C - A);
  if (x > 0) return 1;
  if (x < 0) return -1;
  return 0;
}

template <typename REAL, typename T, typename U>
REAL dist(Point<T> A, Point<U> B) {
  REAL dx = REAL(A.x) - REAL(B.x);
  REAL dy = REAL(A.y) - REAL(B.y);
  return sqrt(dx * dx + dy * dy);
}

// ax+by+c
template <typename T>
struct Line {
  T a, b, c;

  Line(T a, T b, T c) : a(a), b(b), c(c) {}
  Line(Point<T> A, Point<T> B) { a = A.y - B.y, b = B.x - A.x, c = A.x * B.y - A.y * B.x; }
  Line(T x1, T y1, T x2, T y2) : Line(Point<T>(x1, y1), Point<T>(x2, y2)) {}

  template <typename U>
  U eval(Point<U> P) {
    return a * P.x + b * P.y + c;
  }

  template <typename U>
  T eval(U x, U y) {
    return a * x + b * y + c;
  }

  // 同じ直線が同じ a,b,c で表現されるようにする
  void normalize() {
    static_assert(is_same_v<T, int> || is_same_v<T, long long>);
    T g = gcd(gcd(abs(a), abs(b)), abs(c));
    a /= g, b /= g, c /= g;
    if (b < 0) { a = -a, b = -b, c = -c; }
    if (b == 0 && a < 0) { a = -a, b = -b, c = -c; }
  }

  bool is_parallel(Line other) { return a * other.b - b * other.a == 0; }
  bool is_orthogonal(Line other) { return a * other.a + b * other.b == 0; }
};

template <typename T>
struct Segment {
  Point<T> A, B;

  Segment(Point<T> A, Point<T> B) : A(A), B(B) {}
  Segment(T x1, T y1, T x2, T y2) : Segment(Point<T>(x1, y1), Point<T>(x2, y2)) {}

  bool contain(Point<T> C) {
    T det = (C - A).det(B - A);
    if (det != 0) return 0;
    return (C - A).dot(B - A) >= 0 && (C - B).dot(A - B) >= 0;
  }

  Line<T> to_Line() { return Line(A, B); }
};

template <typename REAL>
struct Circle {
  Point<REAL> O;
  REAL r;
  Circle(Point<REAL> O, REAL r) : O(O), r(r) {}
  Circle(REAL x, REAL y, REAL r) : O(x, y), r(r) {}
  template <typename T>
  bool contain(Point<T> p) {
    REAL dx = p.x - O.x, dy = p.y - O.y;
    return dx * dx + dy * dy <= r * r;
  }
};
#line 2 "/home/maspy/compro/library/geo/cross_point.hpp"

#line 4 "/home/maspy/compro/library/geo/cross_point.hpp"

// 平行でないことを仮定
template <typename REAL, typename T>
Point<REAL> cross_point(const Line<T> L1, const Line<T> L2) {
  T det = L1.a * L2.b - L1.b * L2.a;
  assert(det != 0);
  REAL x = -REAL(L1.c) * L2.b + REAL(L1.b) * L2.c;
  REAL y = -REAL(L1.a) * L2.c + REAL(L1.c) * L2.a;
  return Point<REAL>(x / det, y / det);
}

// 浮動小数点数はエラー
// 0: 交点なし
// 1: 一意な交点
// 2:2 つ以上の交点(整数型を利用して厳密にやる)
template <typename T>
int count_cross(Segment<T> S1, Segment<T> S2, bool include_ends) {
  static_assert(!std::is_floating_point<T>::value);
  Line<T> L1 = S1.to_Line();
  Line<T> L2 = S2.to_Line();
  if (L1.is_parallel(L2)) {
    if (L1.eval(S2.A) != 0) return 0;
    // 4 点とも同一直線上にある
    T a1 = S1.A.x, b1 = S1.B.x;
    T a2 = S2.A.x, b2 = S2.B.x;
    if (a1 == b1) {
      a1 = S1.A.y, b1 = S1.B.y;
      a2 = S2.A.y, b2 = S2.B.y;
    }
    if (a1 > b1) swap(a1, b1);
    if (a2 > b2) swap(a2, b2);
    T a = max(a1, a2);
    T b = min(b1, b2);
    if (a < b) return 2;
    if (a > b) return 0;
    return (include_ends ? 1 : 0);
  }
  // 平行でない場合
  T a1 = L2.eval(S1.A), b1 = L2.eval(S1.B);
  T a2 = L1.eval(S2.A), b2 = L1.eval(S2.B);
  if (a1 > b1) swap(a1, b1);
  if (a2 > b2) swap(a2, b2);
  bool ok1 = 0, ok2 = 0;

  if (include_ends) {
    ok1 = (a1 <= T(0)) && (T(0) <= b1);
    ok2 = (a2 <= T(0)) && (T(0) <= b2);
  } else {
    ok1 = (a1 < T(0)) && (T(0) < b1);
    ok2 = (a2 < T(0)) && (T(0) < b2);
  }
  return (ok1 && ok2 ? 1 : 0);
}

// https://codeforces.com/contest/607/problem/E
template <typename REAL, typename T>
vc<Point<REAL>> cross_point(const Circle<T> C, const Line<T> L) {
  T a = L.a, b = L.b, c = L.a * (C.O.x) + L.b * (C.O.y) + L.c;
  T r = C.r;
  bool SW = 0;
  if (abs(a) < abs(b)) {
    swap(a, b);
    SW = 1;
  }
  // ax+by+c=0, x^2+y^2=r^2
  T D = 4 * c * c * b * b - 4 * (a * a + b * b) * (c * c - a * a * r * r);
  if (D < 0) return {};
  REAL sqD = sqrtl(D);
  REAL y1 = (-2 * b * c + sqD) / (2 * (a * a + b * b));
  REAL y2 = (-2 * b * c - sqD) / (2 * (a * a + b * b));
  REAL x1 = (-b * y1 - c) / a;
  REAL x2 = (-b * y2 - c) / a;
  if (SW) swap(x1, y1), swap(x2, y2);
  x1 += C.O.x, x2 += C.O.x;
  y1 += C.O.y, y2 += C.O.y;
  if (D == 0) return {Point<REAL>(x1, y1)};
  return {Point<REAL>(x1, y1), Point<REAL>(x2, y2)};
}

// https://codeforces.com/contest/2/problem/C
template <typename REAL, typename T>
tuple<bool, Point<T>, Point<T>> cross_point_circle(Circle<T> C1, Circle<T> C2) {
  using P = Point<T>;
  P O{0, 0};
  P A = C1.O, B = C2.O;
  if (A == B) return {false, O, O};
  T d = (B - A).norm();
  REAL cos_val = (C1.r * C1.r + d * d - C2.r * C2.r) / (2 * C1.r * d);
  if (cos_val < -1 || 1 < cos_val) return {false, O, O};
  REAL t = acos(cos_val);
  REAL u = (B - A).angle();
  P X = A + P{C1.r * cos(u + t), C1.r * sin(u + t)};
  P Y = A + P{C1.r * cos(u - t), C1.r * sin(u - t)};
  return {true, X, Y};
}
#line 3 "/home/maspy/compro/library/geo/polygon.hpp"

template <typename T>
struct Polygon {
  vc<Point<T>> point;
  T a;

  Polygon(vc<Point<T>> point) : point(point) { build(); }

  int size() { return len(point); }

  template <typename REAL>
  REAL area() {
    return a * 0.5;
  }

  T area_2() { return a; }

  bool is_convex() {
    FOR(j, len(point)) {
      int i = (j == 0 ? len(point) - 1 : j - 1);
      int k = (j == len(point) - 1 ? 0 : j + 1);
      if ((point[j] - point[i]).det(point[k] - point[j]) < 0) return false;
    }
    return true;
  }

  // 中:1, 境界:0, 外:-1.
  int side(Point<T> p) {
    int n = len(point);
    FOR(i, n) if (point[i] == p) return 0;
    FOR(i, n) {
      Point<T> A = point[i], B = point[(i + 1) % n];
      if ((p - A).det(B - A) != 0) continue;
      if ((p - A).dot(B - A) >= 0 && (p - B).dot(A - B) >= 0) return 0;
    }
    // p から x 方向に (+1, +eps) 方向にのびる半直線との交差を考える
    int cnt = 0;
    FOR(i, n) {
      Point<T> A = point[i], B = point[(i + 1) % n];
      FOR(2) {
        swap(A, B);
        if (A.y > p.y) continue;
        if (B.y <= p.y) continue;
        if ((A - p).det(B - p) > 0) ++cnt;
      }
    }
    return (cnt % 2 == 0 ? -1 : 1);
  }

  // point[i] の近傍だけで見た side
  // https://github.com/maspypy/library/blob/main/geo/polygon_side.png
  int side_at(int i, Point<T> p) {
    int n = len(point);
    p -= point[i];
    if (p.x == T(0) && p.y == T(0)) return 0;
    Point<T> L = point[(i + 1) % n] - point[i];
    Point<T> R = point[(i + n - 1) % n] - point[i];
    auto sgn = [&](T x) -> int {
      if (x == T(0)) return 0;
      return (x > T(0) ? 1 : -1);
    };
    int x = sgn(L.det(p)) + sgn(p.det(R)) + sgn(R.det(L));
    if (x == 0) return x;
    return (x > 0 ? 1 : -1);
  }

  // 線分が内部・外部それぞれを通るか
  // https://atcoder.jp/contests/jag2016-domestic/tasks/jag2016secretspring_e
  // https://atcoder.jp/contests/JAG2014Spring/tasks/icpc2014spring_f
  pair<bool, bool> side_segment(Point<T> L, Point<T> R) {
    Segment<T> S(L, R);
    // まず線分と非自明に交わるパターン
    int n = len(point);
    FOR(i, n) {
      Segment<T> S2(point[i], point[(i + 1) % n]);
      if (count_cross(S, S2, false) == 1) { return {1, 1}; }
    }
    bool in = 0, out = 0;
    if (side(L) == 1 || side(R) == 1) in = 1;
    if (side(L) == -1 || side(R) == -1) out = 1;
    FOR(i, n) {
      if (!S.contain(point[i])) continue;
      for (auto& p: {L, R}) {
        int k = side_at(i, p);
        if (k == 1) in = 1;
        if (k == -1) out = 1;
      }
    }
    return {in, out};
  }

private:
  void build() {
    a = 0;
    FOR(i, len(point)) {
      int j = (i + 1 == len(point) ? 0 : i + 1);
      a += point[i].det(point[j]);
    }
    assert(a > 0);
  }
};
#line 2 "/home/maspy/compro/library/geo/angle_sort.hpp"

#line 4 "/home/maspy/compro/library/geo/angle_sort.hpp"

// lower: -1, origin: 0, upper: 1
template <typename T>
int lower_or_upper(const Point<T>& p) {
  if (p.y != 0) return (p.y > 0 ? 1 : -1);
  if (p.x > 0) return -1;
  if (p.x < 0) return 1;
  return 0;
}

// L<R:-1, L==R:0, L>R:1
template <typename T>
int angle_comp_3(const Point<T>& L, const Point<T>& R) {
  int a = lower_or_upper(L), b = lower_or_upper(R);
  if (a != b) return (a < b ? -1 : +1);
  T det = L.det(R);
  if (det > 0) return -1;
  if (det < 0) return 1;
  return 0;
}
// 偏角ソートに対する argsort
template <typename T>
vector<int> angle_sort(vector<Point<T>>& P) {
  vc<int> I(len(P));
  FOR(i, len(P)) I[i] = i;
  sort(all(I), [&](auto& L, auto& R) -> bool { return angle_comp_3(P[L], P[R]) == -1; });
  return I;
}

// 偏角ソートに対する argsort
template <typename T>
vector<int> angle_sort(vector<pair<T, T>>& P) {
  vc<Point<T>> tmp(len(P));
  FOR(i, len(P)) tmp[i] = Point<T>(P[i]);
  return angle_sort<T>(tmp);
}
#line 6 "main.cpp"
using P = Point<ll>;

void solve() {
  LL(N);
  VEC(P, A, N);
  Polygon<ll> poly(A);
  LL(W, C);

  vc<int> FRM, TO;
  vc<P> DIR;

  FOR(i, N) FOR(j, N) {
    if (i == j) continue;
    bool ok = 1;
    if (poly.side_segment(A[i], A[j]).se) ok = 0;
    FOR(k, N) {
      if (k == i || k == j) continue;
      if ((A[i] - A[j]).det(A[i] - A[k]) != 0) continue;
      P d = A[i] - A[j];
      ll a = d.dot(A[i]);
      ll b = d.dot(A[j]);
      ll c = d.dot(A[k]);
      if (a < c && c < b) ok = 0;
      if (b < c && c < a) ok = 0;
    }
    if (!ok) continue;
    SHOW(i, j);
    FRM.eb(i), TO.eb(j), DIR.eb(A[j] - A[i]);
  }
  {
    vc<int> I(len(FRM));
    iota(all(I), 0);
    sort(all(I), [&](auto& i, auto& j) -> bool {
      int k = angle_comp_3(DIR[i], DIR[j]);
      if (k != 0) return k == -1;
      P d = A[TO[i]] - A[FRM[i]];
      return d.dot(A[FRM[i]]) < d.dot(A[FRM[j]]);
    });
    FRM = rearrange(FRM, I);
    TO = rearrange(TO, I);
  }

  int M = len(FRM);
  vv(int, idx, N, N, -1);
  FOR(i, M) idx[FRM[i]][TO[i]] = i;

  FOR(i, M) FRM.eb(FRM[i]);
  FOR(i, M) TO.eb(TO[i]);

  /*
  辺の寄与
  2(area)+W
  */

  // closed
  vv(ll, dp, N, N);
  FOR_R(L, N) FOR(R, L + 1, N) {
    vi sub1(N, -infty<ll>);
    vi sub2(N, -infty<ll>);
    // R -> L
    // L -> R 直行は禁止
    sub1[L] = A[R].det(A[L]) + C + W;
    int p = idx[R][L];
    if (p != -1) {
      // positive area を保証する必要がある!
      FOR(i, p + 1, p + M) {
        int a = FRM[i], b = TO[i];
        if (a > b) continue;
        ll add = dp[a + 1][b - 1] + W + A[a].det(A[b]);
        if (ccw(A[L], A[R], A[b]) == 0) {
          chmax(sub1[b], sub1[a] + add);
          chmax(sub2[b], sub2[a] + add);
        } else {
          chmax(sub2[b], sub1[a] + add);
          chmax(sub2[b], sub2[a] + add);
        }
      }
    }
    SHOW(L, R, sub1, sub2);
    chmax(dp[L][R], sub2[R]);

    FOR(M, L, R) { chmax(dp[L][R], dp[L][M] + dp[M + 1][R]); }
    SHOW(L, R, dp[L][R]);
  }

  ll ANS = dp[0][N - 1];
  print(ANS);
}

signed main() { solve(); }

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3932kb

input:

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

output:

16

result:

ok 1 number(s): "16"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3580kb

input:

12
0 0
1 1
2 0
4 1
5 0
5 1
8 0
9 1
10 0
11 1
5 5
1 4
3 1000000

output:

3000063

result:

ok 1 number(s): "3000063"

Test #3:

score: 0
Accepted
time: 1ms
memory: 3724kb

input:

12
0 0
1 1
2 0
4 1
5 0
5 1
8 0
9 1
10 0
11 1
5 5
1 4
0 9

output:

61

result:

ok 1 number(s): "61"

Test #4:

score: 0
Accepted
time: 0ms
memory: 4004kb

input:

7
0 20
40 0
40 20
70 50
50 70
30 50
0 50
8 12

output:

3980

result:

ok 1 number(s): "3980"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3704kb

input:

3
0 2017
-2017 -2017
2017 0
1 12

output:

12204882

result:

ok 1 number(s): "12204882"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3936kb

input:

3
4 0
0 3
0 0
10 11

output:

53

result:

ok 1 number(s): "53"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

3
-10 0
10 0
0 18
3 10

output:

379

result:

ok 1 number(s): "379"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3940kb

input:

4
0 0
-10 0
-10 -10
0 -10
11 9

output:

253

result:

ok 1 number(s): "253"

Test #9:

score: 0
Accepted
time: 0ms
memory: 3680kb

input:

4
-100 0
0 -100
100 0
0 100
4 9

output:

40025

result:

ok 1 number(s): "40025"

Test #10:

score: 0
Accepted
time: 0ms
memory: 3964kb

input:

4
0 0
10 5
20 0
10 10
13 8

output:

97

result:

ok 1 number(s): "97"

Test #11:

score: 0
Accepted
time: 0ms
memory: 3972kb

input:

4
0 0
20 0
30 10
10 10
6 7

output:

431

result:

ok 1 number(s): "431"

Test #12:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

4
-100 -10
100 -10
100 10
-100 10
15 7

output:

8067

result:

ok 1 number(s): "8067"

Test #13:

score: 0
Accepted
time: 0ms
memory: 3696kb

input:

4
0 0
100 0
60 30
0 30
14 7

output:

4863

result:

ok 1 number(s): "4863"

Test #14:

score: 0
Accepted
time: 0ms
memory: 3996kb

input:

4
0 0
100 0
60 30
40 30
7 7

output:

3635

result:

ok 1 number(s): "3635"

Test #15:

score: 0
Accepted
time: 0ms
memory: 4008kb

input:

7
0 0
10 10
20 0
30 11
20 22
10 11
0 22
15 6

output:

777

result:

ok 1 number(s): "777"

Test #16:

score: 0
Accepted
time: 0ms
memory: 3716kb

input:

10
0 0
10 10
20 0
30 10
40 0
40 21
30 11
20 21
10 11
0 21
8 5

output:

935

result:

ok 1 number(s): "935"

Test #17:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

7
0 0
50 50
80 20
110 50
70 90
40 60
0 100
1 5

output:

8217

result:

ok 1 number(s): "8217"

Test #18:

score: 0
Accepted
time: 1ms
memory: 3604kb

input:

16
0 0
20 0
20 10
40 10
40 20
60 20
60 30
70 30
70 40
50 40
50 30
30 30
30 20
10 20
10 10
0 10
10 4

output:

1576

result:

ok 1 number(s): "1576"

Test #19:

score: 0
Accepted
time: 0ms
memory: 4020kb

input:

12
0 0
400 0
400 500
0 500
0 200
200 200
200 300
100 300
100 400
300 400
300 100
0 100
3 3

output:

160045

result:

ok 1 number(s): "160045"

Test #20:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

10
0 500
-10 20
-350 350
-20 0
-350 -350
0 -20
350 -350
20 0
350 350
10 20
11 3

output:

31594

result:

ok 1 number(s): "31594"

Test #21:

score: 0
Accepted
time: 0ms
memory: 3972kb

input:

8
0 0
20 -10
40 0
40 5
60 0
60 -5
80 0
40 20
98 44

output:

2172

result:

ok 1 number(s): "2172"

Test #22:

score: 0
Accepted
time: 1ms
memory: 3704kb

input:

10
0 0
20 -10
40 0
45 0
40 5
60 0
65 0
60 -5
80 0
40 20
76 73

output:

2029

result:

ok 1 number(s): "2029"

Test #23:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

4
0 0
50 -20
100 0
50 20
57 77

output:

4305

result:

ok 1 number(s): "4305"

Test #24:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

8
0 0
0 10
-10 0
50 -20
110 0
100 10
100 0
50 -10
72 60

output:

1424

result:

ok 1 number(s): "1424"

Test #25:

score: 0
Accepted
time: 0ms
memory: 3736kb

input:

8
100 90
90 100
-90 100
-100 90
-100 -90
-90 -100
90 -100
100 -90
1014818403091 6142309236000

output:

20403165768728

result:

ok 1 number(s): "20403165768728"

Test #26:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

8
0 0
10 100
90 100
100 0
100 201
90 101
10 101
0 201
2554103132320 5961656865249

output:

32356138793098

result:

ok 1 number(s): "32356138793098"

Test #27:

score: 0
Accepted
time: 0ms
memory: 3968kb

input:

8
0 0
100 100
900 100
1000 0
1000 210
900 110
100 110
0 210
744569926410 2151448654813

output:

10259456764906

result:

ok 1 number(s): "10259456764906"

Test #28:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

3
1000000 -1000000
1000000 1000000
-1000000 -1000000
8943626655093 6304386590908

output:

37135266556187

result:

ok 1 number(s): "37135266556187"

Test #29:

score: 0
Accepted
time: 0ms
memory: 3980kb

input:

4
1000000 -1000000
1000000 1000000
1 0
-1000000 -1000000
7138388416478 453029559705

output:

23868194809139

result:

ok 1 number(s): "23868194809139"

Test #30:

score: 0
Accepted
time: 0ms
memory: 4000kb

input:

4
1000000 -1000000
1000000 1000000
0 1
-1000000 -1000000
5337445145160 4610262463095

output:

29960045043735

result:

ok 1 number(s): "29960045043735"

Test #31:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

16
0 0
10 -5
20 0
30 15
40 0
45 10
40 20
25 30
40 40
30 45
20 40
10 25
0 40
-5 30
0 20
15 10
87 175

output:

3692

result:

ok 1 number(s): "3692"

Test #32:

score: 0
Accepted
time: 1089ms
memory: 4392kb

input:

200
-28269 899556
-1000000 898443
-82904 896173
-112799 892903
-1000000 889060
-167758 884227
-196328 878325
-1000000 872613
-248497 865014
-277258 856229
-1000000 847703
-331311 836799
-354953 827048
-1000000 815109
-407788 802314
-431209 789973
-1000000 776039
-479961 761338
-503639 745887
-100000...

output:

5557019453556

result:

ok 1 number(s): "5557019453556"

Test #33:

score: 0
Accepted
time: 1009ms
memory: 4328kb

input:

200
-28269 899556
-1000000 898443
-82904 896173
-112799 892903
-1000000 889060
-167758 884227
-196328 878325
-1000000 872613
-248497 865014
-277258 856229
-1000000 847703
-331311 836799
-354953 827048
-1000000 815109
-407788 802314
-431209 789973
-1000000 776039
-479961 761338
-503639 745887
-100000...

output:

2005314995763087

result:

ok 1 number(s): "2005314995763087"

Test #34:

score: 0
Accepted
time: 1089ms
memory: 4508kb

input:

200
-28269 899556
-1000000 898443
-82904 896173
-112799 892903
-1000000 889060
-167758 884227
-196328 878325
-1000000 872613
-248497 865014
-277258 856229
-1000000 847703
-331311 836799
-354953 827048
-1000000 815109
-407788 802314
-431209 789973
-1000000 776039
-479961 761338
-503639 745887
-100000...

output:

5572019453556

result:

ok 1 number(s): "5572019453556"

Test #35:

score: 0
Accepted
time: 979ms
memory: 4568kb

input:

200
-28269 899556
-1000000 898443
-82904 896173
-112799 892903
-1000000 889060
-167758 884227
-196328 878325
-1000000 872613
-248497 865014
-277258 856229
-1000000 847703
-331311 836799
-354953 827048
-1000000 815109
-407788 802314
-431209 789973
-1000000 776039
-479961 761338
-503639 745887
-100000...

output:

665271354693353

result:

ok 1 number(s): "665271354693353"

Test #36:

score: 0
Accepted
time: 1013ms
memory: 4800kb

input:

200
-28269 899556
-1000000 898443
-82904 896173
-112799 892903
-1000000 889060
-167758 884227
-196328 878325
-1000000 872613
-248497 865014
-277258 856229
-1000000 847703
-331311 836799
-354953 827048
-1000000 815109
-407788 802314
-431209 789973
-1000000 776039
-479961 761338
-503639 745887
-100000...

output:

2005334495763087

result:

ok 1 number(s): "2005334495763087"

Test #37:

score: 0
Accepted
time: 4560ms
memory: 5056kb

input:

200
-28269 899556
-52917 898443
-82904 896173
-112799 892903
-139901 889060
-167758 884227
-196328 878325
-220331 872613
-248497 865014
-277258 856229
-302321 847703
-331311 836799
-354953 827048
-381571 815109
-407788 802314
-431209 789973
-455810 776039
-479961 761338
-503639 745887
-529006 728115...

output:

5088495699259

result:

ok 1 number(s): "5088495699259"

Test #38:

score: 0
Accepted
time: 4470ms
memory: 5036kb

input:

200
-28269 899556
-52917 898443
-82904 896173
-112799 892903
-139901 889060
-167758 884227
-196328 878325
-220331 872613
-248497 865014
-277258 856229
-302321 847703
-331311 836799
-354953 827048
-381571 815109
-407788 802314
-431209 789973
-455810 776039
-479961 761338
-503639 745887
-529006 728115...

output:

2005088431002934

result:

ok 1 number(s): "2005088431002934"

Test #39:

score: 0
Accepted
time: 4582ms
memory: 5228kb

input:

200
-28269 899556
-52917 898443
-82904 896173
-112799 892903
-139901 889060
-167758 884227
-196328 878325
-220331 872613
-248497 865014
-277258 856229
-302321 847703
-331311 836799
-354953 827048
-381571 815109
-407788 802314
-431209 789973
-455810 776039
-479961 761338
-503639 745887
-529006 728115...

output:

5092681903172

result:

ok 1 number(s): "5092681903172"

Test #40:

score: 0
Accepted
time: 4188ms
memory: 4904kb

input:

200
-28269 899556
-52917 898443
-82904 896173
-112799 892903
-139901 889060
-167758 884227
-196328 878325
-220331 872613
-248497 865014
-277258 856229
-302321 847703
-331311 836799
-354953 827048
-381571 815109
-407788 802314
-431209 789973
-455810 776039
-479961 761338
-503639 745887
-529006 728115...

output:

664810489281149

result:

ok 1 number(s): "664810489281149"

Test #41:

score: 0
Accepted
time: 4479ms
memory: 5032kb

input:

200
-28269 899556
-52917 898443
-82904 896173
-112799 892903
-139901 889060
-167758 884227
-196328 878325
-220331 872613
-248497 865014
-277258 856229
-302321 847703
-331311 836799
-354953 827048
-381571 815109
-407788 802314
-431209 789973
-455810 776039
-479961 761338
-503639 745887
-529006 728115...

output:

2005092681903172

result:

ok 1 number(s): "2005092681903172"

Test #42:

score: 0
Accepted
time: 4667ms
memory: 5020kb

input:

200
-28269 899556
-52917 898443
-82904 896173
-112799 892903
-139901 889060
-167758 884227
-196328 878325
-220331 872613
-248497 865014
-277258 856229
-302321 847703
-331311 836799
-354953 827048
-381571 815109
-407788 802314
-431209 789973
-455810 776039
-479961 761338
-503639 745887
-529006 728115...

output:

5088525875819

result:

ok 1 number(s): "5088525875819"

Test #43:

score: 0
Accepted
time: 4569ms
memory: 5076kb

input:

200
-28269 899556
-52917 898443
-82904 896173
-112799 892903
-139901 889060
-167758 884227
-196328 878325
-220331 872613
-248497 865014
-277258 856229
-302321 847703
-331311 836799
-354953 827048
-381571 815109
-407788 802314
-431209 789973
-455810 776039
-479961 761338
-503639 745887
-529006 728115...

output:

2005088525875819

result:

ok 1 number(s): "2005088525875819"

Test #44:

score: 0
Accepted
time: 4712ms
memory: 5060kb

input:

200
-28269 899556
-52917 898443
-82904 896173
-112799 892903
-139901 889060
-167758 884227
-196328 878325
-220331 872613
-248497 865014
-277258 856229
-302321 847703
-331311 836799
-354953 827048
-381571 815109
-407788 802314
-431209 789973
-455810 776039
-479961 761338
-503639 745887
-529006 728115...

output:

5092574918440

result:

ok 1 number(s): "5092574918440"

Test #45:

score: 0
Accepted
time: 4307ms
memory: 5184kb

input:

200
-28269 899556
-52917 898443
-82904 896173
-112799 892903
-139901 889060
-167758 884227
-196328 878325
-220331 872613
-248497 865014
-277258 856229
-302321 847703
-331311 836799
-354953 827048
-381571 815109
-407788 802314
-431209 789973
-455810 776039
-479961 761338
-503639 745887
-529006 728115...

output:

664810594348813

result:

ok 1 number(s): "664810594348813"

Test #46:

score: 0
Accepted
time: 4608ms
memory: 5136kb

input:

200
-28269 899556
-52917 898443
-82904 896173
-112799 892903
-139901 889060
-167758 884227
-196328 878325
-220331 872613
-248497 865014
-277258 856229
-302321 847703
-331311 836799
-354953 827048
-381571 815109
-407788 802314
-431209 789973
-455810 776039
-479961 761338
-503639 745887
-529006 728115...

output:

2005092574918440

result:

ok 1 number(s): "2005092574918440"

Test #47:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

7
518696 -636578
950336 442522
302876 442522
302876 10882
-344584 -420758
-992044 -420758
-992044 -852398
116445681000 232891362001

output:

2352202756202

result:

ok 1 number(s): "2352202756202"

Test #48:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

9
620664 943262
-488556 784802
-805476 -7498
-330096 -7498
-330096 309422
-488556 467882
-13176 784802
145284 626342
620664 626342
50219143199 50219143201

output:

1054602007194

result:

ok 1 number(s): "1054602007194"

Test #49:

score: 0
Accepted
time: 0ms
memory: 4000kb

input:

10
454801 313356
454801 560156
-532399 560156
-532399 -427044
454801 -427044
454801 66556
208001 66556
208001 -180244
-285599 -180244
-285599 313356
15227559999 30455120001

output:

974563839994

result:

ok 1 number(s): "974563839994"

Test #50:

score: 0
Accepted
time: 0ms
memory: 3716kb

input:

10
558206 -457485
-307394 -457485
-307394 -24685
-740194 -24685
-740194 -890285
991006 -890285
991006 840915
-740194 840915
-740194 408115
558206 408115
46828960000 93657920000

output:

2997053440000

result:

ok 1 number(s): "2997053440000"

Test #51:

score: 0
Accepted
time: 1ms
memory: 3784kb

input:

20
-345132 915094
-663000 279358
-504066 199891
-265665 676693
529005 279358
52203 -674246
-583533 -356378
-504066 -197444
-27264 -435845
290604 199891
-186198 438292
-345132 120424
-186198 40957
-106731 199891
52203 120424
-106731 -197444
-583533 40957
-821934 -435845
131670 -912647
767406 358825
0 1

output:

1073550695135

result:

ok 1 number(s): "1073550695135"

Test #52:

score: 0
Accepted
time: 38ms
memory: 3836kb

input:

200
852583 618758
837229 414374
794698 -96480
846601 712925
760273 -243424
783704 38946
757468 -196509
714208 -264778
695590 1586
633718 -118353
553795 -111964
582991 -154377
742084 -469330
665857 -325845
495509 -268848
601126 -224715
354937 -69154
359383 -180745
395063 -389908
243919 98553
155683 1...

output:

2504957496988

result:

ok 1 number(s): "2504957496988"

Test #53:

score: 0
Accepted
time: 33ms
memory: 3848kb

input:

200
-333544 -574445
-598147 -622484
-651928 -640463
-393931 -49618
-490099 -271244
-292007 -398098
-240409 -149614
-247454 -305963
-253438 -323764
-118435 -240455
-197315 -594047
-15140 -579746
-118159 -673109
467618 -711356
113473 -681662
26929 -439208
-93416 -402067
146300 -432047
604463 -702830
7...

output:

2225109494386

result:

ok 1 number(s): "2225109494386"

Test #54:

score: 0
Accepted
time: 40ms
memory: 3904kb

input:

200
-850130 -428567
-948687 -693215
-899930 -670202
-921618 -771356
-729266 -756452
-981111 -837257
-760595 -952788
-473490 -797769
-782892 -692426
-356670 -457947
-700806 -644207
-440814 -483489
-451305 -170444
-433743 179092
-289982 150210
-158766 -61208
-212229 -216122
-103983 -134889
-192206 -33...

output:

2394339738288

result:

ok 1 number(s): "2394339738288"

Test #55:

score: 0
Accepted
time: 30ms
memory: 4104kb

input:

200
1190 -42537
2293 -227978
121063 -254089
-858960 -721280
-977550 -785473
-383367 -501206
-929516 -805268
-869777 -952376
-574475 -739319
357414 -217892
-9239 -446447
149086 -380029
-603359 -816368
157765 -383434
-247203 -655931
-33420 -537463
-240482 -673805
-484154 -800219
-667655 -835313
-84612...

output:

2920577530909

result:

ok 1 number(s): "2920577530909"

Test #56:

score: 0
Accepted
time: 33ms
memory: 4108kb

input:

200
-168789 690178
-8003 -46057
-54594 -36897
-218453 -482495
-68888 126351
-259901 -482636
-375176 -415580
-144630 45409
-238061 -59369
-185291 524494
-211058 648403
-314127 757485
-223281 358941
-344907 22644
-223659 151488
-374249 -102422
-273287 -188832
-436610 -94857
-394400 430038
-683315 7367...

output:

2041866643462

result:

ok 1 number(s): "2041866643462"

Test #57:

score: 0
Accepted
time: 37ms
memory: 3844kb

input:

200
790611 -684635
729859 -926030
489168 -824233
862308 -164636
516663 -771127
594003 -533755
762465 -164306
524572 -448052
679071 -143498
728610 -150785
862834 96562
876811 117742
320481 -435938
409137 -135179
281467 -124520
11643 -10704
409261 -80702
340384 380161
271513 731173
415675 243484
50159...

output:

2399652415448

result:

ok 1 number(s): "2399652415448"

Test #58:

score: 0
Accepted
time: 36ms
memory: 3784kb

input:

200
777747 -698137
723075 -653572
618141 -577950
710221 -858159
275109 -291453
70675 -75561
284841 -156373
20499 -5870
30269 23184
-47579 353193
-87797 489707
140476 -67290
66927 247794
525067 -548406
515683 -170281
518044 -216613
530779 -268842
689133 -281212
502780 -143973
274423 -45807
322000 -53...

output:

2893837439266

result:

ok 1 number(s): "2893837439266"

Test #59:

score: 0
Accepted
time: 40ms
memory: 3884kb

input:

200
-52910 -5942
-124591 -155673
-147550 -227088
-28447 -31274
-15584 16174
245546 266000
345933 316844
327996 316388
412898 399770
397140 305754
448821 474084
320652 -18342
29333 -128634
378993 221583
-54348 -186310
257469 -321024
345567 22644
464327 434876
489293 522483
418365 237693
406611 -17118...

output:

3011168852195

result:

ok 1 number(s): "3011168852195"

Test #60:

score: 0
Accepted
time: 42ms
memory: 4136kb

input:

200
-782773 21268
-745183 -282517
-736677 401251
-809827 154219
-749986 624349
-923173 466784
-826317 405125
-946126 88810
-969555 -361478
-779701 49708
-846240 -368909
-813169 -411913
-824400 -407654
-833002 -395645
-917716 -266813
-978484 -478694
-935905 -671219
-812101 -552670
-988852 -948638
-78...

output:

2508042528666

result:

ok 1 number(s): "2508042528666"

Test #61:

score: 0
Accepted
time: 40ms
memory: 3848kb

input:

200
854079 666859
823064 669517
286305 174275
247575 77053
341226 50476
405633 232205
542313 340399
598950 202433
583719 206260
543546 -277115
410157 -173956
490790 153073
366990 43654
210858 66551
410153 -261893
306702 -119810
217601 -119396
119382 34888
930110 823675
6305 -4664
495737 500443
55963...

output:

2644216355084

result:

ok 1 number(s): "2644216355084"

Test #62:

score: 0
Accepted
time: 0ms
memory: 4012kb

input:

6
-997537 933418
-843571 825280
-843571 -462692
990233 -462692
43457 202276
43457 933418
257474054511 514948109023

output:

3906732532556

result:

ok 1 number(s): "3906732532556"

Test #63:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

10
-134754 -104521
599242 -104521
599242 -100521
559242 -100521
456598 -28429
456598 834219
-805938 834219
-805938 830219
-765938 830219
-134754 386907
64164667143 128329334289

output:

1827690225050

result:

ok 1 number(s): "1827690225050"

Test #64:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

6
-197416 241873
-417908 241873
-417908 -499999
-420401 -508387
-402673 -508387
-402673 -448739
2788429363 5576858729

output:

180307417205

result:

ok 1 number(s): "180307417205"

Test #65:

score: 0
Accepted
time: 0ms
memory: 3696kb

input:

10
873392 -743532
734096 -743532
-647128 -333018
-647128 -327018
-667128 -327018
-667128 -774002
836616 -774002
853392 -778988
853392 -784988
873392 -784988
153443183824 306886367648

output:

2505394369984

result:

ok 1 number(s): "2505394369984"

Test #66:

score: 0
Accepted
time: 0ms
memory: 3972kb

input:

6
-999999 -1000000
1000000 999999
-999999 999999
-999999 -999999
-1000000 -999999
-1000000 -1000000
499999 1000000

output:

3999998999997

result:

ok 1 number(s): "3999998999997"

Test #67:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

6
999999 999998
-1000000 999998
-1000000 -1000000
-999998 -1000000
1000000 999999
999999 999999
999998500000 1999997000002

output:

9999989000001

result:

ok 1 number(s): "9999989000001"

Test #68:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

6
-1000000 1000000
-1000000 999999
-999999 999998
-999999 -1000000
999999 -1000000
999999 -999998
499999 1000000

output:

3999998999997

result:

ok 1 number(s): "3999998999997"

Test #69:

score: 0
Accepted
time: 61ms
memory: 3844kb

input:

200
-972995 -970464
-973578 -971112
-973589 -971112
-975679 -973404
-975690 -973404
-977901 -975828
-977912 -975828
-982972 -981360
-982983 -981360
-986690 -985416
-986701 -985416
-993169 -992484
-993180 -992484
-997998 -997752
-998009 -997752
-998878 -998712
-1000000 -999889
1000000 -999889
-999956...

output:

369841718853

result:

ok 1 number(s): "369841718853"

Test #70:

score: 0
Accepted
time: 60ms
memory: 3908kb

input:

200
-83040 -787694
-83040 -787768
-88332 -786658
-88332 -786732
-97026 -784956
-97026 -785030
-129534 -778592
-129534 -778666
-166578 -771340
-166578 -771414
-197952 -765198
-197952 -765272
-208914 -763052
-208914 -763126
-222144 -760462
-222144 -760536
-261834 -752692
-261834 -752766
-270150 -75106...

output:

14765852605

result:

ok 1 number(s): "14765852605"

Test #71:

score: 0
Accepted
time: 61ms
memory: 3912kb

input:

200
181447 -814426
181447 -814820
178879 -809698
178879 -810092
172673 -798272
172673 -798666
167109 -788028
167109 -788422
165611 -785270
165611 -785664
34215 -543354
34215 -543748
-15219 -452340
-15219 -452734
-41541 -403878
-41541 -404272
-87551 -319168
-87551 -319562
-100819 -294740
-100819 -295...

output:

840785362

result:

ok 1 number(s): "840785362"

Test #72:

score: 0
Accepted
time: 62ms
memory: 3844kb

input:

200
176782 238784
242470 195903
242470 196216
462718 53175
462718 53488
547726 -1913
547726 -1600
656401 -72338
656401 -72025
663646 -77033
663646 -76720
665095 -77972
665095 -77659
724504 -116471
724504 -116158
871336 -211623
871336 -211310
915289 -240106
915289 -239793
997882 -293629
997882 -29331...

output:

76691435280

result:

ok 1 number(s): "76691435280"

Test #73:

score: 0
Accepted
time: 59ms
memory: 3792kb

input:

200
355466 232552
355466 232896
354692 231520
354692 231864
350822 226360
350822 226704
263876 110432
263876 110776
-96550 -370136
-96550 -369792
-249028 -573440
-249028 -573096
-263734 -593048
-263734 -592704
-265540 -595456
-265540 -595112
-276118 -609560
-276118 -609216
-301402 -643272
-301402 -6...

output:

981929460

result:

ok 1 number(s): "981929460"

Test #74:

score: 0
Accepted
time: 61ms
memory: 3740kb

input:

200
-529328 504581
-487652 466998
-488105 466998
-457301 439327
-457754 439327
-281537 279083
-281990 279083
-280178 277844
-280631 277844
-278819 276605
-279272 276605
-277007 274953
-277460 274953
-264323 263389
-264776 263389
-262058 261324
-262511 261324
-259793 259259
-260246 259259
-258887 258...

output:

73275854409

result:

ok 1 number(s): "73275854409"

Test #75:

score: 0
Accepted
time: 61ms
memory: 4080kb

input:

200
696544 -637923
701449 -643383
701122 -643383
710605 -654303
710278 -654303
763906 -717873
763579 -717873
791374 -750633
791047 -750633
820150 -784953
819823 -784953
933946 -920673
933619 -920673
948661 -938223
948334 -938223
970570 -964353
970243 -964353
984631 -981123
984304 -981123
993787 -992...

output:

73656516195

result:

ok 1 number(s): "73656516195"

Test #76:

score: 0
Accepted
time: 60ms
memory: 3848kb

input:

200
-643420 -551447
-643336 -551447
-638212 -574077
-638128 -574077
-637960 -575172
-637876 -575172
-634348 -590867
-634264 -590867
-628552 -616052
-628468 -616052
-623764 -636857
-623680 -636857
-622672 -641602
-622588 -641602
-621832 -645252
-621748 -645252
-620488 -651092
-620404 -651092
-620320 ...

output:

2841929870

result:

ok 1 number(s): "2841929870"

Test #77:

score: 0
Accepted
time: 56ms
memory: 3852kb

input:

200
915800 -565556
915432 -561187
915432 -565556
915248 -565146
915248 -565556
915064 -562815
915064 -565556
914880 -564232
914880 -565556
906324 -558064
906324 -565556
844040 -565051
844040 -565556
755260 -563551
755260 -565556
724164 -557592
724164 -565556
696840 -561578
696840 -565556
688376 -556...

output:

7036854945

result:

ok 1 number(s): "7036854945"

Test #78:

score: 0
Accepted
time: 0ms
memory: 4004kb

input:

4
691982 -889854
-658017 460142
241983 -439856
691984 -889856
0 1

output:

3

result:

ok 1 number(s): "3"

Test #79:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

4
1 1
-999999 1000000
0 0
999998 -999999
0 1

output:

2000000

result:

ok 1 number(s): "2000000"

Test #80:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

5
-999998 999999
1000000 -1000000
1000000 1000000
-999999 1000000
0 999999
0 0

output:

2000000000000

result:

ok 1 number(s): "2000000000000"

Test #81:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

10
-799994 799991
200002 -200000
800001 -799996
1000000 -999994
600001 -599997
200001 -199999
-199997 199997
-599996 599994
-799995 799992
-999995 999991
1 3

output:

22

result:

ok 1 number(s): "22"

Test #82:

score: 0
Accepted
time: 51ms
memory: 4060kb

input:

200
770618 988708
175616 971426
424171 980736
31302 970577
-78653 947338
-38128 937104
-251242 964051
-299096 944258
-879586 994277
-997839 652767
-806386 752805
-787555 785510
-696503 858399
-646005 827516
-821898 713347
-787671 722664
-455221 697038
-358147 667332
-334840 645344
-423249 567910
-94...

output:

3428934350351

result:

ok 1 number(s): "3428934350351"

Test #83:

score: 0
Accepted
time: 43ms
memory: 3912kb

input:

191
-411996 -396628
-411996 -260792
-344078 -260792
-344078 -124956
-479914 -260792
-479914 -124956
-411996 -124956
-479914 -57038
-547832 -57038
-479914 10880
-411996 10880
-344078 78798
-344078 10880
-276160 10880
-411996 -57038
-276160 -57038
-276160 -192874
-208242 -260792
-140324 -192874
-20824...

output:

1185964949504

result:

ok 1 number(s): "1185964949504"

Test #84:

score: 0
Accepted
time: 32ms
memory: 4100kb

input:

183
-695344 -93919
-695344 -121800
-751106 -177562
-723225 -177562
-667463 -121800
-667463 -149681
-723225 -205443
-751106 -205443
-778987 -233324
-778987 -177562
-723225 -121800
-723225 -93919
-751106 -121800
-751106 -93919
-778987 -121800
-778987 -149681
-806868 -121800
-806868 -233324
-778987 -26...

output:

136036278175

result:

ok 1 number(s): "136036278175"

Test #85:

score: 0
Accepted
time: 45ms
memory: 3848kb

input:

195
-486723 -317615
-486723 -404652
-225612 -143541
-225612 -230578
-138575 -230578
35499 -317615
-312649 -317615
-399686 -404652
35499 -404652
122536 -317615
-51538 -230578
-312649 -56504
-312649 -143541
-399686 -143541
-399686 -56504
-486723 -143541
-486723 30533
-399686 117570
-399686 30533
-3126...

output:

1371154525789

result:

ok 1 number(s): "1371154525789"

Test #86:

score: 0
Accepted
time: 41ms
memory: 4108kb

input:

186
-214518 -614808
-268414 -560912
-268414 -776496
-214518 -776496
-214518 -668704
-160622 -668704
-160622 -722600
-106726 -722600
-160622 -776496
-52830 -776496
-52830 -722600
1066 -722600
54962 -668704
54962 -722600
1066 -776496
593922 -776496
593922 -614808
540026 -560912
486130 -560912
540026 -...

output:

546098417408

result:

ok 1 number(s): "546098417408"

Test #87:

score: 0
Accepted
time: 1ms
memory: 3968kb

input:

38
-201096 -549013
-233192 -549013
-205108 -547007
-235198 -547007
-235198 -549013
-245228 -549013
-237204 -547007
-253252 -547007
-253252 -549013
-247234 -549013
-253252 -551019
-173012 -551019
-199090 -549013
-187054 -549013
-171006 -551019
51660 -551019
-20556 -549013
55672 -549013
53666 -551019
...

output:

4335898772

result:

ok 1 number(s): "4335898772"

Test #88:

score: 0
Accepted
time: 2ms
memory: 3768kb

input:

57
-82840 -633995
-82840 -404360
-89401 -437165
-89401 -325628
-82840 -397799
-82840 -82871
-89401 -95993
-89401 -23822
-82840 -76310
-82840 133642
-89401 -17261
-89401 61471
-82840 140203
-82840 264862
-89401 350155
-89401 402643
-82840 271423
-82840 638839
-89401 507619
-89401 599473
-82840 645400...

output:

28410835862

result:

ok 1 number(s): "28410835862"

Test #89:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

71
380434 -887270
243607 -887270
277318 -885287
-269990 -885287
170236 -887270
-164891 -887270
-271973 -885287
-547610 -885287
-414749 -887270
-676505 -887270
-549593 -885287
-962057 -885287
-942227 -887270
-966023 -887270
-964040 -885287
-985853 -885287
-985853 -887270
-983870 -887270
-985853 -8892...

output:

10978950904

result:

ok 1 number(s): "10978950904"

Test #90:

score: 0
Accepted
time: 5ms
memory: 3800kb

input:

80
-375057 167467
-373298 12675
-373298 331054
-375057 169226
-375057 316982
-373298 332813
-373298 417245
-375057 318741
-375057 353921
-373298 419004
-373298 575555
-375057 355680
-375057 466497
-373298 577314
-373298 644156
-375057 468256
-375057 582591
-373298 645915
-373298 712757
-375057 58435...

output:

7558839900

result:

ok 1 number(s): "7558839900"

Test #91:

score: 0
Accepted
time: 7ms
memory: 3732kb

input:

91
-278620 434125
67670 444019
-931624 444019
-793108 434125
-535864 434125
-219256 424231
-654592 424231
-803002 434125
-872260 434125
-664486 424231
-684274 424231
-882154 434125
-911836 434125
-763426 424231
-842578 424231
-931624 434125
-921730 434125
-941518 444019
-961306 444019
-941518 434125...

output:

68621756436

result:

ok 1 number(s): "68621756436"

Test #92:

score: 0
Accepted
time: 5ms
memory: 4100kb

input:

80
-411253 -131509
-367253 -131509
-213253 -127109
-186853 -127109
-362853 -131509
-54853 -131509
-98853 -127109
-59253 -127109
-59253 -122709
-54853 -127109
-50453 -127109
-50453 -131509
-41653 -131509
-46053 -127109
-41653 -127109
-41653 -122709
-46053 -122709
-41653 -118309
-54853 -118309
-50453 ...

output:

61255039981

result:

ok 1 number(s): "61255039981"

Test #93:

score: 0
Accepted
time: 20ms
memory: 3828kb

input:

142
-241091 -799231
-241091 -714879
-241750 -752442
-241750 -725423
-241091 -714220
-241091 -660841
-241750 -701699
-241750 -724764
-242409 -724105
-242409 -634481
-241750 -625255
-241750 -701040
-241091 -660182
-241091 -562650
-241750 -624596
-241750 -587692
-241091 -561991
-241091 -526405
-241750 ...

output:

1363642204

result:

ok 1 number(s): "1363642204"

Test #94:

score: 0
Accepted
time: 17ms
memory: 3724kb

input:

134
-796218 -36397
-795028 -36397
-790268 -35802
-775393 -35802
-783128 -36397
-794433 -36397
-792053 -36992
-790863 -36992
-782533 -36397
-767658 -36397
-790268 -36992
-745643 -36992
-741478 -36397
-767063 -36397
-774798 -35802
-752783 -35802
-724818 -36397
-740883 -36397
-745048 -36992
-710538 -36...

output:

1041984028

result:

ok 1 number(s): "1041984028"

Test #95:

score: 0
Accepted
time: 1ms
memory: 4020kb

input:

20
-831316 -343620
-251926 -343620
-251926 -459498
-831316 -459498
-831316 -575376
-20170 -575376
-20170 -691254
-831316 -691254
-831316 -923010
327464 -923010
327464 235770
-831316 235770
-831316 119892
-715438 119892
-715438 4014
-831316 4014
-831316 -111864
-483682 -111864
-483682 -227742
-831316...

output:

1651608438737

result:

ok 1 number(s): "1651608438737"

Test #96:

score: 0
Accepted
time: 51ms
memory: 4168kb

input:

200
678248 281357
678248 296799
-201946 296799
-201946 312241
678248 312241
678248 327683
-232830 327683
-232830 343125
678248 343125
678248 358567
-263714 358567
-263714 374009
678248 374009
678248 389451
-294598 389451
-294598 404893
678248 404893
678248 420335
-325482 420335
-325482 435777
678248...

output:

2980215139322

result:

ok 1 number(s): "2980215139322"

Test #97:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

26
726358 -880576
695369 -880576
602402 -725631
633391 -694642
354490 -260796
323501 -260796
230534 -105851
261523 -43873
-17378 358984
-48367 358984
-141334 513929
-110345 668874
-234301 978764
-420235 947775
-327268 823819
-234301 668874
-296279 606896
13611 204039
44600 204039
137567 49094
75589 ...

output:

969441143140

result:

ok 1 number(s): "969441143140"

Test #98:

score: 0
Accepted
time: 39ms
memory: 4140kb

input:

200
-153811 101954
-110538 -13951
-21156 16822
20793 -224637
-105318 -28386
-184845 -25122
-55966 -252174
-65073 -240349
-402588 -55614
-319429 351875
-479382 92012
-213699 555429
112299 348899
687998 510477
379335 468944
157461 420548
102219 458523
148907 488400
610913 530181
430304 566961
821268 5...

output:

2391931820113

result:

ok 1 number(s): "2391931820113"

Test #99:

score: 0
Accepted
time: 39ms
memory: 3848kb

input:

200
122301 113556
338694 233402
368238 131577
446030 331311
535103 535679
781548 843294
666909 875595
442356 427784
374568 306449
-26086 6336
356963 370926
75420 132096
109676 185484
392958 553349
511233 697425
-105084 -25122
16287 361251
338613 501111
251648 493356
589628 908975
16500 972309
535022...

output:

2184883791336

result:

ok 1 number(s): "2184883791336"

Test #100:

score: 0
Accepted
time: 43ms
memory: 4080kb

input:

200
421640 547713
650121 928769
547442 928833
346206 886544
-452730 992357
102138 855965
111368 905793
366936 808814
97664 687998
306486 711903
22692 663762
-57963 885504
-55792 734234
-463485 989088
-157192 737144
-241500 603149
-444462 699033
-203932 580725
37067 568415
339672 708146
497484 744522...

output:

2313815513361

result:

ok 1 number(s): "2313815513361"

Test #101:

score: 0
Accepted
time: 38ms
memory: 4080kb

input:

200
207543 18138
233654 136908
700845 -843115
765038 -961705
480771 -367522
784833 -913671
931941 -853932
718884 -558630
197457 373259
426012 6606
359594 164931
795933 -587514
362999 173610
635496 -231358
517028 -17575
653370 -224637
779784 -468309
814878 -651810
970226 -830284
897312 -690219
653588...

output:

2295112553705

result:

ok 1 number(s): "2295112553705"

Test #102:

score: 0
Accepted
time: 40ms
memory: 3848kb

input:

200
384246 119904
515880 90069
537210 144074
706626 62156
434349 603996
378143 465476
443127 317247
164931 198306
533444 341568
239054 104826
37271 27579
161283 99692
-13462 22109
497481 748134
753303 786567
441458 667358
736625 725172
466416 609863
638721 590361
679778 436017
624801 526664
704712 1...

output:

2025458550289

result:

ok 1 number(s): "2025458550289"

Test #103:

score: 0
Accepted
time: 37ms
memory: 3848kb

input:

200
290300 170277
240567 128495
339132 87891
177572 360968
480771 164259
512115 17961
405629 5648
333267 87849
346164 -61209
737469 -277905
699884 -331989
552159 -233661
67764 13977
51210 -31561
624573 -303696
365547 -415143
596037 -320155
382416 -471408
455414 -430867
473946 -409309
653883 -416259
...

output:

2137270937358

result:

ok 1 number(s): "2137270937358"

Test #104:

score: 0
Accepted
time: 39ms
memory: 3944kb

input:

200
-55665 353610
-95883 490124
132390 -66873
58841 248211
516981 -547989
507597 -169864
509958 -216196
522693 -268425
681047 -280795
494694 -143556
266337 -45390
313914 -52921
223239 1950
194649 346206
384276 367670
369288 321381
762722 -204108
497747 152082
716706 205593
526883 280884
795998 34640...

output:

2619534926661

result:

ok 1 number(s): "2619534926661"

Test #105:

score: 0
Accepted
time: 42ms
memory: 3852kb

input:

200
283343 271859
383730 322703
365793 322247
450695 405629
434937 311613
486618 479943
358449 -12483
67130 -122775
416790 227442
-16551 -180451
295266 -315165
383364 28503
502124 440735
527090 528342
456162 243552
444408 -165328
648036 -459271
561377 -12972
539900 87975
597287 63161
566952 304059
7...

output:

2307194075214

result:

ok 1 number(s): "2307194075214"

Test #106:

score: 0
Accepted
time: 39ms
memory: 3952kb

input:

200
5009 71481
-20981 20885
-12 -30222
-99838 189696
103887 126708
351540 380079
242496 299244
527678 785484
336098 539408
101865 137745
64338 267396
147075 359897
524 197672
520671 794027
-45390 774477
408812 806877
32813 864956
-594379 939110
-400881 862851
-841240 825276
-623754 795456
-233265 84...

output:

2390577784651

result:

ok 1 number(s): "2390577784651"

Test #107:

score: 0
Accepted
time: 43ms
memory: 3912kb

input:

200
635384 485892
765764 574319
336258 334347
465048 520794
519375 558921
682283 607704
982737 801953
564318 664179
209807 405618
419262 582690
-7986 577806
-441678 673641
171933 603149
261948 582564
129839 653445
374771 807498
499641 893376
916239 999597
-190753 742980
162081 984042
-325008 701442
...

output:

2146113671653

result:

ok 1 number(s): "2146113671653"

Test #108:

score: 0
Accepted
time: 61ms
memory: 4076kb

input:

200
1000000 -999941
-999956 -999940
-998042 -997864
-998053 -997864
-994830 -994360
-994841 -994360
-990958 -990136
-990969 -990136
-983566 -982072
-983577 -982072
-978319 -976348
-978330 -976348
-976768 -974656
-976779 -974656
-975228 -972976
-975239 -972976
-973116 -970672
-973127 -970672
-972808 ...

output:

369841636089

result:

ok 1 number(s): "369841636089"

Test #109:

score: 0
Accepted
time: 58ms
memory: 3732kb

input:

200
1000000 -998489
-999630 -998488
-992008 -959932
-992082 -959932
-989862 -948970
-989936 -948970
-989344 -946324
-989418 -946324
-978688 -891892
-978762 -891892
-967292 -833680
-967366 -833680
-966182 -828010
-966256 -828010
-965146 -822718
-965220 -822718
-964850 -821206
-964924 -821206
-964480 ...

output:

14764398158

result:

ok 1 number(s): "14764398158"

Test #110:

score: 0
Accepted
time: 61ms
memory: 3848kb

input:

200
-1000000 999787
998030 999786
958630 978600
959024 978600
946810 972180
947204 972180
940112 968542
940506 968542
837278 912688
837672 912688
817972 902202
818366 902202
814426 900276
814820 900276
809698 897708
810092 897708
798272 891502
798666 891502
788028 885938
788422 885938
785270 884440
...

output:

806384434

result:

ok 1 number(s): "806384434"

Test #111:

score: 0
Accepted
time: 58ms
memory: 4136kb

input:

200
-1000000 997586
999374 997585
897023 840127
897336 840127
789977 674941
790290 674941
783091 664315
783404 664315
759616 628090
759929 628090
708597 549361
708910 549361
704215 542599
704528 542599
702963 540667
703276 540667
700459 536803
700772 536803
699520 535354
699833 535354
624400 419434
...

output:

76691435280

result:

ok 1 number(s): "76691435280"

Test #112:

score: 0
Accepted
time: 62ms
memory: 3824kb

input:

200
1000000 -999485
975920 -982198
965600 -974200
965256 -974200
964224 -973168
963880 -973168
962504 -971878
962160 -971878
961816 -971362
961472 -971362
961128 -970846
960784 -970846
948744 -961558
948400 -961558
931200 -948400
930856 -948400
906088 -929566
905744 -929566
881320 -910990
880976 -91...

output:

981929424

result:

ok 1 number(s): "981929424"

Test #113:

score: 0
Accepted
time: 62ms
memory: 4088kb

input:

200
1000000 -999175
975085 -976872
963760 -966134
963307 -966134
918460 -924834
918007 -924834
714157 -738571
713704 -738571
638959 -670013
638506 -670013
460477 -507291
460024 -507291
360364 -416018
359911 -416018
359458 -415192
359005 -415192
355381 -411475
354928 -411475
341338 -398672
340885 -39...

output:

73269119205

result:

ok 1 number(s): "73269119205"

Test #114:

score: 0
Accepted
time: 61ms
memory: 3852kb

input:

200
-1000000 998441
-996730 995710
-994441 992590
-994114 992590
-985285 981670
-984958 981670
-971878 965680
-971551 965680
-967627 960610
-967300 960610
-947026 936040
-946699 936040
-925771 910690
-925444 910690
-797587 757810
-797260 757810
-791374 750400
-791047 750400
-712240 656020
-711913 65...

output:

73634325975

result:

ok 1 number(s): "73634325975"

Test #115:

score: 0
Accepted
time: 62ms
memory: 4144kb

input:

200
-1000000 998176
-999748 997810
-999496 996350
-999412 996350
-999160 994890
-999076 994890
-982360 921890
-982276 921890
-981352 917510
-981268 917510
-975136 890500
-975052 890500
-850144 347380
-850060 347380
-817216 204300
-817132 204300
-800920 133490
-800836 133490
-787816 76550
-787732 765...

output:

2840381504

result:

ok 1 number(s): "2840381504"

Test #116:

score: 0
Accepted
time: 57ms
memory: 3912kb

input:

200
100000 -999633
239 -999632
3094 -999448
239 -999448
7467 -999264
239 -999264
4608 -998896
239 -998896
649 -998712
239 -998712
2980 -998528
239 -998528
1563 -998344
239 -998344
7731 -989788
239 -989788
744 -927504
239 -927504
2244 -838724
239 -838724
8203 -807628
239 -807628
4217 -780304
239 -780...

output:

7019985848

result:

ok 1 number(s): "7019985848"

Test #117:

score: 0
Accepted
time: 48ms
memory: 4180kb

input:

200
-677343 996088
-731021 806109
-703638 644867
-694433 455591
-698504 132249
-745640 -209598
-859170 -239875
-874703 -116547
-922684 -350844
-920583 296332
-867486 433468
-860134 490879
-849686 -2551
-813758 684881
-777869 965896
-905744 958941
-983905 544305
-996951 494366
-982454 -386675
-977004...

output:

2906808603592

result:

ok 1 number(s): "2906808603592"

Test #118:

score: 0
Accepted
time: 39ms
memory: 3780kb

input:

191
2 3
2 2
1 2
0 1
3 2
5 4
5 3
4 2
6 2
8 4
9 4
9 5
8 5
7 4
7 6
6 5
6 3
5 5
4 4
3 4
5 6
6 6
6 7
8 9
7 9
3 5
2 5
4 7
2 6
1 6
1 7
2 7
2 8
1 10
2 9
1 11
3 9
4 10
3 10
2 11
3 11
3 12
1 12
1 13
3 13
1 14
1 15
2 14
3 15
4 15
3 14
4 13
6 13
4 14
5 14
7 13
6 14
8 13
8 12
4 12
4 11
9 11
7 10
5 10
3 8
3 7
5 9...

output:

182

result:

ok 1 number(s): "182"

Test #119:

score: 0
Accepted
time: 37ms
memory: 3852kb

input:

183
3 4
2 8
2 7
1 7
1 8
0 12
0 6
1 6
1 4
0 5
0 0
1 3
1 0
2 6
2 3
3 2
2 2
3 1
2 1
2 0
12 0
12 1
13 0
15 0
13 1
14 1
16 0
16 3
15 1
13 3
14 3
13 4
15 3
15 2
16 4
16 8
15 6
15 4
14 4
12 5
13 5
12 6
12 8
13 7
13 8
12 9
13 9
14 7
14 8
15 8
14 6
13 6
14 5
16 9
16 10
15 12
16 11
16 16
12 16
13 15
13 14
14 ...

output:

175

result:

ok 1 number(s): "175"

Test #120:

score: 0
Accepted
time: 38ms
memory: 4104kb

input:

195
14 11
13 11
13 10
14 9
14 7
15 10
15 8
14 6
13 7
13 9
12 11
12 12
11 12
11 13
10 12
10 13
9 14
9 12
8 14
7 15
6 15
8 13
7 13
8 12
7 11
8 10
8 9
6 12
7 12
6 13
4 14
6 14
5 15
8 16
5 16
4 15
4 16
0 16
0 15
3 15
1 14
1 13
0 14
0 11
1 12
1 9
2 8
1 8
0 10
0 2
1 2
2 1
0 1
0 0
12 0
10 1
11 1
10 2
7 2
6...

output:

181

result:

ok 1 number(s): "181"

Test #121:

score: 0
Accepted
time: 39ms
memory: 3856kb

input:

186
13 16
12 15
12 14
13 15
15 15
15 14
14 14
13 13
14 13
14 12
13 12
12 13
13 14
11 13
9 13
8 14
11 14
11 15
12 16
6 16
10 15
7 15
5 16
2 16
5 15
6 15
7 14
6 14
4 15
3 15
4 14
4 13
2 11
1 14
1 15
2 12
2 14
3 13
3 14
1 16
0 16
0 8
1 10
1 13
2 7
2 10
3 11
3 9
5 11
6 11
7 12
5 12
4 11
4 12
5 13
6 13
5...

output:

188

result:

ok 1 number(s): "188"

Test #122:

score: 0
Accepted
time: 1ms
memory: 4036kb

input:

38
1 95
2 94
2 129
1 96
1 152
2 130
2 156
1 153
1 165
2 157
2 174
1 173
1 189
2 175
2 190
1 190
1 195
2 191
2 199
1 199
1 196
0 199
0 159
1 172
1 166
0 158
0 47
1 83
1 45
0 46
0 0
2 0
2 4
1 1
1 44
2 5
2 93
1 84
0 0

output:

551

result:

ok 1 number(s): "551"

Test #123:

score: 0
Accepted
time: 2ms
memory: 3648kb

input:

57
192 0
170 1
188 1
193 0
195 0
189 1
198 1
196 0
199 0
199 2
164 2
169 1
152 1
163 2
115 2
117 1
106 1
114 2
82 2
105 1
93 1
81 2
62 2
49 1
41 1
61 2
5 2
25 1
11 1
4 2
0 2
0 1
6 1
0 0
4 0
7 1
10 1
5 0
17 0
26 1
40 1
18 0
55 0
50 1
73 1
56 0
97 0
74 1
92 1
98 0
127 0
118 1
128 0
153 0
119 1
151 1
1...

output:

536

result:

ok 1 number(s): "536"

Test #124:

score: 0
Accepted
time: 4ms
memory: 4012kb

input:

71
2 970
1 939
1 966
2 971
2 998
1 967
1 991
2 999
1 992
1 999
0 999
0 825
1 938
1 854
0 824
0 790
1 853
1 820
0 789
0 776
1 801
1 733
0 775
0 729
1 732
1 690
0 728
0 638
1 689
1 620
0 637
0 361
1 583
1 414
0 360
0 221
1 288
1 156
0 220
0 12
1 22
1 10
0 11
0 0
1 0
1 1
2 0
2 13
1 2
1 9
2 14
2 71
1 23...

output:

2792

result:

ok 1 number(s): "2792"

Test #125:

score: 0
Accepted
time: 5ms
memory: 4104kb

input:

80
427 0
435 1
495 1
428 0
467 0
496 1
553 1
468 0
566 0
554 1
655 1
567 0
748 0
656 1
740 1
749 0
797 0
741 1
761 1
798 0
887 0
762 1
825 1
888 0
926 0
826 1
891 1
927 0
965 0
892 1
951 1
966 0
999 0
970 1
999 1
999 2
986 2
969 1
952 1
985 2
492 2
434 1
354 1
491 2
293 2
353 1
217 1
292 2
161 2
216...

output:

2443

result:

ok 1 number(s): "2443"

Test #126:

score: 0
Accepted
time: 3ms
memory: 3840kb

input:

91
0 4
1 18
1 44
2 76
2 32
1 17
1 10
2 31
2 29
1 9
1 6
2 21
2 13
1 4
1 5
0 3
0 1
1 3
1 2
2 12
2 3
1 1
0 0
1 0
2 1
2 0
3 0
3 4
2 2
3 5
3 19
2 22
2 28
3 20
3 61
2 77
2 78
1 45
1 69
2 79
2 92
3 62
3 122
2 93
2 99
3 123
3 135
2 100
2 165
3 136
3 191
2 166
2 178
3 192
3 195
2 188
2 179
1 184
1 196
2 193
...

output:

701

result:

ok 1 number(s): "701"

Test #127:

score: 0
Accepted
time: 5ms
memory: 3848kb

input:

80
52 2
66 1
32 1
16 0
41 0
67 1
75 1
42 0
114 0
122 1
135 1
140 2
187 2
136 1
159 1
115 0
125 0
160 1
166 1
126 0
196 0
186 1
195 1
195 2
196 1
197 1
197 0
199 0
198 1
199 1
199 2
198 2
199 3
196 3
197 2
196 2
195 3
194 3
189 2
194 2
185 1
167 1
188 2
193 3
133 3
139 2
131 2
132 3
20 3
80 2
130 2
1...

output:

747

result:

ok 1 number(s): "747"

Test #128:

score: 0
Accepted
time: 20ms
memory: 3916kb

input:

142
3 368
2 351
2 420
3 369
3 459
2 421
2 446
3 460
3 469
2 447
2 465
1 447
1 487
2 468
2 466
3 470
3 512
2 469
2 515
3 513
3 616
2 516
2 564
3 617
3 625
2 565
2 591
3 626
3 635
2 592
2 607
3 636
3 717
2 658
2 635
1 656
1 693
2 717
2 659
3 718
3 742
2 731
2 718
1 694
1 739
2 735
2 732
3 743
3 749
2 ...

output:

2698

result:

ok 1 number(s): "2698"

Test #129:

score: 0
Accepted
time: 18ms
memory: 3868kb

input:

134
552 1
527 0
702 0
633 1
679 1
703 0
714 0
680 1
700 1
699 2
716 2
722 1
701 1
715 0
734 0
736 1
737 1
735 0
739 0
738 1
743 1
740 0
749 0
744 1
749 1
749 3
746 3
748 2
746 2
745 3
744 3
745 2
741 2
735 1
723 1
720 2
740 2
743 3
737 3
719 2
717 2
736 3
680 3
698 2
663 2
679 3
631 3
662 2
605 2
63...

output:

2803

result:

ok 1 number(s): "2803"

Test #130:

score: 0
Accepted
time: 1ms
memory: 3980kb

input:

20
0 0
10 0
10 10
9 10
9 9
8 9
8 10
7 10
7 7
6 7
6 10
5 10
5 5
4 5
4 10
3 10
3 3
2 3
2 10
0 10
0 0

output:

123

result:

ok 1 number(s): "123"

Test #131:

score: 0
Accepted
time: 53ms
memory: 4120kb

input:

200
0 0
100 0
100 100
99 100
99 99
98 99
98 100
97 100
97 97
96 97
96 100
95 100
95 95
94 95
94 100
93 100
93 93
92 93
92 100
91 100
91 91
90 91
90 100
89 100
89 89
88 89
88 100
87 100
87 87
86 87
86 100
85 100
85 85
84 85
84 100
83 100
83 83
82 83
82 100
81 100
81 81
80 81
80 100
79 100
79 79
78 79...

output:

12498

result:

ok 1 number(s): "12498"

Test #132:

score: 0
Accepted
time: 1ms
memory: 4020kb

input:

26
0 0
5 3
6 2
20 11
20 12
25 15
27 14
40 23
40 24
45 27
50 26
60 30
59 36
55 33
50 30
48 32
35 22
35 21
30 18
26 20
15 10
15 9
10 6
8 7
-3 2
0 -1
0 0

output:

312

result:

ok 1 number(s): "312"

Extra Test:

score: 0
Extra Test Passed