#include #include #include #include struct TCmp { template static inline bool Compare(const T& l, const T& r) { return l.N < r.N; } template static inline bool Compare(const T& l, ui8 r) { return l.N < r; } template static inline bool Compare(ui8 l, const T& r) { return l < r.N; } }; class TNode: public TRbTreeItem { public: inline TNode(ui8 n) noexcept : N(n) { } ui8 N; }; using TTree = TRbTree; extern "C" int LLVMFuzzerTestOneInput(const ui8* data, size_t size) { TDeque records; const ui8 half = 128u; TTree tree; for (size_t i = 0; i < size; ++i) { if (data[i] / half == 0) { records.emplace_back(data[i] % half); tree.Insert(&records.back()); } else { auto* ptr = tree.Find(data[i] % half); if (ptr != nullptr) { tree.Erase(ptr); } } auto check = [](const TNode& node) { size_t childrens = 1; if (node.Left_) { Y_ENSURE(static_cast(node.Left_)->N <= node.N); childrens += node.Left_->Children_; } if (node.Right_) { Y_ENSURE(node.N <= static_cast(node.Right_)->N); childrens += node.Right_->Children_; } Y_ENSURE(childrens == node.Children_); }; tree.ForEach(check); } return 0; }