Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
// http://drken1215.hatenablog.com/entry/2019/05/19/230600

void solve(int M, int K) {
    if(M == 0) {
        if(K ! = 0)
            cout << -1 << endl;
        else
            cout << " 0 0" << endl;
        return;
    } else if(M == 1) {
        if(K ! = 0)
            cout << -1 << endl;
        else
            cout << "0 0 1 1" << endl;
    }
    if(K >= (1 << M)) {
        cout << -1 << endl;
    }
    if(K == 0) {
        for(int bit = 0; bit < (1 << M); bit++) {
            cout << bit << " ";
        }
        for(int bit = (1 << M) - 1; bit >= 0; bit--) {
            cout << bit << " ";
        }
        cout << endl;
        return;
    }
    using pint = pair<int, int>;
    vector<int> v;
    for(int bit = 0; bit < (1 << M); bit++) {
        v.push_back(pint(min(bit, bit ^ K), max(bit, bit ^ K))); // bit xor
    } //小さいのと大きいののペア
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end()));//ほんとに重複有るのかなって思うけど
    for(int i = 0; i < v.size(); i += 2) {
        cout << v[i].first << " " << v[i].second << " " << v[i + 1].first << " "
             << v[i + 1].second << " " << v[i].second << " " << v[i].first
             << " " << v[i + 1].second << " " << v[i + 1].first << " ";
    }
    cout << endl;
}

int main() {
    int M, K;
    cin >> M >> K;
    solve(M, K);
}

Compiler output:
a.cc: In function 'void solve(int, int)':
a.cc:35:13: error: expected ')' before '!' token
   35 |         if(K ! = 0)
      |           ~ ^~
      |             )
a.cc:41:13: error: expected ')' before '!' token
   41 |         if(K ! = 0)
      |           ~ ^~
      |             )
a.cc:62:20: error: no matching function for call to 'std::vector<int>::push_back(pint)'
   62 |         v.push_back(pint(min(bit, bit ^ K), max(bit, bit ^ K))); // bit xor
      |         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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 = int; _Alloc = std::allocator<int>; value_type = int]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note:   no known conversion for argument 1 from 'pint' {aka 'std::pair<int, int>'} to 'const std::vector<int>::value_type&' {aka 'const int&'}
 1283 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note:   no known conversion for argument 1 from 'pint' {aka 'std::pair<int, int>'} to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
a.cc:65:49: error: expected ';' before ')' token
   65 |     v.erase(unique(v.begin(), v.end()), v.end()));//ほんとに重複有るのかなって思うけど
      |                                                 ^
      |                                                 ;
a.cc:67:22: error: request for member 'first' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   67 |         cout << v[i].first << " " << v[i].second << " " << v[i + 1].first << " "
      |                      ^~~~~
a.cc:67:43: error: request for member 'second' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   67 |         cout << v[i].first << " " << v[i].second << " " << v[i + 1].first << " "
      |                                           ^~~~~~
a.cc:67:69: error: request for member 'first' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)(i + 1)))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   67 |         cout << v[i].first << " " << v[i].second << " " << v[i + 1].first << " "
      |                                                                     ^~~~~
a.cc:68:26: error: request for member 'second' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)(i + 1)))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   68 |              << v[i + 1].second << " " << v[i].second << " " << v[i].first
      |                          ^~~~~~
a.cc:68:48: error: request for member 'second' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   68 |              << v[i + 1].second << " " << v[i].second << " " << v[i].first
      |                                                ^~~~~~
a.cc:68:70: error: request for member 'first' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   68 |              << v[i + 1].second << " " << v[i].second << " " << v[i].first
      |                                                                      ^~~~~
a.cc:69:33: error: request for member 'second' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)(i + 1)))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   69 |              << " " << v[i + 1].second << " " << v[i + 1].first << " ";
      |                                 ^~~~~~
a.cc:69:59: error: request for member 'first' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)(i + 1)))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   69 |              << " " << v[i + 1].second << " " << v[i + 1].first << " ";
      |                                                           ^~~~~