[C++] 2 Heaps
\nclass Solution {\npublic:\n    int getNumberOfBacklogOrders(vector<vector<int>>& orders) {\n        int n = orders.size();\n        //0 - buy  , 1 - sell; \n 
```\nclass Solution {\npublic:\n    int getNumberOfBacklogOrders(vector<vector<int>>& orders) {\n        int n = orders.size();\n        //0 - buy  , 1 - sell; \n        priority_queue<vector<int>> buyBacklog;\n        priority_queue<vector<int> , vector<vector<int>> , greater<vector<int>>> sellBacklog;\n        \n        for(auto order : orders) {\n            if(order[2] == 0) \n                buyBacklog.push(order);\n            else \n                sellBacklog.push(order);\n            \n            while(!buyBacklog.empty() && !sellBacklog.empty() && sellBacklog.top()[0] <= buyBacklog.top()[0])  {\n                auto btop = buyBacklog.top();\n                buyBacklog.pop();\n                auto stop = sellBacklog.top();\n                sellBacklog.pop();\n                int diff = btop[1] - stop[1];\n                if(diff > 0) {\n                    btop[1] = diff;\n                    buyBacklog.push(btop);\n                }\n                else if(diff<0) {\n                    stop[1] = abs(diff);\n                    sellBacklog.push(stop);\n                }\n            }\n        }\n        \n        int ans = 0 , mod = 1e9+7;\n        while(!buyBacklog.empty()){\n            ans = (ans +buyBacklog.top()[1])%mod;\n            buyBacklog.pop();\n        }\n        while(!sellBacklog.empty()){\n            ans = (ans+ sellBacklog.top()[1])%mod;\n            sellBacklog.pop();\n        }\n        return ans;\n    }\n};\n```
['C', 'Heap (Priority Queue)', 'C++']