Hi FirefoxMetzger,
It is computationally infeasible to generate and sort all possible combinations of elements from large lists due to the combinatorial explosion. I suggest you use a priority queue (max-heap) to generate the combinations sequentially, starting with the largest sum and gradually stepping down. In this case, you could avoid generating all combinations at once and stop when your criteria are met.
The following MATLAB code might help you better understand this:
function largest_combinations = generate_largest_combinations(list, num_combinations, sum_threshold)
% Initialize priority queue (max-heap)
pq = {};
% Initial combination (largest elements of each list)
initial_combination = cellfun(@(x) max(x), list);
pq{end+1} = initial_combination;
% Set to keep track of visited combinations
visited = containers.Map('KeyType', 'char', 'ValueType', 'logical');
visited(mat2str(initial_combination)) = true;
largest_combinations = zeros(length(list), num_combinations);
for k = 1:num_combinations
if isempty(pq)
break;
end
% Extract maximum sum combination
[~, max_idx] = max(cellfun(@(x) sum(x), pq));
combination = pq{max_idx};
pq(max_idx) = []; % Remove the max element
largest_combinations(:, k) = combination;
% Check stopping criteria
if sum(combination) <= sum_threshold
break;
end
% Generate neighboring combinations
for i = 1:length(list)
if combination(i) > min(list{i})
new_combination = combination;
new_combination(i) = max(list{i}(list{i} < combination(i)));
key = mat2str(new_combination);
if ~isKey(visited, key)
pq{end+1} = new_combination;
visited(key) = true;
end
end
end
% Maintain the priority queue order
pq = sort_priority_queue(pq);
end
end
function pq = sort_priority_queue(pq)
% Sort the priority queue based on the sum of combinations in descending order
[~, sorted_idx] = sort(cellfun(@(x) sum(x), pq), 'descend');
pq = pq(sorted_idx);
end
% Example usage
list = cell(1, 7);
for idx = 1:7
list{idx} = randi([100, 5000], 1, randi([100, 5000], 1));
end
num_combinations = 1000;
sum_threshold = 20000; % Example threshold for stopping criteria
largest_combinations = generate_largest_combinations(list, num_combinations, sum_threshold);
% Process the largest combinations
for idx = 1:size(largest_combinations, 2)
combination = largest_combinations(:, idx);
% Replace with your actual processing code
disp(combination);
% Example stopping criteria: sum of combination less than or equal to threshold
if sum(combination) <= sum_threshold
break;
end
end
5000
4999
5000
4997
4999
4998
4977
5000
4998
5000
4997
4999
4998
4977
5000
4999
4999
4997
4999
4998
4977
5000
4999
5000
4996
4999
4998
4977
5000
4999
5000
4997
4999
4997
4977
5000
4999
5000
4997
4997
4998
4977
5000
4998
4999
4997
4999
4998
4977
5000
4998
5000
4996
4999
4998
4977
5000
4998
5000
4997
4999
4997
4977
5000
4999
4999
4996
4999
4998
4977
5000
4999
4999
4997
4999
4997
4977
5000
4999
5000
4995
4999
4998
4977
5000
4999
5000
4996
4999
4997
4977
4997
4999
5000
4997
4999
4998
4977
5000
4998
5000
4997
4997
4998
4977
5000
4999
4999
4997
4997
4998
4977
5000
4999
5000
4996
4997
4998
4977
5000
4999
5000
4997
4997
4997
4977
5000
4999
5000
4997
4999
4995
4977
5000
4999
5000
4997
4996
4998
4977
5000
4998
4999
4996
4999
4998
4977
5000
4998
4999
4997
4999
4997
4977
5000
4998
5000
4995
4999
4998
4977
5000
4998
5000
4996
4999
4997
4977
5000
4999
4999
4995
4999
4998
4977
5000
4999
4999
4996
4999
4997
4977
5000
4999
5000
4995
4999
4997
4977
4997
4998
5000
4997
4999
4998
4977
5000
4995
5000
4997
4999
4998
4977
4997
4999
4999
4997
4999
4998
4977
4997
4999
5000
4996
4999
4998
4977
4997
4999
5000
4997
4999
4997
4977
5000
4998
4999
4997
4997
4998
4977
5000
4998
5000
4996
4997
4998
4977
5000
4998
5000
4997
4997
4997
4977
5000
4998
5000
4997
4999
4995
4977
5000
4999
4999
4996
4997
4998
4977
5000
4999
4999
4997
4997
4997
4977
5000
4999
4999
4997
4999
4995
4977
5000
4999
5000
4995
4997
4998
4977
5000
4999
5000
4996
4997
4997
4977
5000
4999
5000
4996
4999
4995
4977
5000
4998
5000
4997
4996
4998
4977
5000
4999
4999
4997
4996
4998
4977
5000
4999
5000
4996
4996
4998
4977
5000
4999
5000
4997
4996
4997
4977
5000
4998
4999
4995
4999
4998
4977
5000
4998
4999
4996
4999
4997
4977
5000
4998
5000
4995
4999
4997
4977
5000
4999
4999
4995
4999
4997
4977
5000
4999
4995
4997
4999
4998
4977
4997
4999
5000
4997
4997
4998
4977
4997
4998
4999
4997
4999
4998
4977
5000
4995
4999
4997
4999
4998
4977
4997
4998
5000
4996
4999
4998
4977
5000
4995
5000
4996
4999
4998
4977
4997
4998
5000
4997
4999
4997
4977
5000
4995
5000
4997
4999
4997
4977
4997
4999
4999
4996
4999
4998
4977
4997
4999
4999
4997
4999
4997
4977
4997
4999
5000
4995
4999
4998
4977
4997
4999
5000
4996
4999
4997
4977
5000
4999
5000
4997
4997
4995
4977
5000
4998
4999
4996
4997
4998
4977
5000
4998
4999
4997
4997
4997
4977
5000
4998
4999
4997
4999
4995
4977
5000
4998
5000
4995
4997
4998
4977
5000
4998
5000
4996
4997
4997
4977
5000
4998
5000
4996
4999
4995
4977
5000
4999
4999
4995
4997
4998
4977
5000
4999
4999
4996
4997
4997
4977
5000
4999
4999
4996
4999
4995
4977
5000
4999
5000
4995
4997
4997
4977
5000
4999
5000
4995
4999
4995
4977
5000
4998
4999
4997
4996
4998
4977
5000
4998
5000
4996
4996
4998
4977
5000
4998
5000
4997
4996
4997
4977
5000
4999
4999
4996
4996
4998
4977
5000
4999
4999
4997
4996
4997
4977
5000
4999
5000
4995
4996
4998
4977
5000
4999
5000
4996
4996
4997
4977
5000
4998
4999
4995
4999
4997
4977
5000
4998
4995
4997
4999
4998
4977
5000
4999
4995
4996
4999
4998
4977
5000
4999
4995
4997
4999
4997
4977
4997
4998
5000
4997
4997
4998
4977
5000
4995
5000
4997
4997
4998
4977
4997
4999
4999
4997
4997
4998
4977
4997
4999
5000
4996
4997
4998
4977
4997
4999
5000
4997
4997
4997
4977
4997
4999
5000
4997
4999
4995
4977
4997
4999
5000
4997
4996
4998
4977
5000
4999
5000
4997
4993
4998
4977
4997
4998
4999
4996
4999
4998
4977
5000
4995
4999
4996
4999
4998
4977
4997
4998
4999
4997
4999
4997
4977
5000
4995
4999
4997
4999
4997
4977
4997
4998
5000
4995
4999
4998
4977
5000
4995
5000
4995
4999
4998
4977
4997
4998
5000
4996
4999
4997
4977
5000
4995
5000
4996
4999
4997
4977
4997
4999
4999
4995
4999
4998
4977
4997
4999
4999
4996
4999
4997
4977
4997
4999
5000
4995
4999
4997
4977
5000
4998
5000
4997
4997
4995
4977
5000
4999
4999
4997
4997
4995
4977
5000
4999
5000
4996
4997
4995
4977
5000
4999
5000
4997
4996
4995
4977
5000
4998
4999
4995
4997
4998
4977
5000
4998
4999
4996
4997
4997
4977
5000
4998
4999
4996
4999
4995
4977
5000
4998
5000
4995
4997
4997
4977
5000
4998
5000
4995
4999
4995
4977
5000
4999
4999
4995
4997
4997
4977
5000
4999
4999
4995
4999
4995
4977
5000
4998
4999
4996
4996
4998
4977
5000
4998
4999
4997
4996
4997
4977
5000
4998
5000
4995
4996
4998
4977
5000
4998
5000
4996
4996
4997
4977
5000
4999
4999
4995
4996
4998
4977
5000
4999
4999
4996
4996
4997
4977
5000
4999
5000
4995
4996
4997
4977
5000
4999
5000
4997
4999
4998
4970
5000
4999
5000
4990
4999
4998
4977
4993
4999
5000
4997
4999
4998
4977
5000
4999
4995
4997
4997
4998
4977
5000
4998
4995
4996
4999
4998
4977
5000
4998
4995
4997
4999
4997
4977
5000
4999
4995
4995
4999
4998
4977
5000
4999
4995
4996
4999
4997
4977
4997
4995
5000
4997
4999
4998
4977
4997
4998
4999
4997
4997
4998
4977
5000
4995
4999
4997
4997
4998
4977
4997
4998
5000
4996
4997
4998
4977
5000
4995
5000
4996
4997
4998
4977
4997
4998
5000
4997
4997
4997
4977
5000
4995
5000
4997
4997
4997
4977
4997
4998
5000
4997
4999
4995
4977
5000
4995
5000
4997
4999
4995
4977
4997
4999
4999
4996
4997
4998
4977
4997
4999
4999
4997
4997
4997
4977
4997
4999
4999
4997
4999
4995
4977
4997
4999
5000
4995
4997
4998
4977
4997
4999
5000
4996
4997
4997
4977
4997
4999
5000
4996
4999
4995
4977
4997
4998
5000
4997
4996
4998
4977
5000
4995
5000
4997
4996
4998
4977
5000
4998
5000
4997
4993
4998
4977
4997
4999
4999
4997
4996
4998
4977
5000
4999
4999
4997
4993
4998
4977
4997
4999
5000
4996
4996
4998
4977
5000
4999
5000
4996
4993
4998
4977
4997
4999
5000
4997
4996
4997
4977
5000
4999
5000
4997
4993
4997
4977
4997
4998
4999
4995
4999
4998
4977
5000
4995
4999
4995
4999
4998
4977
4997
4998
4999
4996
4999
4997
4977
5000
4995
4999
4996
4999
4997
4977
4997
4998
5000
4995
4999
4997
4977
5000
4995
5000
4995
4999
4997
4977
4997
4999
4999
4995
4999
4997
4977
5000
4998
4999
4997
4997
4995
4977
5000
4998
5000
4996
4997
4995
4977
5000
4999
4999
4996
4997
4995
4977
5000
4999
5000
4995
4997
4995
4977
5000
4998
5000
4997
4996
4995
4977
5000
4999
4999
4997
4996
4995
4977
5000
4999
5000
4996
4996
4995
4977
5000
4998
4999
4995
4997
4997
4977
5000
4998
4999
4995
4999
4995
4977
5000
4998
4999
4995
4996
4998
4977
5000
4998
4999
4996
4996
4997
4977
5000
4998
5000
4995
4996
4997
4977
5000
4999
4999
4995
4996
4997
4977
5000
4998
5000
4997
4999
4998
4970
5000
4999
4999
4997
4999
4998
4970
5000
4999
5000
4996
4999
4998
4970
5000
4999
5000
4997
4999
4997
4970
5000
4998
5000
4990
4999
4998
4977
5000
4999
4999
4990
4999
4998
4977
5000
4999
5000
4990
4999
4997
4977
4993
4998
5000
4997
4999
4998
4977
4993
4999
4999
4997
4999
4998
4977
4997
4999
4995
4997
4999
4998
4977
4993
4999
5000
4996
4999
4998
4977
4993
4999
5000
4997
4999
4997
4977
5000
4998
4995
4997
4997
4998
4977
5000
4999
4995
4996
4997
4998
4977
5000
4999
4995
4997
4997
4997
4977
5000
4999
4995
4997
4999
4995
4977
5000
4999
4995
4997
4996
4998
4977
5000
4998
4995
4995
4999
4998
4977
5000
4998
4995
4996
4999
4997
4977
5000
4999
4995
4995
4999
4997
4977
4997
4995
4999
4997
4999
4998
4977
4997
4995
5000
4996
4999
4998
4977
4997
4995
5000
4997
4999
4997
4977
4997
4999
5000
4997
4997
4995
4977
4997
4998
4999
4996
4997
4998
4977
5000
4995
4999
4996
4997
4998
4977
4997
4998
4999
4997
4997
4997
4977
5000
4995
4999
4997
4997
4997
4977
4997
4998
4999
4997
4999
4995
4977
5000
4995
4999
4997
4999
4995
4977
4997
4998
5000
4995
4997
4998
4977
5000
4995
5000
4995
4997
4998
4977
4997
4998
5000
4996
4997
4997
4977
5000
4995
5000
4996
4997
4997
4977
4997
4998
5000
4996
4999
4995
4977
5000
4995
5000
4996
4999
4995
4977
4997
4999
4999
4995
4997
4998
4977
4997
4999
4999
4996
4997
4997
4977
4997
4999
4999
4996
4999
4995
4977
4997
4999
5000
4995
4997
4997
4977
4997
4999
5000
4995
4999
4995
4977
4997
4998
4999
4997
4996
4998
4977
5000
4995
4999
4997
4996
4998
4977
5000
4998
4999
4997
4993
4998
4977
4997
4998
5000
4996
4996
4998
4977
5000
4995
5000
4996
4996
4998
4977
5000
4998
5000
4996
4993
4998
4977
4997
4998
5000
4997
4996
4997
4977
5000
4995
5000
4997
4996
4997
4977
5000
4998
5000
4997
4993
4997
4977
4997
4999
4999
4996
4996
4998
4977
5000
4999
4999
4996
4993
4998
4977
4997
4999
4999
4997
4996
4997
4977
5000
4999
4999
4997
4993
4997
4977
4997
4999
5000
4995
4996
4998
4977
5000
4999
5000
4995
4993
4998
4977
4997
4999
5000
4996
4996
4997
4977
5000
4999
5000
4996
4993
4997
4977
4997
4998
4999
4995
4999
4997
4977
5000
4995
4999
4995
4999
4997
4977
5000
4998
4999
4996
4997
4995
4977
5000
4998
5000
4995
4997
4995
4977
5000
4999
4999
4995
4997
4995
4977
5000
4998
4999
4997
4996
4995
4977
5000
4998
5000
4996
4996
4995
4977
5000
4999
4999
4996
4996
4995
4977
5000
4999
5000
4995
4996
4995
4977
4992
4999
5000
4997
4999
4998
4977
5000
4998
4999
4995
4996
4997
4977
5000
4999
5000
4997
4997
4998
4970
5000
4998
4999
4997
4999
4998
4970
5000
4998
5000
4996
4999
4998
4970
5000
4998
5000
4997
4999
4997
4970
5000
4999
4999
4996
4999
4998
4970
5000
4999
4999
4997
4999
4997
4970
5000
4999
5000
4995
4999
4998
4970
5000
4999
5000
4996
4999
4997
4970
5000
4999
5000
4997
4999
4989
4977
5000
4999
5000
4990
4997
4998
4977
5000
4998
4999
4990
4999
4998
4977
5000
4998
5000
4990
4999
4997
4977
5000
4999
4999
4990
4999
4997
4977
4993
4999
5000
4997
4997
4998
4977
4993
4998
4999
4997
4999
4998
4977
4997
4998
4995
4997
4999
4998
4977
5000
4995
4995
4997
4999
4998
4977
4993
4998
5000
4996
4999
4998
4977
4993
4998
5000
4997
4999
4997
4977
4993
4999
4999
4996
4999
4998
4977
4997
4999
4995
4996
4999
4998
4977
4993
4999
4999
4997
4999
4997
4977
4997
4999
4995
4997
4999
4997
4977
4993
4999
5000
4995
4999
4998
4977
4993
4999
5000
4996
4999
4997
4977
5000
4998
4995
4996
4997
4998
4977
5000
4998
4995
4997
4997
4997
4977
5000
4998
4995
4997
4999
4995
4977
5000
4999
4995
4995
4997
4998
4977
5000
4999
4995
4996
4997
4997
4977
5000
4999
4995
4996
4999
4995
4977
5000
4998
4995
4997
4996
4998
4977
5000
4999
4995
4996
4996
4998
4977
5000
4999
4995
4997
4996
4997
4977
5000
4998
4995
4995
4999
4997
4977
4997
4995
5000
4997
4997
4998
4977
4997
4999
5000
4997
4993
4998
4977
5000
4999
5000
4997
4990
4998
4977
4997
4995
4999
4996
4999
4998
4977
4997
4995
4999
4997
4999
4997
4977
4997
4995
5000
4995
4999
4998
4977
4997
4995
5000
4996
4999
4997
4977
4997
4998
5000
4997
4997
4995
4977
5000
4995
5000
4997
4997
4995
4977
4997
4999
4999
4997
4997
4995
4977
4997
4999
5000
4996
4997
4995
4977
4997
4999
5000
4997
4996
4995
4977
5000
4999
5000
4997
4993
4995
4977
4997
4998
4999
4995
4997
4998
4977
5000
4995
4999
4995
4997
4998
4977
4997
4998
4999
4996
4997
4997
4977
5000
4995
4999
4996
4997
4997
4977
4997
4998
4999
4996
4999
4995
4977
5000
4995
4999
4996
4999
4995
4977
4997
4998
5000
4995
4997
4997
4977
5000
4995
5000
4995
4997
4997
4977
4997
4998
5000
4995
4999
4995
4977
5000
4995
5000
4995
4999
4995
4977
4997
4999
4999
4995
4997
4997
4977
4997
4999
4999
4995
4999
4995
4977
4997
4998
4999
4996
4996
4998
4977
5000
4995
4999
4996
4996
4998
4977
5000
4998
4999
4996
4993
4998
4977
4997
4998
4999
4997
4996
4997
4977
5000
4995
4999
4997
4996
4997
4977
5000
4998
4999
4997
4993
4997
4977
4997
4998
5000
4995
4996
4998
4977
5000
4995
5000
4995
4996
4998
4977
5000
4998
5000
4995
4993
4998
4977
4997
4998
5000
4996
4996
4997
4977
5000
4995
5000
4996
4996
4997
4977
5000
4998
5000
4996
4993
4997
4977
4997
4999
4999
4995
4996
4998
4977
5000
4999
4999
4995
4993
4998
4977
4997
4999
4999
4996
4996
4997
4977
5000
4999
4999
4996
4993
4997
4977
4997
4999
5000
4995
4996
4997
4977
5000
4999
5000
4995
4993
4997
4977
5000
4999
5000
4988
4999
4998
4977
5000
4998
4999
4995
4997
4995
4977
5000
4998
4999
4996
4996
4995
4977
5000
4998
5000
4995
4996
4995
4977
5000
4999
4999
4995
4996
4995
4977
4992
4998
5000
4997
4999
4998
4977
4992
4999
4999
4997
4999
4998
4977
4992
4999
5000
4996
4999
4998
4977
4992
4999
5000
4997
4999
4997
4977
4991
4999
5000
4997
4999
4998
4977
4997
4999
5000
4997
4999
4998
4970
5000
4998
5000
4997
4997
4998
4970
5000
4999
4999
4997
4997
4998
4970
5000
4999
5000
4996
4997
4998
4970
5000
4999
5000
4997
4997
4997
4970
5000
4999
5000
4997
4999
4995
4970
5000
4999
5000
4997
4996
4998
4970
5000
4998
4999
4996
4999
4998
4970
5000
4998
4999
4997
4999
4997
4970
5000
4998
5000
4995
4999
4998
4970
5000
4998
5000
4996
4999
4997
4970
5000
4999
4999
4995
4999
4998
4970
5000
4999
4999
4996
4999
4997
4970
5000
4999
5000
4995
4999
4997
4970
5000
4989
5000
4997
4999
4998
4977
5000
4998
5000
4997
4999
4989
4977
5000
4999
4999
4997
4999
4989
4977
5000
4999
5000
4996
4999
4989
4977
4997
4999
5000
4990
4999
4998
4977
5000
4998
5000
4990
4997
4998
4977
5000
4999
4999
4990
4997
4998
4977
5000
4999
5000
4990
4997
4997
4977
5000
4999
5000
4990
4999
4995
4977
5000
4999
5000
4990
4996
4998
4977
5000
4998
4999
4990
4999
4997
4977
4993
4998
5000
4997
4997
4998
4977
4993
4999
4999
4997
4997
4998
4977
4997
4999
4995
4997
4997
4998
4977
4993
4999
5000
4996
4997
4998
4977
4993
4999
5000
4997
4997
4997
4977
4993
4999
5000
4997
4999
4995
4977
4993
4999
5000
4997
4996
4998
4977
4993
4998
4999
4996
4999
4998
4977
4997
4998
4995
4996
4999
4998
4977
5000
4995
4995
4996
4999
4998
4977
4993
4998
4999
4997
4999
4997
4977
4997
4998
4995
4997
4999
4997
4977
5000
4995
4995
4997
4999
4997
4977
4993
4998
5000
4995
4999
4998
4977
4993
4998
5000
4996
4999
4997
4977
4993
4999
4999
4995
4999
4998
4977
4997
4999
4995
4995
4999
4998
4977
4993
4999
4999
4996
4999
4997
4977
4997
4999
4995
4996
4999
4997
4977
4993
4999
5000
4995
4999
4997
4977
5000
4999
4995
4997
4997
4995
4977
5000
4998
4995
4995
4997
4998
4977
5000
4998
4995
4996
4997
4997
4977
5000
4998
4995
4996
4999
4995
4977
5000
4999
4995
4995
4997
4997
4977
5000
4999
4995
4995
4999
4995
4977
5000
4998
4995
4996
4996
4998
4977
5000
4998
4995
4997
4996
4997
4977
5000
4999
4995
4995
4996
4998
4977
5000
4999
4995
4996
4996
4997
4977
4997
4995
4999
4997
4997
4998
4977
4997
4995
5000
4996
4997
4998
4977
4997
4995
5000
4997
4997
4997
4977
4997
4995
5000
4997
4999
4995
4977
4997
4995
5000
4997
4996
4998
4977
4997
4998
5000
4997
4993
4998
4977
5000
4995
5000
4997
4993
4998
4977
5000
4998
5000
4997
4990
4998
4977
4997
4999
4999
4997
4993
4998
4977
5000
4999
4999
4997
4990
4998
4977
4997
4999
5000
4996
4993
4998
4977
5000
4999
5000
4996
4990
4998
4977
4997
4999
5000
4997
4993
4997
4977
5000
4999
5000
4997
4990
4997
4977
4997
4995
4999
4995
4999
4998
4977
4997
4995
4999
4996
4999
4997
4977
4997
4995
5000
4995
4999
4997
4977
4997
4998
4999
4997
4997
4995
4977
5000
4995
4999
4997
4997
4995
4977
4997
4998
5000
4996
4997
4995
4977
5000
4995
5000
4996
4997
4995
4977
4997
4999
4999
4996
4997
4995
4977
4997
4999
5000
4995
4997
4995
4977
4997
4998
5000
4997
4996
4995
4977
5000
4995
5000
4997
4996
4995
4977
5000
4998
5000
4997
4993
4995
4977
4997
4999
4999
4997
4996
4995
4977
5000
4999
4999
4997
4993
4995
4977
4997
4999
5000
4996
4996
4995
4977
5000
4999
5000
4996
4993
4995
4977
4997
4998
4999
4995
4997
4997
4977
5000
4995
4999
4995
4997
4997
4977
4997
4998
4999
4995
4999
4995
4977
5000
4995
4999
4995
4999
4995
4977
4997
4998
4999
4995
4996
4998
4977
5000
4995
4999
4995
4996
4998
4977
5000
4998
4999
4995
4993
4998
4977
4997
4998
4999
4996
4996
4997
4977
5000
4995
4999
4996
4996
4997
4977
5000
4998
4999
4996
4993
4997
4977
4997
4998
5000
4995
4996
4997
4977
5000
4995
5000
4995
4996
4997
4977
5000
4998
5000
4995
4993
4997
4977
4997
4999
4999
4995
4996
4997
4977
5000
4999
4999
4995
4993
4997
4977
5000
4998
5000
4988
4999
4998
4977
5000
4999
4999
4988
4999
4998
4977
5000
4999
5000
4988
4999
4997
4977
4992
4999
5000
4997
4997
4998
4977
5000
4998
4999
4995
4996
4995
4977
5000
4999
5000
4997
4999
4988
4977
4992
4998
4999
4997
4999
4998
4977
4992
4998
5000
4996
4999
4998
4977
4992
4998
5000
4997
4999
4997
4977
4992
4999
4999
4996
4999
4998
4977
4992
4999
4999
4997
4999
4997
4977
4992
4999
5000
4995
4999
4998
4977
4992
4999
5000
4996
4999
4997
4977
5000
4999
5000
4997
4989
4998
4977
5000
4999
5000
4987
4999
4998
4977
4991
4998
5000
4997
4999
4998
4977
4991
4999
4999
4997
4999
4998
4977
4991
4999
5000
4996
4999
4998
4977
4991
4999
5000
4997
4999
4997
4977
4990
4999
5000
4997
4999
4998
4977
4997
4998
5000
4997
4999
4998
4970
5000
4995
5000
4997
4999
4998
4970
4997
4999
4999
4997
4999
4998
4970
4997
4999
5000
4996
4999
4998
4970
4997
4999
5000
4997
4999
4997
4970
5000
4998
4999
4997
4997
4998
4970
5000
4998
5000
4996
4997
4998
4970
5000
4998
5000
4997
4997
4997
4970
5000
4998
5000
4997
4999
4995
4970
5000
4999
4999
4996
4997
4998
4970
5000
4999
4999
4997
4997
4997
4970
5000
4999
4999
4997
4999
4995
4970
5000
4999
5000
4995
4997
4998
4970
5000
4999
5000
4996
4997
4997
4970
5000
4999
5000
4996
4999
4995
4970
5000
4998
5000
4997
4996
4998
4970
5000
4999
4999
4997
4996
4998
4970
5000
4999
5000
4996
4996
4998
4970
5000
4999
5000
4997
4996
4997
4970
5000
4998
4999
4995
4999
4998
4970
5000
4998
4999
4996
4999
4997
4970
5000
4998
5000
4995
4999
4997
4970
5000
4999
4999
4995
4999
4997
4970
5000
4989
4999
4997
4999
4998
4977
5000
4989
5000
4996
4999
4998
4977
5000
4989
5000
4997
4999
4997
4977
5000
4999
5000
4997
4997
4989
4977
5000
4998
4999
4997
4999
4989
4977
5000
4998
5000
4996
4999
4989
4977
5000
4999
4999
4996
4999
4989
4977
5000
4999
5000
4995
4999
4989
4977
4997
4998
5000
4990
4999
4998
4977
5000
4995
5000
4990
4999
4998
4977
4997
4999
4999
4990
4999
4998
4977
4997
4999
5000
4990
4999
4997
4977
5000
4998
4999
4990
4997
4998
4977
5000
4998
5000
4990
4997
4997
4977
5000
4998
5000
4990
4999
4995
4977
5000
4999
4999
4990
4997
4997
4977
5000
4999
4999
4990
4999
4995
4977
5000
4998
5000
4990
4996
4998
4977
5000
4999
4999
4990
4996
4998
4977
5000
4999
5000
4990
4996
4997
4977
4993
4995
5000
4997
4999
4998
4977
4993
4998
4999
4997
4997
4998
4977
4997
4998
4995
4997
4997
4998
4977
5000
4995
4995
4997
4997
4998
4977
4993
4998
5000
4996
4997
4998
4977
4993
4998
5000
4997
4997
4997
4977
4993
4998
5000
4997
4999
4995
4977
4993
4999
4999
4996
4997
4998
4977
4997
4999
4995
4996
4997
4998
4977
4993
4999
4999
4997
4997
4997
4977
4997
4999
4995
4997
4997
4997
4977
4993
4999
4999
4997
4999
4995
4977
4997
4999
4995
4997
4999
4995
4977
4993
4999
5000
4995
4997
4998
4977
4993
4999
5000
4996
4997
4997
4977
4993
4999
5000
4996
4999
4995
4977
4993
4998
5000
4997
4996
4998
4977
4993
4999
4999
4997
4996
4998
4977
4997
4999
4995
4997
4996
4998
4977
5000
4999
4995
4997
4993
4998
4977
4993
4999
5000
4996
4996
4998
4977
4993
4999
5000
4997
4996
4997
4977
4993
4998
4999
4995
4999
4998
4977
4997
4998
4995
4995
4999
4998
4977
5000
4995
4995
4995
4999
4998
4977
4993
4998
4999
4996
4999
4997
4977
4997
4998
4995
4996
4999
4997
4977
5000
4995
4995
4996
4999
4997
4977
4993
4998
5000
4995
4999
4997
4977
4993
4999
4999
4995
4999
4997
4977
4997
4999
4995
4995
4999
4997
4977
5000
4998
4995
4997
4997
4995
4977
5000
4999
4995
4996
4997
4995
4977
5000
4999
4995
4997
4996
4995
4977
5000
4998
4995
4995
4997
4997
4977
5000
4998
4995
4995
4999
4995
4977
5000
4998
4995
4995
4996
4998
4977
5000
4998
4995
4996
4996
4997
4977
5000
4999
4995
4995
4996
4997
4977
4997
4995
4999
4996
4997
4998
4977
4997
4995
4999
4997
4997
4997
4977
4997
4995
4999
4997
4999
4995
4977
4997
4995
5000
4995
4997
4998
4977
4997
4995
5000
4996
4997
4997
4977
4997
4995
5000
4996
4999
4995
4977
4997
4995
4999
4997
4996
4998
4977
4997
4998
4999
4997
4993
4998
4977
5000
4995
4999
4997
4993
4998
4977
5000
4998
4999
4997
4990
4998
4977
4997
4995
5000
4996
4996
4998
4977
4997
4998
5000
4996
4993
4998
4977
5000
4995
5000
4996
4993
4998
4977
5000
4998
5000
4996
4990
4998
4977
4997
4995
5000
4997
4996
4997
4977
4997
4998
5000
4997
4993
4997
4977
5000
4995
5000
4997
4993
4997
4977
5000
4998
5000
4997
4990
4997
4977
4997
4999
4999
4996
4993
4998
4977
5000
4999
4999
4996
4990
4998
4977
4997
4999
4999
4997
4993
4997
4977
5000
4999
4999
4997
4990
4997
4977
4997
4999
5000
4995
4993
4998
4977
5000
4999
5000
4995
4990
4998
4977
4997
4999
5000
4996
4993
4997
4977
5000
4999
5000
4996
4990
4997
4977
4997
4995
4999
4995
4999
4997
4977
4997
4998
4999
4996
4997
4995
4977
5000
4995
4999
4996
4997
4995
4977
4997
4998
5000
4995
4997
4995
4977
5000
4995
5000
4995
4997
4995
4977
4997
4999
4999
4995
4997
4995
4977
4997
4998
4999
4997
4996
4995
4977
5000
4995
4999
4997
4996
4995
4977
5000
4998
4999
4997
4993
4995
4977
4997
4998
5000
4996
4996
4995
4977
5000
4995
5000
4996
4996
4995
4977
5000
4998
5000
4996
4993
4995
4977
4997
4999
4999
4996
4996
4995
4977
5000
4999
4999
4996
4993
4995
4977
4997
4999
5000
4995
4996
4995
4977
5000
4999
5000
4995
4993
4995
4977
4997
4998
4999
4995
4996
4997
4977
5000
4995
4999
4995
4996
4997
4977
5000
4998
4999
4995
4993
4997
4977
5000
4999
5000
4988
4997
4998
4977
5000
4998
4999
4988
4999
4998
4977
5000
4998
5000
4988
4999
4997
4977
5000
4999
4999
4988
4999
4997
4977
4992
4998
5000
4997
4997
4998
4977
4992
4999
4999
4997
4997
4998
4977
4992
4999
5000
4996
4997
4998
4977
4992
4999
5000
4997
4997
4997
4977
4992
4999
5000
4997
4999
4995
4977
4991
4999
5000
4997
4997
4998
4977
5000
4988
5000
4997
4999
4998
4977
5000
4998
5000
4997
4999
4988
4977
5000
4999
4999
4997
4999
4988
4977
5000
4999
5000
4996
4999
4988
4977
4992
4999
5000
4997
4996
4998
4977
4992
4998
4999
4996
4999
4998
4977
4992
4998
4999
4997
4999
4997
4977
4992
4998
5000
4995
4999
4998
4977
4992
4998
5000
4996
4999
4997
4977
4992
4999
4999
4995
4999
4998
4977
4992
4999
4999
4996
4999
4997
4977
4992
4999
5000
4995
4999
4997
4977
5000
4998
5000
4997
4989
4998
4977
5000
4999
4999
4997
4989
4998
4977
5000
4999
5000
4996
4989
4998
4977
5000
4999
5000
4997
4989
4997
4977
5000
4998
5000
4987
4999
4998
4977
5000
4999
4999
4987
4999
4998
4977
5000
4999
5000
4987
4999
4997
4977
4991
4998
4999
4997
4999
4998
4977
4991
4998
5000
4996
4999
4998
4977
4991
4998
5000
4997
4999
4997
4977
4991
4999
4999
4996
4999
4998
4977
4991
4999
4999
4997
4999
4997
4977
4991
4999
5000
4995
4999
4998
4977
4991
4999
5000
4996
4999
4997
4977
5000
4999
5000
4997
4988
4998
4977
4990
4998
5000
4997
4999
4998
4977
4990
4999
4999
4997
4999
4998
4977
4990
4999
5000
4996
4999
4998
4977
4990
4999
5000
4997
4999
4997
4977
5000
4999
4988
4997
4999
4998
4977
5000
4999
4995
4997
4999
4998
4970
4997
4999
5000
4997
4997
4998
4970
4997
4998
4999
4997
4999
4998
4970
5000
4995
4999
4997
4999
4998
4970
4997
4998
5000
4996
4999
4998
4970
5000
4995
5000
4996
4999
4998
4970
4997
4998
5000
4997
4999
4997
4970
5000
4995
5000
4997
4999
4997
4970
4997
4999
4999
4996
4999
4998
4970
4997
4999
4999
4997
4999
4997
4970
4997
4999
5000
4995
4999
4998
4970
4997
4999
5000
4996
4999
4997
4970
5000
4999
5000
4997
4997
4995
4970
5000
4998
4999
4996
4997
4998
4970
5000
4998
4999
4997
4997
4997
4970
5000
4998
4999
4997
4999
4995
4970
5000
4998
5000
4995
4997
4998
4970
5000
4998
5000
4996
4997
4997
4970
5000
4998
5000
4996
4999
4995
4970
5000
4999
4999
4995
4997
4998
4970
5000
4999
4999
4996
4997
4997
4970
5000
4999
4999
4996
4999
4995
4970
5000
4999
5000
4995
4997
4997
4970
5000
4999
5000
4995
4999
4995
4970
5000
4998
4999
4997
4996
4998
4970
5000
4998
5000
4996
4996
4998
4970
5000
4998
5000
4997
4996
4997
4970
5000
4999
4999
4996
4996
4998
4970
5000
4999
4999
4997
4996
4997
4970
5000
4999
5000
4995
4996
4998
4970
5000
4999
5000
4996
4996
4997
4970
5000
4998
4999
4995
4999
4997
4970
5000
4989
5000
4997
4997
4998
4977
4997
4999
5000
4997
4999
4989
4977
5000
4989
4999
4996
4999
4998
4977
5000
4989
4999
4997
4999
4997
4977
5000
4989
5000
4995
4999
4998
4977
5000
4989
5000
4996
4999
4997
4977
5000
4998
5000
4997
4997
4989
4977
5000
4999
4999
4997
4997
4989
4977
5000
4999
5000
4996
4997
4989
4977
5000
4999
5000
4997
4996
4989
4977
5000
4998
4999
4996
4999
4989
4977
5000
4998
5000
4995
4999
4989
4977
5000
4999
4999
4995
4999
4989
4977
5000
4999
5000
4997
4999
4998
4965
5000
4999
4995
4990
4999
4998
4977
4997
4999
5000
4990
4997
4998
4977
4997
4998
4999
4990
4999
4998
4977
5000
4995
4999
4990
4999
4998
4977
4997
4998
5000
4990
4999
4997
4977
5000
4995
5000
4990
4999
4997
4977
4997
4999
4999
4990
4999
4997
4977
5000
4999
5000
4990
4997
4995
4977
5000
4998
4999
4990
4997
4997
4977
5000
4998
4999
4990
4999
4995
4977
5000
4998
4999
4990
4996
4998
4977
5000
4998
5000
4990
4996
4997
4977
5000
4999
4999
4990
4996
4997
4977
4993
4999
4995
4997
4999
4998
4977
4993
4995
4999
4997
4999
4998
4977
4997
4995
4995
4997
4999
4998
4977
4993
4995
5000
4996
4999
4998
4977
4993
4995
5000
4997
4999
4997
4977
4993
4999
5000
4997
4997
4995
4977
4993
4998
4999
4996
4997
4998
4977
4997
4998
4995
4996
4997
4998
4977
5000
4995
4995
4996
4997
4998
4977
4993
4998
4999
4997
4997
4997
4977
4997
4998
4995
4997
4997
4997
4977
5000
4995
4995
4997
4997
4997
4977
4993
4998
4999
4997
4999
4995
4977
4997
4998
4995
4997
4999
4995
4977
5000
4995
4995
4997
4999
4995
4977
4993
4998
5000
4995
4997
4998
4977
4993
4998
5000
4996
4997
4997
4977
4993
4998
5000
4996
4999
4995
4977
4993
4999
4999
4995
4997
4998
4977
4997
4999
4995
4995
4997
4998
4977
4993
4999
4999
4996
4997
4997
4977
4997
4999
4995
4996
4997
4997
4977
4993
4999
4999
4996
4999
4995
4977
4997
4999
4995
4996
4999
4995
4977
4993
4999
5000
4995
4997
4997
4977
4993
4999
5000
4995
4999
4995
4977
4993
4998
4999
4997
4996
4998
4977
4997
4998
4995
4997
4996
4998
4977
5000
4995
4995
4997
4996
4998
4977
5000
4998
4995
4997
4993
4998
4977
4993
4998
5000
4996
4996
4998
4977
4993
4998
5000
4997
4996
4997
4977
4993
4999
4999
4996
4996
4998
4977
4997
4999
4995
4996
4996
4998
4977
5000
4999
4995
4996
4993
4998
4977
4993
4999
4999
4997
4996
4997
4977
4997
4999
4995
4997
4996
4997
4977
5000
4999
4995
4997
4993
4997
4977
4993
4999
5000
4995
4996
4998
4977
4993
4999
5000
4996
4996
4997
4977
4993
4998
4999
4995
4999
4997
4977
4997
4998
4995
4995
4999
4997
4977
5000
4995
4995
4995
4999
4997
4977
5000
4998
4995
4996
4997
4995
4977
5000
4999
4995
4995
4997
4995
4977
5000
4998
4995
4997
4996
4995
4977
5000
4999
4995
4996
4996
4995
4977
5000
4998
4995
4995
4996
4997
4977
4997
4999
5000
4997
4990
4998
4977
4997
4995
5000
4997
4997
4995
4977
4997
4999
5000
4997
4993
4995
4977
5000
4999
5000
4997
4990
4995
4977
4997
4995
4999
4995
4997
4998
4977
4997
4995
4999
4996
4997
4997
4977
4997
4995
4999
4996
4999
4995
4977
4997
4995
5000
4995
4997
4997
4977
4997
4995
5000
4995
4999
4995
4977
4997
4995
4999
4996
4996
4998
4977
4997
4998
4999
4996
4993
4998
4977
5000
4995
4999
4996
4993
4998
4977
5000
4998
4999
4996
4990
4998
4977
4997
4995
4999
4997
4996
4997
4977
4997
4998
4999
4997
4993
4997
4977
5000
4995
4999
4997
4993
4997
4977
5000
4998
4999
4997
4990
4997
4977
4997
4995
5000
4995
4996
4998
4977
4997
4998
5000
4995
4993
4998
4977
5000
4995
5000
4995
4993
4998
4977
5000
4998
5000
4995
4990
4998
4977
4997
4995
5000
4996
4996
4997
4977
4997
4998
5000
4996
4993
4997
4977
5000
4995
5000
4996
4993
4997
4977
5000
4998
5000
4996
4990
4997
4977
4997
4999
4999
4995
4993
4998
4977
5000
4999
4999
4995
4990
4998
4977
4997
4999
4999
4996
4993
4997
4977
5000
4999
4999
4996
4990
4997
4977
4997
4999
5000
4995
4993
4997
4977
5000
4999
5000
4995
4990
4997
4977
4997
4999
5000
4988
4999
4998
4977
4997
4998
4999
4995
4997
4995
4977
5000
4995
4999
4995
4997
4995
4977
4997
4998
4999
4996
4996
4995
4977
5000
4995
4999
4996
4996
4995
4977
5000
4998
4999
4996
4993
4995
4977
4997
4998
5000
4995
4996
4995
4977
5000
4995
5000
4995
4996
4995
4977
5000
4998
5000
4995
4993
4995
4977
4997
4999
4999
4995
4996
4995
4977
5000
4999
4999
4995
4993
4995
4977
4992
4995
5000
4997
4999
4998
4977
5000
4998
5000
4988
4997
4998
4977
5000
4999
4999
4988
4997
4998
4977
5000
4999
5000
4988
4997
4997
4977
5000
4999
5000
4988
4999
4995
4977
5000
4999
5000
4988
4996
4998
4977
5000
4998
4999
4988
4999
4997
4977
5000
4999
5000
4997
4997
4988
4977
4992
4998
4999
4997
4997
4998
4977
4992
4998
5000
4996
4997
4998
4977
4992
4998
5000
4997
4997
4997
4977
4992
4998
5000
4997
4999
4995
4977
4992
4999
4999
4996
4997
4998
4977
4992
4999
4999
4997
4997
4997
4977
4992
4999
4999
4997
4999
4995
4977
4992
4999
5000
4995
4997
4998
4977
4992
4999
5000
4996
4997
4997
4977
4992
4999
5000
4996
4999
4995
4977
5000
4999
5000
4987
4997
4998
4977
4991
4998
5000
4997
4997
4998
4977
4991
4999
4999
4997
4997
4998
4977
4991
4999
5000
4996
4997
4998
4977
4991
4999
5000
4997
4997
4997
4977
4991
4999
5000
4997
4999
4995
4977
4988
4999
5000
4997
4999
4998
4977
4990
4999
5000
4997
4997
4998
4977
5000
4988
4999
4997
4999
4998
4977
5000
4988
5000
4996
4999
4998
4977
5000
4988
5000
4997
4999
4997
4977
5000
4998
4999
4997
4999
4988
4977
5000
4998
5000
4996
4999
4988
4977
5000
4999
4999
4996
4999
4988
4977
5000
4999
5000
4995
4999
4988
4977
4992
4998
5000
4997
4996
4998
4977
4992
4999
4999
4997
4996
4998
4977
4992
4999
5000
4996
4996
4998
4977
4992
4999
5000
4997
4996
4997
4977
4992
4998
4999
4995
4999
4998
4977
4992
4998
4999
4996
4999
4997
4977
4992
4998
5000
4995
4999
4997
4977
4992
4999
4999
4995
4999
4997
4977
5000
4998
4999
4997
4989
4998
4977
5000
4998
5000
4996
4989
4998
4977
5000
4998
5000
4997
4989
4997
4977
5000
4999
4999
4996
4989
4998
4977
5000
4999
4999
4997
4989
4997
4977
5000
4999
5000
4995
4989
4998
4977
5000
4999
5000
4996
4989
4997
4977
5000
4998
4999
4987
4999
4998
4977
5000
4998
5000
4987
4999
4997
4977
5000
4999
4999
4987
4999
4997
4977
4991
4999
5000
4997
4996
4998
4977
4991
4998
4999
4996
4999
4998
4977
4991
4998
4999
4997
4999
4997
4977
4991
4998
5000
4995
4999
4998
4977
4991
4998
5000
4996
4999
4997
4977
4991
4999
4999
4995
4999
4998
4977
4991
4999
4999
4996
4999
4997
4977
4991
4999
5000
4995
4999
4997
4977
5000
4998
5000
4997
4988
4998
4977
5000
4999
4999
4997
4988
4998
4977
5000
4999
5000
4996
4988
4998
4977
5000
4999
5000
4997
4988
4997
4977
4990
4998
4999
4997
4999
4998
4977
4990
4998
5000
4996
4999
4998
4977
4990
4998
5000
4997
4999
4997
4977
4990
4999
4999
4996
4999
4998
4977
4990
4999
4999
4997
4999
4997
4977
4990
4999
5000
4995
4999
4998
4977
4990
4999
5000
4996
4999
4997
4977
5000
4999
5000
4997
4987
4998
4977
5000
4998
4988
4997
4999
4998
4977
5000
4998
4995
4997
4999
4998
4970
5000
4999
4988
4996
4999
4998
4977
5000
4999
4995
4996
4999
4998
4970
5000
4999
4988
4997
4999
4997
4977
5000
4999
4995
4997
4999
4997
4970
4997
4998
5000
4997
4997
4998
4970
5000
4995
5000
4997
4997
4998
4970
4997
4999
4999
4997
4997
4998
4970
4997
4999
5000
4996
4997
4998
4970
4997
4999
5000
4997
4997
4997
4970
4997
4999
5000
4997
4999
4995
4970
4997
4999
5000
4997
4996
4998
4970
5000
4999
5000
4997
4993
4998
4970
4997
4998
4999
4996
4999
4998
4970
5000
4995
4999
4996
4999
4998
4970
4997
4998
4999
4997
4999
4997
4970
5000
4995
4999
4997
4999
4997
4970
4997
4998
5000
4995
4999
4998
4970
5000
4995
5000
4995
4999
4998
4970
4997
4998
5000
4996
4999
4997
4970
5000
4995
5000
4996
4999
4997
4970
4997
4999
4999
4995
4999
4998
4970
4997
4999
4999
4996
4999
4997
4970
4997
4999
5000
4995
4999
4997
4970
5000
4998
5000
4997
4997
4995
4970
5000
4999
4999
4997
4997
4995
4970
5000
4999
5000
4996
4997
4995
4970
5000
4999
5000
4997
4996
4995
4970
5000
4998
4999
4995
4997
4998
4970
5000
4998
4999
4996
4997
4997
4970
5000
4998
4999
4996
4999
4995
4970
5000
4998
5000
4995
4997
4997
4970
5000
4998
5000
4995
4999
4995
4970
5000
4999
4999
4995
4997
4997
4970
5000
4999
4999
4995
4999
4995
4970
5000
4998
4999
4996
4996
4998
4970
5000
4998
4999
4997
4996
4997
4970
5000
4998
5000
4995
4996
4998
4970
5000
4998
5000
4996
4996
4997
4970
5000
4999
4999
4995
4996
4998
4970
5000
4999
4999
4996
4996
4997
4970
5000
4999
5000
4995
4996
4997
4970
4997
4989
5000
4997
4999
4998
4977
5000
4989
4999
4997
4997
4998
4977
5000
4989
5000
4996
4997
4998
4977
5000
4989
5000
4997
4997
4997
4977
4997
4998
5000
4997
4999
4989
4977
5000
4989
5000
4997
4999
4995
4977
5000
4995
5000
4997
4999
4989
4977
4997
4999
4999
4997
4999
4989
4977
4997
4999
5000
4996
4999
4989
4977
5000
4989
5000
4997
4996
4998
4977
5000
4989
4999
4995
4999
4998
4977
5000
4989
4999
4996
4999
4997
4977
5000
4989
5000
4995
4999
4997
4977
5000
4998
4999
4997
4997
4989
4977
5000
4998
5000
4996
4997
4989
4977
5000
4999
4999
4996
4997
4989
4977
5000
4999
5000
4995
4997
4989
4977
5000
4998
5000
4997
4996
4989
4977
5000
4999
4999
4997
4996
4989
4977
5000
4999
5000
4996
4996
4989
4977
5000
4998
4999
4995
4999
4989
4977
5000
4998
5000
4997
4999
4998
4965
5000
4999
4999
4997
4999
4998
4965
5000
4999
5000
4996
4999
4998
4965
5000
4999
5000
4997
4999
4997
4965
5000
4998
4995
4990
4999
4998
4977
5000
4999
4995
4990
4999
4997
4977
4997
4998
5000
4990
4997
4998
4977
5000
4995
5000
4990
4997
4998
4977
4997
4999
4999
4990
4997
4998
4977
4997
4999
5000
4990
4997
4997
4977
4997
4999
5000
4990
4999
4995
4977
4997
4999
5000
4990
4996
4998
4977
5000
4999
5000
4990
4993
4998
4977
4997
4998
4999
4990
4999
4997
4977
5000
4995
4999
4990
4999
4997
4977
5000
4998
5000
4990
4997
4995
4977
5000
4999
4999
4990
4997
4995
4977
5000
4999
5000
4990
4996
4995
4977
5000
4998
4999
4990
4996
4997
4977
4993
4998
4995
4997
4999
4998
4977
4993
4999
4995
4996
4999
4998
4977
4993
4999
4995
4997
4999
4997
4977
4993
4995
5000
4997
4997
4998
4977
4993
4999
5000
4997
4993
4998
4977
4993
4995
4999
4996
4999
4998
4977
4997
4995
4995
4996
4999
4998
4977
4993
4995
4999
4997
4999
4997
4977
4997
4995
4995
4997
4999
4997
4977
4993
4995
5000
4995
4999
4998
4977
4993
4995
5000
4996
4999
4997
4977
4993
4998
5000
4997
4997
4995
4977
4993
4999
4999
4997
4997
4995
4977
4997
4999
4995
4997
4997
4995
4977
4993
4999
5000
4996
4997
4995
4977
4993
4999
5000
4997
4996
4995
4977
4993
4998
4999
4995
4997
4998
4977
4997
4998
4995
4995
4997
4998
4977
5000
4995
4995
4995
4997
4998
4977
4993
4998
4999
4996
4997
4997
4977
4997
4998
4995
4996
4997
4997
4977
5000
4995
4995
4996
4997
4997
4977
4993
4998
4999
4996
4999
4995
4977
4997
4998
4995
4996
4999
4995
4977
5000
4995
4995
4996
4999
4995
4977
4993
4998
5000
4995
4997
4997
4977
4993
4998
5000
4995
4999
4995
4977
4993
4999
4999
4995
4997
4997
4977
4997
4999
4995
4995
4997
4997
4977
4993
4999
4999
4995
4999
4995
4977
4997
4999
4995
4995
4999
4995
4977
4993
4998
4999
4996
4996
4998
4977
4997
4998
4995
4996
4996
4998
4977
5000
4995
4995
4996
4996
4998
4977
5000
4998
4995
4996
4993
4998
4977
4993
4998
4999
4997
4996
4997
4977
4997
4998
4995
4997
4996
4997
4977
5000
4995
4995
4997
4996
4997
4977
5000
4998
4995
4997
4993
4997
4977
4993
4998
5000
4995
4996
4998
4977
4993
4998
5000
4996
4996
4997
4977
4993
4999
4999
4995
4996
4998
4977
4997
4999
4995
4995
4996
4998
4977
5000
4999
4995
4995
4993
4998
4977
4993
4999
4999
4996
4996
4997
4977
4997
4999
4995
4996
4996
4997
4977
5000
4999
4995
4996
4993
4997
4977
4993
4999
5000
4995
4996
4997
4977
5000
4998
4995
4995
4997
4995
4977
5000
4998
4995
4996
4996
4995
4977
5000
4999
4995
4995
4996
4995
4977
4992
4999
4995
4997
4999
4998
4977
4997
4995
5000
4997
4993
4998
4977
4997
4998
5000
4997
4990
4998
4977
5000
4995
5000
4997
4990
4998
4977
4997
4999
4999
4997
4990
4998
4977
4997
4999
5000
4996
4990
4998
4977
4997
4999
5000
4997
4990
4997
4977
4997
4995
4999
4997
4997
4995
4977
4997
4995
5000
4996
4997
4995
4977
4997
4995
5000
4997
4996
4995
4977
4997
4998
5000
4997
4993
4995
4977
5000
4995
5000
4997
4993
4995
4977
5000
4998
5000
4997
4990
4995
4977
4997
4999
4999
4997
4993
4995
4977
5000
4999
4999
4997
4990
4995
4977
4997
4999
5000
4996
4993
4995
4977
5000
4999
5000
4996
4990
4995
4977
4997
4995
4999
4995
4997
4997
4977
4997
4995
4999
4995
4999
4995
4977
4997
4995
4999
4995
4996
4998
4977
4997
4998
4999
4995
4993
4998
4977
5000
4995
4999
4995
4993
4998
4977
5000
4998
4999
4995
4990
4998
4977
4997
4995
4999
4996
4996
4997
4977
4997
4998
4999
4996
4993
4997
4977
5000
4995
4999
4996
4993
4997
4977
The sum_threshold parameter is introduced to demonstrate a stopping condition. The loop will break if the sum of the current combination is less than or equal to this threshold. Replace the sum_threshold and the processing logic with your actual criteria and code as needed. This example demonstrates how to incorporate a stopping condition into the process.
Kindly have a look at the following documentation links to have more information on:
- Map: https://www.mathworks.com/help/matlab/ref/containers.map.html
- Max heap: https://www.mathworks.com/matlabcentral/fileexchange/34218-heap
Hope that helps!
Balavignesh