Suppose that in the final coloring there will be yellow consecutive segments of lengths c_1, c_2, \ldots, b_m. Consider some segment, it was formed from some subset of operations, suppose with length b_1, b_2, \ldots, b_s. It's clear that from segments b_1, b_2, \ldots, b_s we can form any yellow segment of length from max(b_1, b_2, \ldots, b_s) to b_1 + b_2 + \ldots + b_s.
How would we check if we could arrive to these lengths c_1, c_2, \ldots, c_m then? We would look at all possible partitions of the set \{1, 2, \ldots, k\} into nonempty parts (where order of these groups matters), and for each of them we would see if corresponding c_i lies between corresponding max and corresponding sum.
This means that for checking we don't care precisely about values of c_i, we care only about their position relative to all possible maxes and all sums. So, let's write all these bounds (sums of all subsets and values a_i-1), sort them, obtaining some d_1, d_2, \ldots, d_t, and solve the following problem:
How many ways are there to select yellow segments so that the length of the -th one is in the range [d_{i_j}+1, d_{i_j+1}]? If we can solve this problem, then we will iterate through all possible choices of indices i_j (there are less than of them, which gives at most 20^4 configurations in total), and for each choice, we will check if we can obtain it from some partitioning of the set \{1, 2, \ldots, k\} into nonempty parts.
So, from now on we will be focusing on the following problem:
Main Problem: How many ways are there to select yellow segments so that the length of the -th one is in the range [l_i, r_i]?
First, let's solve the following:
Subproblem: How many ways are there to select yellow segments so that the length of the -th one is at least [l_i]?
This is an easy problem. Indeed, let's subtract l_i-1 from for each , reducing the problem to selecting yellow segments of length at least on the strip of length n_1. It's the same as selecting distinct ends of the segments, which is C(n_1+1, 2m).
Now, just do inclusion-exclusion, substituting r_i or l_{i-1}, and solving the subproblem above 2^m times.