<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def mr(items, targets, **kwargs):
 """Max-Rest Complexity O(n^2) """

    bins = [(target, []) for target in targets]
    skip = []

    for item in items:
        capacities = [target - sum(content) for target, content in bins]
        weighted = weight(capacities, **kwargs)

        (target, content), capacity, _ = max(zip(bins, capacities, weighted),
                                             key=operator.itemgetter(2))
        if item <= capacity:
            content.append(item)
        else:
            skip.append(item)
    return bins, skip