Simple solution using set C++
Intuition\nAt first this question does not seem bruteforcable but it is if we use appropriate data structures.\n\n# Approach\nI used a set> fr to store all the 
# Intuition\nAt first this question does not seem bruteforcable but it is if we use appropriate data structures.\n\n# Approach\nI used a set<pair<int, int>> fr to store all the elements as well as indices at which each element occurs. Basically, I stored in the set, all pairs of `{nums[i], i}` for all `0 <= i < n` \nAfter doing this, since set will store the pairs in such a way as exactly described in the question i.e. by first element in pair and then by second. So for our purpose this was useful since our operations were such that they focused on removing elementd based first on the least value of the actual element and then least index.\nAlso I calculated the curr value which  is equal to the current sum of unmarked elements. Initially it is set to $$\\sum_{i=0}^{n} \\text{nums}[i]$$\n\nNow, for each query I did 2 things:\n1.  Mark the element identified by $$index_{i}$$\n* To do this in our representation we can just remove this element in our fr map:`{nums[queries[i][0]], queries[i][1]}` i.e. $$\\{nums[index_{i}],\\, index_{i}\\}$$\n> Removing works because following queries require only work to be done on marked elements.\n* While doing this, we also need to deal with the consequences of marking the $$nums[index_{i}]$$ element i.e. decrement curr by $$nums[index_{i}]$$\n2. Mark k smallest unmarked elements\n* Since order is already taken care of by the data structure we are using we only need to care about checking if elements are unmarked. We directly erase smallest elements from our fr map to mark them.\n* So, we keep on erasing smallest elements from our map till we fulfill removing $$k_{i}$$ number of elements or exhaust the size of the map fr. The latter condition is necessary because it may happen that $$k_{i}$$ is so big that even deleting or marking all the elements doesn\'t fulfill our conditions of deleting $$k_{i}$$ elements. It is given in the question that if no marked elements exist then we can just return `curr = 0` for that index and after that.\n# Complexity\n- Time complexity:\n$$O(m\\cdot log(n))$$\nLet\'s discuss in the comments why is the time complexity not $$O(m\\cdot n \\cdot log(n))$$\n\n- Space complexity:\n$$O(n)$$\n\n# Code\n```\nclass Solution {\npublic:\n    vector<long long> unmarkedSumArray(vector<int>& nums, vector<vector<int>>& queries) {\n        vector<vector<int>> q = queries;\n        vector<long long> ans;\n        int m = queries.size();\n        int n = nums.size();\n        set<pair<int, int>> fr;\n        for(int i = 0; i < n; i++){\n            fr.insert({nums[i], i});\n        }\n        long long curr = accumulate(nums.begin(), nums.end(), (long long) 0);\n        cout << "Start of the operations" << endl;\n        for(int j = 0; j < m; j++){\n            int indexi = q[j][0];\n            int ki = q[j][1];\n            if(fr.find({nums[indexi], indexi}) != fr.end()){\n                fr.erase({nums[indexi], indexi});\n                curr -= nums[indexi];\n            }\n            for(int k = 0; k < ki && fr.size() > 0; k++){\n                curr -= fr.begin()->first;\n                fr.erase(fr.begin());\n            }\n            cout << "ans += " << curr << endl;\n            ans.push_back(curr);\n        }\n        return ans;\n    }\n};\n```
['Ordered Set', 'C++']