Language: C++

#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <time.h>
#include <complex>
 
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
 
using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;
using std::complex;
 
using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;
typedef complex<double> cd;
 
ll min(ll a, ll b)
{
    if (a < b)
        return a;
    return b;
}
 
ll max(ll a, ll b)
{
    if (a > b)
        return a;
    return b;
}
 
namespace MySpace{
    struct Small_Segment_Tree{
        vector<int> a;
        int l, r;
 
        private:
        int __summ(int L, int R, int l, int r, int v)
        {
            if (L <= l && r <= R)
                return a[v];
            if (R <= l || r <= L)
                return 0;
            int m = (l + r) / 2;
            return __summ(L, R, l, m, 2 * v + 1) + __summ(L, R, m, r, 2 * v + 2);
        }
 
        void __set(int P, int l, int r, int v, int V)
        {
            if (l + 1 == r)
            {
                a[v] = V;
                return;
            }
            int m = (l + r) / 2;
            if (P < m)
            {
                __set(P, l, m, 2 * v + 1, V);
                a[v] = a[2 * v + 1] + a[2 * v + 2];
            }
            else
            {
                __set(P, m, r, 2 * v + 2, V);
                a[v] = a[2 * v + 1] + a[2 * v + 2];
            }
        }
 
        public:
        int Summ(int L, int R)
        {
            if (R < L)
                return 0;
            return __summ(L, R + 1, l, r, 0);
        }
 
        void Set(int P, int V)
        {
            __set(P, l, r, 0, V);
        }
 
        Small_Segment_Tree(int _n)
        {
            a.resize(4 * _n);
            l = 0, r = _n;
        }
    };
    long long inq(long long x, long long q, long long MOD)
    {
        if (q == 0)
            return 1;
        long long l = inq(x, q / 2, MOD);
        if (q % 2)
            return l * l % MOD * x % MOD;
        return l * l % MOD;
    }
};
 
 
using namespace MySpace;
 
#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long
 
void YN(int val)
{
    if (val >= 1)
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
}
 
//const ll MOD = 998244353;
const ll MOD = 1e12 + 7;

ll x, y;
ll x0, y0;
ll k;
vector<pii> ans;

pair<int, int> Catch(int x1, int y1, int x2, int y2)
{
    int dx = abs(x2 - x1);
    int dy = abs(y2 - y1);
    if (dx > 2 * k || dy > 2 * k)
    {
        return {-MOD, -MOD};
    }
    int mx1 = x1 + y1;
    int my1 = x1 - y1;
    int mx2 = x2 + y2;
    int my2 = x2 - y2;
    int h[4] = {mx1 - k, mx1 + k, mx2 - k, mx2 + k};
    sort(h, h + 4);
    int w[4] = {my1 - k, my1 + k, my2 - k, my2 + k};
    sort(w, w + 4);
    int mX = h[1];
    int mY = w[1];
    int x = (mX + mY) / 2;
    int y = (mX - mY) / 2;
    return {x, y};
}

signed main()
{
    ios_base::sync_with_stdio();
    cin.tie(0);
    cout.tie(0);
    cin >> k;
    cin >> x0 >> y0;
    if (k % 2 == 0 && (x0 + y0) % 2 != 0)
    {
        cout << "-1";
        return 0;
    }
    while (x0 > k)
    {
        ans.push_back({x0, y0});
        x0 -= k;
    }
    while (x0 < -k)
    {
        ans.push_back({x0, y0});
        x0 += k;
    }
    while (y0 > k)
    {
        ans.push_back({x0, y0});
        y0 -= k;
    }
    while (y0 < -k)
    {
        ans.push_back({x0, y0});
        y0 += k;
    }
    if (k % 2 == 1)
    {
        if (abs(x0) + abs(y0) == k)
        {
            ans.push_back({x0, y0});
        }
        else
        {
            int X = abs(x0);
            int Y = abs(y0);
            if ((X + Y) % 2 == 0)
            {
                pair<int, int> xy = Catch(x0, y0, 0, 0);
                ans.push_back({x0, y0});
                ans.push_back(xy);
            }
            else
            {
                pair<int, int> xy0 = Catch(x0, y0, 0, k);
                pair<int, int> xy1 = Catch(x0, y0, 0, -k);
                pair<int, int> xy2 = Catch(x0, y0, -k, 0);
                pair<int, int> xy3 = Catch(x0, y0, k, 0);
                pair<int, int> No = {-MOD, -MOD};
                if (xy0 != No)
                {
                    ans.push_back({x0, y0});
                    ans.push_back(xy0);
                    ans.push_back({0, k});
                }
                else
                if (xy1 != No)
                {
                    ans.push_back({x0, y0});
                    ans.push_back(xy1);
                    ans.push_back({0, -k});
                }
                else
                if (xy2 != No)
                {
                    ans.push_back({x0, y0});
                    ans.push_back(xy2);
                    ans.push_back({-k, 0});
                }
                else
                if (xy3 != No)
                {
                    ans.push_back({x0, y0});
                    ans.push_back(xy3);
                    ans.push_back({k, 0});
                }
            }
        }
    }
    else
    {
        if (abs(x0) + abs(y0) == k)
        {
            ans.push_back({x0, y0});
        }
        else
        {
            pair<int, int> deg = Catch(0, 0, x0, y0);
            ans.push_back({x0, y0});
            ans.push_back(deg);
        }
    }
    cout << ans.size() << "\n";
    for (int i = 0; i < ans.size(); i++)
    {
        cout << ans[ans.size() - 1 - i].fi << " " << ans[ans.size() - 1 - i].se << "\n";
    }
}

Compiler output:
a.cc:159:8: error: 'll y0' redeclared as different kind of entity
  159 | ll x0, y0;
      |        ^~
In file included from /usr/include/features.h:523,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
                 from /usr/include/c++/14/bits/requires_hosted.h:31,
                 from /usr/include/c++/14/iostream:38,
                 from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:256:1: note: previous declaration 'double y0(double)'
  256 | __MATHCALL (y0,, (_Mdouble_));
      | ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:192:15: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept')
  192 |     cin >> x0 >> y0;
      |     ~~~~~~~~~ ^~ ~~
      |         |        |
      |         |        double(double) noexcept
      |         std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/iostream:42:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  170 |       operator>>(bool& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:170:7: note:   conversion of argument 1 would be ill-formed:
a.cc:192:18: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept'
  192 |     cin >> x0 >> y0;
      |                  ^~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
  174 |       operator>>(short& __n);
      |       ^~~~~~~~
/usr/include/c++/14/istream:174:7: note:   conversion of argument 1 would be ill-formed:
a.cc:192:18: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive]
  192 |     cin >> x0 >> y0;
      |                  ^~
      |                  |
      |                  double (*)(double) noexcept
a.cc:192:18: error: cannot bind rvalue '(short int)y0' to 'short int&'
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  177 |       operator>>(unsigned short& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:177:7: note:   conversion of argument 1 would be ill-formed:
a.cc:192:18: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive]
  192 |     cin >> x0 >> y0;
      |                  ^~
      |                  |
      |                  double (*)(double) noexcept
a.cc:192:18: error: cannot bind rvalue '(short unsigned int)y0' to 'short unsigned int&'
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
  181 |       operator>>(int& __n);
      |       ^~~~~~~~
/usr/include/c++/14/istream:181:7: note:   conversion of argument 1 would be ill-formed:
a.cc:192:18: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
  192 |     cin >> x0 >> y0;
      |                  ^~
      |                  |
      |                  double (*)(double) noexcept
a.cc:192:18: error: cannot bind rvalue '(int)y0' to 'int&'
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  184 |       operator>>(unsigned int& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:184:7: note:   conversion of argument 1 would be ill-formed:
a.cc:192:18: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive]
  192 |     cin >> x0 >> y0;
      |                  ^~
      |                  |
      |                  double (*)(double) noexcept
a.cc:192:18: error: cannot bind rvalue '(unsigned int)y0' to 'unsigned int&'
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  188 |       operator>>(long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:188:7: note:   conversion of argument 1 would be ill-formed:
a.cc:192:18: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive]
  192 |     cin >> x0 >> y0;
      |                  ^~
      |                  |
      |                  double (*)(double) noexcept
a.cc:192:18: error: cannot bind rvalue '(long int)y0' to 'long int&'
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  192 |       operator>>(unsigned long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:192:7: note:   conversion of argument 1 would be ill-formed:
a.cc:192:18: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive]
  192 |     cin >> x0 >> y0;
      |                  ^~
      |                  |
      |                  double (*)(double) noexcept
a.cc:192:18: error: cannot bind rvalue '(long unsigned int)y0' to 'long unsigned int&'
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  199 |       operator>>(long long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:199:7: note:   conversion of argument 1 would be ill-formed:
a.cc:192:18: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive]
  192 |     cin >> x0 >> y0;
      |                  ^~
      |                  |
      |                  double (*)(double) noexcept
a.cc:192:18: error: cannot bind rvalue '(long long int)y0' to 'long long int&'
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  203 |       operator>>(unsigned long long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:203:7: note:   conversion of argument 1 would be ill-formed:
a.cc:192:18: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive]
  192 |     cin >> x0 >> y0;
      |                  ^~
      |                  |
      |                  double (*)(double) noexcept
a.cc:192:18: error: cannot bind rvalue '(long long unsigned int)y0' to 'long long unsigned int&'
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  328 |       operator>>(void*& __p)
      |       ^~~~~~~~
/usr/include/c++/14/istream:328:7: note:   conversion of argument 1 would be ill-formed:
a.cc:192:18: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive]
  192 |     cin >> x0 >> y0;
      |                  ^~
      |                  |
      |                  double (*)(double) noexcept
a.cc:192:18: error: cannot bind rvalue '(void*)y0' to 'void*&'
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  122 |       operator>>(__istream_type& (*__pf)(__istream_type&))
      |       ^~~~~~~~
/usr/include/c++/14/istream:122:7: note:   conversion of argument 1 would be ill-formed:
a.cc:192:18: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
  192 |     cin >> x0 >> y0;
      |                  ^~
      |                  |
      |                  double (*)(double) noexcept
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]' (near match)
  126 |       operator>>(__ios_type& (*__pf)(__ios_type&))
      |       ^~~~~~~~
/usr/include/c++/14/istream:126:7: note:   conversion of argument 1 would be ill-formed:
a.cc:192:18: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} [-fpermissive]
  192 |     cin >> x0 >> y0;
      |                  ^~
      |                  |
      |                  double (*)(double) noexcept
/usr/include/c++/14/istream:133:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::bas