C++ || EASY CLEAN CODE || SHORT
\n\n# Code\n\nclass Solution {\npublic:\n    static bool cmp(vector<int> &a,vector<int> &b)\n    {\n        return a[1]<b[1];\n    }\n    long long minimumMoney
\n\n# Code\n```\nclass Solution {\npublic:\n    static bool cmp(vector<int> &a,vector<int> &b)\n    {\n        return a[1]<b[1];\n    }\n    long long minimumMoney(vector<vector<int>>& t) {\n        vector<vector<int>> a,b;\n        long long int c=0,m=INT_MAX;\n\n        for(auto i : t)\n         if(i[0]<=i[1]) a.push_back(i);\n         else b.push_back(i);\n\n         sort(a.begin(),a.end(),greater<vector<int>> ());\n         sort(b.begin(),b.end(),cmp);\n\n         for(int i=0;i<b.size();i++)\n         {\n             c-=b[i][0];\n             m=min(m,c);\n             c+=b[i][1];\n         }\n         for(int i=0;i<a.size();i++)\n         {\n             c-=a[i][0];\n             m=min(m,c);\n             c+=a[i][1];\n         }\n         return -1*m;\n    }\n};\n```
['C++']