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

#include <bits/stdc++.h>
using namespace std;
int h, w, n, a[1100], mp[1100][1100], cnt = 0, now = 1;
int main() {
    scanf("%d%d%d", &h, &w, &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    for(int i = 1; i <= h; i++) {
        int from = (i & 1) ? 1 : w;
        int to = (i & 1) ? w + 1 : 0;
        int delta = (i & 1) ? 1 : -1;
        for(int j = from; j != to; j += delta) {
            mp[i][j] = now;
            cnt++;
            if(a[now] == cnt) {
                now++;
                cnt = 0;
            }
        }
    }
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j < w; j++) {
            printf("%d ", mp[i][j]);
        }
        printf("%d\n", mp[i][w]);
    }
    return 0;
}



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>
    int c[2000][2000];
    int main() {
      int n, m, k;
      int x = 0, y = 0;
      scanf("%d%d%d", &n, &m, &k);
      for (int i = 0; i < k; ++i);
        int a;
        scanf("%d", &a);
        while (a--) {
          c[x][y] = i + 1;
          if (~x & 1) y < m - 1 ? ++y : ++x;
          else y > 0 ? --y : ++x;
        }
      }
      for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j)
          printf("%d ", c[i][j]);
        printf("\n");
      }
      return 0;
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:11:21: error: 'i' was not declared in this scope
   11 |           c[x][y] = i + 1;
      |                     ^
a.cc: At global scope:
a.cc:16:7: error: expected unqualified-id before 'for'
   16 |       for (int i = 0; i < n; ++i) {
      |       ^~~
a.cc:16:23: error: 'i' does not name a type
   16 |       for (int i = 0; i < n; ++i) {
      |                       ^
a.cc:16:30: error: expected unqualified-id before '++' token
   16 |       for (int i = 0; i < n; ++i) {
      |                              ^~
a.cc:21:7: error: expected unqualified-id before 'return'
   21 |       return 0;
      |       ^~~~~~
a.cc:22:5: error: expected declaration before '}' token
   22 |     }
      |     ^
Language: C++

#include <cstdio>
int c[2000][2000];
int main() {
  int n, m, k;
  int x = 0, y = 0;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < k; ++i);
    int a;
    scanf("%d", &a);
    while (a--) {
      c[x][y] = i + 1;
      if (~x & 1) y < m - 1 ? ++y : ++x;
      else y > 0 ? --y : ++x;
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j)
      printf("%d ", c[i][j]);
    printf("\n");
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:17: error: 'i' was not declared in this scope
   11 |       c[x][y] = i + 1;
      |                 ^
a.cc: At global scope:
a.cc:16:3: error: expected unqualified-id before 'for'
   16 |   for (int i = 0; i < n; ++i) {
      |   ^~~
a.cc:16:19: error: 'i' does not name a type
   16 |   for (int i = 0; i < n; ++i) {
      |                   ^
a.cc:16:26: error: expected unqualified-id before '++' token
   16 |   for (int i = 0; i < n; ++i) {
      |                          ^~
a.cc:21:3: error: expected unqualified-id before 'return'
   21 |   return 0;
      |   ^~~~~~
a.cc:22:1: error: expected declaration before '}' token
   22 | }
      | ^
Language: C++

#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <functional>
#include <map>
#include <ios>
#include <iosfwd>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#include <complex.h>
#include <fenv.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
#include <tgmath.h>
#include <conio.h>
#include <numeric>
#include <list>
#include <windows.h>
#include <cfloat>
#include <climits>
#include <unordered_map>
#include <unordered_set>
using namespace std;

int n,m,k,num[10010],mp[110][110],x,y;

inline void solve(int c,bool dic)
{
	if(num[c])
	{
		mp[x][y]=c;
		num[c]--;
		if(dic==0&&y==m-1) x++,solve(c,1);
		else if(dic==1&&y==0) x++,solve(c,0);
		else if(dic==0) y++,solve(c,0);
		else y--,solve(c,1);
	}
}

int main()
{
	cin>>n>>m>>k;
	for(int i=1;i<=k;i++) cin>>num[i];
	
	for(int i=1;i<=k;i++)
		if(y==m-1||mp[x][y+1]) solve(i,1); else solve(i,0);
	
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++) cout<<mp[i][j]<<' ';
		cout<<endl;
	}
	
	return 0;
}

Compiler output:
a.cc:53:10: fatal error: conio.h: No such file or directory
   53 | #include <conio.h>
      |          ^~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
using namespace std;
 
const int MAXN = 1e2 + 10;
int gel[MAXN][MAXN];
int a[MAXN * MAXN];
 
int main(void){
    int h, w, n;
    cin >> h >> w >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int cnt1 = 0, indx = 1;
    for(int i = 0; i < h; i++){
        if(i % 2 == 0){
            for(int j = 0; j < w; j++){
                gel[i][j] = indx;
                a[indx]--;
                if(a[indx] <= 0) indx++;
            }
        }else{
            for(int j = w - 1; j >= 0; j--){
                gel[i][j] = indx;
                a[indx]--;
                if(a[indx] <= 0) indx++;
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout << gel[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Compiler output:
a.cc:3:1: error: extended character   is not valid in an identifier
    3 |  
      | ^
a.cc:7:1: error: extended character   is not valid in an identifier
    7 |  
      | ^
a.cc:3:1: error: '\U000000a0' does not name a type
    3 |  
      | ^
a.cc:5:9: error: 'MAXN' was not declared in this scope
    5 | int gel[MAXN][MAXN];
      |         ^~~~
a.cc:5:15: error: 'MAXN' was not declared in this scope
    5 | int gel[MAXN][MAXN];
      |               ^~~~
a.cc:6:7: error: 'MAXN' was not declared in this scope
    6 | int a[MAXN * MAXN];
      |       ^~~~
a.cc:6:14: error: 'MAXN' was not declared in this scope
    6 | int a[MAXN * MAXN];
      |              ^~~~
a.cc:7:1: error: '\U000000a0' does not name a type
    7 |  
      | ^
Language: C++


#include<bits/stdc++.h>
using namespace std;
 
const int MAXN = 1e2 + 10;
int gel[MAXN][MAXN];
int a[MAXN * MAXN];
 
int main(){
    int h, w, n;
    cin >> h >> w >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int cnt1 = 0, indx = 1;
    for(int i = 0; i < h; i++){
        if(i % 2 == 0){
            for(int j = 0; j < w; j++){
                gel[i][j] = indx;
                a[indx]--;
                if(a[indx] <= 0) indx++;
            }
        }else{
            for(int j = w - 1; j >= 0; j--){
                gel[i][j] = indx;
                a[indx]--;
                if(a[indx] <= 0) indx++;
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout << gel[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Compiler output:
a.cc:4:1: error: extended character   is not valid in an identifier
    4 |  
      | ^
a.cc:8:1: error: extended character   is not valid in an identifier
    8 |  
      | ^
a.cc:4:1: error: '\U000000a0' does not name a type
    4 |  
      | ^
a.cc:6:9: error: 'MAXN' was not declared in this scope
    6 | int gel[MAXN][MAXN];
      |         ^~~~
a.cc:6:15: error: 'MAXN' was not declared in this scope
    6 | int gel[MAXN][MAXN];
      |               ^~~~
a.cc:7:7: error: 'MAXN' was not declared in this scope
    7 | int a[MAXN * MAXN];
      |       ^~~~
a.cc:7:14: error: 'MAXN' was not declared in this scope
    7 | int a[MAXN * MAXN];
      |              ^~~~
a.cc:8:1: error: '\U000000a0' does not name a type
    8 |  
      | ^
Language: Java

package main.tasks;

import lib.io.MyInput;
import java.io.PrintWriter;
import java.util.Arrays;

public class TaskD {
    public void solve(int testNumber, MyInput in, PrintWriter out) {
        h = in.nextInt();
        w = in.nextInt();
        n = in.nextInt();
        a = in.nextIntArray(n);
        ans = new int[h][w];
        int[] dx = new int[]{1,0,-1,0,};
        int[] dy = new int[]{0,1,0,-1,};
        for (int i = 0, x = -1, y = 0, d = 0; i < n; ) {
            while (true) {
                x += dx[d];
                y += dy[d];
                if (x < 0 || x >= w || y < 0 || y >= h || ans[y][x] != 0) {
                    x -= dx[d];
                    y -= dy[d];
                    d = (d+1)%4;
                } else {
                    break;
                }
            }
            ans[y][x] = i+1;
            if (--a[i] == 0) i++;
//            dump(i, x, y);
        }

        for (int y = 0; y < h; y++) {
            for (int x = 0; x < w; x++) {
                out.print(ans[y][x] + (x==w-1?"\n":" "));
            }
        }
    }

    int n;
    int[] a;
    int w, h;
    int[][] ans;
    static void dump(Object... o) { System.err.println(Arrays.deepToString(o)); }
}


Compiler output:
Main.java:7: error: class TaskD is public, should be declared in a file named TaskD.java
public class TaskD {
       ^
Main.java:3: error: package lib.io does not exist
import lib.io.MyInput;
             ^
Main.java:8: error: cannot find symbol
    public void solve(int testNumber, MyInput in, PrintWriter out) {
                                      ^
  symbol:   class MyInput
  location: class TaskD
3 errors
Language: Java

import java.io.*;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class GridColoring80D {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int h = in.nextInt();
        int w = in.nextInt();
        int n = in.nextInt();
        ArrayList<Integer> numColors = new ArrayList<>();
        for (int i = 0; i < n; i++) numColors.add(in.nextInt());
        int curColor = 0;
        int[][] grid = new int[h][w];
        for (int i = 0; i < h; i += 2) {
            for (int j = 0; j < w; j++) {
                grid[i][j] = curColor + 1;
                numColors.set(curColor, numColors.get(curColor) - 1);
                if (numColors.get(curColor) == 0) curColor++;
            }
            if (i == h - 1) break;
            for (int j = w-1; j >= 0; j--) {
                grid[i+1][j] = curColor + 1;
                numColors.set(curColor, numColors.get(curColor) - 1);
                if (numColors.get(curColor) == 0) curColor++;
            }
        }
        
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                System.out.print(grid[i][j] + " ");
            }
            System.out.println();
        }
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}


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

実装しきれなかった><

Compiler output:
a.cc:1:1: error: '\U00005b9f\U000088c5\U00003057\U0000304d\U0000308c\U0000306a\U0000304b\U00003063\U0000305f' does not name a type
    1 | 実装しきれなかった><
      | ^~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using P=pair<int,int>;

int main(){
	int n;cin>>n;
	vector<int> p(n);
	for(auto&& w:p)cin>>w;
	vector<vector<int>> d;
	queue<vector<int>> q;
	q.push(p);
	while(!q.empty()){
		x=q.front();q.pop();
		int m1,m2,idx1,idx2;
		idx1=0,m1=x[idx1];
		for(int i=0;i<x.size();i+=2){
			if(m1>x[i]){m1=x[i],idx1=i;}
		}
		idx2=idx1+1,m2=x[idx2];
		for(int i=idx2;i<x.size();i+=2){
			if(m2>x[i]){m2=x[i],idx2=i;}	
		}
	vector<int>v={m1,m2};
	d.push_back(v);

		if(idx1>0){ vector<int> y;copy(begin(x),begin(x)+idx1,begin(y));if(y.size()==2)d.push_back(y);else q.push(y);}
		if(idx2-idx1>1){vector<int> z;copy(begin(x)+idx1+1,begin(x)+idx2,begin(z));if(z.size()==2)d.push_back(z);else q.push(z);}
		if(idx2<n-1){vector<int> w;copy(begin(x)+idx2+1,begin(x)+n,begin(w));if(w.size()==2)d.push_back(w);else q.push(w);}
	}
	sort(begin(d),end(d),[&](vector<int> x,vector<int> y){return x[0]<y[0];});
	for(auto&& w:d)for(auto&& v:w)cout<<v<<" "; 

}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:17: error: 'x' was not declared in this scope
   13 |                 x=q.front();q.pop();
      |                 ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using P=pair<int,int>;

int main(){
	int n;cin>>n;
	vector<int> p(n);
	for(auto&& w:p)cin>>w;
	vector<vector<int>> d;
	queue<vector<int>> q;
	q.push(p);
	while(!q.empty()){
		x=q.top();q.pop();
		int m1,m2,idx1,idx2;
		idx1=0,m1=x[idx1];
		for(int i=0;i<x.size();i+=2){
			if(m1>x[i]){m1=x[i],idx1=i;}
		}
		idx2=idx1+1,m2=x[idx2];
		for(int i=idx2;i<x.size();i+=2){
			if(m2>x[i]){m2=x[i],idx2=i;}	
		}
	vector<int>v={m1,m2};
	d.push_back(v);

		if(idx1>0){ vector<int> y;copy(begin(x),begin(x)+idx1,begin(y));if(y.size()==2)d.push_back(y);else q.push(y);}
		if(idx2-idx1>1){vector<int> z;copy(begin(x)+idx1+1,begin(x)+idx2,begin(z));if(z.size()==2)d.push_back(z);else q.push(z);}
		if(idx2<n-1){vector<int> w;copy(begin(x)+idx2+1,begin(x)+n,begin(w));if(w.size()==2)d.push_back(w);else q.push(w);}
	}
	sort(begin(d),end(d),[&](vector<int> x,vector<int> y){return x[0]<y[0];});
	for(auto&& w:d)for(auto&& v:w)cout<<v<<" "; 

}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:17: error: 'x' was not declared in this scope
   13 |                 x=q.top();q.pop();
      |                 ^
a.cc:13:21: error: 'class std::queue<std::vector<int> >' has no member named 'top'; did you mean 'pop'?
   13 |                 x=q.top();q.pop();
      |                     ^~~
      |                     pop
Language: C++

#include <bits/stdc++.h>

using namespace std;

const int maxn=200005;
const int inf=0x3f3f3f3f;

int n;
int xx[maxn];

#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)

struct node
{
	struct Node
	{
		int jx, ox;
	} no[maxn << 2];
	int k;
	inline int minn(int a, int b)
	{
		if (!a || !b)
			return a | b;
		else
			return xx[a] < xx[b] ? a : b;
	}
	inline void push_up(int k)
	{
		no[k].jx=minn(no[ls(k)].jx, no[rs(k)].jx);
		no[k].ox=minn(no[ls(k)].ox, no[rs(k)].ox);
	}

	inline void build_tree(int n)
	{
		for (k=1; k <= n; k <<= 1);
		for (int i=1; i <= n; ++i)
		{
			if (i & 1)
				no[i + k].jx=i;
			else
				no[i + k].ox=i;
		}
		for (int i=k; i; --i)
			push_up(i);
	}

	inline int query(int l, int r, int kk)
	{
		int ans=0;
		for (l += k - 1, r += k + 1; l ^ r ^ 1; l >>= 1, r >>= 1)
		{
			if (~l & 1)
				ans=minn(kk ? no[l ^ 1].jx : no[l ^ 1].ox, ans);
			if (r & 1)
				ans=minn(kk ? no[r ^ 1].jx : no[r ^ 1].ox, ans);
		}
		return ans;
	}
} tr;

struct Node
{
	int l, r, ansl, ansr; 
	friend bool operator < (Node a, Node b)
	{
		return xx[a.ansl] > xx[b.ansl];
	}

	Node (int l, int r)
	{
		this->l=l;
		this->r=r;
		this->ansl=tr.query(l, r, 1);
		this->ansr=tr.query(ansl + 1, r, 0);
	}
};

priority_queue<Node> q;

int main()
{
	read(n);
	for (int i=1; i <= n; ++i)
		cin>>xx[i];
	tr.build_tree(n);
	q.push(Node(1, n));
	while (!q.empty())
	{
		Node now=q.top();
		q.pop();
		cout<<xx[now.ansl]<<' '<<xx[now.ansr]<<' ';
		if (now.ansl + 1 < now.ansr - 1)
			q.push(Node(now.ansl + 1, now.ansr - 1));
		if (now.l < now.ansl - 1)
			q.push(Node(now.l, now.ansl - 1));
		if (now.ansr + 1 < now.r)
			q.push(Node(now.ansr + 1, now.r));
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:83:13: error: too few arguments to function 'ssize_t read(int, void*, size_t)'
   83 |         read(n);
      |         ~~~~^~~
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from /usr/include/c++/14/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:116,
                 from a.cc:1:
/usr/include/unistd.h:371:16: note: declared here
  371 | extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur
      |                ^~~~
Language: C++

#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) rep2(i,0,n-1)
int MOD=1000000000+7;
int INF=1e6;
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");
 
int a[800000];
 
struct section{
    int first;
    int last;
    int min;
  	
};
bool operator> (const section &s1,const section &s2){
    return s1.min>s2.min;
};
 
 
int d1[800000],d2[800000];
priority_queue<section,vector<section>,greater<section>> p;
 
int search1(int first,int last,int k,int l,int r){
    if(r<first||l>last) return INF;
    if(first<=l&&last>=r) return d1[k];
    int leftmin=search1(first,last,k*2+1,l,(l+r)/2);
    int rightmin=search1(first,last,k*2+2,(l+r+1)/2,r);
    return min(leftmin,rightmin);
}
int search2(int first,int last,int k,int l,int r){
    if(r<first||l>last) return INF;
    if(first<=l&&last>=r) return d2[k];
    int leftmin=search2(first,last,k*2+1,l,(l+r)/2);
    int rightmin=search2(first,last,k*2+2,(l+r+1)/2,r);
    return min(leftmin,rightmin);
}
int n;
int pos[210000];
void GO(){
    while(!p.empty()){
        section s=p.top();
        p.pop();
        int min2;
        if(pos[s.min]%2){
            min2=search2(pos[s.min]+1,s.last,0,0,n-1);
        }
        else{
            min2=search1(pos[s.min]+1,s.last,0,0,n-1);
        }
      	section t;
        if(s.first!=pos[s.min]){
            if(s.first%2) 
            t={s.first,pos[s.min]-1,search1(s.first,pos[s.min]-1,0,0,n-1)};
            else
            t={s.first,pos[s.min]-1,search2(s.first,pos[s.min]-1,0,0,n-1)};
            p.push(t);
        }
        if(pos[s.min]+1!=pos[min2]){
            if(pos[s.min]%2)
            t={pos[s.min]+1,pos[min2]-1,search2(pos[s.min]+1,pos[min2]-1,0,0,n-1)};
            else
            t={pos[s.min]+1,pos[min2]-1,search1(pos[s.min]+1,pos[min2]-1,0,0,n-1)};
            p.push(t);
        }
        if(pos[min2]!=s.last){
            if(pos[min2]%2)
            t={pos[min2]+1,s.last,search2(pos[min2]+1,s.last,0,0,n-1)};
            else
            t={pos[min2]+1,s.last,search1(pos[min2]+1,s.last,0,0,n-1)};
            p.push(t);
        }
        printf("%d %d",s.min,min2);
    }
}
main(){
    cin>>n;
    rep(i,n){
        scanf("%d",&a+i)
        pos[a[i]]=i;
        if(i%2){
            d1[n-1+i]=a[i];
            d2[n-1+i]=INF;
        }
        else{
            d2[n-1+i]=a[i];
            d1[n-1+i]=INF;
        }
    }
    for(int i=n-2;i>=0;i--){
        d1[i]=min(d1[i*2+1],d1[i*2+2]);
        d2[i]=min(d2[i*2+1],d2[i*2+2]);
    }
    section temp{0,n-1,d2[0]};
  	p.push(temp);
    GO();
    return 0;
}

Compiler output:
a.cc:79:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   79 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:82:25: error: expected ';' before 'pos'
   82 |         scanf("%d",&a+i)
      |                         ^
      |                         ;
   83 |         pos[a[i]]=i;
      |         ~~~
Language: C++

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 200010
#define M 20
int n;
int a[N], b[N][M+1];

int query(int l, int r){
	if(r-l<=0) return n;
	if(r-l<2) return l;
	int t = 0;
	while(l+(2<<(t+1))<=r) t++;
	int res = b[l][t];
	int res2 = query(l+(2<<t), r);
	return a[res]<a[res2]?res:res2;
}

vector<int> rec(int l, int r){
	if(r-l<=0) return vector<int>();
	int x1 = query(l, r);
	int x2 = query(x1+1, r);
	vector<int> v[3];
	v[0] = rec(l, x1);
	v[1] = rec(x1+1, x2);
	v[2] = rec(x2+1, r);
	int mxn = v[0].size()+v[1].size()+v[2].size();
	if(v[0].size()<v[2].size()) v[0].swap(v[2]);
	if(v[0].size()<v[1].size()) v[0].swap(v[1]);
	int p[3] = {};
	while(true){
		bool f = false;
		int t = -1;
		rep(i, 3){
			if(p[i]<v[i].size() && (t<0 || a[v[i][p[i]]]<a[v[t][p[t]]])) t = i;
		}
		if(t<0) break;
		res.push_back(v[t][p[t]++]);
		res.push_back(v[t][p[t]++]);
	}
	res.insert(res.begin(), x2);
	res.insert(res.begin(), x1);
	return res;
}

int main(){
	scanf("%d", &n);
	rep(i, n) scanf("%d", a+i);
	a[n] = INF;
	rep(i, n) b[i][0] = i;
	rep(j, M) for(int i = n-1; i >= 0; i--){
		b[i][j+1] = b[i][j];
		int i2 = min(i+(2<<j), n-1);
		if(i%2!=i2%2) i2--;
		if(a[b[i][j+1]]>a[b[i2][j]]) b[i][j+1] = b[i2][j];
	}
	vector<int> res = rec(0, n);
	rep(i, n) printf("%d ", a[res[i]]);
	puts("");
	return 0;
}


Compiler output:
a.cc: In function 'std::vector<int> rec(int, int)':
a.cc:75:17: error: 'res' was not declared in this scope; did you mean 'rec'?
   75 |                 res.push_back(v[t][p[t]++]);
      |                 ^~~
      |                 rec
a.cc:78:9: error: 'res' was not declared in this scope; did you mean 'rec'?
   78 |         res.insert(res.begin(), x2);
      |         ^~~
      |         rec
Language: C++

#include <cstdio>
#include <algorithm>
#include <queue>

const int INF = 0x1f1f1f1f;

const int N = 200000;

const int lgN = 20;

typedef int ST[lgN][N];

ST st[2];

int p[N];

int lg[N];

int inv[N];

int qi;
int q[N];

int n;

void build(int d) {
	for (int x = 0; (1 << x) <= n; x++) {
		int y = 1 << x;
		int h = y >> 1;
		for (int i = 0; i <= n - y; i++) {
			if (x == 0)
				st[d][x][i] = i % 2 == d ? p[i] : INF;
			else
				st[d][x][i] = std::min(st[d][x - 1][i], st[d][x - 1][i + h]);
		}
	}
}

int query(int l, int r) {
	int x = lg[r - l + 1];
	return std::min(st[l % 2][x][l], st[l % 2][x][r - (1 << x) + 1]);
}

void init() {
	for (int i = 0; (1 << i) + 1 <= n; i++)
		lg[1 << i] = i;
	for (int i = 2; i <= n; i++)
		lg[i] = lg[i] == 0 ? lg[i - 1] : lg[i];
}

struct pair {
	int l, r, val;
	friend operator < (const pair& a, const pair& b) {
		return a.val > b.val;
	}
};

pair make_pair(int l, int r) {
	return (pair){l, r, query(l, r)};
}

std::priority_queue<pair> pq;

void solve() {

	pq.push(make_pair(0, n - 1));

	while (!pq.empty()) {

		pair t = pq.top();
		pq.pop();

		q[qi++] = t.val;

		int i = inv[t.val];

		int j_ = query(i + 1, t.r);

		q[qi++] = j_;

		int j = inv[j_];

		if (t.l < i - 1) pq.push(make_pair(t.l, i - 1));
		if (i + 1 < j - 1) pq.push(make_pair(i + 1, j - 1));
		if (j + 1 < t.r) pq.push(make_pair(j + 1, t.r));

	}

}

int main(int argc, char *argv[]) {
	
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &p[i]);
		inv[p[i]] = i;
	}
		
	init();
	
	build(0);
	build(1);
	
	solve();
	
	for (int i = 0; i < qi; i++)
		printf("%d ", q[i]);
	putchar('\n');
	
	return 0;

}


Compiler output:
a.cc:53:16: error: ISO C++ forbids declaration of 'operator<' with no type [-fpermissive]
   53 |         friend operator < (const pair& a, const pair& b) {
      |                ^~~~~~~~
Language: C++

#include<iostream>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
using vi = vector<int> ;
using P = pair<int, int>;

template<typename T>
class segtree {
public:
	segtree(int n) {
		for (size = 1; size < n; size *= 2);
		vec.resize(2 * size -1, zero);
	}
	segtree(std::vector<T> v) {
		int n = v.size();
		for (size = 1; size < n; size *= 2);
		vec.resize(2 * size -1, zero);
		for (int i = 0; i < n; i++) {
			vec[i + size-1] = v[i];
		}
		for (int i = size - 2; i >= 0; i--) {
			vec[i] = func(vec[i * 2 + 1], vec[i * 2 + 2]);
		}
	}
	void set(int n, T x) {
		n += size - 1;
		while (n >= 0) {
			vec[n] = func(vec[n], x);
			n = (n + 1) / 2 - 1;
		}
	}
	int get(int a, int b) {
		return get_func(0, 0, size, a, b);
	}
private:
	T zero = INT_MAX;
	std::function<T(T, T)> func = [](T a, T b) {return std::min(a, b); };
	vector<T> vec;
	int size;
	
	int get_func(int n, int p, int q, int x, int y) {
		if (q - p == 1)return vec[n];
		if (x == p && q == y) return vec[n];
		int mean = (p + q) / 2;
		T l = zero;
		T r = zero;
		if (x < mean)l = get_func(n * 2 + 1, p, mean, x, std::min(y,mean));
		if (mean < y)r = get_func(n * 2 + 2, mean, q, std::max(x,mean), y);
		return func(l, r);
	}
};

int main() {
	int n;
	cin >> n;
	vi p(n);
	vi index(n+1);
	segtree<int> evens(n);
	segtree<int> odds(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		index[p[i]] = i;
		if (i % 2 == 0) {
			evens.set(i, p[i]);
		}
		else {
			odds.set(i, p[i]);
		}
	}
	priority_queue<pair<int, P>> que;
	que.emplace(-evens.get(0,n), P(0, n));
	vi ans;
	while (!que.empty()) {
		pair<int,P> p = que.top(); que.pop();
		int minimum = -p.first;
		int a = p.second.first;
		int b = p.second.second;
		int pos = index[minimum];
		int next;
		if (pos % 2 == 0) {
			next = odds.get(pos+1, b);
		}
		else {
			next = evens.get(pos+1, b);
		}
		ans.push_back(minimum);
		ans.push_back(next);
		if (a < pos) {
			if ((a) % 2 == 0) {
				int m = evens.get(a ,pos);
				que.emplace(-m, P(a, pos));
			}
			else {
				int m = odds.get(a, pos);
				que.emplace(-m, P(a, pos));
			}
		}
		if (pos + 1 < index[next]) {
			if ((pos + 1) % 2 == 0) {
				int m = evens.get(pos + 1, index[next]);
				que.emplace(-m, P(pos + 1, index[next]));
			}
			else {
				int m = odds.get(pos + 1, index[next]);
				que.emplace(-m, P(pos + 1, index[next]));
			}
		}
		if (index[next] + 1 < b) {
			if ((index[next] + 1) % 2 == 0) {
				int m = evens.get(index[next] + 1, b);
				que.emplace(-m, P(index[next] + 1, b));
			}
			else {
				int m = odds.get(index[next] + 1, b);
				que.emplace(-m, P(index[next] + 1, b));
			}
		}
	}

	for (int x : ans) {
		cout << x << " ";
	}
	cout << endl;

}



Compiler output:
a.cc:39:18: error: 'INT_MAX' was not declared in this scope
   39 |         T zero = INT_MAX;
      |                  ^~~~~~~
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    5 | #include<queue>
  +++ |+#include <climits>
    6 | using namespace std;
Language: C

#include <stdio.h>

int p[200000];
int q[200000];

int main(){
    int N;
    scanf("%d", &N);
    
    for(int i = 0; i < N; i++){
        scanf("%d", &p[i]);
    }

    int i = 0;
    while(i < N){

        int n = 0;
        int min = N + 1;
        int xIdx = -1;
        for(int j = 0; j < N; j++){
            if(p[j] == -1){
                j++;
                continue;
            }
            
            if(n % 2 != 0){
                continue;
            }

            if(p[j] < min){
                min = p[j];
                xIdx = j;
            }

            n++;
        }

        q[i] = min;
        p[xIdx] = -1;
        i++;

        n = 1;
        min = N + 1;
        int yIdx = -1;
        for(int j = xIdx + 1; j < N; j++){
            if(p[j] == -1){
                j++;
                continue;
            }
            
            if(n % 2 != 1){
                continue;
            }

            if(p[j] < min){
                min = p[j];
                minIdx = j;
            }
            
            n++;
        }

        q[i] = min;
        p[yIdx] = -1;
        i++;
    }

    for(int i = 0; i < N; i++){
        printf("%d ", q[i]);
    }

    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:57:17: error: 'minIdx' undeclared (first use in this function)
   57 |                 minIdx = j;
      |                 ^~~~~~
main.c:57:17: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include<iostream>
#include<vector>

using namespace std;

vector<int> ans;
int n;
const int INF = 0x3f3f3f;

void solve(vector<int> dir,int f,int s)
{
	if (dir.empty()) return;
	int maxhead = 0, cnt = 0,down=0;
	for (int i = 0; i < dir.size()-1; ++i) {
		if (dir[i] != f && dir[i] != s) {
			if (dir[i + 1] != f && dir[i + 1] != s) {
				if (dir[i] > maxhead) {
					maxhead = dir[i];
					down = i;
				}
			}
		}
	}

	ans.push_back(dir[down + 1]); ans.push_back(dir[down]);
	vector<int> nex;
	for (int i = 0; i < dir.size(); ++i) {
		if (i != down && i!=down+1) {
			nex.push_back(dir[i]);
		}
	}
	solve(nex, f, s);
}

int main()
{
	vector<int> iv; int temp,goalf=INF,goals=INF;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> temp;
		iv.push_back(temp);
		if (temp < goalf && !(i%2)) {
			goalf = temp;
		}
	}
	int i;
	for (i = 0; iv[i] != goalf; ++i);
	for (int j = i + 1; j < n; ++j) {
		if (iv[j] < goals) {
			goals = iv[j];
		}
	}
	solve(iv,goalf,goals);
	reverse(ans.begin(), ans.end());
	for (int i = 0; i < ans.size(); ++i) {
		cout << ans[i] << " ";
	}
	cout << endl;
//	system("pause");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:9: error: 'reverse' was not declared in this scope
   54 |         reverse(ans.begin(), ans.end());
      |         ^~~~~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>

using namespace std;

template<class T>
void show(vector<T> &v) {
	if (!v.empty()) {
		copy(v.begin(), v.end(), ostream_iterator<T>(cout, " "));
	}
	cout << endl;
}

class AAA {
public:
	int x;
	int y;
	int x_idx;
	int y_idx;
	vector<int> v;

	AAA(vector<int> &vv) {
		v = vv;

		if (v.empty()) {
			x = y = x_idx = y_idx = -1;
			return;
		}

		x_idx = 0;
		x = v[x_idx];
		for (int i = 2; i < v.size(); i += 2) {
			if (v[i] < x) {
				x = v[i];
				x_idx = i;
			}
		}

		y_idx = x_idx + 1;
		y = v[y_idx];
		for (int i = y_idx + 2; i < v.size(); i+= 2) {
			if (v[i] < y) {
				y = v[i];
				y_idx = i;
			}
		}

		// printf("xy %d %d, idx %d %d\n", x, y, x_idx, y_idx);
	}
};

bool operator < (const AAA &a, const AAA &b) {
	return a.x < b.x;
}
bool operator > (const AAA &a, const AAA &b) {
	return a.x > b.x;
}

int main() {
	int n;
	cin >> n;

	vector<int> p(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}

	priority_queue<AAA, vector<AAA>, greater<AAA>> que;
	vector<int> ans;

	AAA aaa(p);

	que.push(aaa);
	while(!que.empty()) {
		auto a = que.top();
		que.pop();

		ans.emplace_back(a.x);
		ans.emplace_back(a.y);

		auto v = a.v;

		// cout << "ans: ";
		// show(ans);
		// cout << "v  : ";
		// show(v);

		auto v1 = vector<int>(v.begin(), v.begin() + a.x_idx);
		auto v2 = vector<int>(v.begin() + a.x_idx + 1, v.begin() + a.y_idx);
		auto v3 = vector<int>(v.begin() + a.y_idx + 1, v.end());
		if (!v1.empty()) { que.push(AAA(v1)); }
		if (!v2.empty()) { que.push(AAA(v2)); }
		if (!v3.empty()) { que.push(AAA(v3)); }

		// cout << "-----" << endl;
		// show(v1);
		// cout << a.x << endl;
		// show(v2);
		// cout << a.y << endl;
		// show(v3);
		// cout << "....." << endl;
	}

	show(ans);
	return 0;
}


Compiler output:
a.cc: In function 'void show(std::vector<_Tp>&)':
a.cc:13:42: error: 'ostream_iterator' was not declared in this scope
   13 |                 copy(v.begin(), v.end(), ostream_iterator<T>(cout, " "));
      |                                          ^~~~~~~~~~~~~~~~
a.cc:7:1: note: 'std::ostream_iterator' is defined in header '<iterator>'; this is probably fixable by adding '#include <iterator>'
    6 | #include <queue>
  +++ |+#include <iterator>
    7 | 
a.cc:13:60: error: expected primary-expression before '>' token
   13 |                 copy(v.begin(), v.end(), ostream_iterator<T>(cout, " "));
      |                                                            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
 
 
struct SegmentTree{
    vector<int> Seg;
	int n;
 
	void build(vector<int>& v, int m){
		n = m;
        Seg = vector<int> (4*n,1e6);
		build(v, 1, 0, n);
	}
	void build( vector<int>& v, int id,int left, int right){
		if(left + 1 >= right){
			Seg[id] = v[left];
			return;
		}
		int mid = (left + right)/2;
		build(v, id * 2, left, mid);
		build(v, id * 2 + 1, mid, right);
		Seg[id] = min(Seg[id*2],Seg[id*2 + 1]);
	}
 
	int find(int x, int y){
		return find(x, y, 1, 0, n);
	}
	int find(int x, int y, int id, int left, int right){
		if(left >= y or right <= x){
			return 1e6;
		}
		if(left >= x and right <= y){
			return Seg[id];
		}
		int mid = (left + right)/2;
		return min(find(x, y, 2*id, left, mid), find(x, y, 2*id + 1, mid, right));
	}
};
SegmentTree S[2];
 
struct obj {
	int x,y,i;
	bool operator < (const obj& o) const {
		return x > o.x;
	}
};

int pos[200010];
int s = 0;
vector<obj> adj[200010];
priority_queue<obj> pq;
	
void getans(int l, int r, int p, int par) {
	if(l + 1 >= r) return;
	int curNode = s++;
	sz[curNode] = 0;
	int x = S[p].find(l,r);
	int px = pos[x];
	int y = S[p^1].find(px + 1, r);
	int py = pos[y];

	if(par != -1) {
		adj[par].push_back(x,y,curNode);
	}
	else {
		pq.push({x,y,curNode});
	}
	
	getans(l, px, p, par);
	getans(px + 1, py, p^1, curNode);
	getans(py + 1, r, p, par);
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> odd(n, 1e6), even(n, 1e6);
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		pos[x] = i;
		if(i&1) even[i] = x;
		else odd[i] = x;
	}
 
	S[0].build(odd, n);
	S[1].build(even, n);
	getans(0,n,0,-1);
 
	int ans[n];

	while(pq.size()) {
		auto x = pq.top();
		pq.pop();
		cout << x.x << ' ' << x.y << ' ';
		for(auto i : adj[x.i]) pq.push(i);
	}

}


Compiler output:
a.cc: In function 'void getans(int, int, int, int)':
a.cc:56:9: error: 'sz' was not declared in this scope; did you mean 's'?
   56 |         sz[curNode] = 0;
      |         ^~
      |         s
a.cc:63:35: error: no matching function for call to 'std::vector<obj>::push_back(int&, int&, int&)'
   63 |                 adj[par].push_back(x,y,curNode);
      |                 ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = obj; _Alloc = std::allocator<obj>; value_type = obj]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note:   candidate expects 1 argument, 3 provided
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = obj; _Alloc = std::allocator<obj>; value_type = obj]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note:   candidate expects 1 argument, 3 provided
Language: C++

#include<bits/stdc++.h>
using namespace std;
 
 
struct SegmentTree{
    vector<int> Seg;
	int n;
 
	void build(vector<int>& v, int m){
		n = m;
        Seg = vector<int> (4*n,1e6);
		build(v, 1, 0, n);
	}
	void build( vector<int>& v, int id,int left, int right){
		if(left + 1 >= right){
			Seg[id] = v[left];
			return;
		}
		int mid = (left + right)/2;
		build(v, id * 2, left, mid);
		build(v, id * 2 + 1, mid, right);
		Seg[id] = min(Seg[id*2],Seg[id*2 + 1]);
	}
 
	int find(int x, int y){
		return find(x, y, 1, 0, n);
	}
	int find(int x, int y, int id, int left, int right){
		if(left >= y or right <= x){
			return 1e6;
		}
		if(left >= x and right <= y){
			return Seg[id];
		}
		int mid = (left + right)/2;
		return min(find(x, y, 2*id, left, mid), find(x, y, 2*id + 1, mid, right));
	}
};
SegmentTree S[2];
 
struct obj {

}
int pos[200010];
int s = 0;
int parent[200010];
pair<int,int> E[200010];
int sz[200010];
void getans(int l, int r, int p, int par) {
	if(l + 1 >= r) return;
	int curNode = s++;
	sz[curNode] = 0;
	int x = S[p].find(l,r);
	int px = pos[x];
	int y = S[p^1].find(px + 1, r);
	int py = pos[y];
 
	E[curNode] = {x,y};
	if(par != -1) {
		parent[curNode] = par;
		sz[par]++;
	}
	getans(l, px, p, par);
	getans(px + 1, py, p^1, curNode);
	getans(py + 1, r, p, par);
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	memset(parent, -1, sizeof parent);
	vector<int> odd(n, 1e6), even(n, 1e6);
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		pos[x] = i;
		if(i&1) even[i] = x;
		else odd[i] = x;
	}
 
	S[0].build(odd, n);
	S[1].build(even, n);
	getans(0,n,0,-1);
 
	int ans[n];
	priority_queue<pair<pair<int,int>,int>> pq;
	for(int i = 0; i < s; ++i) {
		if(parent[i] == -1) pq.push({E[i],i});
	}
	int last = n-1;
	while(pq.size()) {
		auto x = pq.top();
		pq.pop();
		ans[last--] = x.first.second;
		ans[last--] = x.first.first;
 
		int pare = parent[x.second];
		for(int i : pair
	}
 
	for(int i = 0; i < n; ++i) cout << ans[i] << ' ';
	cout << endl;
}

Compiler output:
a.cc:43:2: error: expected ';' after struct definition
   43 | }
      |  ^
      |  ;
a.cc: In function 'int main()':
a.cc:101:9: error: missing template arguments before '}' token
  101 |         }
      |         ^
a.cc:100:33: error: expected ')' before '}' token
  100 |                 for(int i : pair
      |                    ~            ^
      |                                 )
  101 |         }
      |         ~                        
a.cc:101:9: error: expected primary-expression before '}' token
  101 |         }
      |         ^
Language: C++

#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int odd[800010], even[800010], lf, rt, pos[200010], a[200010];
int qry1(int x, int st, int nd){
  if(st>rt||nd<lf)
    return 1e9;
  if(st>=lf&&nd<=rt){
    return odd[x];
  }
  int md=(st+nd)/2;
  return min(qry1(x*2, st, md), qry1(x*2+1, md+1, nd));
}
int qry2(int x, int st, int nd){
  if(st>rt||nd<lf)
    return 1e9;
  if(st>=lf&&nd<=rt){
    return even[x];
  }
  int md=(st+nd)/2;
  return min(qry2(x*2, st, md), qry2(x*2+1, md+1, nd));
}
void init(int x, int st, int nd){
  if(st==nd){
    if(st%2){
      odd[x]=a[st];
      even[x]=1e9;
    }
    else{
      even[x]=a[st];
      odd[x]=1e9;
    }
    return;
  }
  int md=(st+nd)/2;
  init(x*2, st, md);init(x*2+1, md+1, nd);
  odd[x]=min(odd[x*2], odd[x*2+1]);
  even[x]=min(even[x*2], even[x*2+1]);
}
int mp[200010];
int main(){
  int n, x, tmp, ans, y;
  cin>>n;
  for(int i=0; i<n; ++i){
      a[i]=i+1;
//    scanf("%d",&a[i]);
    pos[a[i]]=i;
  }
  init(1,0,n-1);
  set<int> s;
  vector <int> v;
  s.insert(n);s.insert(-1);
  for(int i=1; i<=n; ++i){
    if(mp[i])
      continue;
    tmp=pos[i];
    x=*s.upper_bound(tmp);
    --x;
    y=*--s.upper_bound(tmp);
    ++y;
    if(tmp%2){
      lf=tmp;rt=x;
      ans=qry2(1,0,n-1);
      if(ans!=1e9){
        s.insert(tmp);
        s.insert(pos[ans]);
        v.push_back(i);v.push_back(ans);
        mp[ans]=1;
      }
      else{
        lf=y;rt=tmp;
        ans=qry2(1,0,n-1);
        if(ans! =1e9){
          s.insert(tmp);
          s.insert(pos[ans]);
          v.push_back(ans);v.push_back(i);
          mp[ans]=1;
        }
      }
    }
    else{
      lf=tmp;rt=x;
      ans=qry1(1,0,n-1);
      if(ans!=1e9){
        s.insert(tmp);
        s.insert(pos[ans]);
        v.push_back(i);v.push_back(ans);
        mp[ans]=1;
      }
      else{
        lf=y;rt=tmp;
        ans=qry1(1,0,n-1);
        if(ans!=1e9){
          s.insert(tmp);
          s.insert(pos[ans]);
          v.push_back(ans);v.push_back(i);
          mp[ans]=1;
        }
      }
    }
  }
  for(int i=0; i<v.size(); ++i){
    printf("%d ",v[i]);
  }
  return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:77:15: error: expected ')' before '!' token
   77 |         if(ans! =1e9){
      |           ~   ^
      |               )
Language: C++


ll match[maxn], vis[maxn];

ll dfs(ll now)
{
	for(ll to : edge[now])
	{
		if(vis[to]) continue;
		vis[to] = 1;
		if(!match[to] || dfs(match[to]))
		{
			match[now] = to, match[to] = now;
			return 1;
		}
	}
	return 0;
}

void hungarian()
{
	rep(i, 1, tot)
	{
		if(col[i] == 2) continue;
		rep(j, 1, tot) vis[j] = 0;
		ans += dfs(i);
	}
}

Compiler output:
a.cc:2:1: error: 'll' does not name a type
    2 | ll match[maxn], vis[maxn];
      | ^~
a.cc:4:1: error: 'll' does not name a type
    4 | ll dfs(ll now)
      | ^~
a.cc: In function 'void hungarian()':
a.cc:21:13: error: 'i' was not declared in this scope
   21 |         rep(i, 1, tot)
      |             ^
a.cc:21:19: error: 'tot' was not declared in this scope
   21 |         rep(i, 1, tot)
      |                   ^~~
a.cc:21:9: error: 'rep' was not declared in this scope
   21 |         rep(i, 1, tot)
      |         ^~~
Language: C++

/********************************************************************************
	
	Code by a weak man named CYJian, and he hopes the code can get more points.

	Algorithm: 

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

int tot;
int pri[5010];
int chk[5010];

inline void Sieve(int n) {
	chk[1] = 0;
	for(int i = 2; i <= n; i++) {
		if(!chk[i]) pri[++tot] = i;
		for(int j = 1; j <= tot; j++) {
			if(i * pri[j] > n) break;
			chk[i * pri[j]] = 0;
			if(i % pri[j] == 0) break;
		}
	}
}

inline int check(int x) {
	if(x <= 5000) return !chk[x];
	for(int *p = pri + 1;; ++p) {
		if((*p) * (*p) > x) return 1;
		if(x % (*p) == 0) return 0;
	}
}

vector<int>to[210];
int vis[210];
int p[210];
int N;

inline int Try(int x) {
	cerr << x << endl;
	inq[x] = 1;
	for(auto u : to[x]) {
		if(!vis[u]) {
			vis[u] = x;
			vis[x] = u;
			inq[x] = 0;
			return 1;
		} else if(!inq[vis[u]] && Try(vis[u])) {
			vis[u] = x;
			vis[x] = u;
			inq[x] = 0;
			return 1;
		}
	} return inq[x] = 0;
}

int main() {
#ifdef LOCAL
	FILE("");
#endif

	Sieve(5000);
	int n = ri, ce = 0, co = 0;

	for(int i = 1; i <= n; i++) {
		int x = ri;
		if(p[N] == x) --N;
		else p[++N] = x;
		p[++N] = x + 1;
	}

	for(int i = 1; i <= N; i++) 
		p[i] & 1 ? ++co : ++ce;

	for(int i = 1; i <= N; i++)
		for(int j = i + 1; j <= N; j++) {
			if(((p[i] ^ p[j]) & 1) && check(p[j] - p[i]))
				to[i].push_back(j), to[j].push_back(i);
		}

	int res = 0;
	for(int i = 1; i <= N; i++)
		if((p[i] & 1) && Try(i))
			--co, --ce, ++res;

	res += (co / 2 + ce / 2) << 1;
	if((co | ce) & 1) res += 3;

	cout << res << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int Try(int)':
a.cc:69:9: error: 'inq' was not declared in this scope; did you mean 'int'?
   69 |         inq[x] = 1;
      |         ^~~
      |         int
Language: C++

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#define inf 1e9
using namespace std;
struct node{
	int nxt,to,weigh;
}edge[400010];
int head[100100],n,S,T,cnt=1,level[100100];
int a[10010],b[10010],c[10001000],sum,tot,ans;
queue<int> qu;
bool check(int a){
	for(int i=2;i<=sqrt(a);i++)
		if(a%i==0)return false;
	return true;
}
void addedge(int x,int y,int z){
	edge[++cnt].nxt=head[x];
	edge[cnt].to=y;
	edge[cnt].weigh=z;
	head[x]=cnt;
	edge[++cnt].nxt=head[y];
	edge[cnt].to=x;
	edge[cnt].weigh=0;
	head[y]=cnt;	
}
bool bfs(){
	memset(level,-1,sizeof(level));
	level[S]=0;
	qu.push(S);
	while(!qu.empty()){
		int u=qu.front();
		qu.pop();
		for(int i=head[u];i;i=edge[i].nxt){
			int upup=edge[i].to;
			if(edge[i].weigh!=0 && level[upup]==-1){
				level[upup]=level[u]+1;
				qu.push(upup);
			}
		}
	}
	if(level[T]==-1)return false;
	return true;
}
int dfs(int x,int flow){
	if(x==T)return flow;
	int rest=0;
	for(int i=head[x];i;i=edge[i].nxt){
		int upup=edge[i].to;
		if(rest==flow)break;
		if(level[upup]==level[x]+1){
			int sum=dfs(upup,min(flow-rest,edge[i].weigh));
			rest+=sum,edge[i].weigh-=sum;edge[i^1].weigh+=sum;
		}
	} 
	return rest;
}
int Dinic(){
	int ans=0;
	while(bfs())
		ans+=dfs(S,inf);
	return ans;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		c[a[i]]=1;
	}
	for(int i=1;i<=10000000;i++)
		if(c[i]!=c[i-1])
			b[++sum]=i;
	S=0,T=sum+1;
	for(int i=1;i<=sum;i++)
		if(b[i]&1){
			tot++;
			addedge(S,i,1);
			for(int j=1;j<=sum;j++)
				if(!b[j]&1&&check(abs(b[j]-b[i])))
					addedge(i,j,1);
		}
		else addedge(i,T,1);
	ans=Dinic();
	printf("%d\n",sum-ans+(tot-ans)%2);
	return 0;
}

Compiler output:
a.cc: In function 'bool check(int)':
a.cc:14:24: error: 'sqrt' was not declared in this scope
   14 |         for(int i=2;i<=sqrt(a);i++)
      |                        ^~~~