<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def efficiency_capacity_demand_difference(slots, events, X, **kwargs):
 """ A function that calculates the total difference between demand for an event and the slot capacity it is scheduled in. """

    overflow = 0
    for row, event in enumerate(events):
        for col, slot in enumerate(slots):
            overflow += (event.demand - slot.capacity) * X[row, col]
    return overflow