Language: C++

#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

vector<pii> solve(lint x, lint y, lint k){
    vector<pii> v;
    if(x+y == k){
        v.emplace_back(x, y);
        return v;
    }
    int n = max(2, (x+y-1)/k+1);
    lint d = n*k - (x+y);
    if(d%2){
        if(k%2 == 0) return v;
        d += k;
        ++n;
    }
    d /= 2;
    if(n == 3){
        lint c = (3*k-x-y) / 2;
        lint a = c / 2;
        lint b = c - a;
        For(i, 1, n+1){
            if(i*k <= a) v.emplace_back(-i*k, 0);
            else if(i*k <= a+y+b) v.emplace_back(-a, i*k-a);
            else if(i*k <= a+y+b+a+x) v.emplace_back(i*k-a-y-b-a, y+b);
            else v.emplace_back(x, y+b-(i*k-a-y-b-a-x));
        }
        return v;
    }
    For(i, 1, n+1){
        if(i*k <= y) v.emplace_back(0, i*k);
        else if(i*k <= y+d+x) v.emplace_back(i*k-y-d, y+d);
        else v.emplace_back(x, y+d-(i*k-y-d-x));
    }
    return v;
}

int main(){
    int k, x, y;
    scanf("%d%d%d", &k, &x, &y);
    bool flag = false;
    if(abs(y) > abs(x)) swap(x, y), flag = true;
    pii sig = pii(0, 0);
    if(x < 0) x *= -1, sig.fi = 1;
    if(y < 0) y *= -1, sig.se = 1;
    auto ans = solve(x, y, k);
    if(!ans.size()){
        printf("-1\n");
        return 0;
    }
    printf("%d\n", (int)ans.size());
    for(pll p: ans){
        if(sig.fi) p.fi *= -1;
        if(sig.se) p.se *= -1;
        if(flag) swap(p.fi, p.se);
        printf("%lld %lld\n", p.fi, p.se);
    }
}

Compiler output:
a.cc: In function 'std::vector<std::pair<int, int> > solve(lint, lint, lint)':
a.cc:19:16: error: no matching function for call to 'max(int, lint)'
   19 |     int n = max(2, (x+y-1)/k+1);
      |             ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:19:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'lint' {aka 'long long int'})
   19 |     int n = max(2, (x+y-1)/k+1);
      |             ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:19:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   19 |     int n = max(2, (x+y-1)/k+1);
      |             ~~~^~~~~~~~~~~~~~~~