Now add the total budget tracking after the try_close call:


   732→                        bt_rings.push_back(std::move(r));
   733→                        continue;
   734→                    }
   735→                }
   736→                bt_used[si] = false;
   737→            }
   738→
   739→            // Keep whichever pass produced more rings
   740→            if (bt_rings.size() > rings.size()) {
   741→                rings = std::move(bt_rings);

                        bt_rings.push_back(std::move(r));
                        continue;
                    }
                }
                bt_used[si] = false;
            }

            // Keep whichever pass produced more rings
            if (bt_rings.size() > rings.size()) {
                rings = std::move(bt_rings);


Edit

                bt_used[si] = false;
            }

                bt_used[si] = false;
                total_bt_calls += bt2.calls;
            }