https://bugs.openldap.org/show_bug.cgi?id=10236
--- Comment #2 from aalekseyev@janestreet.com --- (In reply to Howard Chu from comment #1)
LLM-generated code is by definition plagiarized from unknown numbers of authors.
Welp, that's fair enough, although so is everything produced by my brain.
Let's try to find references with free enough license to resolve the liability of having to reimplement-but-not-plagiarize this code.
An MIT-licensed k-way-merge in Python can be seen here: https://github.com/amitrajitbose/Competitive_Programming/blob/master/Heap/me....
A heapify definition can be seen on Wikipedia (with indexes off-by-1): https://en.wikipedia.org/wiki/Binary_heap#Heap_implementation, search for "Max-Heapify".
It even mentions the optimization idea that I thought was cute in GPT-generated code:
The down-heap operation (without the preceding swap) can also be used to modify the value of the root, even when an element is not being deleted.
(I might have done pop followed by push naively)