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

#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <random>
#include <chrono>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

int main() {

	int N, M;
	scanf_s("%d%d", &N, &M);

	if (M % 2 == 1) {
		printf("-1\n");
		return 0;
	}

	int u, v;
	map<pair<int, int>, int> dir;
	vector<vector<int>> edge(N);
	vector<int> out(N);
	for (int i = 0; i < M; i++) {
		scanf_s("%d%d", &u, &v);
		u--, v--;
		edge[u].emplace_back(v);
		edge[v].emplace_back(u);
		if (v < u) swap(u, v);
		dir[{u, v}] = 1; // intial direction is u->v when u < v
		out[u] ^= 1;
	}

	stack<pair<int,int>> que;
	vector<int> used(N);
	int idx = 2;
	que.emplace(0, 0);
	while (!que.empty()) {
		
		int now = que.top().first;
		int fliping = que.top().second;
		que.pop();
		DMP(now);
		DMP(fliping);

		idx++;
		used[now] = idx;

		if (out[now]) fliping ^= 1;

		for (const auto &e : edge[now]) {
			if (!used[e] && used[e] != used[now] - 1) {
				dir[minmax(now, e)] ^= fliping;
				out[now] ^= fliping;
				que.emplace(e, fliping);
				break;
			}
		}

		//if (all_used && fliping) {
		//	for (const auto &e : edge[now]) {
		//		if (used[e] < used[now]) {
		//			dir[minmax(now, e)] ^= fliping;
		//			out[now] ^= fliping;
		//			out[e] ^= fliping;
		//			que.emplace(e);
		//			all_used = false;
		//		}
		//	}
		//}
	}


	for (int i = 0; i < N; i++) {
		DMP(out[i]);
	}
	for (auto &e : dir) {
		if (e.second == 1) printf("%d %d\n", e.first.first + 1, e.first.second + 1);
		else printf("%d %d\n", e.first.second + 1, e.first.first + 1);
	}

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   27 |         scanf_s("%d%d", &N, &M);
      |         ^~~~~~~
      |         scanf
Language: C++

#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <algorithm>
#include <random>
#include <chrono>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

int main() {

	int N, M;
	scanf_s("%d%d", &N, &M);

	if (M % 2 == 1) {
		printf("-1\n");
		return 0;
	}

	int u, v;
	map<pair<int, int>, int> dir;
	vector<vector<int>> edge(N);
	vector<int> out(N);
	for (int i = 0; i < M; i++) {
		scanf_s("%d%d", &u, &v);
		u--, v--;
		edge[u].emplace_back(v);
		edge[v].emplace_back(u);
		if (v < u) swap(u, v);
		dir[{u, v}] = 1; // intial direction is u->v when u < v
		out[u] ^= 1;
	}

	stack<int> que;
	vector<int> used(N);
	used[0] = 1;
	int idx = 1;
	int fliping = 0;
	que.emplace(0);
	while (!que.empty()) {

		int now = que.top();
		que.pop();
		fliping = out[now];

		bool all_used = true;
		for (const auto &e : edge[now]) {
			if (!used[e]) {
				dir[minmax(now, e)] ^= fliping;
				out[now] ^= fliping;
				out[e] ^= fliping;
				idx++;
				used[e] = idx;
				all_used = false;
				que.emplace(e);
			}
		}
	}

	for (auto &e : dir) {
		if (e.second == 1) printf("%d %d\n", e.first.first + 1, e.first.second + 1);
		else printf("%d %d\n", e.first.second + 1, e.first.first + 1);
	}

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   26 |         scanf_s("%d%d", &N, &M);
      |         ^~~~~~~
      |         scanf
Language: C++

#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <algorithm>
#include <random>
#include <chrono>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

int main() {

	int N, M;
	scanf_s("%d%d", &N, &M);

	if (M % 2 == 1) {
		printf("-1\n");
		return 0;
	}

	int u, v;
	map<pair<int, int>, int> dir;
	vector<vector<int>> edge(N);
	vector<int> out(N);
	for (int i = 0; i < M; i++) {
		scanf_s("%d%d", &u, &v);
		u--, v--;
		edge[u].emplace_back(v);
		edge[v].emplace_back(u);
		if (v < u) swap(u, v);
		dir[{u, v}] = 1; // intial direction is u->v when u < v
		out[u] ^= 1;
	}

	stack<int> que;
	vector<int> used(N);
	used[0] = 1;
	int idx = 1;
	int fliping = 0;
	que.emplace(0);
	while (!que.empty()) {

		int now = que.top();
		que.pop();
		fliping = out[now];

		bool all_used = true;
		for (const auto &e : edge[now]) {
			if (!used[e]) {
				dir[minmax(now, e)] ^= fliping;
				out[now] ^= fliping;
				out[e] ^= fliping;
				idx++;
				used[e] = idx;
				all_used = false;
				que.emplace(e);
				break;
			}
		}

		if (all_used) {
			for (const auto &e : edge[now]) {
				if (used[e] < used[now]) {
					dir[minmax(now, e)] ^= fliping;
					out[now] ^= fliping;
					out[e] ^= fliping;
					que.emplace(e);
					all_used = false;
				}
			}
		}

		if (all_used) exit(-1);

	}

	for (auto &e : dir) {
		if (e.second == 1) printf("%d %d\n", e.first.first + 1, e.first.second + 1);
		else printf("%d %d\n", e.first.second + 1, e.first.first + 1);
	}

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   26 |         scanf_s("%d%d", &N, &M);
      |         ^~~~~~~
      |         scanf
Language: C

#include<stdio.h>
int main()
{
	long int m,n;
	scanf("%ld%ld",&n,&m);
	long int a[m],b[m];
	for(int i=0;i<m;i++)
	{
		scanf("%ld%ld",&a[i],&b[i]);
	}
	for(long int i=0;i<m;i++)
	{
		if(a[i]==n&&b[i]==1||a[i]==1&&b[i]==n||a[i]==b[i]-1||a[i]==b[i]+1)
		int a=1;
		else
		{printf("-1");return 0;}
	}
	int t;
	for(long int i=0;i<m;i++)
	{
		if(a[i]%2==0)
		{
			t=a[i];
			a[i]=b[i];
			b[i]=t;
		}
	}
	for(long int i=0;i<m;i++)
	{
		for(long int j=0;j<m-i;j++)
		{
			if(a[j]>a[j+1])
			{
				t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;
				t=b[j];
				b[j]=b[j+1];
				b[j+1]=t;
			}
		}
	}
	for(long int i=0;i<m;i=i+2)
	{
		if(b[i]<b[i+1])
		printf("%ld %ld\n%ld %ld\n",a[i],b[i],a[i+1],b[i+1]);
		else
		printf("%ld %ld\n%ld %ld\n",a[i+1],b[i+1],a[i],b[i]);
	}
} 

Compiler output:
main.c: In function 'main':
main.c:14:17: error: expected expression before 'int'
   14 |                 int a=1;
      |                 ^~~
Language: C++

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#include "prettyprint.hpp"

long getKey(int A, int B) {
  if (A < B) {
    return A * 100005 + B;
  } else {
    return B * 100005 + A;
  }
}

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> adj[N + 1];

  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    adj[A].push_back(B);
    adj[B].push_back(A);
  }

  if (M % 2 != 0) {
    cout << -1 << endl;
    return 0;
  }

  stack<pair<int, int>> treeEdgeStack;
  queue<int> bfsQueue;
  bool visited[N + 1];
  int count[N + 1];
  int parent[N + 1];
  vector<string> results;
  for (int i = 1; i <= N; i++) {
    visited[i] = false;
    count[i] = 0;
    parent[i] = 0;
  }

  bfsQueue.push(1);
  visited[1] = true;

  while (bfsQueue.size() > 0) {
    int u = bfsQueue.front();
    bfsQueue.pop();

    // cout << "u: " << u << endl;

    for (int i = 0; i < adj[u].size(); i++) {
      int v = adj[u][i];
      if (!visited[v]) {
        bfsQueue.push(v);
        treeEdgeStack.emplace(u, v);
        parent[v] = u;
        visited[v] = true;
      } else {
        // cout << "parent[v]: " << parent[v] << " v: " << v << " u: " << u
        //  << endl;
        if (v != parent[u] && v > u) {
          results.push_back(to_string(u) + " " + to_string(v));
          count[u] += 1;
          // cout << "u - v: " << u << " - " << v << endl;
        }
      }
    }
  }

  while (treeEdgeStack.size() > 0) {
    pair<int, int> e = treeEdgeStack.top();
    treeEdgeStack.pop();
    if (count[e.second] % 2 == 0) {
      results.push_back(to_string(e.first) + " " + to_string(e.second));
      count[e.first] += 1;
    } else {
      results.push_back(to_string(e.second) + " " + to_string(e.first));
      count[e.second] += 1;
    }
  }

  for (int i = 0; i < results.size(); i++) {
    cout << results[i] << endl;
  }

  return 0;
}

Compiler output:
a.cc:12:10: fatal error: prettyprint.hpp: No such file or directory
   12 | #include "prettyprint.hpp"
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<vector>

using namespace std;

const int maxn = 2e5+7;
vector<int> g[maxn];
int xx[maxn], yy[maxn], len  = 0;
int dep[maxn], in[maxn];
void dfs(int u,int pre){
    for(int i=0;i<g[u].size();i++){
        int v = g[u][i];
        if(dep[v]==0){
            dfs(v, u);
        }
        else if(dep[v]>dep[u]){
            in[u]++;
            xx[++len] = u;    
            yy[len] = v;
        }
    }
    if(in[u]&1){
        assert(pre != 0);
        len++;
        in[u]++;
        xx[len] = u;
        yy[len] = pre;
    }
    else{
        len++;
        in[pre]++;
        xx[len] = pre;
        yy[len] = u;
    }
}
int main()
{
    int n,m;scanf("%d%d", &n, &m);
    for(int i=1;i<=m;i++){
        int a,b;
        scanf("%d%d", &a, &b);
        g[a].push_back(b);   
        g[b].push_back(a);   
    }
    if(m & 1){
        printf("-1\n");
        return 0;    
    }
    dfs(1, 0);
    for(int i=1;i<=n;i++)assert((in[i]&1)==0);
    for(int i=1;i<=m;i++)printf("%d %d\n", xx[i], yy[i]);
    return 0;
}


Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:23:9: error: 'assert' was not declared in this scope
   23 |         assert(pre != 0);
      |         ^~~~~~
a.cc:3:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    2 | #include<vector>
  +++ |+#include <cassert>
    3 | 
a.cc: In function 'int main()':
a.cc:50:26: error: 'assert' was not declared in this scope
   50 |     for(int i=1;i<=n;i++)assert((in[i]&1)==0);
      |                          ^~~~~~
a.cc:50:26: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
Language: C++

#include <stdlib.h>
#include<iostream>
#include<algorithm>
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<cmath>
#define ll long long
const ll INF=0x3f3f3f3f;
#define mod 1000000007
#define mem(a,b) memset(a,b,sizeof(a))
//__builtin_popcount
using namespace std;
//priority_queue
const ll MAX=100000;
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
ll kc(ll a,ll b)
{
    ll c=1;
    while(b)
    {
        if(b&1)c=(c*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return c;
}
bool cmp(double x,double y)
{
    return x>y;
}
int F[50003*3];
int Find(int a)
{
    return F[a]<0?a:F[a]=Find(F[a]);
}
int same(int a,int b)
{
    if(Find(a)==Find(b))return 1;
    return 0;
}
int up1(int a,int b)
{
    int x,y;
    x=Find(a);
    y=Find(b);
    if(x!=y)
    F[x]=y;
    return 0;
}
vector<int>q[MAX+10];
int de[MAX+10];
int out[MAX+10];
void dfs(int a,int fa)
{
    for(auto i:q[a])
    {
        if(de[i]==0)
        {
            de[i]=de[a]+1;
              dfs(i,a);
        }
        else if(de[i]>de[a]){

            cout<<a<<" "<<i<<endl;
            out[a]++;
        }
    }
    if(out[a]%2)
    {  if(fa!=0)
        {
            cout<<a<<" "<<fa<<endl;
        out[a]++;
        }
           }
    else {
       if(fa!=0)
       {
     cout<<fa<<" "<<a<<endl;
        out[fa]++;
       }
    }
}
int main()
{
 int n,m;
   cin>>n>>m;
   if(m%2)
   {
       cout<<-1<<endl;
       return 0;
   }
   for(int i=1;i<=m;i++)
   {
       int x,y;
       cin>>x>>y;
       q[x].push_back(y);
       q[y].push_back(x);
   }
   de[1]=1;
   dfs(1,0);
}


Compiler output:
a.cc:54:1: error: 'vector' does not name a type
   54 | vector<int>q[MAX+10];
      | ^~~~~~
a.cc: In function 'void dfs(int, int)':
a.cc:59:16: error: 'q' was not declared in this scope
   59 |     for(auto i:q[a])
      |                ^
a.cc: In function 'int main()':
a.cc:100:8: error: 'q' was not declared in this scope
  100 |        q[x].push_back(y);
      |        ^
Language: C++

#include <stdlib.h>
#include<iostream>
#include<algorithm>
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<cmath>
#define ll long long
const ll INF=0x3f3f3f3f;
#define mod 1000000007
#define mem(a,b) memset(a,b,sizeof(a))
//__builtin_popcount
using namespace std;
//priority_queue
const ll MAX=1000000;
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
ll kc(ll a,ll b)
{
    ll c=1;
    while(b)
    {
        if(b&1)c=(c*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return c;
}
bool cmp(double x,double y)
{
    return x>y;
}
int F[50003*3];
int Find(int a)
{
    return F[a]<0?a:F[a]=Find(F[a]);
}
int same(int a,int b)
{
    if(Find(a)==Find(b))return 1;
    return 0;
}
int up1(int a,int b)
{
    int x,y;
    x=Find(a);
    y=Find(b);
    if(x!=y)
    F[x]=y;
    return 0;
}
vector<int>q[MAX+10];
int de[MAX+10];
int out[MAX+10];
void dfs(int a,int fa)
{
    for(auto i:q[a])
    {
        if(de[i]==0)
        {
            de[i]=de[a]+1;
              dfs(i,a);
        }
        else if(de[i]>de[a]){

            cout<<a<<" "<<i<<endl;
            out[a]++;
        }
    }

    if(out[a]%2)
    {  if(fa!=0)
        cout<<a<<" "<<fa<<endl;
        out[a]++;
    }
    else {
   if(fa!=0)
        cout<<fa<<" "<<a<<endl;
        out[fa]++;
    }
}
int main()
{
 int n,m;
   cin>>n>>m;
   if(m%2)
   {
       cout<<-1<<endl;
       return 0;
   }
   for(int i=1;i<=m;i++)
   {
       int x,y;
       cin>>x>>y;
       q[x].push_back(y);
       q[y].push_back(x);
   }
   de[1]=1;
   dfs(1,0);
}


Compiler output:
a.cc:54:1: error: 'vector' does not name a type
   54 | vector<int>q[MAX+10];
      | ^~~~~~
a.cc: In function 'void dfs(int, int)':
a.cc:59:16: error: 'q' was not declared in this scope
   59 |     for(auto i:q[a])
      |                ^
a.cc: In function 'int main()':
a.cc:97:8: error: 'q' was not declared in this scope
   97 |        q[x].push_back(y);
      |        ^
Language: C++

#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define   ull unsigned long long 
#define mp make_pair
#define pb push_back
const int MAX=2e5+9;
const long long mod=1e9+7;
using namespace std;
vector<int>adj[MAX];
int d[MAX];
int deg[MAX];
void dfs(int x, int y){
	d[x]=y;
	for(int i=0;i<adj[x].size();i++){
		if(d[adj[x][i]]==0){
			dfs(adj[x][i] , y+1);
			if(deg[adj[x][i]]%2==0){
				deg[x]++;
				cout<<x+1<<" "<<adj[x][i]+1<<"\n";
			}
			else{
				deg[adj[x][i]]++;
				cout<<adj[x][i]+1<<" "<<x+1<<"\n";
			}
		}
		else if(d[adj[x][i]]>d[x]){
			d[X]++;
			cout<<x+1<<" "<<adj[x][i]+1<<"\n";
		}

	}
}

int main(){
	int n , m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x, y;
		cin>>x>>y;
		x--;
		y--;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	if(m%2){
		cout<<-1;
	}
	else
	{
		dfs(0, 1);
	}
}

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:28:27: error: 'X' was not declared in this scope
   28 |                         d[X]++;
      |                           ^
Language: C++

int deg[MAX];
void dfs(int x, int y){
	d[x]=y;
	for(int i=0;i<adj[x].size();i++){
		if(d[adj[x][i]]==0){
			dfs(adj[x][i] , y+1);
			if(deg[adj[x][i]]%2==0){
				deg[x]++;
				cout<<x+1<<" "<<adj[x][i]+1<<"\n";
			}
			else{
				deg[adj[x][i]]++;
				cout<<adj[x][i]+1<<" "<<x+1<<"\n";
			}
		}
		else if(d[adj[x][i]]>d[x]){
			d[adj[x][i]]++;
			cout<<x+1<<" "<<adj[x][i]+1<<"\n";
		}

	}
}

int main(){
	int n , m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x, y;
		cin>>x>>y;
		x--;
		y--;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	if(m%2){
		cout<<-1;
	}
	else
	{
		dfs(0, 1);
	}
}

Compiler output:
a.cc:1:9: error: 'MAX' was not declared in this scope
    1 | int deg[MAX];
      |         ^~~
a.cc: In function 'void dfs(int, int)':
a.cc:3:9: error: 'd' was not declared in this scope
    3 |         d[x]=y;
      |         ^
a.cc:4:23: error: 'adj' was not declared in this scope
    4 |         for(int i=0;i<adj[x].size();i++){
      |                       ^~~
a.cc:7:28: error: 'deg' was not declared in this scope
    7 |                         if(deg[adj[x][i]]%2==0){
      |                            ^~~
a.cc:9:33: error: 'cout' was not declared in this scope
    9 |                                 cout<<x+1<<" "<<adj[x][i]+1<<"\n";
      |                                 ^~~~
a.cc:13:33: error: 'cout' was not declared in this scope
   13 |                                 cout<<adj[x][i]+1<<" "<<x+1<<"\n";
      |                                 ^~~~
a.cc:18:25: error: 'cout' was not declared in this scope
   18 |                         cout<<x+1<<" "<<adj[x][i]+1<<"\n";
      |                         ^~~~
a.cc: In function 'int main()':
a.cc:26:9: error: 'cin' was not declared in this scope
   26 |         cin>>n>>m;
      |         ^~~
a.cc:32:17: error: 'adj' was not declared in this scope
   32 |                 adj[x].push_back(y);
      |                 ^~~
a.cc:36:17: error: 'cout' was not declared in this scope
   36 |                 cout<<-1;
      |                 ^~~~
Language: C++

#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef long long ll;

const int mn = 105;
const int mod = 1e9 + 7;

const int mn = 2e5 + 5;
const int mod = 998244353;

int n, m;

struct edge {
	int u, v, directed;

	int to(int x) { return x == u ? v : u; }
} e[mn];

vector<int> g[mn];
vector<int> span_tree;

int f[mn];
int out[mn];

int sf(int x) { return f[x] == x ? x : f[x] = sf(f[x]); }

void dfs(int x, int fa) {
	for (auto &i:g[x]) {
		if (fa != e[i].to(x)) {
			dfs(e[i].to(x), x);
		}
	}
	for (auto &i:g[x]) {
		if (!e[i].directed) {
			if (out[x] % 2 == 0) {
				if (e[i].v == x) e[i].directed = 1, out[e[i].u]++;
				else e[i].directed = -1, out[e[i].v]++;
			} else {
				if (e[i].u == x) e[i].directed = 1, out[e[i].u]++;
				else e[i].directed = -1, out[e[i].v]++;
			}
		}
	}

}

int main() {
#ifdef LOCAL
	freopen("../1.txt", "r", stdin);
	freopen("../2.txt", "w", stdout);
	size_t bg = clock();
#endif
	scanf("%d%d", &n, &m);
	if (m & 1) {
		puts("-1");
		return 0;
	}
	for (int i = 1; i <= m; i++) {
		scanf("%d%d", &e[i].u, &e[i].v);
	}
	for (int i = 1; i <= n; i++) {
		f[i] = i;
	}

	for (int i = 1; i <= m; i++) {
		if (sf(e[i].u) != sf(e[i].v)) {
			span_tree.pb(i);
			f[sf(e[i].u)] = sf(e[i].v);
		} else {
			e[i].directed = 1;
			out[e[i].u]++;
		}
	}
	for (auto &i:span_tree) {
		g[e[i].u].pb(i);
		g[e[i].v].pb(i);
	}
	//for (int i = 1; i <= n; i++) printf("!%d %d\n", i, out[i]);
	for (int i = 1; i <= n; i++) {
		if (sz(g[i]) > 1) {
			dfs(i, 0);
			break;
		}
	}
	for (int i = 1; i <= m; i++) {
		if (e[i].directed == 1) printf("%d %d\n", e[i].u, e[i].v);
		else printf("%d %d\n", e[i].v, e[i].u);
	}

#ifdef LOCAL
	size_t ed = clock();
	printf("time: %f\n", (double) (ed - bg) / CLOCKS_PER_SEC);
#endif
	return 0;
}

Compiler output:
a.cc:15:11: error: redefinition of 'const int mn'
   15 | const int mn = 2e5 + 5;
      |           ^~
a.cc:12:11: note: 'const int mn' previously defined here
   12 | const int mn = 105;
      |           ^~
a.cc:16:11: error: redefinition of 'const int mod'
   16 | const int mod = 998244353;
      |           ^~~
a.cc:13:11: note: 'const int mod' previously defined here
   13 | const int mod = 1e9 + 7;
      |           ^~~
Language: C++

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

public class Main {
    static Scanner scanner = new Scanner();

    static List<List<Integer>> edge = new ArrayList<>();
    static boolean[] visited;
    public static void main(String[]$) throws Exception {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        visited = new boolean[n];
        for (int i = 0; i < n; i++) {
            edge.add(new ArrayList<>());
        }
        for (int i = 0; i < m; i++) {
            int a = scanner.nextInt() - 1;
            int b = scanner.nextInt() - 1;
            edge.get(a).add(b);
            edge.get(b).add(a);
        }
        if (m % 2 == 1) {
            System.out.println(-1);
        } else {
            dfs(-1, 0);
        }
    }

    static boolean dfs(int parent, int node) {
        visited[node] = true;
        int use = 0;
        for (int i : edge.get(node)) {
            if (i != parent && (visited[i] || dfs(node, i))) {
                edge.get(i).remove(Integer.valueOf(node));
                System.out.printf("%d %d\n", node + 1, i + 1);
                use++;
            }
        }
        if (use % 2 == 1 && parent != -1) {
            System.out.printf("%d %d\n", node + 1, parent + 1);
        }
        return use % 2 == 0;
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer;

        String next() throws IOException {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
            return tokenizer.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
    }
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: expected unqualified-id before 'public'
    4 | public class Main {
      | ^~~~~~
Language: C++

#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);


int main() {

    int n,m;
    cin>>n>>m;


    vector<int> v[n+1];

   // int vn[n+1][n+1];
    rep(i,n+1){rep(j,n+1){vn[i][j]=0;}}
    int ty[n+1];
    rep(i,n+1){ty[i]=0;}

    rep(i,m){
        int a,b;
        cin>>a>>b;
        v[a].emplace_back(b);
        v[b].emplace_back(a);
       // vn[a][b]=1;
      //  vn[b][a]=1;
        ty[a]++;ty[b]++;
    }


    vector<pair<int,int>> ans;


//    while(true){
//        bool update=false;
//        for(int i=0;i<n;i++){
//            int k=i+1;//kは頂点(-1)スタート変
//            if(ty[k]%2==0&&ty[k]>0){//頂点の数が偶数かつ0出ない
//                ty[k]=0;
//                for (int j = 0; j < v[k].size(); j++) {
//                    int kt=v[k][j];//頂点kから繋がっている頂点
//                    if( vn[k][kt]==1||vn[kt][k]==1) {//まだkから変が通っているか
//                        ans.push_back({k,kt});//通っているなら矢印
//                        ty[kt]--;
//                        vn[k][kt]=0;vn[kt][k]=0;//頂点通らなくする
//                        update=true;
//                    }
//                }
//            }
//        }
//
//        if(!update)break;
//    }


if(ans.size()!=m){
    cout<<-1<<endl;
}
else {
   rep(i,ans.size()){
       cout<<ans[i].first<<" "<<ans[i].second<<endl;
   }
}



    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:27: error: 'vn' was not declared in this scope; did you mean 'v'?
   37 |     rep(i,n+1){rep(j,n+1){vn[i][j]=0;}}
      |                           ^~
      |                           v
Language: C++

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


int main(){
   
    long int n,m,i,u,v;
    cin>>n>>m;
    
    vector<long int>deg(n+1,0);
    vector<long int>edges[n+1];
    set<pair<int,int>>hash;
                        
    for(i=0;i<m;i++){ cin>>u>>v;deg[u]++;deg[v]++;edges[u].push_back(v);edges[v].push_back(u);}
                        
    if(m&1){
        cout<<"-1";
        return 0;
    }
    
    
    vector<pair<int,int>>ans;
    queue<int>q;
   for(int i=1;i<=n;i++){
      if(deg[i]%2==0) q.push(i);
   }
    
    
    while(!q.empty()){
       i = q.front();q.pop();
       if(deg[i]>0 && deg[i]%2==0){
           for(auto v:edges[i]){
                                   if(hash.find({i,v})==hash.end()){
                                   ans.push_back({i,v});
                                   hash.insert({i,v});
                                   hash.insert({v,i}); 
                                   deg[v]--;m--; if(deg[v]>0 && deg[v]%2==0)
                                    q.push(v);
               }
       }  
    }
    
    if(m==0){
     for(auto &p:ans) cout<<p.first<<" "<<p.second<<endl;   
    }
    else cout<<"-1";
   
                            
                            
    
    
 return 0;   
}

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

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

static const int MAX = 100005;
static const int WHITE = 0; // 未到達
static const int GRAY = 1; // 到達
static const int BLACK = 2; // 探索済み

int N, M;

int color[MAX];

vector<pair<int, int>> ans;

int solve (int s) {
  int ret;
  queue<int> que;
  for (int i = 0; i < MAX; i++) {
    color[i] = WHITE;
  }

  que.push(s);

  while (!que.empty()) {
    int u = que.front();
    que.pop();
    color[u] = BLACK;
    int adjNum = 0;
    for (int j = 0; j < adj[u].size(); j++) {
      int v = adj[u][j];
      if (color[v] == WHITE) adjNum++;
    }
    int base;
    if (adjNum % 2 == 0) {
      base = adjNum;
    } else base = adjNum - 1;
    for (int j = 0; j < adj[u].size(); j++) {
      int v = adj[u][j];
      if (color[v] == BLACK) continue;
      if (base > 0) {
        que.push(v);
        ans.pb(make_pair(u, v));
        base--;
        ret++;
      }
    }
  }
  return ret;
};

vector<int> adj[MAX];

int main() {
  cin >> N >> M;
  int A, B;
  int s;
  rep(i, 0, M) {
    cin >> A >> B;
    adj[A].pb(B);
    adj[B].pb(A);
    s = A;
  }
  int tmp = solve(s);

  if (tmp != M) {
    cout << -1 << endl;
  } else {
    rep(i, 0, ans.size()) {
      cout << ans[i].first << " " << ans[i].second << endl;
    }
  }
};


Compiler output:
a.cc: In function 'int solve(int)':
a.cc:38:25: error: 'adj' was not declared in this scope
   38 |     for (int j = 0; j < adj[u].size(); j++) {
      |                         ^~~
a.cc:46:25: error: 'adj' was not declared in this scope
   46 |     for (int j = 0; j < adj[u].size(); j++) {
      |                         ^~~
Language: C++

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

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	vector<pair<int, int> > edge(M);
	vector<int> now(N, 0);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		edge[i].first = a;
		edge[i].second = b;
		now[a]++; now[b]++;
	}
	if (M % 2 == 1) { cout << "-1" << endl; }
	else {
		for (int i = 0; i < M; i++) {
			if (now[edge[i].first] % 2 != now[edge[i].second] % 2) {
				if (now[edge[i].first] % 2 == 1) {
					now[edge[i].first]--;
					cout << edge[i].second << " " << edge[i].first << endl;
				}
				else {
					now[edge[i].second]--;
					cout << edge[i].first << " " << edge[i].second << endl;
				}
			}
			else {
				if (now[edge[i].first] > now[edge[i].second]) {
					now[edge[i].first]--;
					cout << edge[i].second << " " << edge[i].first << endl;
				}
				else {
					now[edge[i].second]--;
					cout << edge[i].first << " " << edge[i].second << endl;
				}
			}
		}
	}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:10: error: expected '}' at end of input
   46 |         }
      |          ^
a.cc:9:12: note: to match this '{'
    9 | int main() {
      |            ^
Language: C++

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

int main (){
	int n,m,i,a[100005],b[100005],d[100005]={0},s[100005];
	vector<int> v[100005];
	cin >> n >> m;
	for(i=1;i<=m;i++){
		cin >> a[i] >> b[i];
		v[a[i]].push_back(b[i]);
		v[b[i]].push_back(a[i]);
	}
	if(m%2==1){
		cout << "-1" << endl;
		return 0;
	}
	for(i=1;i<=n;i++) s[i]=v[i].size()
	for(i=1;i<=m;i++){
		if(d[a[i]]==1&&s[a[i]]==1){
			cout << a[i] << " " << b[i] << endl;
			s[b[i]]--;
		} else if(d[b[i]]==1&&s[b[i]]==1){
			cout << b[i] << " " << a[i] << endl;
			s[a[i]]--;
		} else {
			cout << a[i] << " " << b[i] << endl;
			s[a[i]]--;
			s[b[i]]--;
			d[a[i]]=(d[a[i]]+1)%2;
			d[b[i]]=(d[b[i]]+1)%2;
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:43: error: expected ';' before 'for'
   17 |         for(i=1;i<=n;i++) s[i]=v[i].size()
      |                                           ^
      |                                           ;
   18 |         for(i=1;i<=m;i++){
      |         ~~~                                
a.cc:18:25: error: expected ';' before ')' token
   18 |         for(i=1;i<=m;i++){
      |                         ^
      |                         ;
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  int n,m;
  cin>>n>>m;
  if(m%2==1){
    cout<<-1<<endl;
    return 0;
  }
  int a[m],b[m];
  vector<int> G[n];
  bool used[m]={};
  int d[n]={};
  bool odd[n]={};
  
  REP(i,m){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
    odd[a[i]]=!odd[a[i]];
  }
  
  int cnt=0;
  REP(i,n){
    if(odd[i]){
      cnt++;
    }
  }
  if(cnt%2==1){
    cout<<-1<<endl;
  }else{
    
        
  
  return 0;
}

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

#include <bits/stdc++.h>
#include <map.h>
#define rep(i, n) for (int i=0; i < n; i ++)
#define rep1(i, n) for (int i=1; i <= n; i ++)
using namespace std;

typedef pair<int, int> P;

int main() {
  int N, M;
  map<int, vector<int> > to;
  map<P, bool> used;
  int cnt[100000];

  cin >> N >> M;
  if (M % 2 == 1) {
    cout << -1 << endl;
    return 0;
  }
  rep(i, M) {
    int c, d;
    cin >> c >> d;
    to[c].push_back(d);
    to[d].push_back(c);
  }
  for(const auto& [key, value]: to) {
    int size = value.size() - cnt[key];
    for (int i = 0; i < size - (size % 2); i ++) {
      int l, r;
      if (value[i] > key) {
        l = key;
        r = value[i];
      } else {
        r = key;
        l = value[i];
      }
      cnt[value[i]] += 1;
      P p = P(r, l);
      if (used[p]) continue;
      cout << key << " " << value[i] << endl;
      used[p] = true;
    }
  }

  return 0;
}


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

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

int main (){
	int n,m,i,a[100005],b[100005],d[100005]={0},s[100005];
	vector v[100005];
	cin >> n >> m;
	for(i=1;i<=m;i++){
		cin >> a[i] >> b[i];
		v[a[i]].push_back(b[i]);
		v[b[i]].push_back(a[i]);
	}
	if(m%2==1){
		cout << "-1" << endl;
		return 0;
	}
	for(i=1;i<=n;i++) s[i]=v[i].size()
	for(i=1;i<=m;i++){
		if(d[a[i]]==1&&s[a[i]]==1){
			cout << a[i] << " " << b[i] << endl;
			s[b[i]]--;
		} else if(d[b[i]]==1&&s[b[i]]==1){
			cout << b[i] << " " << a[i] << endl;
			s[a[i]]--;
		} else {
			cout << a[i] << " " << b[i] << endl;
			s[a[i]]--;
			s[b[i]]--;
			d[a[i]]=(d[a[i]]+1)%2;
			d[b[i]]=(d[b[i]]+1)%2;
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:9: error: missing template argument list after 'std::vector'; for deduction, template placeholder must be followed by a simple declarator-id
    6 |         vector v[100005];
      |         ^~~~~~
      |               <>
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:428:11: note: 'template<class _Tp, class _Alloc> class std::vector' declared here
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
a.cc:10:17: error: 'v' was not declared in this scope
   10 |                 v[a[i]].push_back(b[i]);
      |                 ^
a.cc:17:32: error: 'v' was not declared in this scope
   17 |         for(i=1;i<=n;i++) s[i]=v[i].size()
      |                                ^
a.cc:18:25: error: expected ';' before ')' token
   18 |         for(i=1;i<=m;i++){
      |                         ^
      |                         ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
#define ld long double
int inf=100000000;
ll INF=4000000000000000000;
ll MOD=1000000007;



int main() {
  int n,m;
  cin >> n >> m;
  if (m%2==1) {cout << -1 << endl;return 0;}
  vector<vector<pp>> a(n+1,vector<pp>(0));
  vector<int> b(n+1,0),c(n+1,0);
  rep (i,m){
    int f,g;
    cin >> f >> g;
    a.at(f).push_back(make_pair(g,0));
    a.at(g).push_back(make_pair(f,0));
    b.at(f)++;
    b.at(g)++;
    c.at(f)++;
    c.at(g)++;
  }
  vector<pp> o(0);
  queue<int> q;
  rep(i,n+1){
    if (b.at(i)==1) q.push(i);
  }
  int y=0;
  while (true){
    while (!q.empty()){
      int u=q.front();
      q.pop();
      rep(i,a.at(u).size()){
        if (a.at(u).at(i).second==0){
          a.at(u).at(i).second=1;
          rep(j,a.at(a.at(u).at(i).first).size()){
            if (a.at(a.at(u).at(i).first).at(j).first==u) a.at(a.at(u).at(i).first).at(j).second=1;
          }
          b.at(a.at(u).at(i).first)--;
          if (b.at(a.at(u).at(i).first)==1) q.push(a.at(u).at(i).first);
          if (c.at(u)%2==0) {
            o.push_back(make_pair(u,a.at(u).at(i).first));
            //cout << u << " " << a.at(u).at(i).first << endl;
            y++;
            c.at(a.at(u).at(i).first)--;
          }
          else {
            o.push_back(make_pair(a.at(u).at(i).first,u));
            //cout << a.at(u).at(i).first << " " << u << endl;
            c.at(u)--;
            y++;
          }
          break;
        }
      }
    }
    rep(u,n+1){
      if (b.at(u)>=2) {
        if (b.at(u)==2) q.push(u);
        b.at(u)--;
        rep(i,a.at(u).size()){
        if (a.at(u).at(i).second==0){
          a.at(u).at(i).second=1;
          rep(j,a.at(a.at(u).at(i).first).size()){
            if (a.at(a.at(u).at(i).first).at(j).first==u) a.at(a.at(u).at(i).first).at(j).second=1;
          }
          b.at(a.at(u).at(i).first)--;
          if (b.at(a.at(u).at(i).first)==1) q.push(a.at(u).at(i).first);
          if (c.at(u)%2==0) {
            o.push_back(make_pair(u,a.at(u).at(i).first));
            //cout << u << " " << a.at(u).at(i).first << endl;
            c.at(a.at(u).at(i).first)--;
            y++;
          }
          else {
            o.push_back(make_pair(a.at(u).at(i).first,u));
            //cout << a.at(u).at(i).first << " " << u << endl;
            c.at(u)--;
            y++;
          }
          break;
        }
      }
      break;
        }
      }
      if (y==m) break;
    }
    for (int i=1;i<n+1){
      if (c.at(i)%2==1) {cout << -1 << endl;return 0;}
    }
    rep(i,o.size()){
      cout << o.at(i).first << " " << o.at(i).second << endl;
    }
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:95:23: error: expected ';' before ')' token
   95 |     for (int i=1;i<n+1){
      |                       ^
      |                       ;
Language: C++

#include <iostream>
#include <vector>
using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  if (M%2){
      cout << -1 << endl;
      return 0;
  }
  int q[N], a[N], b[N], last=0;
  for(int i=0; i<N; i++) q[i] = 0;
  for(int i=0; i<M; i++){
      cin >> a[i] >> b[i];
      q[a[i]]++; q[b[i]]++;
  }
  for(int i=0; i<10){
    for(int i=0; i<N; i++){
      if (q[a[i]]%2){
        int t=a[i];
        a[i]=b[i];
        b[i]=a[i];
        q[a[i]]--; q[b[i]]++;
      }
    }
  }
  
  for(int i=0; i<N; i++){
    cout << a[i] << " " << b[i] << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:20: error: expected ';' before ')' token
   18 |   for(int i=0; i<10){
      |                    ^
      |                    ;
Language: C++

#include <iostream>
#include <cstring>
using namespace std;
int count(int graph[][], int N){
    int count = 0;
    for(int i = 0;i < N; i++){
        for(int j = 0; j < N; j++){
            if(graph[i][j] == 1) count++;
        }
        if((count % 2) != 0 ) return -1;
    }
    return 0;
}
int main(){
    int N,M;
    cin >> N >> M;
    int graph[N][N];
    memset(graph, 0, sizeof(graph));
    for(int i = 0; i < N; i++){
        int x, y;
        cin >> x >> y;
        graph[x][y] = 1;
        graph[y][x] = -1;
    }
    int t = 1, ans;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(graph[i][j] == t){
                graph[i][j] = 1;
                graph[j][i] = -1;
                int tmp;
                tmp = i;
                i = j;
                j = tmp;
                t *= -1; 
            }
            ans = count(graph,N);
            if(ans == 0){
                for(int k = 0; k < N; k++){
                    for(int l = 0; l < N; l++){
                        if(graph[k][l] == 1){
                            cout << k << " " << l << endl;
                        }
                    }
                }
                return 0;
            }
        }

    }
}

Compiler output:
a.cc:4:15: error: declaration of 'graph' as multidimensional array must have bounds for all dimensions except the first
    4 | int count(int graph[][], int N){
      |               ^~~~~
a.cc:4:24: error: expected ')' before ',' token
    4 | int count(int graph[][], int N){
      |          ~             ^
      |                        )
a.cc:4:26: error: expected unqualified-id before 'int'
    4 | int count(int graph[][], int N){
      |                          ^~~
Language: C++

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

using namespace std;
using PII = pair<int, int>;

vector<set<int>> graph;
vector<PII> ans;

int main() {
	int n, m, x, y;
	cin >> n >> m;

	graph.assign(n, {});

	for (int i = 0; i < m; i++) {
		cin >> x >> y;
		x--;
		y--;

		graph[x].insert(y);
		graph[y].insert(x);
	}

	if (m % 2 == 1) {
		cout << -1 << endl;
		return 0;
	}

	priority_queue<PII, vector<PII>, greater<PII>> que;
	for (int i = 0; i < n; i++) {
		que.push(make_pair(graph[i].size(), i));
	}

	vector<int> n_out(n, 0);

	while (!que.empty() && ans.size() < m) {
		auto p = que.top();
		que.pop();
		int node = p.second;

		// printf("p: node %d, first %d, size %lu\n", node, x, graph[x].size());
		if (graph[node].emtpy()) {
			continue;
		}

		if (graph[node].size() == 1) {
			int from = node;
			int to = *graph[from].begin();
			// printf("x1: from %d, to %d\n", from, to);

			if (n_out[from] % 2 == 0) {
				ans.emplace_back(make_pair(to, from));
				n_out[to]++;
			} else {
				ans.emplace_back(make_pair(from, to));
				n_out[from]++;
			}

			graph[from].erase(to);
			graph[to].erase(from);

			que.push(make_pair(graph[from].size(), from));
			que.push(make_pair(graph[to].size(), to));
		} else {
			int from = node;
			int to1 = *graph[from].begin();
			int to2 = *graph[from].rbegin();
			// printf("x2: from %d, to %d %d: size %lu %lu %lu\n", from, to1, to2, graph[from].size(), graph[to1].size(), graph[to2].size());
			ans.emplace_back(make_pair(from, to1));
			ans.emplace_back(make_pair(from, to2));
			n_out[from] += 2;

			graph[from].erase(to1);
			graph[from].erase(to2);
			graph[to1].erase(from);
			graph[to2].erase(from);

			que.push(make_pair(graph[from].size(), from));
			que.push(make_pair(graph[to1].size(), to1));
			que.push(make_pair(graph[to2].size(), to2));
			// printf("x3: from %d, to %d %d: size %lu %lu %lu\n", from, to1, to2, graph[from].size(), graph[to1].size(), graph[to2].size());
		}
	}

	for (auto p: ans) {
		cout << p.first+1 << " " << p.second+1 << endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:33: error: '__gnu_cxx::__alloc_traits<std::allocator<std::set<int> >, std::set<int> >::value_type' {aka 'class std::set<int>'} has no member named 'emtpy'; did you mean 'empty'?
   49 |                 if (graph[node].emtpy()) {
      |                                 ^~~~~
      |                                 empty
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define BUF 1e5
#define INF 1 << 30
constexpr ll mod = 1e9 + 7;
using namespace std;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

int main() {
    cin >> N >> M;
    if (M % 2 != 0) {
        cout << -1 << endl;
        return 0;
    }
    vector<vector<int>> g(N);
    vector<int> deg(N, 0);
    vector<int> flag(N, 0);
    map<pair<int, int>, int> edge;
    for (int i = 0; i < M; i++) {
        int u, v;
        u--, v--;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
        deg[u]++;
        deg[v]++;
    }
    queue<int> q;
    for (int i = 0; i < N; i++) {
        if (deg[i] == 1) {
            q.push(i);
        }
    }
    vector<int> out(N, 0);
    while (!q.empty) {
        int now = q.front();
        q.pop();
        if (deg[now] == 0) {
            flag[now] = 1;
            continue;
        }
        int adj = g[now][0];
        cout << adj + 1 << now + 1 << endl;
        out[adj] = (out[adj] + 1) % 2;
        deg[adj]--;
        if (deg[adj] == 1)
            q.push(adj);
    }

    for (int i = 0; i < N; i++) {
        if (deg[i] == 0)
            continue;
        int n;
        if (out[i] == 0) {
            n = deg[i] / 2 * 2;
        } else {
            if (deg[i] % 2 == 0) {
                n = deg[i] - 1;
            } else {
                n = deg[i];
            }
        }
        int count = 0;
        for (int j = 0; j < g[i].size(); j++) {
            int adj = g[i][j];
            if (deg[adj] == 0)
                continue;
            count++;
            if (count <= n) {
                cout << i + 1 << adj + 1 << endl;
            } else {
                cout << adj + 1 << i + 1 << endl;
                out[adj] = (out[adj] + 1) % 2;
            }
            deg[adj]--;
        }
        deg[i] = 0;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:15: error: cannot convert 'std::queue<int>::empty' from type 'bool (std::queue<int>::)() const' to type 'bool'
   37 |     while (!q.empty) {
      |               ^~~~~
a.cc:37:15: error: in argument to unary !
   37 |     while (!q.empty) {
      |             ~~^~~~~
Language: C++

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

map<long, int> mark;
vector<int> adj[100000 + 5];
int color[100000 + 5];
int vcount[100000 + 5];
vector<pair<int, int>> result;

long getKey(int A, int B) {
  if (A < B) {
    return A * 100005 + B;
  } else {
    return B * 100005 + A;
  }
}

void addToResult(int u, int v) {
  vcount[u] -= 1;
  vcount[v] -= 1;
  mark[getKey(u, v)] = 0;
  result.emplace_back(u, v);
}

void solve(int u) {
  color[u] = 0;

  vector<int> next;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (mark[getKey(u, v)]) {
      addToResult(u, v);
      next.push_back(v);
    }
  }

  for (int i = 0; i < next.size(); i++) {
    if (color[next[i]] && vcount[i] >= 2 && vcount[i] % 2 == 0) {
      solve(next[i]);
    }
  }
}

int main() {
  int N, M;
  cin >> N >> M;

  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    adj[A].push_back(B);
    adj[B].push_back(A);

    mark[getKey(A, B)] = 1;
  }

  if (M % 2 != 0) {
    cout << -1 << endl;
    return 0;
  }

  for (int i = 1; i <= N; i++) {
    color[i] = 1;
    vcount[i] = adj[i].size();
  }

  for (int i = 1; i <= N; i++) {
    if (vcount[i] == 0) {
      color[i] = 0;
    } else if (color[i] && vcount[i] >= 2 && vcount[i] % 2 == 0) {
      solve(i);
    }
  }

  bool flag = true;
  for (int i = 1; i <= N; i++) {
    if (count[i] != 0) {
      flag = false;
      break;
    }
  }

  if (flag) {
    for (int i = 0; i < M; i++) {
      cout << result[i].first << " " << result[i].second << endl;
    }
  } else {
    cout << -1 << endl;
  }

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:86:14: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   86 |     if (count[i] != 0) {
      |              ^