#include <string>
#include <iostream>
#include <iomanip>
#include <list>
#include <chrono>

class muTimer
{
    using Clock = std::chrono::high_resolution_clock;
    bool active = false;
    Clock::duration   duration_;
    Clock::time_point start_ = Clock::now(), stop_ = Clock::now();

    muTimer(const muTimer&)             = delete;
    muTimer& operator=(const muTimer&)  = delete;
public:
    using ns       = std::chrono::nanoseconds;
    using mks      = std::chrono::microseconds;
    using ms       = std::chrono::milliseconds;
    muTimer() { reset(); start(); }
    ~muTimer() = default;
    muTimer& reset()
    {
        duration_ = std::chrono::nanoseconds(0);
        active    = false;
        return *this;
    }
    muTimer& start()
    {
        if (!active)
        {
            start_ = Clock::now();
            active = true;
        }
        return *this;
    }
    muTimer& stop()
    {
        if (active)
        {
            stop_      = Clock::now();
            duration_ += stop_ - start_;
            active     = false;
        }
        return *this;
    }
    template<typename T = mks>
        unsigned long long duration()
    {
        return static_cast<unsigned long long>
            (std::chrono::duration_cast<T>(stop_-start_).count());
    }
};


using namespace std;

void kill(list<int>& l, size_t count)
{
    list<int> tmp;
    auto it = l.begin();
    advance(it,count);
    tmp.splice(tmp.begin(),l,l.begin(),it);
}


int main([[maybe_unused]] int argc,
         [[maybe_unused]] const char * argv[])
{
    list<int> L, M;
    for(int i = 0; i < 1000000; ++i) { L.push_back(i); M.push_back(i); }

    {
        muTimer mt;
        kill(L,5000);
        mt.stop();
        cout << "Kill  for " << mt.duration<>() << "mks\n";
    }
    {
        muTimer mt;
        auto it = M.begin();
        advance(it,5000);
        M.erase(M.begin(),it);
        mt.stop();
        cout << "Erase for " << mt.duration<>() << "mks\n";
    }
    cout << (L == M) << endl;
}
