m with a pair (INT_MIN, 0) to track the adjusted value and the maximum sum of a balanced subsequence ending with that value.nums.nums[i], calculate the adjusted value nums[i] - i.m that is not greater than nums[i] - i using upper_bound.nums[i] plus the second value of the found pair in the map (if any).(nums[i] - i, sum) in the map m.nums[i] - i and a sum smaller than sum.m as the maximum sum of a balanced subsequence.