Language: C++

#include <bits/stdc++.h>

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver2 {
 public:
  int n, m;
  vector<map<int, int>> t;
  Solver2(LL n, LL m) : n(n), m(m), t(n){};

  void solve() {
    for (int i = 0; i < m; ++i) {
      int a, b;
      cin >> a >> b;
      t[--a][--b] = 0;
      t[b][a] = 0;
    }
    bool ans = true;
    int ans2 = 0;
    int cnt6 = 0;
    vector<int> v4;
    for (int i = 0; i < n; ++i) {
      if (t[i].size() % 2) ans = false;
      ans2 += max(0, (int)t[i].size() - 2);
      if (t[i].size() >= 6) cnt6++;
      if (t[i].size() == 4) v4.push_back(i);
    }
    if (ans && ans2 >= 4) {
      if (ans2 >= 6 || cnt6) {
        cout << "Yes" << endl;
      } else {
        cout << (check(v4[0], v4[1]) ? "Yes" : "No") << endl;
      }
    } else {
      cout << "No" << endl;
    }
  }
  bool check(int s, int v) {
    int now = s;
    vector<int> res;
    vector<int> target = {s, s, v, v};
    while (1) {
      if (now == s || now == v) {
        res.push_back(now);
      }
      bool found = false;
      for (auto e : t[now]) {
        if (e.second == 0) {
          t[now][e.first]= 1;
          t[e.first][now] = 1;
          now = e.first;
          found = true;
          break;
        }
      }
      if (!found) break;
    }
    res.erase(res[0]);
    for (int i = 0; i < 4; ++i) {
      rotate(res.begin(), res.begin() + 1, res.end());
      if (res == target) return true;
    }
    return false;
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0, m;
  std::cin >> n >> m;

  Problem::Solver2 sol(n, m);
  sol.solve();
  return 0;
}


Compiler output:
a.cc: In member function 'bool Problem::Solver2::check(int, int)':
a.cc:75:14: error: no matching function for call to 'std::vector<int>::erase(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   75 |     res.erase(res[0]);
      |     ~~~~~~~~~^~~~~~~~
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:1536:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]'
 1536 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1536:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'std::vector<int>::const_iterator'
 1536 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator, const_iterator) [with _Tp = int; _Alloc = std::allocator<int>; iterator = std::vector<int>::iterator; const_iterator = std::vector<int>::const_iterator]'
 1564 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:7: note:   candidate expects 2 arguments, 1 provided