#include <iostream>
#include <vector>
class Set{
public:
std :: vector<int64_t> c;
Set(std::vector<int64_t>& other) {
this->c = other;
}
Set() {}
void deleteEl(int i) {
for (int j = i + 1; j < c.size(); j++) {
c[j-1] = c[j];
}
this->c.pop_back();
}
void Add(int64_t value) {
for (int i = 1; i < c.size(); i++) {
while (i < c.size() && c[i] == c[i-1]) {
deleteEl(i);
}
}
if (!this->Contains(value))
this->c.push_back(value);
}
void Remove(int64_t value) {
for (int j = 1; j < c.size(); j++) {
while (j < c.size() && c[j] == c[j-1]) {
deleteEl(j);
}
}
int i;
for (i = 0; i < this->c.size(); i++) {
if (this->c[i] == value) break;
}
if (i == this->c.size()) {
return;
}
deleteEl(i);
}
bool Contains(int64_t value) const {
int i;
for (i = 0; i < this->c.size(); i++) {
if (value == this->c[i]) return true;
}
return false;
}
Set Union(const Set& other) const {
Set NewSet(this->c);
bool flag = false;
for (int i = 0; i < other.c.size(); i++) {
flag = false;
for (int j = 0; j < c.size() && !flag; j++) {
if (other.c[i] == c[j]) {
flag = true;
}
}
if (!flag) {
NewSet.c.push_back(other.c[i]);
}
}
return NewSet;
}
Set Intersection(const Set& other) const {
std :: vector<int64_t> NewVector;
for (int i = 0; i < this->c.size(); i++) {
for (int j = 0; j < other.c.size(); j++)
if (this->c[i] == other.c[j]) NewVector.push_back(this->c[i]);
}
Set NewSet(NewVector);
return NewSet;
}
Set Difference(const Set& other) const {
std :: vector<int64_t> NewVector;
bool flag = false;
for (int i = 0; i < this->c.size(); i++) {
flag = false;
for (int j = 0; j < other.c.size() && !flag; j++) {
if (other.c[j] == c[i]) {
flag = true;
}
}
if (!flag) {
NewVector.push_back(c[i]);
}
}
Set NewSet(NewVector);
return NewSet;
}
Set SymmetricDifference(const Set& other) const {
Set set1 = Difference(other);
Set set2 = other.Difference(Set(c));
return set1.Union(set2);
/*
std :: vector<int64_t> NewVector;
for(int i = 0; i < this->c.size(); i++){
for(int j = 0; j < other.c.size(); j++)
if(this->c[i]!=other.c[j]) NewVector.push_back(this->c[i]);
}
for(int j = 0; j < other.c.size(); j++){
for(int i = 0; i < this->c.size(); i++)
if(other.c[j] != this->c[i]) NewVector.push_back(other.c[j]);
}
Set NewSet(NewVector);
return NewSet;*/
}
std :: vector<int64_t> Data() const {
std :: vector<int64_t> NewVector;
NewVector = this->c;
return NewVector;
}
};