Language: C++

#include <iostream>
#include <vector>
using namespace std;

int main() {
  vector<int> p;
  int X, N;
  cin >> X >> N;
  for (int i = 0; i < N; i++) {
    int pi;
    cin >> pi;
    p.back(pi);
  }
  for (int a = 0; a < 101; a++) {
    if (vector_finder(p, N-a)) {
      count << N-a << endl;
      return 0;
    } else if (vector_finder(p, N+a)) {
      count << N+a << endl;
      return 0;
    }
  }
}

bool vector_finder(vector<int> vec, int number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance( vec.begin(), itr );
  if (index != vec.size()) {
    return true;
  }
  else {
    return false;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:11: error: no matching function for call to 'std::vector<int>::back(int&)'
   12 |     p.back(pi);
      |     ~~~~~~^~~~
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:1235:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::back() [with _Tp = int; _Alloc = std::allocator<int>; reference = int&]'
 1235 |       back() _GLIBCXX_NOEXCEPT
      |       ^~~~
/usr/include/c++/14/bits/stl_vector.h:1235:7: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/stl_vector.h:1247:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::back() const [with _Tp = int; _Alloc = std::allocator<int>; const_reference = const int&]'
 1247 |       back() const _GLIBCXX_NOEXCEPT
      |       ^~~~
/usr/include/c++/14/bits/stl_vector.h:1247:7: note:   candidate expects 0 arguments, 1 provided
a.cc:15:9: error: 'vector_finder' was not declared in this scope
   15 |     if (vector_finder(p, N-a)) {
      |         ^~~~~~~~~~~~~
a.cc:16:7: error: 'count' was not declared in this scope
   16 |       count << N-a << endl;
      |       ^~~~~
a.cc:19:7: error: 'count' was not declared in this scope
   19 |       count << N+a << endl;
      |       ^~~~~
a.cc: In function 'bool vector_finder(std::vector<int>, int)':
a.cc:26:18: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   26 |   auto itr = find(vec.begin(), vec.end(), number);
      |              ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:26:18: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   26 |   auto itr = find(vec.begin(), vec.end(), number);
      |              ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~