#pragma once
#include <algorithm>
#include <string>
#include <vector>

class Set {
 public:
    Set() = default;
    explicit Set(const std::vector<int64_t>& vector) {
        for (auto i : vector)
            Add(i);
    }
    Set Union(const Set& other) const {
        Set set(vector);
        for (auto i : other.vector)
            if (!Contains(i))
                set.Add(i);
        return set;
    }
    Set Intersection(const Set& other) const {
        Set set(vector);
        for (auto i : vector)
            if (!other.Contains(i))
                set.Remove(i);
        return set;
    }
    Set Difference(const Set& other) const {
        Set set(vector);
        for (auto i : other.vector)
            if (Contains(i))
                set.Remove(i);
        return set;
    }
    Set SymmetricDifference(const Set& other) const {
        Set first = Union(other);
        Set second = Intersection(other);
        return first.Difference(second);
    }
    void Add(int64_t n) {
        if (!Contains(n)) {
            vector.push_back(n);
            std::sort(vector.begin(), vector.end());
        }
    }
    void Remove(int64_t n) {
        if (Contains(n))
            vector.erase(std::find(vector.begin(), vector.end(), n));
        }
        bool Contains(int64_t n) const {
            auto i = std::find(vector.begin(), vector.end(), n);
            if (i != vector.end())
                return true;
            return false;
        }
        std::vector < int64_t > Data() const {
        return vector;
    }

 private:
    std::vector < int64_t > vector;
};