Language: C++

#include <bits/stdc++.h>
using namespace std;
#defind int long long
int k, x, y;
class line{
  public:
 	 int a, b, c;
	line(int q, int w, int e, int r){
    	//a*q+b*w+c=0
      	//a*e+b*r+c=0
      	//a*(q-e)+b*(w-r)=0
    	a=r-w;
      	b=q-e;
      	c=-(a*q+b*w);
      	int d=__gcd(abs(a), abs(b));
      d=__gcd(d, abs(c));
      a/=d;
      b/=d;
      c/=d;
    }
  pair <int, int> cut(line l){
  	//a*x+y*b+c==0;
    //l.a*x+l.y*b+l.c=0;
    //l.a*a*x+y*b*l.a+c*l.a=0;
    //l.a*x*a+y*l.b*a+l.c*a=0;
    int y=-(c*l.a-l.c*a)/(l.a*b-l.b*a);
    int x=(-c-y*b)/a;
    return {x, y};
  }
};
class data{
  public:
  int x, y, z, t;
  data(int x, int y, int z, int t): x(x), y(y), z(z), t(t){}
};
vector <data> dist(int x, int y, int k){
	vector <data> res;
  res.push_back(data(x+k, y, x, y+k));
  res.push_back(data(x, y+k, x-k, y));
  res.push_back(data(x-k, y, x, y-k));
  res.push_back(data(x, y-k, x+k, y));
  return res;
}
vector <pair <int ,int>> cut(int a, int b, int c, int d, int x, int y, int z, int t){
  vector <pair <int, int>> res;
  if(max(a, c)<min(x, z)) return res;
  if(max(x, z)<min(a, c)) return res;
  if(max(b, d)<min(y, t)) return res;
  if(max(y, t)<min(b, d)) return res;
  line l1(a, b, c, d);
  line l2(x, y, z, t);
  res.push_back(l1.cut(l2));
  return res;
}
vector <pair <int, int>> find_mid(int nx, int ny){
	//a, b such at abs(nx-a)+abs(ny-b)==abs(x-a)+abs(y-b)==k
  	vector <data> line1=dist(nx, ny, k);
  	vector <data> line2=dist(nx, ny, k);
  for(auto x: line1) for(auto y: line2){
  	auto res=cut(x.x, x.y, x.z, x.t, y.x, y.y, y.z, y.t); 
    if(res.empty()) continue;
    return res;
  }
}
signed main(){
  cin>>k>>x>>y;
  if((x+y+k)%2){
    cout<<"-1\n";
    return 0;
  }
  vector <pair <int, int>> ans;
int nx=0, ny=0;
  while(true){
    if(abs(x-nx)+abs(y-ny)==k){
    	ans.push_back({x, y});
      	break;
    }
  	auto res=find_mid(nx, ny);
    if(res.empty()){
      int maxx=x-nx;
      if(abs(maxx)>=k){
        maxx=k*maxx/abs(maxx);
        nx+=maxx;
      }
      else{
      	int availy=k-abs(maxx);
        nx+=x;
        if(ny<y) ny+=availy;
        else ny-=availy;
      }
      ans.push_back({nx, ny});
    }
    else{
      ans.push_back(res[0]);
      nx=res[0].first;
      ny=res[0].first;
    }
  }
  cout<<ans.size()<<'\n';
  for(auto p: ans) cout<<p.first<<' '<<p.second<<'\n';
}

Compiler output:
a.cc:3:2: error: invalid preprocessing directive #defind; did you mean #define?
    3 | #defind int long long
      |  ^~~~~~
      |  define
a.cc:36:13: error: template argument 1 is invalid
   36 | vector <data> dist(int x, int y, int k){
      |             ^
a.cc:36:13: error: template argument 2 is invalid
a.cc: In function 'int dist(int, int, int)':
a.cc:37:21: error: template argument 1 is invalid
   37 |         vector <data> res;
      |                     ^
a.cc:37:21: error: template argument 2 is invalid
a.cc:38:7: error: request for member 'push_back' in 'res', which is of non-class type 'int'
   38 |   res.push_back(data(x+k, y, x, y+k));
      |       ^~~~~~~~~
a.cc:38:17: error: reference to 'data' is ambiguous
   38 |   res.push_back(data(x+k, y, x, y+k));
      |                 ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:31:7: note:                 'class data'
   31 | class data{
      |       ^~~~
a.cc:39:7: error: request for member 'push_back' in 'res', which is of non-class type 'int'
   39 |   res.push_back(data(x, y+k, x-k, y));
      |       ^~~~~~~~~
a.cc:39:17: error: reference to 'data' is ambiguous
   39 |   res.push_back(data(x, y+k, x-k, y));
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:31:7: note:                 'class data'
   31 | class data{
      |       ^~~~
a.cc:40:7: error: request for member 'push_back' in 'res', which is of non-class type 'int'
   40 |   res.push_back(data(x-k, y, x, y-k));
      |       ^~~~~~~~~
a.cc:40:17: error: reference to 'data' is ambiguous
   40 |   res.push_back(data(x-k, y, x, y-k));
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:31:7: note:                 'class data'
   31 | class data{
      |       ^~~~
a.cc:41:7: error: request for member 'push_back' in 'res', which is of non-class type 'int'
   41 |   res.push_back(data(x, y-k, x+k, y));
      |       ^~~~~~~~~
a.cc:41:17: error: reference to 'data' is ambiguous
   41 |   res.push_back(data(x, y-k, x+k, y));
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:31:7: note:                 'class data'
   31 | class data{
      |       ^~~~
a.cc: In function 'std::vector<std::pair<int, int> > find_mid(int, int)':
a.cc:57:21: error: template argument 1 is invalid
   57 |         vector <data> line1=dist(nx, ny, k);
      |                     ^
a.cc:57:21: error: template argument 2 is invalid
a.cc:58:21: error: template argument 1 is invalid
   58 |         vector <data> line2=dist(nx, ny, k);
      |                     ^
a.cc:58:21: error: template argument 2 is invalid
a.cc:59:15: error: 'begin' was not declared in this scope
   59 |   for(auto x: line1) for(auto y: line2){
      |               ^~~~~
a.cc:59:15: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:59:15: error: 'end' was not declared in this scope
   59 |   for(auto x: line1) for(auto y: line2){
      |               ^~~~~
a.cc:59:15: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
a.cc:59:34: error: 'begin' was not declared in this scope
   59 |   for(auto x: line1) for(auto y: line2){
      |                                  ^~~~~
a.cc:59:34: note: suggested alternatives:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:59:34: error: 'end' was not declared in this scope
   59 |   for(auto x: line1) for(auto y: line2){
      |                                  ^~~~~
a.cc:59:34: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~