Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int x, n;
    vector<int> seq;
    cin >> x >> n;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        seq.push_back(tmp);
    }
    auto result = find(seq.begin(), seq.end(), x);
    if (result == seq.end()) {
        cout << x << endl;
        return 0;
    }
    
    for (int i = 0; i < n + 2; i++) {
        auto result1 = find(seq.begin(), seq.end(), x - (i + 1));
        auto result2 = find(seq.begin(), seq.end(), x + (i + 1));
        if (result1 == seq.end()) {
            cout << x - (i + 1) << endl;
            break;
        }
        if (result2 == seq.end()) {
            cout << x + (i + 1) << endl;
            break;
        }
    }
    return 0;
    
}



Compiler output:
a.cc: In function 'int main()':
a.cc:16:23: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   16 |     auto result = find(seq.begin(), seq.end(), x);
      |                   ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:16:23: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   16 |     auto result = find(seq.begin(), seq.end(), x);
      |                   ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:23:28: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int)'
   23 |         auto result1 = find(seq.begin(), seq.end(), x - (i + 1));
      |                        ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:23:28: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   23 |         auto result1 = find(seq.begin(), seq.end(), x - (i + 1));
      |                        ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:24:28: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int)'
   24 |         auto result2 = find(seq.begin(), seq.end(), x + (i + 1));
      |                        ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:24:28: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   24 |         auto result2 = find(seq.begin(), seq.end(), x + (i + 1));
      |                        ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~