then, try to add smaller coins until we accumulate the target amount
181007
function pickMultipleCoinsAndContinue(){
		conn.query(
			"SELECT unit, message_index, output_index, amount, address, blinding \n\
			FROM outputs \n\
			CROSS JOIN units USING(unit) \n\
			WHERE address IN(?) AND asset"+(asset ? "="+conn.escape(asset) : " IS NULL")+" AND is_spent=0 \n\
				AND sequence='good' "+confirmation_condition+"  \n\
			ORDER BY amount DESC LIMIT ?",
			[arrSpendableAddresses, constants.MAX_INPUTS_PER_PAYMENT_MESSAGE-2],
			function(rows){
				async.eachSeries(
					rows,
					function(row, cb){
						var input = row;
						objectHash.cleanNulls(input);
						required_amount += is_base*TRANSFER_INPUT_SIZE;
						addInput(input);
						// if we allow equality, we might get 0 amount for change which is invalid
						var bFound = is_base ? (total_amount > required_amount) : (total_amount >= required_amount);
						bFound ? cb('found') : cb();
					},
					function(err){
						if (err === 'found')
							onDone(arrInputsWithProofs, total_amount);
						else if (asset)
							issueAsset();
						else
							addHeadersCommissionInputs();
					}
				);
			}
		);
	}
359243
@SuppressWarnings("unchecked")
    protected final void ensureCapacity(long targetSize) {
        long capacity = capacity();
        if (targetSize > capacity) {
            inflateSpine();
            for (int i=spineIndex+1; targetSize > capacity; i++) {
                if (i >= spine.length) {
                    int newSpineSize = spine.length * 2;
                    spine = Arrays.copyOf(spine, newSpineSize);
                    priorElementCount = Arrays.copyOf(priorElementCount, newSpineSize);
                }
                int nextChunkSize = chunkSize(i);
                spine[i] = (E[]) new Object[nextChunkSize];
                priorElementCount[i] = priorElementCount[i-1] + spine[i-1].length;
                capacity += nextChunkSize;
            }
        }
    }
1051533
def _assemble_regulate_amount(self, stmt):
        """"""
        activates = isinstance(stmt, IncreaseAmount)
        relation = get_causal_edge(stmt, activates)
        self._add_nodes_edges(stmt.subj, stmt.obj, relation, stmt.evidence)
629083
private void expandAndRehash() {
    final int[] newHashSet = new int[hashSet.length * 2];
    final int bucketMask = (newHashSet.length - 1);

    for (int j = 0; j < hashSet.length; j++) {
      final int state = hashSet[j];
      if (state > 0) {
        int slot = hash(state, stateLength(state)) & bucketMask;
        for (int i = 0; newHashSet[slot] > 0;) {
          slot = (slot + (++i)) & bucketMask;
        }
        newHashSet[slot] = state;
      }
    }
    this.hashSet = newHashSet;
  }
372101
private void updateIncrementalSimonsIncrease(long inc, long now) {
		for (Simon simon : incrementalSimons.values()) {
			((CounterImpl) simon).increasePrivate(inc, now);
		}
	}
325649
public synchronized void addMicro(long micros) {
		total.addAndGet(micros);

		if (count.incrementAndGet() == 1) {
			min.set(micros);
			max.set(micros);
		} else {
			if (micros < min.get()) {
				min.set(micros);
			}
			if (micros > max.get()) {
				max.set(micros);
			}
		}
	}
285377
private void grow(int minCapacity) {
		int oldCapacity = segment.size();
		int newCapacity = oldCapacity + (oldCapacity >> 1);
		if (newCapacity - minCapacity < 0) {
			newCapacity = minCapacity;
		}
		segment = MemorySegmentFactory.wrap(Arrays.copyOf(segment.getArray(), newCapacity));
		afterGrow();
	}
408718
void add(long value) {
		if (value >= 0) {
			if (count > 0) {
				min =  Math.min(min, value);
				max = Math.max(max, value);
			} else {
				min = value;
				max = value;
			}

			count++;
			sum += value;
		}
	}
913385
private function addPending()
    {
        while (count($this->inProcess) < $this->concurrency) {

            $item = $this->getUnprocessed();

            if (empty($item)) {

                break;
            }

            $this->inProcess[$item['index']] = $item['process'];

            $item['process']->start();

            if (count($this->inProcess) >= $this->concurrency) {

                break;
            }
        }
    }
822636
public void ensureCapacity (int minCapacity)
    {
        int size = _buckets.length;
        while (minCapacity > (int) (size * _loadFactor)) {
            size *= 2;
        }
        if (size != _buckets.length) {
            resizeBuckets(size);
        }
    }
543749
def increment(key, amount = 1, options = {})
      value = Utils.to_int(load(key, options)) + amount
      store(key, value.to_s, options)
      value
    end
870537
def put(self, *args, **kwargs):
        
        self.inq.put((self._putcount, (args, kwargs)))
        self._putcount += 1
1348733
def _increment_attempt(self, mongo_id):
        
        entry = self._database.lis_outcome_queue.find_one_and_update({"_id": mongo_id}, {"$inc": {"nb_attempt": 1}})

        self._add_to_queue(entry)
854095
private final void growIfNeeded(int minimumDesired) {
        if (buffer.b().remaining() < minimumDesired) {
            // Compute the size of the new buffer
            int newCapacity = buffer.b().capacity();
            int newRemaining = newCapacity - buffer.b().position();
            while (newRemaining < minimumDesired) {
                newRemaining += newCapacity;
                newCapacity *= 2;
            }

            // Allocate and copy
            BBContainer next;
            if (isDirect) {
                next = DBBPool.allocateDirect(newCapacity);
            } else {
                next = DBBPool.wrapBB(ByteBuffer.allocate(newCapacity));
            }
            buffer.b().flip();
            next.b().put(buffer.b());
            assert next.b().remaining() == newRemaining;
            buffer.discard();
            buffer = next;
            if (callback != null) callback.onBufferGrow(this);
            assert(buffer.b().order() == ByteOrder.BIG_ENDIAN);
        }
    }
531448
def accumulate(self, buf):
        ''''''
        accum = self.crc
        for b in buf:
            tmp = b ^ (accum & 0xff)
            tmp = (tmp ^ (tmp<<4)) & 0xFF
            accum = (accum>>8) ^ (tmp<<8) ^ (tmp<<3) ^ (tmp>>4)
        self.crc = accum
605429
public void add(long n)
    {
        int index = Arrays.binarySearch(bucketOffsets, n);
        if (index < 0)
        {
            // inexact match, take the first bucket higher than n
            index = -index - 1;
        }
        // else exact match; we're good
        buckets.incrementAndGet(index);
    }
758172
protected function increaseCapacity()
    {
        $this->capacity = $this->square(max(count($this) + 1, $this->capacity * $this->getGrowthFactor()));
    }