Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

int main()
{
	int N, M;
	std::vector<std::pair<int, int>> E;
	std::set<std::pair<int, int>> numedge_idx;
	std::vector<std::unordered_set<int>> neighs;
	std::vector<bool> parity;
	std::vector<std::set<std::pair<int, int>>::iterator> numedgeitr;

	std::cin >> N >> M;
	E.resize(M);
	parity.resize(N);
	neighs.resize(N);
	numedgeitr.resize(N);
	for (auto& e : E) {
		std::cin >> e.first >> e.second;
		--e.first;
		--e.second;
		neighs[e.first].insert(e.second);
		neighs[e.second].insert(e.first);
	}
	for (int i = 0; i < N; ++i) {
		numedgeitr[i] = numedge_idx.insert({neighs[i].size(), i}).first;
	}

	if (M % 2 == 1) {
		std::cout << "-1\n";
		return 0;
	}

	while (M > 0) {
		auto it = numedge_idx.begin();
		auto idx = it->second;
		for (auto neigh : neighs[idx]) {
			if (parity[idx]) {
				std::cout << (idx + 1) << " " << (neigh + 1) << "\n";
				parity[neigh] = false;
			} else {
				std::cout << (neigh + 1) << " " << (idx + 1) << "\n";
				parity[neigh] ^= true;
			}
			neighs[neigh].erase(idx);
			numedge_idx.erase(numedgeitr[neigh]);
			numedgeitr[neigh] = numedge_idx.insert({neighs[neigh].size(), neigh}).first;
		}
		numedge_idx.erase(it);
		--M;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:58:47: error: no match for 'operator^=' (operand types are 'std::vector<bool>::reference' and 'bool')
   58 |                                 parity[neigh] ^= true;
      |                                 ~~~~~~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:38,
                 from /usr/include/c++/14/string:68,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/cstddef:178:3: note: candidate: 'constexpr std::byte& std::operator^=(byte&, byte)'
  178 |   operator^=(byte& __l, byte __r) noexcept
      |   ^~~~~~~~
/usr/include/c++/14/cstddef:178:20: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::byte&'
  178 |   operator^=(byte& __l, byte __r) noexcept
      |              ~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:114:3: note: candidate: 'constexpr const std::_Ios_Fmtflags& std::operator^=(_Ios_Fmtflags&, _Ios_Fmtflags)'
  114 |   operator^=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
      |   ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:114:29: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Fmtflags&'
  114 |   operator^=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
      |              ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:164:3: note: candidate: 'constexpr const std::_Ios_Openmode& std::operator^=(_Ios_Openmode&, _Ios_Openmode)'
  164 |   operator^=(_Ios_Openmode& __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
      |   ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:164:29: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Openmode&'
  164 |   operator^=(_Ios_Openmode& __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
      |              ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:211:3: note: candidate: 'constexpr const std::_Ios_Iostate& std::operator^=(_Ios_Iostate&, _Ios_Iostate)'
  211 |   operator^=(_Ios_Iostate& __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW
      |   ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:211:28: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Iostate&'
  211 |   operator^=(_Ios_Iostate& __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW
      |              ~~~~~~~~~~~~~~^~~