Language: C++

#include <bits/stdc++.h>

using namespace std;

#define ll             long long int
#define pii            pair <int, int>

static const int maxn = 2e5 + 5;

set <int> graph[maxn];
int deg[maxn];
bool bad[maxn];

signed main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(nullptr);
      cout.tie(nullptr);



      int tnode, tedge;
      cin >> tnode >> tedge;
      for (int e = 1; e <= tedge; e++)
      {
            int u, v;
            cin >> u >> v;
            graph[u].emplace(v);
            graph[v].emplace(u);
            ++deg[u];
            ++deg[v];
      }
      set <int> odd, even;
      for (int i = 1; i <= tnode; i++)
      {
            if (deg[i] & 1) odd.emplace(i);
            else even.emplace(i);
      }
      vector <pii> edges;
      if (even.empty())
      {
            int from = *odd.begin(); odd.erase(odd.begin());
            //if (bad[from] == 1) continue;
            vector <int> add;
            for (int to : graph[from])
            {
                  add.emplace_back(to);
            }
            assert(add.size() % 2 == 1);
            graph[from].clear();
            graph[from].emplace(add.back());
            add.pop_back();
            deg[from] = 1;
            for (int to : add)
            {
                  graph[to].erase(graph[to].find(from));
                  --deg[to];
                  edges.emplace_back(from, to);
//                  cerr << "ans " << from << " " << to << endl;
                  if (deg[to] % 2 == 0)
                  {
                        odd.erase(to);
                        even.insert(to);
                  }
                  else
                  {
                        even.erase(to);
                        odd.insert(to);
                  }
            }
      }
      while (1)
      {
            //cerr << even.size() << " --- " << odd.size() << endl;
            if (even.empty()) break;
            int from = *even.begin(); even.erase(even.begin());
//            cerr << "from " << from << endl;
            for (int to : graph[from])
            {
                  graph[to].erase(graph[to].find(from));
                  --deg[to];
                  edges.emplace_back(from, to);
//                  cerr << "ans " << from << " " << to << endl;
                  if (deg[to] % 2 == 0)
                  {
                        odd.erase(to);
                        even.insert(to);
                  }
                  else
                  {
                        even.erase(to);
                        odd.insert(to);
                  }
            }
            graph[from].clear();
      }
      if (odd.empty() == false)
      {
            cout << "-1" << endl;
            return 0;
      }
      assert(edges.size() == m);
      for (auto it : edges) cout << it.first << " " << it.second << endl;
}


Compiler output:
In file included from /usr/include/c++/14/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:106,
                 from a.cc:1:
a.cc: In function 'int main()':
a.cc:102:30: error: 'm' was not declared in this scope; did you mean 'tm'?
  102 |       assert(edges.size() == m);
      |                              ^