#include <iostream>
#include <set>
#include <string>
int main() {
std::multiset<int> numbers = {5, 2, 8, 2, 1, 9, 3, 7, 3};
// Inserting elements
numbers.insert(4);
numbers.insert(2); // Duplicate allowed
// Printing the multiset
std::cout << "Numbers in the multiset:" << std::endl;
for (const auto& num : numbers) {
std::cout << num << " ";
}
std::cout << std::endl;
// Counting occurrences
std::cout << "Count of 2: " << numbers.count(2) << std::endl;
// Finding elements
auto range = numbers.equal_range(3);
std::cout << "Elements equal to 3: ";
for (auto it = range.first; it != range.second; ++it) {
std::cout << *it << " ";
}
std::cout << std::endl;
// Removing an element
numbers.erase(numbers.find(3)); // Removes only one instance of 3
// Size of the multiset
std::cout << "Number of elements: " << numbers.size() << std::endl;
return 0;
}