C++ priority_queue solution
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)$$ -->\nO(n log n)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(n)\n\n# Code\n```\n#include <queue>\n#include <vector>\n#include <algorithm>\n\nusing std::accumulate;\nusing std::vector;\nusing std::priority_queue;\n\nclass Solution {\npublic:\n    int getNumberOfBacklogOrders(vector<vector<int>>& orders) {\n        auto MinHeapFn = [](const pair<int, int> &a, const pair<int, int> &b) {\n            return a.first > b.first;\n        };\n        priority_queue<pair<int, int>> buy; // max heap (default behavior)\n        priority_queue<pair<int, int>, vector<pair<int, int>>, decltype(MinHeapFn)> sell; // min heap\n\n        auto toBuy = [&buy, &sell](int buyPrice, int buyAmount){\n            while(buyAmount > 0 && !sell.empty() && buyPrice >= sell.top().first){\n                auto [sellPrice, sellAmount] = sell.top();\n                sell.pop();\n                int finalAmount = std::min(buyAmount, sellAmount);\n                sellAmount -= finalAmount;\n                buyAmount -= finalAmount;\n\n                if(sellAmount > 0){\n                    sell.push({sellPrice, sellAmount});\n                }\n            }\n\n            if(buyAmount > 0){\n                buy.push({buyPrice, buyAmount});\n            }\n        };\n\n        auto toSell = [&buy, &sell](int sellPrice, int sellAmount){\n            while(sellAmount > 0 && !buy.empty() && sellPrice <= buy.top().first){\n                auto[buyPrice, buyAmount] = buy.top();\n                buy.pop();\n                int finalAmount = std::min(sellAmount, buyAmount);\n                buyAmount -= finalAmount;\n                sellAmount -= finalAmount;\n\n                if(buyAmount > 0){\n                    buy.push({buyPrice, buyAmount});\n                }\n            }\n\n            if(sellAmount > 0){\n                sell.push({sellPrice, sellAmount});\n            }\n        };\n\n        for(const auto &order : orders){\n            if(order[2]){ // sell 1\n                toSell(order[0], order[1]);\n            }else{ // buy 0\n                toBuy(order[0], order[1]);\n            }\n        }\n\n        size_t res = 0;\n        auto sumFn = [&res](auto &que){\n            while(!que.empty()){\n                res += que.top().second;\n                que.pop();\n            } \n        };\n\n        sumFn(buy);\n        sumFn(sell);\n\n        return res % (int(1e9) + 7);\n    }\n};\n```
['C++']