criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<bits/stdc++.h>
using namespace std ;
typedef long long ll; 
ll mod = 1e9 + 7 ;
int main () {
  
  int N ;
  string s ;
  cin >> s ;
  N = (int)s.size() ;
  reverse(s.begin(),s.end()) ;
  int dp[N][13] ;
  for(int j = 0 ; j < N ;j++
 	 for(int i = 0 ; i < 13 ;i++)
   	 	dp[j][i] = 0 ;
  if(s[0]=='?'){
    for(int i =0 ; i < 10 ;i++)
      dp[0][i] = 1 ;
  }
  ll pw = 1LL ;
  for(int i = 1 ; i < N ;i++){
    pw = (pw  * 10) %mod ;
    if(s[i] == '?'){
      for(int j = 0 ; j < 10 ;j++)
        for(int k = 0 ; k < 13 ;k++){
          dp[i][(k + j*pw)%13]=(dp[i][(k + j*pw)%13] + dp[i - 1][k])%mod ;
          
    }
    else 
      for(int j =0 ; j < 13 ;j++)
        dp[i][(j + (s[i]-'0')*pw)%13]=(dp[i][(j + (s[i]-'0')*pw)%13] + dp[i - 1][j])%mod ;
      
  }
  cout<<dp[N - 1][5]<<endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:29: error: expected ')' before 'for'
   13 |   for(int j = 0 ; j < N ;j++
      |      ~                      ^
      |                             )
   14 |          for(int i = 0 ; i < 13 ;i++)
      |          ~~~                 
a.cc:29:5: error: expected '}' before 'else'
   29 |     else
      |     ^~~~
a.cc:23:20: note: to match this '{'
   23 |     if(s[i] == '?'){
      |                    ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll mod = 1e9+7;
const int M = 13;
int main(){
    string s;
    cin >>s;

    int n = s.size();

    ll dp[M];
    dp[0] = 1;

    rep(i,n){
        int l = 0, r = 10;
        if(s[i] != '?'){
            l = s[i]-'0';
            r = l+1;
        }

        ll nx[M] = {};
        for(int j=l; j<r; ++j){
            rep(k,M){
                int a = (k*10+j)%M;
                (nx[a] += dp[k]) %= mod; 
            }
        }

        rep(j,M) dp[j] = nx[j];
    }

    cout << dp[5] << endl;
    return 0;
}


Compiler output:
a.cc:35:41: error: extended character   is not valid in an identifier
   35 |                 (nx[a] += dp[k]) %= mod; 
      |                                         ^
a.cc: In function 'int main()':
a.cc:35:41: error: '\U000000a0' was not declared in this scope
   35 |                 (nx[a] += dp[k]) %= mod; 
      |                                         ^
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  ll ans=0,cnt=0,A[10],B[10];
  REP(i,10) A[i]=0;
  
  string S;
  cin>>S;
  ll s=S.size();
  char T[s];
  for(int i=0; i<s; ++2) T[i]=S.at(s-i-1);
  
  for(int i=0; i<s; ++i){
    int a=(i+1)%6;
    if(T[i]=='?') A[a]+=1;
    else if(a==0) cnt+=(T[i]-'0')*4;
    else if(a==5) cnt+=(T[i]-'0')*3;
    else if(a==4) cnt-=T[i]-'0';
    else if(a==3) cnt-=(T[i]-'0')*4;
    else if(a==2) cnt-=(T[i]-'0')*3;
    else cnt+=T[i]-'0';
  }
  
  cnt%=13;
  
  for(int i=0; i<=A[0]; ++i){
    for(int j=0; j<=A[1]; ++j){
      for(int t=0; t<=A[2]; ++t){
        for(int r=0; r<=A[3]; ++r){
          for(int q=0; q<=A[4]; ++q){
            for(int w=0; w<=A[5]; ++w){
              if((4*A[0]+A[1]-3*A[2]-4*A[3]-A[4]+3*A[5]+cnt)%13==5) ans++;
            }
          }
        }
      }
    }
  }
  
  
  
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:23: error: lvalue required as increment operand
   26 |   for(int i=0; i<s; ++2) T[i]=S.at(s-i-1);
      |                       ^
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  ll ans=0,cnt=0,A[10],B[10];
  REP(i,10) A[i]=0;
  
  string S;
  cin>>S;
  ll s=S.size();
  char T[s];
  for(int i=0; i<s; ++S) T[i]=S.at(s-i-1);
  
  for(int i=0; i<s; ++i){
    int a=(i+1)%6;
    if(T[i]=="?") A[a]+=1;
    else if(a==0) cnt+=(T[i]-'0')*4;
    else if(a==5) cnt+=(T[i]-'0')*3;
    else if(a==4) cnt-=T[i]-'0';
    else if(a==3) cnt-=(T[i]-'0')*4;
    else if(a==2) cnt-=(T[i]-'0')*3;
    else cnt+=T[i]-'0';
  }
  
  cnt%=13;
  
  for(int i=0; i<=A[0]; ++i){
    for(int j=0; j<=A[1]; ++j){
      for(int t=0; t<=A[2]; ++t){
        for(int r=0; r<=A[3]; ++r){
          for(int q=0; q<=A[4]; ++q){
            for(int w=0; w<=A[5]; ++w){
              if((4*A[0]+A[1]-3*A[2]-4*A[3]-A[4]+3*A[5]+cnt)%13==5) ans++;
            }
          }
        }
      }
    }
  }
  
  
  
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:21: error: no match for 'operator++' (operand type is 'std::string' {aka 'std::__cxx11::basic_string<char>'})
   26 |   for(int i=0; i<s; ++S) T[i]=S.at(s-i-1);
      |                     ^~~
a.cc:30:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   30 |     if(T[i]=="?") A[a]+=1;
      |        ~~~~^~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

class DDigitsParade {
public:

int f(char c){
    return c - '0';
}

void solve(std::istream& cin, std::ostream& cout) {
    string S;
    cin >> S;
    int n = S.size();
    vector<vector<int64_t>> DP(n + 1, vector<int64_t>(13));
    DP[0][0] = 1;
    int d = 1;
    int p = int(1e9) + 7;

    for (int i = 0; i < n; i++){
        for (int j = 0; j < 13; j++){
            DP[i][j] %= p;
            char s = S[n - i - 1];
            if (s == '?'){
                for (int k = 0; k < 10; k++)
                    DP[i + 1][(j + k * d) % 13] += DP[i][j];
            } else {
                int k = (j + f(s) * d) % 13;
                DP[i + 1][k] += DP[i][j];
            }
        }
        d = d * 10 % 13;
    }

    cout << DP[n][5] % p << endl;
}
};

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+9;
const int mod=1e9+7;
int n;
string s;
ll dp[2][N];
int main(){
  cin>>s;n=s.size();s=" "+s;
  dp[0][0]=1;
  for(int i=1,j=1;i<=n;i++,j^=1){
    if(s[i]!='?'){
      for(int k=0;k<13;k++)dp[j][(k*10+s[i]-'0')%13]=(dp[j][(k*10+s[i]-'0')%13]+dp[j^1][k])%mod;
    }else
      for(int t=0;t<10;t++)
         for(int k=0;k<13;k++)dp[j][(k*10+t)%13]=(dp[j][(k*10+t)%13]+dp[j^1][k])%mod;
  }
  cout<<dp[i%2][5]<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:12: error: 'i' was not declared in this scope
   21 |   cout<<dp[i%2][5]<<endl;
      |            ^
Language: C++

#include <iostream>
#include <string>
using namespace std;
long long MOD = 1000000007;
int main()
{
  string S;
  cin >> S;
  vector<long long> count(13, 0LL);
  count[0] = 1LL;
  for (auto c : S)
  {
    vector<long long> nextgen(13, 0LL);
    for (int digit = 0; digit < 10; digit++)
    {
      if (c == '?' || c == digit + '0')
        for (int i = 0; i < 13; i++)
        {
          int next = (i * 10 + digit) / 13;
          nextgen[next] += count[i];
          nextgen[next] %= MOD;
        }
    }
    count = nextgen;
  }
  cout << count[5] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: 'vector' was not declared in this scope
    9 |   vector<long long> count(13, 0LL);
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | #include <string>
a.cc:9:10: error: expected primary-expression before 'long'
    9 |   vector<long long> count(13, 0LL);
      |          ^~~~
a.cc:10:3: error: 'count' was not declared in this scope
   10 |   count[0] = 1LL;
      |   ^~~~~
a.cc:13:12: error: expected primary-expression before 'long'
   13 |     vector<long long> nextgen(13, 0LL);
      |            ^~~~
a.cc:20:11: error: 'nextgen' was not declared in this scope; did you mean 'next'?
   20 |           nextgen[next] += count[i];
      |           ^~~~~~~
      |           next
a.cc:24:13: error: 'nextgen' was not declared in this scope
   24 |     count = nextgen;
      |             ^~~~~~~
Language: Java

/*input
 
?6?42???8??2??06243????9??3???7258??5??7???????774????4?1??17???9?5?70???76???



*/
import java.io.*;
import java.util.*;

 
public class mymy
{
 
	static OutputStream outputStream = System.out;
	static PrintWriter out = new PrintWriter(outputStream);
	static InputStream inputStream = System.in;
	static InputReader br = new InputReader(inputStream);

	
	
	static String s;
	static int n;


	static long[][] dp;

	static long mod=1000000007;

	static long find(int i,int rem)
	{
		if(i>=n)
		{
			if(rem==5) return 1L;
			return 0L;
		}


		if(dp[i][rem]!=-1) return dp[i][rem];


		if(s.charAt(i)=='?')
		{
			long ans=0;

			for(int j=0;j<=9;j++)
			{
				ans+=find(i+1,((10*rem)+j)%13);
				ans%=mod;
			}
			return dp[i][rem]=ans;
		}
		int nr=(10*rem)+(s.charAt(i)-'0');
		nr%=13;

		return dp[i][rem]=(find(i+1,nr)%mod);
	}



	

	public static void main(String[] args)throws IOException
	{
		
 
		s=br.next();
		n=s.length();

		dp=new long[n][13];

		for(int i=0;i<n;i++) Arrays.fill(dp[i],-1);

		out.println(find(0,0)%mod);



		

 
		out.close();
 
	}





















	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
 
		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
 
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
 
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
 
	}
	
}

Compiler output:
Main.java:12: error: class mymy is public, should be declared in a file named mymy.java
public class mymy
       ^
1 error
Language: C++

#include <iostream>
#include <vector>
#include <stdio.h>
#include <tuple>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <stack>
#include <set>
//#include <complex>
#define INF 1000000021
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222
#define fauto(it, c) for(__typeof((c).begin())  it=(c).begin();it!=(c).end();it++)

using namespace std;
//using namespace __gnu_pbds;
 
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}
 
//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

ll MOD = 1000000007ll;
string s;
int n;
ll dp[N][20];
ll f(int id, int x)
{
	if(id == n)
		return (x == 5);
	if(dp[id][x] != -1)
		return dp[id][x];
	ll ans = 0;
	if(s[id] != '?')
	{
		int q = x;
		q *= 10;
		q += (s[id] - 48);
		q %= 13;
		ans = f(id +1, q);
	}
	else
	{
		for(int i = 0; i <= 9; i ++)
		{
			int q = x;
			q *= 10;
			q += i;
			q %= 13;
			ans = (ans + f(id + 1, q)) % MOD;
		}
	}
	return dp[id][x] = ans % MOD;
}

int main()
{
	memset(dp, -1, sizeof dp);
	cin >> s;
	n = s.size();
	cout << f(0, 0);


		

}

















Compiler output:
a.cc: In function 'int main()':
a.cc:79:9: error: 'memset' was not declared in this scope
   79 |         memset(dp, -1, sizeof dp);
      |         ^~~~~~
a.cc:13:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   12 | #include <set>
  +++ |+#include <cstring>
   13 | //#include <complex>
Language: C++

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007LL;
const int MOD2 = 13;
const int MAX_N = 100005;

int n;
string s;
int pow10[MAX_N];
ll dp[MAX_N][MOD2];

int main()
{
	ios::sync_with_stdio(false);
	cin >> s;
	n = (int)s.length();
	reverse(s.begin(), s.end());

	pow10[0] = 1;
	for (int i = 1; i < n; i++)
		pow10[i] = (pow10[i - 1] * 10LL) % MOD2;

	dp[0][0] = 1;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < MOD2; j++)
		{
			if (s[i] == '?')
			{
				for (int k = 0; k < 10; k++)
				{
					int newRem = (j + pow10[i] * k) % MOD2;
					dp[i + 1][newRem] += dp[i][j];
					if (dp[i + 1][newRem] >= MOD)
						dp[i + 1][newRem] -= MOD;
				}
			}
			else
			{
				int newRem = (j + pow10[i] * (s[i] - '0')) % MOD2;
				dp[i + 1][newRem] += dp[i][j];
				if (dp[i + 1][newRem] >= MOD)
					dp[i + 1][newRem] -= MOD;
			}
		}
	cout << dp[n][5] << endl;
}

Compiler output:
a.cc:14:5: warning: built-in function 'pow10' declared as non-function [-Wbuiltin-declaration-mismatch]
   14 | int pow10[MAX_N];
      |     ^~~~~
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:4:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = char]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:186:14: note: called from here
  186 |       struct _Alloc_hider : allocator_type // TODO check __is_final
      |              ^~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define int long long
using namespace std;

const int DX[4] = {-1, 0, 1, 0}, DY[4] = {0, 1, 0, -1};

int k, x, y;
vector<pair<int, int>> ve;

pair<int, int> forward(int ox, int oy, int dx, int dy, int dst) {
    int tmp = dst, dir;
    if (dx < ox) {
        int mov = min(ox - dx, tmp);
        ox -= mov;
        tmp -= mov;
        dir = -1;
    } else {
        int mov = min(dx - ox, tmp);
        ox += mov;
        tmp -= mov;
        dir = 1;
    }
    if (dy < oy) {
        int mov = min(oy - dy, tmp);
        oy -= mov;
        tmp -= mov;
    } else {
        int mov = min(dy - oy, tmp);
        oy += mov;
        tmp -= mov;
    }
    return {ox + dir * tmp, oy};
}

vector<pair<int, int>> solve(int ox, int oy, int dx, int dy) {
    vector<pair<int, int>> ret;
    while (abs(ox - dx) + abs(oy - dy) >= 2 * k) {
        pair<int, int> fi = forward(ox, oy, dx, dy, k);
        ret.push_back(fi);
        ox = fi.first; oy = fi.second;
    }
    if ((abs(dx - ox) + abs(dy - oy)) % 2 == 1) {
        pair<int, int> fi = forward(ox, oy, dx, dy, k);
        ret.push_back(fi);
        ox = fi.first; oy = fi.second;
    }
    if (ox == dx && oy == dy) {
        return ret;
    }
    int dst = abs(ox - dx) + abs(oy - dy);
    pair<int, int> mid = forward(ox, oy, dx, dy, dst / 2);
    for (int i = 0; i < 4; i++) {
        int tx = mid.first + DX[i] * (k - dst / 2), ty = mid.second + DY[i] * (k - dst / 2);
        if (abs(tx - ox) + abs(ty - oy) == k && abs(tx - dx) + abs(ty - dy) == k) {
            ret.push_back({tx, ty});
            ret.push_back({dx, dy});
            return ret;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> k >> x >> y;
    if (abs(x + y) % 2 == 1 && k % 2 == 0) {
        return cout << -1, 0;
    }
    if (abs(x + y) % 2 == 1) {
        if (abs(x) + abs(y) == k) {
            return cout << "1\n" << x << " " << y, 0;
        } else {
            pair<int, int> st = forward(0, 0, x, y, k);
            int tx = st.first, ty = st.second;
            ve = solve(tx, ty, x, y);
            cout << ve.size() + 1 << '\n' << tx << " " << ty << '\n';
            for (pair<int, int> &v : ve) {
                cout << v.first << " " << v.second << '\n';
            }
            return 0;
        }
    } else {
        ve = solve(0, 0, x, y);
        cout << ve.size() << '\n';
        for (pair<int, int> &v : ve) {
            cout << v.first << " " << v.second << '\n';
        }
        return 0;
    }
}


Compiler output:
cc1plus: error: '::main' must return 'int'
a.cc: In function 'std::vector<std::pair<long long int, long long int> > solve(long long int, long long int, long long int, long long int)':
a.cc:60:1: warning: control reaches end of non-void function [-Wreturn-type]
   60 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

template<typename T>
struct MP {
    int n;
    T t;
    vector<int> a;
    MP() {}
    MP(const T& t): t(t) {
        n = t.size();
        a = vector<int>(n+1);
        a[0] = -1;
        int j = -1;
        for (int i = 0; i < n; ++i) {
            while (j != -1 && t[j] != t[i]) j = a[j];
            j++;
            a[i+1] = j;
        }
    }
    int operator[](int i) { return a[i]; }
    vector<int> findAll(const T& s) {
        vector<int> res;
        int j = 0;
        for (int i = 0; i < s.size(); ++i) {
            while (j != -1 && t[j] != s[i]) j = a[j];
            j++;
            if (j == n) {
                res.push_back(i-j+1);
                j = a[j];
            }
        }
        return res;
    }
};
const int MX = 1000005;
vector<int> to[MX];
bool used[MX];
bool visited[MX];
int path[MX];

bool dfs (int v) {
    if (visited[v]) return false;
    if (used[v]) return true;
    visited[v] = true;
    if (to[v].size()) {
        bool res = dfs(to[v][0]);
        if (!res) return false;
        path[v] = path[to[v][0]] + 1;
    }
    else {
        path[v] = 0;
    }
    visited[v] = false;
    used[v] = true;
    return true;
}

int main(){
    ans = 0;
    cout << ans << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:71:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   71 |     ans = 0;
      |     ^~~
      |     abs
Language: C++

#include <stdio.h>
#include <stdint.h>
#include <utility>
#include <vector>
#include <assert.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int main() {
	int k = ri();
	int x = ri();
	int y = ri();
	bool x_inv = x < 0;
	bool y_inv = y < 0;
	x = std::abs(x);
	y = std::abs(y);
	
	if (!(k & 1) && ((x + y) & 1)) {
		puts("-1");
		return 0;
	}
	
	std::vector<std::pair<int, int> > res;
	int cur_x = 0, cur_y = 0;
	auto go = [&] () {
		int remain = k;
		if (cur_x < x) {
			int add = std::min(remain, x - cur_x);
			cur_x += add;
			remain -= add;
		}
		cur_y += remain;
		res.push_back({cur_x, cur_y});
	};
	
	for (int i = 0; i < (x + y) / k; i++) go();
	
	bool match = !((k & 1) && ((x + y - cur_x - cur_y) & 1));
	if (!res.size() && !((x + y) & 1)) go();
	bool slide = !res.size();
	if (!res.size()) y += k, res = {{0, 0}, {cur_x = x, cur_y = k - x}};
	if (cur_x != x || cur_y != y) {
		int over = k - (x + y - cur_x - cur_y);
		if (over & 1) res.push_back({cur_x = x, cur_y = y + over}), over += k;
		over /= 2;
		if (!cur_y) {
			cur_x -= over;
			cur_y -= over;
		} else {
			if (over > cur_y) {
				over -= cur_y;
				cur_x = -over;
				cur_y = -cur_y - over;
			} else {
				cur_x += over;
				cur_y -= over;
			}
		}
		res.back() = {cur_x, cur_y};
		res.push_back({x, y});
	}
	if (slide) for (auto &i : res) i.second -= k;
	if (x_inv) for (auto &i : res) i.first = -i.first;
	if (y_inv) for (auto &i : res) i.second = -i.second;
	printf("%d\n", (int) res.size());
	for (auto i : res) printf("%d %d\n", i.first, i.second);
	for (int i = 0; i + 1 < (int) res.size(); i++)
		if (std::abs(res[i].first - res[i + 1].first) + std::abs(res[i].second - res[i + 1].second) != k)
			fprintf(stderr, "FAIL %d\n", i), assert(0);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:18: error: 'abs' is not a member of 'std'
   18 |         x = std::abs(x);
      |                  ^~~
a.cc:19:18: error: 'abs' is not a member of 'std'
   19 |         y = std::abs(y);
      |                  ^~~
a.cc:71:26: error: 'abs' is not a member of 'std'
   71 |                 if (std::abs(res[i].first - res[i + 1].first) + std::abs(res[i].second - res[i + 1].second) != k)
      |                          ^~~
a.cc:71:70: error: 'abs' is not a member of 'std'
   71 |                 if (std::abs(res[i].first - res[i + 1].first) + std::abs(res[i].second - res[i + 1].second) != k)
      |                                                                      ^~~
Language: C++

#include<iostream>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int sX, sY;
bool yx;
void put(int x, int y, bool end = false) {
  x*=sX; y*=sY;
  if(yx) std::swap(x, y);
  std::cout << x << " " << y << "\n";
  if(end) exit(0);
}


int main() {
  int K, X, Y; std::cin >> K >> X >> Y;
  sX = sY = 1; yx = false;
  if(X < 0) { sX = -1; X = -X; }
  if(Y < 0) { sY = -1; X = -Y; }
  if(X < Y) { std::swap(X, Y); yx = true; }
  int m = X+Y;
  if(m%2 == 1 && K%2 == 0) fin(-1);
  if(m == K) {
    std::cout << 1 << "\n";
    put(X, Y, true);
  }
  int n = 2;
  if(m < K) {
    if(m%2 == 1) { // K should be also odd
      int fx = (K+X-Y)/2, fY = (K-X+Y)/2;
      std::cout << 3 << "\n";
      put(X, -(K-X)); put(fx, fy); put(-fx, fy, true);
    }
  } else {
    n = (m+K-1)/K;        // ceil(m/K)
    int c = (K - m%K)%K; // -m mod K
    n += c%2;
  }
  std::cout << n << "\n";
  int fy = -(K*n-m)/2, gy = Y - fy;
  int fx = K + fy;
  put(fx, fy); X -= fx;
  while(X >= K) { put(K, 0); X -= K; }
  put(X, K-X); gy -= K-X;
  while(gy >= K){ put(0, K); gy -= K; }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:31: error: 'fy' was not declared in this scope; did you mean 'fY'?
   35 |       put(X, -(K-X)); put(fx, fy); put(-fx, fy, true);
      |                               ^~
      |                               fY
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<bool> change(3, false);

void typea(ll k, ll x, ll y, ll n) {
  vector<pair<ll, ll>> ans;
  pair<ll, ll> res = {0, 0};
  while (res.second - k >= -((k * n - x - y) / 2)) {
    res.second -= k;
    ans.push_back(res);
  }
  ll r = k - (res.second + (k * n - x - y) / 2);
  res = {r, -(k * n - x - y) / 2};
  ans.push_back(res);
  while (res.first + k <= x) {
    res.first += k;
    ans.push_back(res);
  }
  r = k - (x - res.first);
  res = {x, r - (k * n - x - y) / 2};
  ans.push_back(res);
  while (res.second < y) {
    res.second += k;
    ans.push_back(res);
  }
  cout << ans.size() << endl;
  rep(i, ans.size()) {
    if (change[2]) swap(ans[i].first, ans[i].second);
    if (change[0]) ans[i].first *= -1;
    if (change[1]) ans[i].second *= -1;
    cout << ans[i].first << " " << ans[i].second << endl;
  }
}

void typeb(ll k, ll x, ll y) {
  vector<pair<ll, ll>> ans;
  pair<ll, ll> res = {0, 0};
  res = {x, -(k - x)};
  ans.push_back(res);
  res = {x + (k + x - y) / 2, (k - x + y) / 2 - (k - x)};
  ans.push_back(res);
  res = {x, y};
  ans.push_back(res);
  cout << 3 << endl;
  rep(i, 3) {
    if (change[2]) swap(ans[i].first, ans[i].second);
    if (change[0]) ans[i].first *= -1;
    if (change[1]) ans[i].second *= -1;
    cout << ans[i].first << " " << ans[i].second << endl;
  }
}

int main() {
  ll k, x, y;
  cin >> k >> x >> y;

  if (x < 0) {
    change[0] = true;
    x = -x;
  }
  if (y < 0) {
    change[1] = true;
    y = -y;
  }
  if (x < y) {
    change[2] = true;
    swap(x, y);
  }
  if ((x + y) % 2 == 1 && k % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }
  if ((x + y) < k) {
    if ((x + y) % 2 == 1) {
      typeb(k, x, y);
    }
    else {
      typea(k, x, y, 2);
    }
  }
  else {
    ll c = (k - ((x + y) % k)) % k;
    if (c == 0) {
      if ((x + y) / k == 1) {
        if (change[2]) swap(x, y);
        if (change[0]) x = -x;
        if (change[1]) y = -y;
        cout << 1 << endl;
        cout << x << " " << y << endl;
      }
      else typea(k, x, y, (x + y) / k); 
    else if (c % 2 == 0) typea(k, x, y, (x + y) / k + 1);
    else typea(k, x, y, (x + y) / k + 2);
  }




  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:108:5: error: expected '}' before 'else'
  108 |     else if (c % 2 == 0) typea(k, x, y, (x + y) / k + 1);
      |     ^~~~
a.cc:99:17: note: to match this '{'
   99 |     if (c == 0) {
      |                 ^
Language: C++

#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll K,X,Y;
  cin>>K>>X>>Y;
  vector<pair<ll,ll>> ans;

  ll x=abs(X),y=abs(Y);

  if(K%2==0 && (x+y)%2!=0){
    cout<<-1<<endl;
    return 0;
  }

  ll nowx=0,nowy=0;

  // 貪欲に近づく
  while(x-nowx+y-nowy>=2*K){
    if(x-nowx>=K){
      nowx+=K;
    }else{
      assert(y-nowy>=K);
      nowy+=K;
    }
    ans.emplace_back(nowx,nowy);
  }


  ll dx=x-nowx, dy=y-nowy;
  if(dx==0 || dy==0){
    // もう到着している
  }else if(dx+dy==K){
    // 自明に一手でいける
    ans.emplace_back(x,y);
  }else{
    // 偶奇が合わないのでいい感じにパスする
    if((dx+dy)%2!=0){
      if(x-nowx<=K){
        nowy-=K-(x-nowx);
        nowx=x;
      }else{
        assert(y-nowy<=K);
        nowx-=K-(y-nowy);
        nowy=y;
      }
      dx=x-nowx, dy=y-nowy;
      ans.emplace_back(nowx,nowy);
    }

    // ここから必ず2手で行ける
    assert(dx>=0);
    assert(dy>=0);
    assert((dx+dy)%2==0);
    assert(dx+dy<=2*K);
    assert(dx+dy!=K);
    assert(dx+dy!=0);
    if(dx<=dy){
      nowx+=K-(dy-dx)/2;
      nowy+=(dy-dx)/2;
      ans.emplace_back(nowx,nowy);
      ans.emplace_back(x,y);
    }else{
      nowy+=K-(dx-dy)/2;
      nowx+=(dx-dy)/2;
      ans.emplace_back(nowx,nowy);
      assert(abs(nowx-x)+abs(nowy-y)==K)
      ans.emplace_back(x,y);
    }
  }

  cout<<ans.size()<<endl;
  // REP(i,ans.size()-1){
  //   assert(
  //     abs(ans[i].first-ans[i+1].first) + abs(ans[i].second-ans[i+1].second) == K
  //   );
  // }
  for(auto e:ans){
    ll f,s;
    if(X<0){
      f=-e.first;
    }else{
      f=e.first;
    }
    if(Y<0){
      s=-e.second;
    }else{
      s=e.second;
    }
    cout<<f<<" "<<s<<endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:109:7: error: expected ';' before 'ans'
  109 |       ans.emplace_back(x,y);
      |       ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int k,x,y,nowx=0,nowy=0;

struct r2{int x,y;};
vector<r2> ans;

void move(int x,int y){
  nowx+=x;nowy+=y;
  ans.push_back({nowx,nowy});
}

//main
signed main(){
  cin>>k>>x>>y;

  if(!(k&1)&&((x+y)&1))fin(-1);
  if(abs(x)+abs(y)==k){
    cout<<1<<endl<<x<<" "<<y<<endl;
    return 0;
  }

  int X=abs(x),Y=abs(y);
  if(X>Y)swap(X,Y);

  int sousai=-1;
  for(int j=k*2;sousai<0;j+=k)
    if((j-(X+Y))%2==0)sousai=(j-(X+Y))/2;

  if(sousai){
    while(sousai>=k){
      move(0,-k);
      sousai-=k;
    }
    move(-sousai,k-sousai);
  }

  while(nowx+k<=X)move(k,0);
  while(nowy+k<=Y)move(0,k);
  if(nowx!=X||nowy!=Y)ans.push_back({X,Y});

  cout<<ans.size()<<endl;

  for(auto p:ans){
    int ansx=p.x,ansy=p.y;
    if(abs(x)>abs(y))swap(ansx,ansy);
    if(x<0)ansx*=-1;
    if(y<0)ansy*=-1;
    cout<<ansx<<" "<<ansy<<endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:24: error: 'fin' was not declared in this scope; did you mean 'sin'?
   18 |   if(!(k&1)&&((x+y)&1))fin(-1);
      |                        ^~~
      |                        sin
Language: C++

#include <bits/stdc++.h>
using namespace std;

using ULL = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)

void solve(){
  int k; cin >> k;
  int x,y; cin >> x >> y;
  int px = 0, py = 0;
  int mulx = x > 0 ? 1 : -1;
  int muly = y > 0 ? 1 : -1;
  x /= mulx; y /= muly;
  
  vector<pair<int,int>> ans;
  if(k % 2 == 0){
    if((x+y)%2 == 1){cout << -1 << endl; return;}
    while(x+y >= 2 * k){
      if(x >= k){px+=k; ans.push_back({px,py}); x-=k; continue;}
      if(y >= k){py+=k; ans.push_back({px,py}); y-=k; continue;}
    }
    if(x+y != k){
      if(x>y){
        int dy = y+k-(x+y)/2;
        px+=(k-dy); py+=dy;
        ans.push_back({px,py});
      } else {
        int dx = x+k-(x+y)/2;
        px+=dx; py+=(k-dx);
        ans.push_back({px,py});
      }
    }
    ans.push_back({px+x, py+y});
  }
  else{
    while(x+y >= 2 * k){
      if(x >= k){px+=k; ans.push_back({px,py}); x-=k; continue;}
      if(y >= k){py+=k; ans.push_back({px,py}); y-=k; continue;}
    }
    if(ans.size()%2 == 0){
      if(x+y == k){ans.push_back({px+x,py+y}); x=y=0;}
      else{
      }
    }
    if(x+y != 0){
      if(x>y){
        int dy = y+k-(x+y)/2;
        px+=(k-dy); py+=dy;
        ans.push_back({px,py});
      } else {
        int dx = x+k-(x+y)/2;
        px+=dy; py+=(k-dy);
        ans.push_back({px,py});
      }
      ans.push_back({px+x, py+y});
    }
  }
  
  cout << ans.size() << endl;
  rep(i,ans.size()){
    cout << ans[i].first * mulx << " " << ans[i].second * muly << endl;
  }
}
int main(){
  solve();
  return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:52:13: error: 'dy' was not declared in this scope; did you mean 'dx'?
   52 |         px+=dy; py+=(k-dy);
      |             ^~
      |             dx
Language: C++

#include <bits/stdc++.h>
using namespace std;

using ULL = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)

void solve(){
  int k; cin >> k;
  int x,y; cin >> x >> y;
  int px = 0, py = 0;
  int mulx = x > 0 ? 1 : -1;
  int muly = y > 0 ? 1 : -1;
  x /= mulx; y /= muly;
  
  vector<pair<int,int>> ans;
  if(k % 2 == 0){
    if((x+y)%2 == 1){cout << -1 << endl; return;}
    while(x+y >= 2 * k){
      if(x >= k){px+=k; ans.push_back({px,py}); x-=k; continue;}
      if(y >= k){py+=k; ans.push_back({px,py}); y-=k; continue;}
    }
    if(x+y != k){
      if(x>y){
        int dy = y+k-(x+y)/2;
        px+=(k-dy); py+=dy;
        ans.push_back({px,py});
      } else {
        int dx = x+k-(x+y)/2;
        px+=dy; py+=(k-dy);
        ans.push_back({px,py});
      }
    }
    ans.push_back({px+x, py+y});
  }
  else{
    while(x+y >= 2 * k){
      if(x >= k){px+=k; ans.push_back({px,py}); x-=k; continue;}
      if(y >= k){py+=k; ans.push_back({px,py}); y-=k; continue;}
    }
    if(ans.size()%2 == 0){
      if(x+y == k){ans.push_back({px+x,py+y}); x=y=0;}
      else{
      }
    }
    if(x+y != 0){
      if(x>y){
        int dy = y+k-(x+y)/2;
        px+=(k-dy); py+=dy;
        ans.push_back({px,py});
      } else {
        int dx = x+k-(x+y)/2;
        px+=dy; py+=(k-dy);
        ans.push_back({px,py});
      }
      ans.push_back({px+x, py+y});
    }
  }
  
  cout << ans.size() << endl;
  rep(i,ans.size()){
    cout << ans[i].first * mulx << " " << ans[i].second * muly << endl;
  }
}
int main(){
  solve();
  return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:29:13: error: 'dy' was not declared in this scope; did you mean 'dx'?
   29 |         px+=dy; py+=(k-dy);
      |             ^~
      |             dx
a.cc:52:13: error: 'dy' was not declared in this scope; did you mean 'dx'?
   52 |         px+=dy; py+=(k-dy);
      |             ^~
      |             dx
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int k;
  cin >> k;
  int x,y;
  cin >> x >> y;
  int s=0;
  
  int adjust_x = 1;
  int adjust_y = 1;
  
  int just_x=0;//just_ではまだ第一象限のみで考えている
  int just_y=0;//
  
  if(x < 0){
    adjust_x = -1;
    x *= -1;
  }
  if(y < 0){
    adjust_y = -1;
    y *= -1;
  }
  
  
  if(k%2 == 0 && (x + y)%2 == 1){
    cout << -1 << endl;
    return 0;
  }
  
  if(k%2 == 0 && (x + y)%2 == 0){//k=偶数の話
    if(k > x + y) {
      cout << 2 << endl;
      if(x >= y){
        just_x = (x+y)/2;
        just_y = (x+y)/2 - k;
      }
      else{
        just_y = (x+y)/2;
        just_x = (x+y)/2 - k;
       }
      cout << just_x*adjust_x <<" "<< just_y*adjust_y << endl;
    }
    if(k <= x + y){
      s += (x + y)/k;
      if((x + y)%k != 0) s += 1;
      cout << s << endl;
      if((x + y)%k == 0){
        just_x = 0;
        just_y = 0;
      }
      else{
        if(x >= y){
          just_x = (k + (x + y)%k)/2;
          just_y = -(k - (x + y)%k)/2;
        }
        else{
          just_y = (k + (x + y)%k)/2;
          just_x = -(k - (x + y)%k)/2;
        }
        cout << just_x*adjust_x <<" "<< just_y*adjust_y << endl;
      }     
    }
  }
  if(k%2 == 1){//k=奇数の話
    if(k > x + y){//ボールの飛距離が大きすぎる
      if((k - (x + y))%2 == 1){
        cout << 2 << endl;//奇数戻ってその後ゴール
        if(x >= y){
          just_x = (k - (k - (x + y)%k))/2;
          just_y = -((k + (k - (x + y)%k))/2);
        }
        if(x < y){
          just_y = (k - (k - (x + y)%k))/2;
          just_x = -((k + (k - (x + y)%k))/2);
        }
        cout << just_x*adjust_x <<" "<< just_y*adjust_y << endl;
      }
      else{//とにかく純粋に下がってから前へ出て調整
        cout << 3 << endl;
        cout << -k*adjust_x <<" "<< 0 << endl;
        if(x >= y){
          just_x = (k + (x + y)%k)/2 - k;
          just_y = -((k - (x + y)%k))/2;
        }
        if(x < y){
          just_y = (k + (x + y)%k)/2 - k;
          just_x = -((k - (x + y)%k))/2;
        }
         cout << just_x*adjust_x <<" "<< just_y*adjust_y << endl;
      }
    }
    if(k <= x + y){//kが奇数で飛距離がほどほど
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:95:2: error: expected '}' at end of input
   95 | }
      |  ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: C++

#include <cmath>
#include <iostream>
#include <vector>
#include <tuple>

int main(){
  int K,X,Y;
  std::cin >> K >> X >> Y;
  int init_x = X, init_y = Y;

  auto L = [&](){return std::abs(X)+std::abs(Y);};
  std::vector<std::tuple<int, int>> move_arr;
  auto xy_move1 = [&](){
    if(X <= -K){
      X += K;
    }else if(X >= K){
      X -= K;
    }else{
      if(Y > 0){
        Y -= K-std::abs(X);
      }else{
        Y += K-std::abs(X);
      }
      X = 0;
    }
    move_arr.emplace_back(X,Y);
  };
  auto xy_move2 = [&](){
    int l = L()/2;
    if(std::abs(X) > std::abs(Y)){
      if(X < 0){
        X += l;
      }else{
        X -= l;
      }
      if(Y < 0){
        Y -= K-l;
      }else{
        Y += K-l;
      }
    }else{
      if(Y < 0){
        Y += l;
      }else{
        Y -= l;
      }
      if(X < 0){
        X -= K-l;
      }else{
        X += K-l;
      }
    }
    move_arr.emplace_back(X,Y);
  };

  if(K&1){
    if(L()&1){
      xy_move1();
    }
    while(L() > 2*K){
      xy_move1();
      xy_move1();
    }
    if(K() > 0){
      xy_move2();
      xy_move1();
    }
  }else{
    if(L()&1){
      std::cout << "-1\n";
      return 0;
    }
    while(L() > 2*K){
      xy_move1();
    }
    if(L() == 0){
    }else if(L() == K){
      xy_move1();
    }else{
      xy_move2();
      xy_move1();
    }
  }
  std::cout << move_arr.size() << "\n";
  for(auto&& it: move_arr){
    int x,y;
    std::tie(x,y) = it;
    std::cout << init_x-x << " " << init_y-y << "\n";
  }

  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:64:9: error: 'K' cannot be used as a function
   64 |     if(K() > 0){
      |        ~^~
Language: C++

#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(f, 0, (x.size()-1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

int K,X,Y;
void input()
{
    cin>>K;
    cin>>X>>Y;
}
void solve()
{
    // クリア可能かどうか
    if (K%2==0 and (X+Y)%2==1){
        // 不可能
        cout<<-1<<endl;
        return;
    }

    // クリア可能な場合
    bool xrev = false, yrev = false, swapped=false;
    if (X<0){X*=-1;xrev=1;}
    if (Y<0){*=-1Y;yrev=1;}
    if (X<Y){swap(X,Y);swapped=1;} // X>Yにする

    vector<pii> anss;
    int N = max((X+Y+K-1)/K , 2LL);
    if ((X+Y)%2 != N*K%2) N++; // 

    if (X+Y==K) anss.push_back(pii(X,Y));
    else if (N==3 && X<K) {
        int mid = (K+X-Y) / 2;
        anss.push_back(pii(X,X-K));
        anss.push_back(pii(X+mid, Y-K+mid));
        anss.push_back(pii(X,Y));
    }
    else {
        int over = (N*K-X-Y)/2;
        rep(i,1,N){
            int d = i*K; // 総移動距離
            if (d <= Y+over) anss.push_back(pii(0,d));
            else if (d <= Y + over + X) anss.push_back(pii(d-Y-over,Y+over));
            else anss.push_back(pii(X, Y+(N-i)*K));
        }
    }
    if (swapped) rep(i,0,anss.size()-1) swap(anss[i].first, anss[i].second);
    if (xrev) rep(i,0,anss.size()-1) anss[i].first*=-1;
    if (yrev) rep(i,0,anss.size()-1) anss[i].second*=-1;

    cout<<anss.size()<<endl;
    for(auto &x : anss){
        cout<<x.first<<" "<<x.second<<endl;;
    }

}
signed main()
{
    input();
    solve();
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:32:14: error: expected primary-expression before '*=' token
   32 |     if (Y<0){*=-1Y;yrev=1;}
      |              ^~
a.cc:32:17: error: unable to find numeric literal operator 'operator""Y'
   32 |     if (Y<0){*=-1Y;yrev=1;}
      |                 ^~
Language: C++

#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>

std::vector<std::pair<intmax_t, intmax_t>> neko(intmax_t X, intmax_t Y, intmax_t K, intmax_t d) {
  std::vector<std::pair<intmax_t, intmax_t>> res;
  intmax_t x = 0;
  intmax_t y = 0;

  if (X+Y < K && (X+Y) % 2 != 0) {
    x += X;
    y -= K-X;
    res.emplace_back(x, y);
    intmax_t d = (K+X-Y) / 2;
    x += d;
    y += K-d;
    res.emplace_back(x, y);
    res.emplace_back(X, Y);
    return res;
  }

  while (y-K > -d) {
    y -= d;
    // fprintf(stderr, "1: (%jd, %jd)\n", x, y);
    res.emplace_back(x, y);
  }
  x += y-d;
  y = -d;
  // fprintf(stderr, "2: (%jd, %jd)\n", x, y);
  if (d) res.emplace_back(x, y);
  while (x+K < X) {
    x += K;
    // fprintf(stderr, "3: (%jd, %jd)\n", x, y);
    res.emplace_back(x, y);
  }
  y += K-(X-x);
  x = X;
  // fprintf(stderr, "4: (%jd, %jd)\n", x, y);
  res.emplace_back(x, y);
  while (y+K <= Y) {
    y += K;
    // fprintf(stderr, "5: (%jd, %jd)\n", x, y);
    res.emplace_back(x, y);
  }
  return res;
}

int main() {
  intmax_t K, X, Y;
  scanf("%jd %jd %jd", &K, &X, &Y);

  if ((X+Y) % 2 != 0 && K % 2 == 0) return puts("-1"), 0;

  bool xneg = (X < 0);
  if (xneg) X = -X;
  bool yneg = (Y < 0);
  if (yneg) Y = -Y;
  bool swapped = (X < Y);
  if (swapped) std::swap(X, Y);

  intmax_t d = 0;
  intmax_t d0 = 2;
  if (X+Y >= K) {
    d0 = (X+Y+K-1) / K;
    intmax_t c = (K - (X+Y)%K) % K;
    if (X+Y >= K && c % 2 != 0) ++d0;
    // fprintf(stderr, "n: %jd\n", d0);
  }
  // fprintf(stderr, "(%jd*%jd-(%jd+%jd))/2 = %jd\n", d0, K, X, Y, ((d0*K-(X+Y))/2));
  d = (d0*K-(X+Y)) / 2;
  // fprintf(stderr, "d: %jd\n", d);

  auto res = neko(X, Y, K, d);
  assert(size_t(d0) == res.size());
  printf("%zu\n", res.size());
  for (auto p: res) {
    intmax_t x, y;
    std::tie(x, y) = p;
    if (swapped) std::swap(x, y);
    if (xneg) x = -x;
    if (yneg) y = -y;
    printf("%jd %jd\n", x, y);
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:78:3: error: 'assert' was not declared in this scope
   78 |   assert(size_t(d0) == res.size());
      |   ^~~~~~
a.cc:7:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    6 | #include <utility>
  +++ |+#include <cassert>
    7 | #include <tuple>
Language: C++

#include<bits/stdc++.h>

using namespace std;

// typedef pair<int, int> P;
struct P {
	int x, y;
	P(int x = 0, int y = 0): x(x), y(y) {}
};
const int maxn = 2e5 + 10;
P p[maxn];
int K;

P cal(int x, int y) {
	if (x > y) {
		P p = cal(y, x);
		return P(p.y, p.x);
	}
	if (x < 0) {
		P p = cal(-x, y);
		return P(-p.x, p.y);
	}
	if (x + y == K) return P(0, 0);
	if (x + y >= 2 * K) return P(x, y - K);
	int t = K - (x + y) / 2;
	return P(-t, y - K + x + t);
}
int main(void) {
	cin >> K;
	int x, y;
	cin >> x >> y;
	if (((x + y) & 1) && k % 2 == 0) return puts("-1"), 0;
	int cnt = 0;
	p[++cnt] = P(x, y);

	for (; p[cnt].x || p[cnt].y; ++cnt) {
		p[cnt + 1] = cal(p[cnt].x, p[cnt].y);
	}
	cout << cnt - 1 << endl;
	for (int i = cnt - 1; i >= 1; --i) {
		printf("%d %d\n", p[i].x, p[i].y);
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:30: error: 'k' was not declared in this scope
   32 |         if (((x + y) & 1) && k % 2 == 0) return puts("-1"), 0;
      |                              ^
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;

struct point{
    ll x, y;
    point(ll x = 0, ll y = 0) : x(x), y(y) {}
};

void answer(vector<point>& vec, ll size, bool x, bool y, bool s){
    cout << (ll)vec.size() << endl;
    for(point p : vec){
        if(s)swap(p.x, p.y);
        if(y)p.y = -p.y;
        if(x)p.x = -p.x;
        cout << p.x << ' ' << p.y << endl;
    }
}

int64_t main(){

    ll K, X, Y;
    cin >> K >> X >> Y;

    bool xnegative = false;
    if(X < 0){
        X = -X;
        xnegative = true;
    }
    bool ynegative = false;
    if(Y < 0){
        Y = -Y;
        ynegative = true;
    }
    bool swapped = false;
    if(X < Y){
        swap(X, Y);
        swapped = true;
    }

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

    ll step = 0;
    vector<point> ans;

    if(D < K and D % 2 == 1){
        step = 3;
        ans.push_back(point(X, X - K));
        ans.push_back(point(X + (K + X - Y) / 2, Y - K + (K + X - Y) / 2));
        ans.push_back(point(X, Y));
        answer(ans, step, xnegative, ynegative, swapped);
        return 0;
    } else {
        if(D < K and D % 2 == 0)step = 2;
        else if(((K - D % K) % K) % 2 == 0)step = (D + K - 1) / K;
        else step = ((D + K - 1) / K) + 1;
        ll down = (D - K * step) / 2;
        assert(D - 2 * down == step * K);
        point now(0, 0);
        while(now.y - K >= down){
            now.y -= K;
            ans.push_back(now);
        }
        now.x = K - (now.y - down);
        now.y = down;
        assert((abs(now.x) + abs(now.y)) % K == 0);
        ans.push_back(now);
        while(now.x + K <= X){
            now.x += K;
            ans.push_back(now);
        }
        now.y = down + K - (X - now.x);
        now.x = X;
        assert((Y - now.y) % K == 0);
        ans.push_back(now);
        ll tmp = (Y - now.y) / K;
        assert(tmp * K + now.y == Y); //ここまではREにならない
        rep(i, tmp){
            now.y += K;
            ans.push_back(now);
        }
        assert(now.y == Y); //ここでRE
        answer(ans, step, xnegative, ynegative, swapped);
        return 0;
    }

}


Compiler output:
a.cc:24:1: error: '::main' must return 'int'
   24 | int64_t main(){
      | ^~~~~~~