Language: C++

#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

template<typename T>
struct Matrix{
    // Arguments
    int H, W;
    T E;
    vector<vector<T>> A;

    // Functions
    Matrix(int h=1, int w=1, T e=0){
        if(h < 1 || w < 1) exit(1);
        H = h; W = w; E = e;
        A.resize(H);
        for(int i=0; i<H; i++){
            A[i].resize(W);
            for(int j=0; j<W; j++){
                A[i][j] = E;
            }
        }
    }
    Matrix(const Matrix<T>& x){
        H = x.H;
        W = x.W;
        E = x.E;
        A.resize(H);
        for(int i=0; i<H; i++){
            A[i].resize(W);
            for(int j=0; j<W; j++){
                A[i][j] = x.A[i][j];
            }
        }
    }
    void resize(int h=1, int w=1, T e=0){
        if(h < 1 || w < 1) exit(1);
        H = h; W = w; E = e;
        A.resize(H);
        for(int i=0; i<H; i++){
            A[i].resize(W);
            for(int j=0; j<W; j++){
                A[i][j] = E;
            }
        }
    }

    // Operators with Matrix
    vector<T>& operator[](int i){ return A[i]; }
    Matrix<T> operator=(const Matrix<T>& x){
        H = x.H;
        W = x.W;
        E = x.E;
        A.resize(H);
        for(int i=0; i<H; i++){
            A[i].resize(W);
            for(int j=0; j<W; j++){
                A[i][j] = x.A[i][j];
            }
        }
        return *this;
    }
    Matrix<T> operator+(const Matrix<T>& x){
        assert(H == x.H && W == x.W && E == x.E);
        Matrix<T> tmp(H, W, E);
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                tmp.A[i][j] = A[i][j] + x.A[i][j];
            }
        }
        return tmp;
    }
    Matrix<T> operator-(const Matrix<T>& x){
        return (*this)+(-1)*x;
    }
    Matrix<T> operator*(const Matrix<T>& x){
        assert(W == x.H && E == x.E);
        Matrix<T> tmp(H, x.W, 0);
        for(int i=0; i<H; i++){
            for(int j=0; j<x.W; j++){
                for(int k=0; k<W; k++){
                    tmp.A[i][j] += A[i][k] * x.A[k][j];
                }
            }
        }
        return tmp;
    }

    // Operators with Integers
    friend Matrix<T> operator*(const Matrix<T>& a, T b){
        Matrix<T> tmp(a.H, a.W, a.E);
        for(int i=0; i<a.H; i++){
            for(int j=0; j<a.W; j++){
                tmp[i][j] = b * a.A[i][j];
            }
        }
        return tmp;
    }
    friend Matrix<T> operator*(T b, const Matrix<T>& a){
        Matrix<T> tmp(a.H, a.W, a.E);
        for(int i=0; i<a.H; i++){
            for(int j=0; j<a.W; j++){
                tmp[i][j] = b * a.A[i][j];
            }
        }
        return tmp;
    }
};

void form(Matrix<int>& mat){
    int k = 0;
    rep(i, mat.W){
        for(int j=k; j<mat.H; j++){
            if(mat[j][i] == 1){
                swap(mat[j], mat[k]);
                break;
            }
        }
        if(mat[k][i] == 1){
            for(int j=k+1; j<mat.H; j++){
                if(mat[j][i] == 1){
                    rep(l, mat.W){
                        mat[j][l] ^= mat[k][l];
                    }
                }
            }
            k++;
        }
    }
}

int N, K;
pair<ll, int> num[100000];

ll solve(int k, int d){
    Matrix<int> mat(d, N+1);
    rep(i, N){
        for(int j=29; j>=30-d; j--){
            mat[29-j][i] = (num[i].second>>j)&1;
        }
    }
    for(int j=29; j>=30-d; j--){
        mat[29-j][N] = (k>>j)&1;
    }
    /*cout << "Start\n";
    rep(j, d){
        rep(i, N+1){
            cout << mat[j][i] << " ";
        }
        cout << endl;
    }
    cout << endl;*/
    form(mat);
    /*rep(j, d){
        rep(i, N+1){
            cout << mat[j][i] << " ";
        }
        cout << endl;
    }
    cout << endl;
    for(int j=d-1; j>=0; j--){
        if(mat[j][N-1] < mat[j][N]) return 0;
        if(mat[j][N-1] == 1) break;
    }*/

    int j = 0;
    ll ret = 0;
    rep(i, N){
        if(j < d && mat[j][i] == 1){
            if(mat[j][N] == 1) ret += num[i].first;
            j++;
        }
        else{
            ret += num[i].first;
        }
    }
    return ret;
}

signed main(){
    cin >> N >> K;
    rep(i, N) cin >> num[i].second >> num[i].first;
    sort(num, num+N);

    ll ans = solve(K, 30);
    for(int i=29; i>=0; i--){
        if((K>>i)&1){
            ans = max(ans, solve(K-(1<<i), 30-i));
        }
    }
    cout << ans << endl;
}


godokugodokugodoku

Compiler output:
a.cc:208:1: error: 'godokugodokugodoku' does not name a type
  208 | godokugodokugodoku
      | ^~~~~~~~~~~~~~~~~~