java || O(1) space || Optimised Simple Code || Segment Tree (TLE)
Time Complexity :- O(nqueries)\nSpace Complexity :- O(1)\n\nJava Code (Segment Tree)\n\nclass Solution {\n    private static final int MOD = 1000000007;\n\n    
Time Complexity :- O(n*queries)\nSpace Complexity :- O(1)\n\n**Java Code** (Segment Tree)\n```\nclass Solution {\n    private static final int MOD = 1000000007;\n\n    class SegmentTree {\n        private int[] tree;\n        private int[] arr;\n        private int n;\n\n        public SegmentTree(int[] nums) {\n            this.n = nums.length;\n            this.tree = new int[4 * n];\n            this.arr = nums;\n            build(0, 0, n - 1);\n        }\n\n        private void build(int node, int start, int end) {\n            if (start == end) {\n                tree[node] = Math.max(0, arr[start]);\n            } else {\n                int mid = (start + end) / 2;\n                build(2 * node + 1, start, mid);\n                build(2 * node + 2, mid + 1, end);\n                tree[node] = Math.max(tree[2 * node + 1], tree[2 * node + 2]);\n            }\n        }\n\n        public void update(int idx, int value) {\n            update(0, 0, n - 1, idx, value);\n        }\n\n        private void update(int node, int start, int end, int idx, int value) {\n            if (start == end) {\n                arr[idx] = value;\n                tree[node] = Math.max(0, value);\n            } else {\n                int mid = (start + end) / 2;\n                if (start <= idx && idx <= mid) {\n                    update(2 * node + 1, start, mid, idx, value);\n                } else {\n                    update(2 * node + 2, mid + 1, end, idx, value);\n                }\n                tree[node] = Math.max(tree[2 * node + 1], tree[2 * node + 2]);\n            }\n        }\n\n        public int query(int l, int r) {\n            return query(0, 0, n - 1, l, r);\n        }\n\n        private int query(int node, int start, int end, int l, int r) {\n            if (r < start || end < l) {\n                return 0;\n            }\n            if (l <= start && end <= r) {\n                return tree[node];\n            }\n            int mid = (start + end) / 2;\n            int leftQuery = query(2 * node + 1, start, mid, l, r);\n            int rightQuery = query(2 * node + 2, mid + 1, end, l, r);\n            return Math.max(leftQuery, rightQuery);\n        }\n    }\n\n    public int maximumSumSubsequence(int[] nums, int[][] queries) {\n        int n = nums.length;\n        long totalSum = 0;\n\n        SegmentTree segmentTree = new SegmentTree(nums);\n\n        for (int[] query : queries) {\n            int pos = query[0];\n            int value = query[1];\n\n            segmentTree.update(pos, value);\n\n            long[] dp = new long[n];\n            dp[0] = Math.max(0, nums[0]);\n            if (n > 1) {\n                dp[1] = Math.max(dp[0], nums[1]);\n            }\n\n            for (int i = 2; i < n; i++) {\n                dp[i] = Math.max(dp[i - 1], nums[i] + dp[i - 2]);\n            }\n\n            totalSum = (totalSum + dp[n - 1]) % MOD;\n        }\n\n        return (int) totalSum;\n    }\n}\n```\n\n\n**Java Code** (Optimised SImple Code)\n```\nclass Solution {\n    private static final int MOD = 1000000007;\n\n    public int maximumSumSubsequence(int[] nums, int[][] queries) {\n        long totalSum = 0;\n\n        for (int[] query : queries) {\n            int pos = query[0];\n            int value = query[1];\n            nums[pos] = value;\n\n            // Recalculate the maximum sum of non-adjacent elements\n            totalSum = (totalSum + calculateMaxSum(nums)) % MOD;\n        }\n\n        return (int) totalSum;\n    }\n\n    private int calculateMaxSum(int[] nums) {\n        int n = nums.length;\n        if (n == 0) return 0;\n        if (n == 1) return Math.max(0, nums[0]);\n\n        long prevInclude = Math.max(0, nums[0]);\n        long prevExclude = 0;\n\n        for (int i = 1; i < n; i++) {\n            long newInclude = Math.max(prevInclude, prevExclude + nums[i]);\n            prevExclude = prevInclude;\n            prevInclude = newInclude;\n        }\n\n        return (int) (prevInclude % MOD);\n    }\n}\n```
[]