cpp solution
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, vector<vector<int>>& edges) {\n        long long sum = 0;\n        bool odd = false;\n        int min_diff = INT_MAX;\n        for(int num: nums) {\n            int flip = num^k;\n            if(flip>num) {\n                odd = !odd;\n                sum += (num^k);\n                min_diff = min(min_diff, flip-num);\n            } else {\n                sum+=num;\n                min_diff = min(min_diff, num-flip);\n            }\n        }\n        if(!odd) return sum;\n        else return sum-min_diff;\n    }\n};\n```
['C++']