AB
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    long long maximumValueSum(vector<int>& nums, int k,\n                              vector<vector<int>>& e) {\n        int i, j = 0, m = INT_MAX, n = nums.size(), p = m;\n        long s = 0;\n\n        for (i = 0; i < n; i++) {\n            if ((nums[i] ^ k) > nums[i]) {\n                s += nums[i] ^ k;\n                m = min(m, (nums[i] ^ k) - nums[i]);\n\n                j++;\n            } else {\n                if ((nums[i] - (nums[i] ^ k)) < p) {\n                    p = nums[i] - (nums[i] ^ k);\n                }\n                s += nums[i];\n            }\n        }\n\n        if (j % 2 == 0)\n            return s;\n\n        return max(s - m, s - p);\n    }\n};\n```
['C++']