Language: C++

#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

vector<pair<int,int>> ans;

signed main(){
  int k,x,y;cin>>k>>x>>y;
  int s = 0;
  s += abs(x)/k + abs(y)/k;
  int res = k - (abs(x)%k + abs(y)%k);
  if(res < 0){
    res += k;s++;
  }
  if(k % 2 == 0 && res % 2 == 1){
    cout << "-1" << endl;return 0;
  }
  rep(i,10000000){
    if((k*i+res)%2 == 1)continue;
    int w = (k*i+res)/2;
    int m = w%k;if(m < k)m += k;
    int xx = (w-m)/2 + m/2, yy = (w-m)/2 + (m-m/2);
    cout << res << " " << w << " " << m << " " << xx << " " << yy << endl;
    if(xx%k + yy < k || xx + yy%k < k)continue;
    int xxx = xx, yyy = yy;
    s += xxx/k;
    while(xxx >= k){
      ans.push_back(make_pair(k,0));
      xxx -= k;
    }
    int nex = k;
    if(xxx > 0){
      s++;ans.push_back(xxx, max(0,k - xxx));nex -= xxx;
    }
    yyy -= nex;
    s += yyy/k;
    while(yyy >= k){
      ans.push_back(make_pair(0,k));
      yyy -= k;
    }
    int nnex = k;
    if(yyy > 0){
      s++;ans.push_back(make_pair(max(0,k - yyy), yyy));nnex -= yyy;
    }
    xx -= nnex;
    s += xx/k;
    while(xx >= k){
      ans.push_back(make_pair(k,0));
    }
    int nnnex = k;
    if(xx > 0){
      s++;ans.push_back(xx, make_pair(max(0,k - xx)));nnnex -= xx;
    }
    yy -= nnex;
    s += yy/k;
    while(yy >= k){
      s++;ans.push_back(make_pair(yy, max(0,k - yy)));nnex -= yyy;
    }
    break;
  }
  cout << s << endl;
  rep(i,ans.size()){
    cout << ans[i].first << " " << ans[i].second << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:74:33: error: no matching function for call to 'max(int, long long int)'
   74 |       s++;ans.push_back(xxx, max(0,k - xxx));nex -= xxx;
      |                              ~~~^~~~~~~~~~~
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:74:33: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   74 |       s++;ans.push_back(xxx, max(0,k - xxx));nex -= xxx;
      |                              ~~~^~~~~~~~~~~
/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:74:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   74 |       s++;ans.push_back(xxx, max(0,k - xxx));nex -= xxx;
      |                              ~~~^~~~~~~~~~~
a.cc:84:38: error: no matching function for call to 'max(int, long long int)'
   84 |       s++;ans.push_back(make_pair(max(0,k - yyy), yyy));nnex -= yyy;
      |                                   ~~~^~~~~~~~~~~
/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:84:38: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   84 |       s++;ans.push_back(make_pair(max(0,k - yyy), yyy));nnex -= yyy;
      |                                   ~~~^~~~~~~~~~~
/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
/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:84:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   84 |       s++;ans.push_back(make_pair(max(0,k - yyy), yyy));nnex -= yyy;
      |                                   ~~~^~~~~~~~~~~
a.cc:93:42: error: no matching function for call to 'max(int, long long int)'
   93 |       s++;ans.push_back(xx, make_pair(max(0,k - xx)));nnnex -= xx;
      |                                       ~~~^~~~~~~~~~
/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:93:42: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   93 |       s++;ans.push_back(xx, make_pair(max(0,k - xx)));nnnex -= xx;
      |                                       ~~~^~~~~~~~~~
/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
/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:93:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   93 |       s++;ans.push_back(xx, make_pair(max(0,k - xx)));nnnex -= xx;
      |                                       ~~~^~~~~~~~~~
a.cc:98:42: error: no matching function for call to 'max(int, long long int)'
   98 |       s++;ans.push_back(make_pair(yy, max(0,k - yy)));nnex -= yyy;
      |                                       ~~~^~~~~~~~~~
/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:98:42: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   98 |       s++;ans.push_back(make_pair(yy, max(0,k - yy)));nnex -= yyy;
      |                                       ~~~^~~~~~~~~~
/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
/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:98:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   98 |       s++;ans.push_back(make_pair(yy, max(0,k - yy)));nnex -= yyy;
      |                                       ~~~^~~~~~~~~~