def calculate_cost(files):
    """ Calculate the cost associated with a possible solution """
    offset = cost = 0

    for file in files:
        cost += (offset + file[0]) * file[1]
        offset += file[0]

    return cost