input: from typing import List
  
  def sum_of_unmarked_elements(nums: List[int], queries: List[List[int]]) -> List[int]:
      """
      Given a 0-indexed array nums consisting of positive integers.
  
      You are also provided with a 2D array queries where each query is represented as [index_i, k_i].
  
      Initially, consider all elements of the array as unmarked.
  
      For each query, perform the following operations in sequence:
  
      Mark the element at position index_i if it is not already marked.
      Then proceed to mark k_i unmarked elements in the array that have the smallest values. If multiple such elements are present, mark those with the smallest indices first. If fewer than k_i unmarked elements exist, mark all available ones.
  
      Return an array result where result[i] is the sum of the unmarked elements in the array after the i-th query.
  
      Examples:
      >>> nums = [1,2,2,1,2,3,1], queries = [[1,2],[3,3],[4,2]]
      [8, 3, 0]
      >>> nums = [1,4,2,3], queries = [[0,1]]
      [7]
  
      Constraints:
      n == len(nums)
      m == len(queries)
      1 <= m <= n <= 10^5
      1 <= nums[i] <= 10^5
      queries[i] has dimensions of 2
      0 <= index_i, k_i < n
      """
output:     marked = [False] * len(nums)
      result = []
  
      for index_i, k_i in queries:
          if not marked[index_i]:
              marked[index_i] = True
              
          unmarked_elements = sorted((num, idx) for idx, num in enumerate(nums) if not marked[idx])
          
          for i in range(min(k_i, len(unmarked_elements))):
              numb, idx = unmarked_elements[i]
              marked[idx] = True
              
          result.append(sum(num for idx, num in enumerate(nums) if not marked[idx]))
          
      return result