Language: C++

#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

vector<pair<ll,ll> > ans;
ll K;
ll X,Y;
ll dx,dy;
pair<ll,ll> modify;
pair<ll,ll> move;

pair<ll,ll> strategy(ll x,ll y,ll K){
  //x,yは残りの距離、Kは移動可能距離
  // cout<<"remain "<<x<<" "<<y<<endl;
  if(x<0){
    modify = strategy(-x,y,K);
    return mp(-modify.first,modify.second);
  }
  if(y<0){
    modify = strategy(x,-y,K);
    return mp(modify.first,-modify.second);
  }
  if(x>y){
    modify = strategy(y,x,K);
    return mp(modify.second,modify.first);
  }
  //ここでは0<=x<=yであるはず
  ll L = x+y;
  //まだまだだからとりあえず近ずく
  if(L>2*K){
    dx = min(x,K);
    dy = K - dx;
    return mp(dx,dy);
  }
  //lastの移動
  if(L==K){
    return mp(x,y);
  }
  if((x+y)%2==0){
    //2回でいける
    ll t = (y-x)/2;
    dx = K-t;
    dy = t;
    return mp(dx,dy);
  }
  //3回でいける
  dx = min(K,x);
  dy = K-dx;
  return mp(dx,dy);
}

int main(){
  cin>>K;
  cin>>X>>Y;
  ll x=0,y=0;

  if(K%2==0 and (X+Y)%2!=0){
    cout<<-1<<endl;
    return 0;
  }

  else{
    while(x!=X or y!=Y){
      move = strategy(X-x,Y-y,K);
      x += move.first;
      y += move.second;
      ans.pb(mp(x,y));
    }
    cout<<ans.size()<<endl;
    rep(i,ans.size()) cout<<ans[i].first<<" "<<ans[i].second<<endl;
  }

}


Compiler output:
a.cc: In function 'int main()':
a.cc:91:7: error: reference to 'move' is ambiguous
   91 |       move = strategy(X-x,Y-y,K);
      |       ^~~~
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:3:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
  353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
      | ^~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:675:5: note:                 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
  675 |     move(_II __first, _II __last, _OI __result)
      |     ^~~~
In file included from /usr/include/c++/14/bits/exception_ptr.h:41,
                 from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41:
/usr/include/c++/14/bits/move.h:137:5: note:                 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
  137 |     move(_Tp&& __t) noexcept
      |     ^~~~
a.cc:37:13: note:                 'std::pair<long long int, long long int> move'
   37 | pair<ll,ll> move;
      |             ^~~~
a.cc:92:12: error: reference to 'move' is ambiguous
   92 |       x += move.first;
      |            ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
  353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
      | ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note:                 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
  675 |     move(_II __first, _II __last, _OI __result)
      |     ^~~~
/usr/include/c++/14/bits/move.h:137:5: note:                 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
  137 |     move(_Tp&& __t) noexcept
      |     ^~~~
a.cc:37:13: note:                 'std::pair<long long int, long long int> move'
   37 | pair<ll,ll> move;
      |             ^~~~
a.cc:93:12: error: reference to 'move' is ambiguous
   93 |       y += move.second;
      |            ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
  353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
      | ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note:                 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
  675 |     move(_II __first, _II __last, _OI __result)
      |     ^~~~
/usr/include/c++/14/bits/move.h:137:5: note:                 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
  137 |     move(_Tp&& __t) noexcept
      |     ^~~~
a.cc:37:13: note:                 'std::pair<long long int, long long int> move'
   37 | pair<ll,ll> move;
      |             ^~~~