#include #include #include #include #include #include using namespace std; int main() { struct P { int n, d; P(int _n, int _d) : n(_n), d(_d) {} }; auto compare = [] (const P &lhs, const P &rhs) { return max(lhs.n, lhs.d) > max(rhs.n, rhs.d); }; priority_queue, decltype(compare)> pq(compare); pq.emplace(0, 1); vector

v; const int N = 1'000'000; while (v.size() < N / 4) { const P p = pq.top(); pq.pop(); v.push_back(p); const auto [n, d] = p; assert(gcd(n, d) == 1); if (n > 0) pq.emplace(n, d + n); pq.emplace(d + n, d); } sort(v.begin(), v.end(), [](const P &lhs, const P &rhs) { return lhs.n * rhs.d < rhs.n * lhs.d; }); int x = 0, y = 0; cout << N << '\n'; for (auto [n, d] : v) x -= n, y += d, cout << x << ' ' << y << '\n'; for (auto [n, d] : v) x -= d, y -= n, cout << x << ' ' << y << '\n'; for (auto [n, d] : v) x += n, y -= d, cout << x << ' ' << y << '\n'; for (auto [n, d] : v) x += d, y += n, cout << x << ' ' << y << '\n'; }