#include <iostream>
#include <algorithm>
#include <vector>

template <class It, class Less>
bool almost_increasing_seq(It begin, It end, Less cmp) {
  const auto lbound = std::adjacent_find(begin, end, std::not2(cmp));
  if (lbound == end) {
    return true; // already sorted
  }
  const auto rbound = lbound + 1;
  if (rbound == end || (rbound + 1) == end) {
    return true; // can just drop the last one
  }
  return std::adjacent_find(rbound, end, std::not2(cmp)) == end &&
         (lbound == begin || cmp(*lbound, *(rbound + 1)) ||
          cmp(*(lbound - 1), *rbound));
}

bool almost_increasing_vector(const std::vector<int>& ints) {
  return almost_increasing_seq(ints.begin(), ints.end(), std::less<int>());
}

int main() {
  std::cout << "[] => " << almost_increasing_vector({}) << "\n";
  std::cout << "[0, 1] => " << almost_increasing_vector({0, 1}) << "\n";
  std::cout << "[1, 0] => " << almost_increasing_vector({1, 0}) << "\n";
  std::cout << "[0, 1, 2, 3] => " << almost_increasing_vector({0, 1, 2, 3}) << "\n";
  std::cout << "[5, 1, 2, 3] => " << almost_increasing_vector({5, 1, 2, 3}) << "\n";
  std::cout << "[1, 2, 0, 3] => " << almost_increasing_vector({1, 2, 0, 3}) << "\n";
  std::cout << "[1, 5, 2, 3] => " << almost_increasing_vector({1, 5, 2, 3}) << "\n";
  std::cout << "[1, 5, 0, 2] => " << almost_increasing_vector({1, 5, 0, 2}) << "\n";
  std::cout << "[3, 2, 1, 0] => " << almost_increasing_vector({3, 2, 1, 0}) << "\n";
  return 0;
}
