A set stores unique elements in sorted order automatically. When you add values, it removes duplicates and keeps everything sorted from smallest to largest without any extra work. In C++, write set s; to create an empty set of integers.
Insert elements with s.insert(5). Adding the same value twice has no effect since sets don't allow duplicates. Sets support fast membership testing, insertion, and deletion, all in time.
Use them whenever you need to track distinct values or check whether elements exist quickly.