#include <iostream>
#include <iterator>
#include <numeric>
#include <vector>
#include <algorithm>
template <typename T>
struct min
{
typedef T element_type;
min(int& min) : min_(min) { }
min& operator *() { return *this; }
min& operator=(const T& t)
{
if (first_)
min_ = t, first_ = false;
else if (t < min_)
min_ = t;
}
min& operator++() { return *this; }
bool first_ = true;
T& min_;
};
template <typename Iterator>
struct skip_take
{
skip_take(Iterator i, size_t skip, size_t take = size_t(-1))
: i_(i), skip_(skip), take_(take)
{ }
skip_take& operator *() { return *this; }
skip_take& operator=(const typename Iterator::element_type& t)
{
if (skip_ == 0 && take_)
*i_ = t;
}
skip_take& operator++()
{ if (skip_) --skip_; else if (take_) --take_, ++i_; return *this; }
Iterator& i_;
size_t skip_, take_;
};
int main()
{
std::vector<int> numbers = { 10, 1, 43, 59, 78, 46, 63, 12 };
int result;
std::adjacent_difference(numbers.begin(), numbers.end(),
skip_take<min<int>>(min<int>(result), 1));
std::cout << result << '\n';
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8aXRlcmF0b3I+CiNpbmNsdWRlIDxudW1lcmljPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKdGVtcGxhdGUgPHR5cGVuYW1lIFQ+CnN0cnVjdCBtaW4KewoJdHlwZWRlZiBUIGVsZW1lbnRfdHlwZTsKICAgIG1pbihpbnQmIG1pbikgOiBtaW5fKG1pbikgeyB9CiAgICBtaW4mIG9wZXJhdG9yICooKSB7IHJldHVybiAqdGhpczsgfQogICAgbWluJiBvcGVyYXRvcj0oY29uc3QgVCYgdCkKICAgIHsKICAgIAlpZiAoZmlyc3RfKQogICAgICAgICAgICBtaW5fID0gdCwgZmlyc3RfID0gZmFsc2U7CiAgICAgICAgZWxzZSBpZiAodCA8IG1pbl8pCiAgICAgICAgICAgIG1pbl8gPSB0OwogICAgfQogICAgbWluJiBvcGVyYXRvcisrKCkgeyByZXR1cm4gKnRoaXM7IH0KICAgIGJvb2wgZmlyc3Rf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