Python Hard
```python3 []
class Solution:
    def minimumMoney(self, transactions: List[List[int]]) -> int:
        '''
        regardless of the order of the transactions.

        meaning we want the worst order possible

        then binary search on ans

        [[2,1],[5,0],[4,2]]

        worst way

        $10

        5, 3, 

        [5,0], [2,1], [4,2]







        '''


 
        def good(target):
            money = target
    


            for c, t in A:
                money -= c
                if money < 0:
                    return False
                money += t
            return money >= mx

 

        

        mx = 0

        A = []

        for v, t in transactions:
            if v <= t:
                mx = max(mx, v)

            else:
                A.append((v, t))

        A.sort(key=lambda x: (x[1], -x[0]))

     



     
    

        l, r = 0, 10 ** 15
        best = 0
        while l <= r:
            mid = (l + r) // 2
            if good(mid):
                best = mid
                r = mid - 1
            else:
                l = mid + 1
       
        return best
            

        

        
```
['Python3']