#include <random>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>

template <typename container_type>
void unique_sort(container_type & c)
{
    auto begin = std::begin(c);
    auto end = std::end(c);

    std::sort(begin, end);
    c.erase(std::unique(begin, end), end);
}

std::vector<std::string> randomized_string_vector(std::size_t elements)
{
    std::mt19937 rng((std::random_device())());
    std::uniform_int_distribution<int> alpha('a', 'e');

    std::vector <std::string> v;
    for (unsigned i = 0; i < elements; ++i)
    {
        std::string element;
        for (unsigned j = 0; j < 2; ++j)
            element += (char)alpha(rng);
        v.emplace_back(std::move(element));
    }

    return v;
}

template <typename container_type>
void print(const container_type& c)
{
    const unsigned perLine = 10;
    unsigned count = 0;

    for (const auto& e : c)
    {
        std::cout << std::setw(80 / perLine) << e;
        if (++count == perLine)
        {
            std::cout << '\n';
            count = 0;
        }
    }
    std::cout << '\n';
}

int main()
{
    auto v = randomized_string_vector(40);
    std::cout << "original vector size: " << v.size() << '\n';
    std::cout << "original vector:\n";
    print(v);

    unique_sort(v);
    std::cout << "vector size after sort: " << v.size() << '\n';
    std::cout << "vector after sort:\n";
    print(v);
}
