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

#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cmath>
#define ll long long

using namespace std;
int l[100010],r[100010];
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    int N;
    int sum=0;
    cin>>N;
    for(int i=1;i<=N;i++){
        cin>>l[i]>>r[i];
    }
    l[0]=0; r[0]=0;
    sort(r,r+N+1);
    sort(l,l+N+1,cmp);
    for(int i=0;i<N;i++){
        if(l[i]>r[i]){
            sum+=2*(l[i]-r[i]);
        }
    }
    cout<<sum<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:5: error: 'cin' was not declared in this scope
   19 |     cin>>N;
      |     ^~~
a.cc:7:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    6 | #include <cmath>
  +++ |+#include <iostream>
    7 | #define ll long long
a.cc:31:5: error: 'cout' was not declared in this scope
   31 |     cout<<sum<<endl;
      |     ^~~~
a.cc:31:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:31:16: error: 'endl' was not declared in this scope
   31 |     cout<<sum<<endl;
      |                ^~~~
a.cc:7:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    6 | #include <cmath>
  +++ |+#include <ostream>
    7 | #define ll long long
Language: C++

#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long ll;
int l[100010],r[100010];
int main(){
	int n,i;
	ll ans;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d%d",l+i,r+i);
	sort(l,l+n+1,greater<int>());
	sort(r,r+n+1);
	ans=0;
	for(i=0;i<=n;i++){
		if(l[i]<=r[i])break;
		ans+=l[i]-r[i];
	}
	printf("%lld",ans<<1);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:22: error: 'greater' was not declared in this scope
   11 |         sort(l,l+n+1,greater<int>());
      |                      ^~~~~~~
a.cc:11:30: error: expected primary-expression before 'int'
   11 |         sort(l,l+n+1,greater<int>());
      |                              ^~~
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;
int n, st1[810000], st2[810000], l[110000], r[110000], num1[810000], num2[810000];
void update(int a, int b, int index, int val, int toadd, int* n1, int* s1, int mode)
{
	//cout << a << " " << b << " " << val << " " << mode << endl;;
	if (a > val || b < val)
		return;
	if (a == b)
	{
		n1[index] += toadd;
		if (n1[index] > 0)
			s1[index] = a;
		else
		{
			if (mode == 1)
				s1[index] = 0;
			else
				s1[index] = 2e5 + 1;
		}
	}
	else
	{
		update(a, (a + b) / 2, 2 * index, val, toadd, n1, s1, mode);
		update((a + b) / 2 + 1, b, 2 * index + 1, val, toadd, n1, s1, mode);
		if (mode == 1)
			s1[index] = max(s1[2 * index], s1[2 * index + 1]);
		else
			s1[index] = min(s1[2 * index], s1[2 * index + 1]);
	}
}
int main()
{
	cin >> n;
	memset(st1, 0, sizeof(st1));
	memset(num1, 0, sizeof(num1));
	memset(num2, 0, sizeof(num2));
	for (int i = 0; i < 8e5; i++)
		st2[i] = 2e5 + 1;
	
	for (int i = 0; i < n; i++)
	{
		cin >> l[i] >> r[i];
		update(0, 2e5, 1, l[i]+1e5, 1, num1, st1, 1);
		update(0, 2e5, 1, r[i]+1e5, 1, num2, st2, 2);
	}

	int currpos = 1e5;
	ll ans = 0;

	while (n--)
	{
		int t1 = st1[1], t2 = st2[1];
		if (t1 <= currpos && t2 >= currpos)
			break;
		if (t1 <= currpos)
		{
			ans += (currpos - t2);
			currpos = t2;
			update(0, 2e5, 1, t2, -1, num2, st2, 2);
		}
		else if (t2 >= currpos)
		{
			ans += (t1 - currpos);
			currpos = t1;
			update(0, 2e5, 1, t1, -1, num1, st1, 1);
		}
		else
		{
			int diff1 = (currpos - t2);
			int diff2 = (t1 - currpos);
			if (diff1 > diff2)
			{
				ans += diff1;
				currpos = t2;
				update(0, 2e5, 1, t2, -1, num2, st2, 2);
			}
			else
			{
				ans += diff2;
				currpos = t1;
				update(0, 2e5, 1, t1, -1, num1, st1, 1);
			}
		}
	}
	if (currpos < 1e5)
		ans += (1e5-currpos);
	else
		ans += (currpos-1e5);
	
	cout << ans << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:37:9: error: 'memset' was not declared in this scope
   37 |         memset(st1, 0, sizeof(st1));
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <algorithm>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
long long main(void){
    long long N;
    cin >> N;
    vector<long long> L, R;
    L.resize(N+1); R.resize(N+1);
    L[0] = 0; R[0] = 0;
    for(long long i=1; i<N+1; ++i) cin >> L[i] >> R[i];
    sort(L.begin(), L.end(), greater<long long>());
    sort(R.begin(), R.end());
    long long ans = 0;
    for(long long i=0; i<N+1; ++i){
        ans += 2 * max(0LL, L[i]-R[i]);
    }
    cout << ans << endl;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int L[100001],R[100001];
bool used[100001];
int main(){
        int n;
    cin>>n;
    int l,r;
    rep(i,n){
        cin>>l>>r;
        L[i]=l;
        R[i]=r;
    }
    sort(L,L+n,greater<int>());
    sort(R,R+n);
    ll mx=0;
    ll sum=0;
    rep(i,n){
        mx=max(mx,sum+max(L[i],-R[i]));
        sum+=L[i]-R[i];
        mx=max(mx,sum);
    }
    cout<<mx*2<<endl;
    return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:30:14: error: expected '}' at end of input
   30 |     return 0;
      |              ^
a.cc:11:11: note: to match this '{'
   11 | int main(){
      |           ^
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int n,a[100003],b[100003];
int main()
{
	cin>>n;
	int q1,q2,len=0;
	for(int i=1;i<=n;i++)
	{
		cin>>q1>>q2;
		if(q1<=0&&q2>=0) continue;
		a[++len]=q1; b[len]=q2;
	}
	sort(a+1,a+len+1);
	sort(b+1,b+len+1);
	long long tot=0;
	for(int i=1;i<=len;i++)
	{
		if(i<len-i+1)
		{
			tot+=a[len-i+1]-b[i];
		}
		else
		{
			if(i==len-i+1)
			{
				if(a[len-i+1]<=0&&b[len-i+1]>=0) ;
				else tot+=min(abs(a[len-i+1]),abs(b[len-i+1]));
			}
			break;
		}
	}
	cout<<tot*2;
	return 0;
}
	sort(a+1,a+len+1);
	sort(b+1,b+len+1);
	long long tot=0;
	for(int i=1;i<=len;i++)
	{
		if(i<len-i+1)
		{
			tot+=a[len-i+1]-b[i];
		}
		else
		{
			if(i==len-i+1)
			{
				if(a[len-i+1]<=0&&b[len-i+1]>=0) ;
				else tot+=min(abs(a[len-i+1]),abs(b[len-i+1]));
			}
			break;
		}
	}
	cout<<tot*2;
	return 0;
}

Compiler output:
a.cc:39:13: error: expected constructor, destructor, or type conversion before '(' token
   39 |         sort(a+1,a+len+1);
      |             ^
a.cc:40:13: error: expected constructor, destructor, or type conversion before '(' token
   40 |         sort(b+1,b+len+1);
      |             ^
a.cc:42:9: error: expected unqualified-id before 'for'
   42 |         for(int i=1;i<=len;i++)
      |         ^~~
a.cc:42:21: error: 'i' does not name a type
   42 |         for(int i=1;i<=len;i++)
      |                     ^
a.cc:42:28: error: 'i' does not name a type
   42 |         for(int i=1;i<=len;i++)
      |                            ^
a.cc:58:9: error: 'cout' does not name a type
   58 |         cout<<tot*2;
      |         ^~~~
a.cc:59:9: error: expected unqualified-id before 'return'
   59 |         return 0;
      |         ^~~~~~
a.cc:60:1: error: expected declaration before '}' token
   60 | }
      | ^
Language: C++

#include<cstdio>
#include<algorithm>
#include<queue>
#include<math.h>

using namespace std;

typedef long long ll;

ll N, L[100000], R[100000];

ll check(bool ok) {
  priority_queue<ll> left;
  priority_queue<ll, vector<ll>, greater<ll> > right;
  for (ll i = 0; i < N; i++) {
    left.push(L[i]);
    right.push(R[i]);
  }
  ll ans = 0;
  ll now = 0;
  for (ll i = 0; i < N; i++) {
    ll l = left.top() - now;
    ll r = now - right.top();
    if (l <= 0 && r <= 0) break;
    if (l == r && i == 0) {
      if (ok) {
        ans += (ll) l;
        now = left.top();
        left.pop();
      } else {
        ans += (ll) r;
        now = right.top();
        right.pop();
      }
    } else if (l > r) {
      ans += (ll) l;
      now = left.top();
      left.pop();
    } else {
      ans += (ll) r;
      now = right.top();
      right.pop();
    }
  }
  ans += (ll) abs(now);
  return ans;
}

int main(){
  scanf("%lld", &N);
  for (ll i = 0; i < N; i++) {
    scanf("%lld%lld", &L[i], &R[i]);
  }
  printf("%lld\n", max(check(true), check(false)));

Compiler output:
a.cc: In function 'int main()':
a.cc:54:52: error: expected '}' at end of input
   54 |   printf("%lld\n", max(check(true), check(false)));
      |                                                    ^
a.cc:49:11: note: to match this '{'
   49 | int main(){
      |           ^
Language: C++

#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>

#define max(a,b) ((a > b) ? a : b)
#define min(a,b) ((a < b) ? a : b)
#define abs(a) (((a) < 0) ? -(a) : (a))

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

typedef struct {
	int num;
	int r;
	int l;
	bool used;
} Ku;

int compl(const void *a, const void *b) {
	return (*(Ku**)a)->l - (*(Ku**)b)->l;
}
int compr(const void *a, const void *b) {
	return (*(Ku**)a)->r - (*(Ku**)b)->r;
}


static inline int ri() {
	int a;
	scanf("%d", &a);
	return a;
}

int main() {
	int n = ri();
	
	Ku k[n];
	Ku *l[n];
	Ku *r[n];
	for (int i = 0; i < n; i++) {
		k[i].num = i;
		k[i].l = ri();
		k[i].r = ri();
		k[i].used = false;
		l[i] = &k[i];
		r[i] = &k[i];
	}
	
	qsort(l, n, sizeof(Ku*), compl);
	qsort(r, n, sizeof(Ku*), compr);
	
	/** DEBUGGGGGG */
	/*
	for (int i = 0; i < n; i++) {
		printf("l : %d, r : %d\n", l[i]->l, r[i]->r);
	}
	*/
	
	u64 res = 0;
	int cur_pos = 0;
	int used = 0;
	while(1) {
		// select the rightest
		int right = -1;
		for (int i = n - 1; i >= 0; i--) {
			if (!l[i]->used) {
				l[i]->used = true;
				right = i;
				used++;
				/** DEBUGGGGGG */
				// printf("rightest/l : %d\n", l[i]->num);
				break;
			}
		}
		if (right == -1) while(1); // unexpected
		if (l[right]->l <= cur_pos && l[right]->r >= cur_pos) {} // ------[---.---]----------
		else if (l[right]->l <= cur_pos) { // ------[-----]---.-------
			res += (u64)abs(cur_pos - l[right]->r);
			cur_pos = l[right]->r;
			/** DEBUGGGGGGG */
			// printf("-----[------]---.-----\ncur_pos = %d\n", cur_pos);
		} else { // ---.---[-----]----------
			res += (u64)abs(cur_pos - l[right]->l);
			cur_pos = l[right]->l;
			/** DEBUGGGGGGG */
			// printf("---.---[-----]----------\ncur_pos = %d\n", cur_pos);
		}
		
		if (used >= n) break;
		
		
		// select the leftest
		int left = -1;
		for (int i = 0; i < n; i++) {
			if (!r[i]->used) {
				r[i]->used = true;
				left = i;
				used++;
				/** DEBUGGGGGG */
				// printf("leftest/r : %d\n", r[i]->num);
				break;
			}
		}
		if (left == -1) while(1); // unexpected
		if (r[left]->l <= cur_pos && r[left]->r >= cur_pos) {} // ------[---.---]----------
		else if (r[left]->l <= cur_pos) { // ------[-----]---.-------
			res += (u64)abs(cur_pos - r[left]->r);
			cur_pos = r[left]->r;
			/** DEBUGGGGGGG */
			// printf("------[-----]---.-------\ncur_pos = %d\n", cur_pos);
		} else { // ---.---[-----]----------
			res += (u64)abs(cur_pos - r[left]->l);
			cur_pos = r[left]->l;
			/** DEBUGGGGGGG */
			// printf("---.---[-----]----------\ncur_pos = %d\n", cur_pos);
		}
		
		if (used >= n) break;
	}
	
	res += (u64) abs(cur_pos);
	
	printf("%llu", res);
	// printf("%I64u", res);
	
	return 0;
}


Compiler output:
a.cc:26:10: error: expected class-name before '(' token
   26 | int compl(const void *a, const void *b) {
      |          ^
a.cc: In function 'int main()':
a.cc:55:39: error: expected primary-expression before ')' token
   55 |         qsort(l, n, sizeof(Ku*), compl);
      |                                       ^
Language: C++

#include<cstdio>
#include<algorithm>
#include<queue>
#include<math.h>

using namespace std;

typedef long long ll;

ll N, L[100000], R[100000];

ll check(bool ok) {
  priority_queue<ll> left;
  priority_queue<ll, vector<ll>, greater<ll> > right;
  for (ll i = 0; i < N; i++) {
    left.push(L[i]);
    right.push(R[i]);
  }
  ll ans = 0;
  ll now = 0;
  if (ok) {
    now = ans = left.top();
    left.pop();
  } else {
    now = ans = right.top();
    right.pop();
  }
  for (ll i = 1; i < N; i++) {
    ll l = left.top() - now;
    ll r = now - right.top();
    if (l < 0 && r < 0) break;
    if (l > r) {
      ans += (ll) l;
      now = left.top();
      left.pop();
    } else {
      ans += (ll) r;
      now = right.top();
      right.pop();
    }
  }
  ans += (ll) abs(now);
  return ans;
}

int main(){
  scanf("%d", &N);
  for (ll i = 0; i < N; i++) {
    scanf("%d%d", &L[i], &R[i]);
  }
  prllf("%lld\n", max(check(true), check(false)));
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:3: error: 'prllf' was not declared in this scope
   51 |   prllf("%lld\n", max(check(true), check(false)));
      |   ^~~~~
Language: C++

#include<bits/stdc++.h>
#define INF 0x7fffffff
typedef long long ll;
using namespace std;
const int MAXN=1e5+10;
int n,stal[MAXN][2],star[MAXN][2],szl,szr,a[MAXN],b[MAXN];
bool del[MAXN];
ll ans;
void pushdownl(int x)
{
	int l=x*2,r=x*2+1;
	if(l>szl)
		return;
	if(stal[l][0]>stal[x][0]&&(stal[l][0]>=stal[r][0]||r>szl))
	{
		swap(stal[x][0],stal[l][0]);
		swap(stal[x][1],stal[l][1]);
		pushdownl(l);
	}
	else
		if(r<=szl&&stal[r][0]>stal[x][0]&&stal[r][0]>stal[l][0])
		{
			swap(stal[x][0],stal[r][0]);
			swap(stal[x][1],stal[r][1]);
			pushdownl(r);
		}
}
void pushdownr(int x)
{
	int l=x*2,r=x*2+1;
	if(l>szr)
		return;
	if(star[l][0]<star[x][0]&&(star[l][0]<=star[r][0]||r>szr))
	{
		swap(star[x][0],star[l][0]);
		swap(star[x][1],star[l][1]);
		pushdownr(l);
	}
	else
		if(r<=szr&&star[r][0]<star[x][0]&&star[r][0]<star[l][0])
		{
			swap(star[x][0],star[r][0]);
			swap(star[x][1],star[r][1]);
			pushdownr(r);
		}
}
int main()
{
	int x=0;
	cin>>n;
	szl=szr=n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&stal[i][0],&star[i][0]);
		a[i]=stal[i][0];
		b[i]=star[i][0];
		stal[i][1]=star[i][1]=i;
	}
	for(int i=n/2;i;i--)
	{
		pushdownl(i);
		pushdownr(i);
	}	
	for(int i=1;i<=n;i++)
	{
		while(del[stal[1][1]])
		{
			swap(stal[1][0],stal[szl][0]);
			swap(stal[1][1],stal[szl--][1]);
			pushdownl(1);
		}
		while(del[star[1][1]])
		{
			swap(star[1][0],star[szr][0]);
			swap(star[1][1],star[szr--][1]);
			pushdownr(1);
		}
		if(stal[1][0]-x>0&&stal[1][0]-x>=x-star[1][0]&&b[])
		{
			ans+=stal[1][0]-x;
			del[stal[1][1]]=true;
			x=stal[1][0];
		}
		else
		{
			if(x-star[1][0]>0)
			{
				ans+=x-star[1][0];
				x=star[1][0];
			}
			else
				break;
			del[star[1][1]]=true;
		}
	}
	cout<<ans+(long long)(x>0?x:-x)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:78:66: error: expected primary-expression before ']' token
   78 |                 if(stal[1][0]-x>0&&stal[1][0]-x>=x-star[1][0]&&b[])
      |                                                                  ^
Language: C++

/*
for (int i = 0; i < N; ++i){}
 
// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
 
sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート
 
int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}
 
map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
 
 
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
 
using namespace std;

int main() {
	// 入力
    int N;
    cin >> N;
    int L[N], R[N];
    for (int i = 0; i < N; ++i) cin >> L[i] >>R[i];
 
 
    sort(L, L + N, greater<int>());  // a[0:N] を大きい順にソート
    sort(R, R + N);  // a[0:N] を大きい順にソート
    int i = 0;
    int place = 0;
    long long distance = 0;
    //cout << "=> " << place << " dis " << distance << endl;
    if (L[0]>=0) cout << -R[0] * 2 << endl;
    elif  (R[0]<=0) cout << L[0] * 2 << endl;
    else{
	    while (true){
	    	if (L[i]<=place){
	    		distance += 0 - place;
	    		place = 0;
	    		// cout << "=> " << place << " dis " << distance << endl; 
	    		break;	
	    	} 
	    	else{
	    		// cout << "L[" << i << "]: " << L[i] << endl;
	    		distance += L[i] - place;
	    		place = L[i];
	    		// cout << "=> " << place << " dis " << distance << endl; 
	    	}
	    	if (R[i]>=place){
	    		distance += place;
	    		place = 0;
	    		// cout << "=> " << place << " dis " << distance << endl; 
	    		break;	
	    	} 
	    	else{
	    		distance += place - R[i];
	    		place = R[i];
	    		// cout << "=> " << place << "dis " << distance << endl; 
	    	}
	    	++i;
	    }
	    

		//出力
	    cout << distance << endl;
    }
}
 
 

Compiler output:
a.cc: In function 'int main()':
a.cc:58:5: error: 'elif' was not declared in this scope
   58 |     elif  (R[0]<=0) cout << L[0] * 2 << endl;
      |     ^~~~
a.cc:59:5: error: 'else' without a previous 'if'
   59 |     else{
      |     ^~~~
Language: C++

#include <cstdio>
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 100100;

int l[N], r[N], idl[N], idr[N];
int pass[N];


bool cmpl(int a, int b) {
	return l[idl[a]] > l[idl[b]];
}

bool cmpr(int a, int b) {
	return l[idr[a]] < l[idr[b]];
}

int main() {
	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; ++i) {
		scanf("%d%d", &l[i], &r[i]);
		idl[i] = i;
		idr[i] = i;
	}

	sort(idl, idl+n, cmpl);
	sort(idr, idr+n, cmpr);


	memset (pass, 0, sizeof pass);
	int pl = 0, pr = 0;
	int at = 0;
	long long ans1 = 0;
	for (int i = 0; i < n; ++i) {
		if(i%2 == 0) {
			while(pass[idl[pl]]) {
				pl++;
			}
			if(pass[idl[pl]] == 0){
				pass[idl[pl]] = 1;
				if(abs(l[idl[pl]] - at) > abs(r[idl[pl]] - at) ){
					ans1 +=  abs(r[idl[pl]] - at);
					at = r[idl[pl]];
				}
				else {
					ans1 +=  abs(l[idl[pl]] - at);
					at = l[idl[pl]];
				}
			}
		}
		else {
			while(pass[idr[pr]]) {
				pr++;
			}
			if(pass[idr[pr]] == 0){
				pass[idr[pr]] = 1;
				if(abs(l[idr[pr]] - at) > abs(r[idr[pr]] - at) ){
					ans1 +=  abs(r[idr[pr]] - at);
					at = r[idr[pr]];
				}
				else {
					ans1 +=  abs(l[idr[pr]] - at);
					at = l[idr[pr]];
				}
			}		
		}
	}
	ans1 += abs(at);
	memset (pass, 0, sizeof pass);
	pl = 0, pr = 0;
	at = 0;
	long long ans2 = 0;
	for (int i = 0; i < n; ++i) {
		if(i%2 == 1) {
			while(pass[idl[pl]]) {
				pl++;
			}
			if(pass[idl[pl]] == 0){
				pass[idl[pl]] = 1;
				if(abs(l[idl[pl]] - at) > abs(r[idl[pl]] - at) ){
					ans2 +=  abs(r[idl[pl]] - at);
					at = r[idl[pl]];
				}
				else {
					ans2 +=  abs(l[idl[pl]] - at);
					at = l[idl[pl]];
				}
			}
		}
		else {
			while(pass[idr[pr]]) {
				pr++;
			}
			if(pass[idr[pr]] == 0){
				pass[idr[pr]] = 1;
				if(abs(l[idr[pr]] - at) > abs(r[idr[pr]] - at) ){
					ans2 +=  abs(r[idr[pr]] - at);
					at = r[idr[pr]];
				}
				else {
					ans2 +=  abs(l[idr[pr]] - at);
					at = l[idr[pr]];
				}
			}		
		}
	}
	ans2 += abs(at);
	printf("%lld\n", max(ans1, ans2));
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:9: error: 'memset' was not declared in this scope
   35 |         memset (pass, 0, sizeof pass);
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <iostream>
  +++ |+#include <cstring>
    4 |
Language: C++

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

#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int> 
#define vll vector<ll>
#define all(c) c.begin(),c.end()
#define tr(it,c) for( typeof(c.begin()) it = c.begin() ; it!=c.end() ; it++)

ll modulo(ll num){ return ((num%mod)+mod)%mod;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),mod-2,MOD); }

bool comp(pair<ll,ll> p1, pair<ll,ll> p2)
{
    return p1.se < p2.se ; 
}

int main()
{
    boost;
    
    ll n,i,j,l,r ; 
    
    pair<ll,ll> p1[N],p2[N];
    
    cin>>n;
    
    for(i=0;i<n;i++)
    {
        cin>>l>>r; p1[i] = mp(l,r) ; p2[i] = p1[i];
    }
    
    sort(p1,p1+n) ;
    reverse(p1,p1+n);
    
    sort(p2,p2+n,comp);
    
    
    ll ans,ind1,ind2,cur,ans2 ;
    
    ans = ans2 =  ind1 = ind2 = cur = 0 ;
    
    while(ind1<n and ind2<n)
    {
        if(p2[ind2].se < cur)
        {
            ans = ans + (cur - p2[ind2].se) ; 
            cur = p2[ind2].se ; 
            
        }
        ind2++;
        if(p1[ind1].fi > cur )
        {
            ans = ans + (p1[ind1].fi - cur) ;
            cur = p1[ind1].fi ; 
            
        }
        ind1++;
        
    }
  //  cout<<cur<<endl;
    ans = ans + abs(cur)    ;
    
    ind1 = ind2 = cur = 0 ;
    
    while(ind1<n and ind2<n)
    {
        if(p1[ind1].fi > cur )
        {
            ans = ans + (p1[ind1].fi - cur) ;
            cur = p1[ind1].fi ; 
            
        }
        ind1++;
        if(p2[ind2].se < cur)
        {
            ans = ans + (cur - p2[ind2].se) ; 
            cur = p2[ind2].se ; 
            
        }
        ind2++;
    }
    
    ans2 = ans2 + abs(cur);
    
    cout<<max(ans1,ans2);
    
//    cout<<ans<<endl;    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:99:15: error: 'ans1' was not declared in this scope; did you mean 'ans2'?
   99 |     cout<<max(ans1,ans2);
      |               ^~~~
      |               ans2
Language: C++

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

#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int> 
#define vll vector<ll>
#define all(c) c.begin(),c.end()
#define tr(it,c) for( typeof(c.begin()) it = c.begin() ; it!=c.end() ; it++)

ll modulo(ll num){ return ((num%mod)+mod)%mod;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),mod-2,MOD); }

bool comp(pair<ll,ll> p1, pair<ll,ll> p2)
{
    return p1.se < p2.se ; 
}

int main()
{
    boost;
    
    ll n,i,j,l,r ; 
    
    pair<ll,ll> p1[N],p2[N];
    
    cin>>n;
    
    for(i=0;i<n;i++)
    {
        cin>>l>>r; p1[i] = mp(l,r) ; p2[i] = p1[i];
    }
    
    sort(p1,p1+n) ;
    reverse(p1,p1+n);
    
    sort(p2,p2+n,comp);
    
    
    ll ans,ind1,ind2,cur ;
    
    ans = ans2 =  ind1 = ind2 = cur = 0 ;
    
    while(ind1<n and ind2<n)
    {
        if(p2[ind2].se < cur)
        {
            ans = ans + (cur - p2[ind2].se) ; 
            cur = p2[ind2].se ; 
            
        }
        ind2++;
        if(p1[ind1].fi > cur )
        {
            ans = ans + (p1[ind1].fi - cur) ;
            cur = p1[ind1].fi ; 
            
        }
        ind1++;
        
    }
  //  cout<<cur<<endl;
    ans = ans + abs(cur)    ;
    
    ind1 = ind2 = cur = 0 ;
    
    while(ind1<n and ind2<n)
    {
        if(p1[ind1].fi > cur )
        {
            ans = ans + (p1[ind1].fi - cur) ;
            cur = p1[ind1].fi ; 
            
        }
        ind1++;
        if(p2[ind2].se < cur)
        {
            ans = ans + (cur - p2[ind2].se) ; 
            cur = p2[ind2].se ; 
            
        }
        ind2++;
    }
    
    ans2 = ans2 + abs(cur);
    
    cout<<max(ans1,ans2);
    
//    cout<<ans<<endl;    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:11: error: 'ans2' was not declared in this scope; did you mean 'ans'?
   54 |     ans = ans2 =  ind1 = ind2 = cur = 0 ;
      |           ^~~~
      |           ans
a.cc:99:15: error: 'ans1' was not declared in this scope; did you mean 'ans'?
   99 |     cout<<max(ans1,ans2);
      |               ^~~~
      |               ans
Language: C++

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
struct nodel{
    int x,id;
    node1(){}nodel(int a,int b){x=a;id=b;}
    bool operator < (const nodel a)const {
        return a.x > x;
    }
};
struct noder{
    int x,id;
    noder(){}noder(int a,int b){x=a;id=b;}
    bool operator < (const noder a)const {
        return a.x < x;
    }
};
priority_queue<nodel> ql,ql2;
priority_queue<noder> qr,qr2;
int n,out[100000+100];
ll ans1,ans2;
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;++i) {int l,r;
        scanf("%d%d",&l,&r);
        ql.push(nodel(l,i));
        ql2.push(nodel(l,i));
        qr.push(noder(r,i));
        qr2.push(noder(r,i));
    }
    // l r
    int now=0;
    for(int ti=1;ti<=n;++ti) {
        while(!ql.empty()&&out[ql.top().id])ql.pop();
        while(!qr.empty()&&out[qr.top().id])qr.pop();
        if(ti%2&&now < ql.top().x)ans1+=abs(now-ql.top().x),now=ql.top().x,out[ql.top().id]=1,ql.pop();
        else if(now > qr.top().x) ans1+=abs(now-qr.top().x),now=qr.top().x,out[qr.top().id]=1,qr.pop();
        //cout << now <<' ';
    }//cout << endl;
    ans1 += abs(now);
    //cout << ans1 <<'\n';
    memset(out,0,sizeof(out));
    now=0;
    for(int ti=1;ti<=n;++ti) {
        while(!ql2.empty()&&out[ql2.top().id])ql2.pop();
        while(!qr2.empty()&&out[qr2.top().id])qr2.pop();
        if(ti%2==0&&now < ql2.top().x)ans2+=abs(now-ql2.top().x),now=ql2.top().x,out[ql2.top().id]=1,ql2.pop();
        else if(now > qr2.top().x) ans2+=abs(now-qr2.top().x),now=qr2.top().x,out[qr2.top().id]=1,qr2.pop();
        //cout << now <<' ';
    }//cout << endl;
    ans2 += abs(now);
    cout << max(ans1,ans2) <<'\n';
    return 0;
}


Compiler output:
a.cc:6:5: error: ISO C++ forbids declaration of 'node1' with no type [-fpermissive]
    6 |     node1(){}nodel(int a,int b){x=a;id=b;}
      |     ^~~~~
a.cc: In member function 'int nodel::node1()':
a.cc:6:13: warning: no return statement in function returning non-void [-Wreturn-type]
    6 |     node1(){}nodel(int a,int b){x=a;id=b;}
      |             ^
Language: C++

#include <iostream>
#include <map>
#include <vector>

using namespace std;
bool cmp1 (vector<long long> a, vector<long long> b) {
  return(a[1] > b[1]);
}

bool cmp2 (vector<long long> a, vector<long long> b) {
  return(a[2] < b[2]);
}

int main(){
  vector<vector<long long>> l, r, l_sorted, r_sorted;
  vector<bool> flag;
  int n;
  int i=0;
  int j=0;
  long long current_pos = 0;
  long long ans = 0;
  cin >> n;
  for (int i=0;i<n;i++) {
    vector<long long> tmpl, tmpr;
    long long l1, r1;
    cin >> l1 >> r1;
    tmpl.push_back(i);
    tmpl.push_back(l1);
    tmpl.push_back(r1);
    tmpr.push_back(i);
    tmpr.push_back(l1);
    tmpr.push_back(r1);
    l.push_back(tmpl);
    //    l_sorted.push_back(tmpl);
    r.push_back(tmpr);
    //    r_sorted.push_back(tmpr);
    flag.push_back(false);
  }
  sort(l.begin(), l.end(), cmp1);
  sort(r.begin(), r.end(), cmp2);
  while (i < n && j < n) {
    //    cout << i << "\t" << j << endl;
    if (flag[l[i][0]]) {
      i++;
      continue;
    }
    flag[l[i][0]] = true;
    if (current_pos < l[i][1]) {
      ans += l[i][1] - current_pos;
      current_pos = l[i][1];
    } else if (l[i][2] < current_pos) {
      ans += current_pos - l[i][2];
      current_pos = l[i][2];
    }
    i++;
    while (j < n) {
      if (flag[r[j][0]]) {
	j++;
	continue;
      }
      flag[r[j][0]] = true;
      if (current_pos < r[j][1]) {
	ans += r[j][1] - current_pos;
	current_pos = r[j][1];
      } else if (r[j][2] < current_pos) {
	ans += current_pos - r[j][2];
	current_pos = r[j][2];
      }
      j++;
      break;
    }
  }
  if (current_pos > 0) {
    ans += current_pos;
  } else {
    ans -= current_pos;
  }
  cout << ans << endl;
  return(0);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   39 |   sort(l.begin(), l.end(), cmp1);
      |   ^~~~
      |   short
Language: C++

#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 1;

set <pair<long long, long long> > sl, sr;
long long l[N], r[N];

long long main() {
    long long i, j, n;
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (i = 0; i < n; ++i) {
        cin >> l[i] >> r[i];
        sl.insert({l[i], i});
        sr.insert({r[i], i});
    }
    long long x = 0, ans = 0, val = 0;
    for (i = 0; i < n; ++i)
    if (i % 2 == 0) {
        set <pair<long long, long long > > :: iterator it = sl.end();
        --it;
        long long j = (*it).second;
        sl.erase(it);
        sr.erase(sr.find({r[j], j}));
        if (l[j] <= x && x <= r[j])
            continue;
        if (i == n - 1) {
            val += min(abs(l[j] - x) + abs(l[j]), abs(r[j] - x) + abs(r[j]));
            x = 0;
        } else {
            val += abs(l[j] - x);
            x = l[j];
        }
    } else {
        set <pair<long long, long long > > :: iterator it = sr.begin();
        long long j = (*it).second;
        sr.erase(it);
        sl.erase(sl.find({l[j], j}));
        if (l[j] <= x && x <= r[j])
            continue;
        if (i == n - 1)
            val += min(abs(l[j] - x) + abs(l[j]), abs(r[j] - x) + abs(r[j]));
        else {
            val += abs(r[j] - x);
            x = r[j];
        }
    }
    ans = val;
     for (i = 0; i < n; ++i) {
        sl.insert({l[i], i});
        sr.insert({r[i], i});
    }
    x = 0;
    val = 0;
    for (i = 0; i < n; ++i)
    if (i % 2 == 1) {
        set <pair<long long, long long > > :: iterator it = sl.end();
        --it;
        long long j = (*it).second;
        sl.erase(it);
        sr.erase(sr.find({r[j], j}));
        if (l[j] <= x && x <= r[j])
            continue;
        if (i == n - 1)
            val += min(abs(l[j] - x) + abs(l[j]), abs(r[j] - x) + abs(r[j]));
        else {
            val += abs(l[j] - x);
            x = l[j];
        }
    } else {
        set <pair<long long, long long > > :: iterator it = sr.begin();
        long long j = (*it).second;
        sr.erase(it);
        sl.erase(sl.find({l[j], j}));
        if (l[j] <= x && x <= r[j])
            continue;
        if (i == n - 1) {
            val += min(abs(l[j] - x) + abs(l[j]), abs(r[j] - x) + abs(r[j]));
            x = 0;
        } else {
            val += abs(r[j] - x);
            x = r[j];
        }
    }
    cout << max(ans, val);
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C

#include <bits/stdc++.h>

using namespace std;

int n, d1, d2;
vector<pair<int, int> > v[2], a[2];

int main(){
	scanf("%d%d%d", &n, &d1, &d2);
	int x = 1;
	while(d1 / x % 4 == 0) x *= 4;
	for(int i = 0;i < n * 2;i++){
		for(int j = 0;j < n * 2;j++){
			int ii = i / x, jj = j / x;
			if(d1 / x % 4 == 1){
				v[ii & 1].push_back({i, j});
			}else if(d1 / x % 4 == 2){
				v[(ii + jj) & 1].push_back({i, j});
			}else{
				v[0].push_back({i, j});
			}
		}
	}
	if(v[0].size() < v[1].size()) swap(v[0], v[1]);
	x = 1;
	while(d2 / x % 4 == 0) x *= 4;
	for(int k = 0;k < v[0].size();k++){
		int i = v[0][k].first, j = v[0][k].second;
		int ii = i / x, jj = j / x;
		if(d2 / x % 4 == 1){
			a[ii & 1].push_back({i, j});
		}else if(d2 / x % 4 == 2){
			a[(ii + jj) & 1].push_back({i, j});
		}else{
			a[0].push_back({i, j});
		}
	}
	if(a[0].size() < a[1].size()) swap(a[0], a[1]);
	for(int i = 1;i <= n * n;i++) printf("%d %d\n", a[0].back().first, a[0].back().second), a[0].pop_back();
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long LL;

LL n,d;
LL col[2][500005] = {0};
vector <LL> v[4];

LL id(LL x,LL y){ return x * n + y + 1; } // (x,y) -> id
LL getx(LL x){ return (x - 1) / n; } // id(x,y) -> x
LL gety(LL y){ return (y - 1) % n; } // id(x,y) -> y

void dfs(LL u,LL idd){
	LL tx = getx(u),ty = gety(u);
	for(LL dy,dx = 0;dx <= n;dx ++){
		if(dx * dx > d) continue;
		dy = sqrt(d - dx * dx);
		if(dx * dx + dy * dy != d) continue;
		
		if(tx + dx < n && ty + dy < n)
			if(col[idd][id(tx + dx,ty + dy)] == -1) { col[idd][id(tx + dx,ty + dy)] = 1 - col[idd][u]; dfs(id(tx + dx,ty + dy),idd); }
		if(tx + dx < n && ty - dy >= 0)
			if(col[idd][id(tx + dx,ty - dy)] == -1) { col[idd][id(tx + dx,ty - dy)] = 1 - col[idd][u]; dfs(id(tx + dx,ty - dy),idd); }
		if(tx - dx >= 0 && ty + dy < n)
			if(col[idd][id(tx - dx,ty + dy)] == -1) { col[idd][id(tx - dx,ty + dy)] = 1 - col[idd][u]; dfs(id(tx - dx,ty + dy),idd); }
		if(tx - dx >= 0 && ty - dy >= 0)
			if(col[idd][id(tx - dx,ty - dy)] == -1) { col[idd][id(tx - dx,ty - dy)] = 1 - col[idd][u]; dfs(id(tx - dx,ty - dy),idd); }
	}
}

int main(){
	memset(col,-1,sizeof(col));
	cin >> n; n <<= 1;
	cin >> d;
	for(LL i = 0;i < n;i ++)
		for(LL j = 0;j < n;j ++)
			if(col[0][id(i,j)] == -1){ col[0][id(i,j)] = 1; dfs(id(i,j),0); }
	cin >> d;
	for(LL i = 0;i < n;i ++)
		for(LL j = 0;j < n;j ++)
			if(col[1][id(i,j)] == -1){ col[1][id(i,j)] = 1; dfs(id(i,j),1); }
	/*
	for(LL i = 0;i < n;i ++)
		for(LL j = 0;j < n;j ++)
			cout << col[0][id(i,j)] << (j == n - 1 ? '\n' : ' ');
	for(LL i = 0;i < n;i ++)
		for(LL j = 0;j < n;j ++)
			cout << col[1][id(i,j)] << (j == n - 1 ? '\n' : ' ');
	*/		
	for(LL i = 1;i <= id(n,n);i ++) v[col[0][i] + col[1][i] * 2].push_back(i);
	for(LL i = 0;i < 3;i ++){
		if(v[i].size() >= n * n / 4){
			for(LL j = 0;j < n * n / 4;j ++) cout << getx(v[i][j]) << ' ' << gety(v[i][j]) << '\n';
			break;
		}
	}
	return 0;
}

Compiler output:
a.cc:11:1: error: 'vector' does not name a type
   11 | vector <LL> v[4];
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:54:41: error: 'v' was not declared in this scope
   54 |         for(LL i = 1;i <= id(n,n);i ++) v[col[0][i] + col[1][i] * 2].push_back(i);
      |                                         ^
a.cc:56:20: error: 'v' was not declared in this scope
   56 |                 if(v[i].size() >= n * n / 4){
      |                    ^
Language: C++

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int n,d[2];
vvi G;
vi in,used,c;
void dfs(int a){
	rep(i,G[a].size()){
		int to=G[a][i];
		if(c[to]+1)continue;
		c[to]=c[a]^1;
		dfs(to);
	}
}
int main(){
	cin>>n>>d[0]>>d[1];
	rep(i,2*n)rep(j,2*n)in.pb(i*2*n+j);
	used=vi(in.size(),1);
	
	vi sqr(1000000);
	rep(i,1000000)sqr[i]=(sqrt(i)+EPS);
	rep(q,2){
		G=vvi(in.size());
		rep(i,in.size())if(used[i])rep(j,2*n){
			int x=in[i]/(2*n),y=in[i]%(2*n);
			int dis=d[q]-(x-j)*(x-j);
			if(dis<0)continue;
			int t=[dis];
			if(t*t!=dis)continue;
			if(y-t>=0&&used[2*n*j+y-t])G[i].pb(2*n*j+y-t);
			if(t&&y+t<2*n&&used[2*n*j+y+t])G[i].pb(2*n*j+y+t);
		}
		c=vi(in.size(),-1);
		rep(i,c.size())if(used[i]&&c[i]==-1){
			c[i]=0;
			dfs(i);
		}
		int co1=0,co2=0;
		rep(i,c.size())if(c[i]==0)co1++;
		else if(c[i]==1)co2++;
		int t=0;
		if(co1<co2)t=1;
		rep(i,in.size())if(used[i]&&t!=c[i])
			used[i]=0;
		
	}
	int co=n*n;
	rep(i,in.size())if(used[i]&&co){
		cout<<in[i]/(2*n)<<" "<<in[i]%(2*n)<<endl;
		co--;
	}
}







Compiler output:
a.cc: In lambda function:
a.cc:80:36: error: expected '{' before ';' token
   80 |                         int t=[dis];
      |                                    ^
a.cc: In function 'int main()':
a.cc:80:31: error: cannot convert 'main()::<lambda()>' to 'int' in initialization
   80 |                         int t=[dis];
      |                               ^~~~~
      |                               |
      |                               main()::<lambda()>
Language: C++

#include<cstdio>
#include<cassert>
#include<cstring>
#include<cmath>
/#pragma GCC optimize(2)
using namespace std;
const int maxl = 3e5 + 10;
const int maxn = 600 + 10; 
typedef long long ll;
inline ll sqr(ll x) { return x * x;}
int n;
int col1[maxn][maxn]; // color
int col2[maxn][maxn];
ll sqt[maxl];
int cr[2];
void dfs(int col[][maxn],int r,int c,int k,ll d){
	col[r][c] = k;
	for(ll i = -r;r + i < 2 * n;i++){
//		
//		if(d - sqr(i) < 0) continue;
//		ll j = sqt[d - sqr(i)];
//		if(j == -1) continue;
		if(d - sqr(i) < 0) continue;
		int j = (ll)(sqrt(d - sqr(i)) + 0.5);
		if(sqr(j) != d - sqr(i)) continue;
		if(j + c < n * 2){
			if(col[r + i][c + j] == -1)  dfs(col,r + i,c + j,k ^ 1,d);	
		} 
		if(c - j >= 0){
			if(col[r + i][c - j] == -1) dfs(col,r + i,c - j,k ^ 1,d);
		}
		
	}
}
int main(){
	memset(col1,-1,sizeof(col1));
	memset(col2,-1,sizeof(col2));
	memset(sqt,-1,sizeof(sqt));
	ll d1,d2;
	scanf("%d%lld%lld",&n,&d1,&d2);
	for(ll i = 0;i * i < maxn;i++) sqt[i * i] = i;
	for(int i = 0;i < 2 * n;i++) for(int j = 0;j < 2 * n;j++)if(col1[i][j] == -1) dfs(col1,i,j,0,d1);
	for(int i = 0;i < 2 * n;i++) for(int j = 0;j < 2 * n;j++) if(col2[i][j] == -1) dfs(col2,i,j,0,d2);
	int cnt = 0;
	for(int i = 0;i < 2 * n;i++){
		for(int j = 0;j < 2 * n;j++){
			if(cnt < n * n && col1[i][j] == col1[0][0] && col2[i][j] == col2[0][0]){
				printf("%d %d\n",i,j);
				++cnt;
			}
		}
	}
	assert(cnt == n * n); 
	return 0;
}

Compiler output:
a.cc:5:2: error: stray '#' in program
    5 | /#pragma GCC optimize(2)
      |  ^
a.cc:5:1: error: expected unqualified-id before '/' token
    5 | /#pragma GCC optimize(2)
      | ^
Language: C++

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 350
int map[N][N],n;
void work(int D) {
	while(D%4==0) D/=4;
	int i,j;
	if(d&1) {
		for(i=0;i<2*n;i++) {
			for(j=0;j<2*n;j++) {
				if((i+j)&1) map[i][j]=1;
			}
		}
	}else {
		for(i=0;i<2*n;i++) {
			for(j=0;j<2*n;j++) {
				if(i&1) map[i][j]=1;
			}
		}
	}
}
int main() {
	scanf("%d",&n);
	int i,j,sum=0;
	for(i=0;i<2*n;i++) {
		for(j=0;j<2*n;j++) {
			if(!map[i][j]) {
				printf("%d %d\n",i,j); sum++;
				if(sum==n*n) return 0;
			}
		}
	}
}

Compiler output:
a.cc: In function 'void work(int)':
a.cc:10:12: error: 'd' was not declared in this scope
   10 |         if(d&1) {
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int a[1001[1001], n, d1, d2, p;
void work(int k) {
	int b = 0;
	while (k % 4 == 0) 
	{
	      k /= 4;
	      b++;
	}
	if (k & 1) {
		for (int i = 0; i < 2 * n; i++) 
		{
			for (int j = 0; j < 2 * n; j++) 
			{
				if (((i >> b) + (j >> b)) & 1) 
				{
					a[i][j] = 1;
				}
			}
		}
	} 
	else 
	{
		for (int i = 0; i < 2 * n; i++) 
		{
			for (int j = 0; j < 2 * n; j++) 
			{
				if ((i >> b) & 1) 
				{
					a[i][j] = 1;
				}
			}
		}
	}
}
int main() 
{
	scanf("%d%d%d", &n, &d1, &d2);
	work(d1);
	work(d2);
	for (int i = 0; i < 2 * n; i++) 
	{
		for (int j = 0; j < 2 * n; j++) 
		{
			if (p < n * n && !a[i][j]) 
			{
				printf("%d %d\n", i, j);
				p++;
			}
		}
	}
	return 0;
}

Compiler output:
a.cc:3:11: error: invalid types 'int[int]' for array subscript
    3 | int a[1001[1001], n, d1, d2, p;
      |           ^
a.cc:3:17: error: expected ']' before ',' token
    3 | int a[1001[1001], n, d1, d2, p;
      |                 ^
      |                 ]
a.cc: In function 'void work(int)':
a.cc:18:41: error: 'a' was not declared in this scope
   18 |                                         a[i][j] = 1;
      |                                         ^
a.cc:31:41: error: 'a' was not declared in this scope
   31 |                                         a[i][j] = 1;
      |                                         ^
a.cc: In function 'int main()':
a.cc:46:43: error: 'a' was not declared in this scope
   46 |                         if (p < n * n && !a[i][j])
      |                                           ^
Language: C++

#include <cstdio>
#include <cmath>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int N, D1, D2;
std::vector<int> G[360001];
short col[2][360001];
int cnt[4];

void mkG( int D )
{
  rep( i, 2*N ) rep( j, 2*N )
    G[i*2*N+j].clear();

  rep( i, 2*N ) rep( j, 2*N ) rep( k, 2*N ) if( (i-k)*(i-k) < D*D )
  {
    double d = sqrt( D-(i-k)*(i-k) );

    if( floor(d) == d )
    {
      int l;

      if( j+d < 2*N && !(i == k && j == j+d) )
      {
        l = j+d;
        G[i*2*N+j].push_back( k*2*N+l );
        G[k*2*N+l].push_back( i*2*N+j );
      }

      if( j-d >= 0 && !(i == k && j == j-d) )
      {
        l = j-d;
        G[i*2*N+j].push_back( k*2*N+l );
        G[k*2*N+l].push_back( i*2*N+j );
      }
    }
  }

  return;
}

void dfs( int v, int c, int idx )
{
  col[idx][v] = c;

  for( auto u : G[v] ) if( !col[idx][u] )
    dfs( u, -c, idx );

  return;
}

int main()
{
  scanf( "%d%d%d", &N, &D1, &D2 );
  
  mkG( D1 );
  rep( i, 2*N ) rep( j, 2*N ) if( !col[0][i*2*N+j] )
    dfs( i*2*N+j, 1, 0 );

  mkG( D2 );
  rep( i, 2*N ) rep( j, 2*N ) if( !col[1][i*2*N+j] )
    dfs( i*2*N+j, 1, 1 );

  rep( i, 2*N ) rep( j, 2*N ) 
  {
    int v = i*2*N+j;
    int kind = 0;

    rep( k, 2 ) rep( l, 2 )
    {
      if( col[0][v] == pow( -1, k ) && col[1][v] == pow( -1, l ) )
        ++cnt[kind];

      ++kind;
    }
  }

  int mkind = std::max_element( cnt, cnt+4 )-cnt;

  int sum = 0;

  rep( i, 2*N ) rep( j, 2*N ) 
  {
    int v = i*2*N+j;
    int kind = 0;

    rep( k, 2 ) rep( l, 2 )
    {
      if( col[0][v] == pow( -1, k ) && col[1][v] == pow( -1, l ) && kind == mkind && sum < N*N )
        printf( "%d %d\n", i, j ), ++sum;

      ++kind;
    }
  }  
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:81:20: error: 'max_element' is not a member of 'std'; did you mean 'tuple_element'?
   81 |   int mkind = std::max_element( cnt, cnt+4 )-cnt;
      |                    ^~~~~~~~~~~
      |                    tuple_element
Language: C++

#include <bits/stdc++.h>

const int N=610;

struct Edge{ int to,next; }way[N*N*300];

int n,D1,D2,num[N*N],tot,sqrp[200010];

void Build(int x,int y) { ++tot; way[tot]=Edge{y,num[x]}; num[x]=tot; }

void add(int x,int y) { Build(x,y); Build(y,x); } 

void Init() {
	scanf("%d%d%d",&n,&D1,&D2);	
}

int Node(int x,int y) { return x*2*n+y; }

bool vis[N*N],chose[N*N];

void PrintDfs(int x,int &need) {
	int op=1;
	for (int i=num[x];i;i=way[i].next) {
		int v=way[i].to;
		if (chose[v]) op=0;
	}
	vis[x]=1;
	if (op && need) printf("%d %d\n",x/(2*n),x%(2*n)),need--,chose[x]=1;
	for (int i=num[x];i;i=way[i].next) {
		int v=way[i].to;
		if (vis[v]) continue;
		PrintDfs(v,need);
	}
}

void Solve() {
	for (int i=0;i<=200000;++i) sqrp[i]=-1;
	for (int i=1;i*i<=200000;++i) sqrp[i*i]=i;
	for (int i=0;i<2*n;++i) 
		for (int j=0;j<2*n;++j) {
			for (int k=0;k*k<=D1;++k) 
				if (sqrp[D1-k*k]!=-1) {
					int a=sqrp[D1-k*k],b=k;
					if (i+a<2*n && j+b<2*n) 
						add(Node(i+a,j+b),Node(i,j));
					if (i+b<2*n && j+a<2*n) 
						add(Node(i+b,j+a),Node(i,j));
					if (i+a<2*n && j-b>=0) 
						add(Node(i+a,j-b),Node(i,j));
					if (i+b<2*n && j-a>=0) 
						add(Node(i+b,j-a),Node(i,j));
				}
			for (int k=0;k*k<=D2;++k)
				if (sqrp[D2-k*k]!=-1) {
					int a=sqrp[D2-k*k],b=k;
					if (i+a<2*n && j+b<2*n) 
						add(Node(i+a,j+b),Node(i,j));
					if (i+b<2*n && j+a<2*n) 
						add(Node(i+b,j+a),Node(i,j));
					if (i+a<2*n && j-b>=0) 
						add(Node(i+a,j-b),Node(i,j));
					if (i+b<2*n && j-a>=0) 
						add(Node(i+b,j-a),Node(i,j));		
				}
		}
	int need=n*n;
	for (int i=0;i<2*n;++i) 
		for (int j=0;j<2*n;++j) if (need && !vis[Node(i,j)]) 
			PrintDfs(Node(i,j),need);
}

int main()
{    
	int size = 30 << 20; // 256MB
    char *p = (char*)malloc(size) + size;
    __asm__("movl %0, %%esp\n" :: "r"(p));
	Init();
	Solve();
	return 0;
}


Compiler output:
a.cc: Assembler messages:
a.cc:76: Error: operand type mismatch for `mov'
Language: C++

#include <bits/stdc++.h>

const int N=610;

struct Edge{ int to,next; }way[N*N*300];

int n,D1,D2,num[N*N],tot,sqrp[200010];

void Build(int x,int y) { ++tot; way[tot]=Edge{y,num[x]}; num[x]=tot; }

void add(int x,int y) { Build(x,y); Build(y,x); } 

void Init() {
	scanf("%d%d%d",&n,&D1,&D2);	
}

int Node(int x,int y) { return x*2*n+y; }

bool vis[N*N],chose[N*N];

void PrintDfs(int x,int &need) {
	int op=1;
	for (int i=num[x];i;i=way[i].next) {
		int v=way[i].to;
		if (chose[v]) op=0;
	}
	vis[x]=1;
	if (op && need) printf("%d %d\n",x/(2*n),x%(2*n)),need--,chose[x]=1;
	for (int i=num[x];i;i=way[i].next) {
		int v=way[i].to;
		if (vis[v]) continue;
		PrintDfs(v,need);
	}
}

void Solve() {
	for (int i=0;i<=200000;++i) sqrp[i]=-1;
	for (int i=1;i*i<=200000;++i) sqrp[i*i]=i;
	for (int i=0;i<2*n;++i) 
		for (int j=0;j<2*n;++j) {
			for (int k=0;k*k<=D1;++k) 
				if (sqrp[D1-k*k]!=-1) {
					int a=sqrp[D1-k*k],b=k;
					if (i+a<2*n && j+b<2*n) 
						add(Node(i+a,j+b),Node(i,j));
					if (i+b<2*n && j+a<2*n) 
						add(Node(i+b,j+a),Node(i,j));
					if (i+a<2*n && j-b>=0) 
						add(Node(i+a,j-b),Node(i,j));
					if (i+b<2*n && j-a>=0) 
						add(Node(i+b,j-a),Node(i,j));
				}
			for (int k=0;k*k<=D2;++k)
				if (sqrp[D2-k*k]!=-1) {
					int a=sqrp[D2-k*k],b=k;
					if (i+a<2*n && j+b<2*n) 
						add(Node(i+a,j+b),Node(i,j));
					if (i+b<2*n && j+a<2*n) 
						add(Node(i+b,j+a),Node(i,j));
					if (i+a<2*n && j-b>=0) 
						add(Node(i+a,j-b),Node(i,j));
					if (i+b<2*n && j-a>=0) 
						add(Node(i+b,j-a),Node(i,j));		
				}
		}
	int need=n*n;
	for (int i=0;i<2*n;++i) 
		for (int j=0;j<2*n;++j) if (need && !vis[Node(i,j)]) 
			PrintDfs(Node(i,j),need);
}

int main()
{    
	int size = 30 << 20; //30MB
    char *p = (char*)malloc(size) + size;
    __asm__("movl %0, %%esp\n" :: "r"(p));
	Init();
	Solve();
	return 0;
}


Compiler output:
a.cc: Assembler messages:
a.cc:76: Error: operand type mismatch for `mov'