Easy python solution (priority queue)
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:\n    def getNumberOfBacklogOrders(self, orders: List[List[int]]) -> int:\n        sell_backlog = []\n        buy_backlog = []\n        import heapq\n\n        for price, amount, order_type in orders:\n            if order_type == 0:\n                while amount > 0 and (len(sell_backlog) > 0 and price >= sell_backlog[0][0]):\n                    if sell_backlog[0][1] > amount:\n                        sell_backlog[0][1] -= amount\n                        amount = 0\n                    else:\n                        amount -= sell_backlog[0][1]\n                        heapq.heappop(sell_backlog)\n                if amount > 0:\n                    heapq.heappush(buy_backlog, [-price, amount])\n            else:\n                while amount > 0 and (len(buy_backlog) > 0 and price <= -buy_backlog[0][0]):\n                    if buy_backlog[0][1] > amount:\n                        buy_backlog[0][1] -= amount\n                        amount = 0\n                    else:\n                        amount -= buy_backlog[0][1]\n                        heapq.heappop(buy_backlog)\n                \n                if amount > 0:\n                    heapq.heappush(sell_backlog, [price, amount])\n        \n        res = sum(x[1] for x in buy_backlog) + sum(x[1] for x in sell_backlog)\n        return res % (10 ** 9 + 7)\n\n\n        \n```
['Python3']