#include <vector>
#include <algorithm>
using std::copy;
using std::vector;
using std::find;
using std::sort;
class Set {
public:
Set(vector<int64_t> list)
vector<int64_t> Data()
Add(int64_t value)
Remove(int64_t value)
bool Contains(int64_t value)
Set Union(Set other)
Set Intersection(Set other)
Set Difference(Set other)
Set SymmetricDifference(Set other)
private:
vector<int64_t> list;
int Index(int64_t value)
}
Set::Set(vector<int64_t> list) {
copy(list.begin(), list.end(), this->list);
}
vector<int64_t> Set::Data() { return this->list; }
auto Set::Index(int64_t value) {
vector<int64_t>::iterator idx = find(this->list.begin(), this->list.end(), value);
return idx;
}
Set::Add(int64_t value) {
this->list.pushback(value)
}
Set::Remove(int64_t value) {
this->list.erase(this->Index(value));
}
Set::Union(Set other) {
vector<int64_t> res;
res.reserve(this->list.size() + this->list.size());
res.insert(res.end(), this->list.begin(), this->list.end() );
res.insert(res.end(), other.Data().begin(), other.Data().end());
return Set(res);
}
Set::Intersection(Set other) {
vector<int64_t> res;
for (auto k: other.Data())
if (this->Contains(k))
res.pushback(k);
sort(res);
return Set(res);
}
Set::Difference(Set other) {
vector<int64_t> res;
for (auto k: other.Data())
if (!this->Contains(k))
res.pushback(k);
sort(res);
return Set(res);
}
Set::SymmetricDifference(Set other) {
vector<int64_t> res;
for (auto k: other.Data())
if (!this->Contains(k))
res.pushback(k);
for (auto k: this->list)
if (!other.Contains(k))
res.pushback(k);
sort(res);
return Set(res);
}
bool Set::Contains(int64_t value) {
if (this->Index(value) == this->list.end())
return false;
return true;
}