Language: C++

#include <iostream>
#include <vector>
using namespace std;
int X,ans = 0,s = 1;
vector<int > x;
int solve(){
	while(true){
		vector<int > xx;
		for (int i = 0; i < x.size(); ++i)
		{
			if(find(xx.begin(), xx.end(),x[i]+s) == xx.end())xx.push_back(x[i]+s);
			if(find(xx.begin(), xx.end(),x[i]) == xx.end())xx.push_back(x[i]);
			if(find(xx.begin(), xx.end(),x[i]-s) == xx.end())xx.push_back(x[i]-s);
			if(x[i]+s == X || x[i] == X || x[i]-s == X)return s;
		}
		x = xx;
		s++;
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin >> X;
	x.push_back(0);
	ans = solve();
	cout << ans << "\n";
	return 0;
}

Compiler output:
a.cc: In function 'int solve()':
a.cc:11:32: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   11 |                         if(find(xx.begin(), xx.end(),x[i]+s) == xx.end())xx.push_back(x[i]+s);
      |                            ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:11:32: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   11 |                         if(find(xx.begin(), xx.end(),x[i]+s) == xx.end())xx.push_back(x[i]+s);
      |                            ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:12:32: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   12 |                         if(find(xx.begin(), xx.end(),x[i]) == xx.end())xx.push_back(x[i]);
      |                            ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:12:32: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   12 |                         if(find(xx.begin(), xx.end(),x[i]) == xx.end())xx.push_back(x[i]);
      |                            ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:13:32: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   13 |                         if(find(xx.begin(), xx.end(),x[i]-s) == xx.end())xx.push_back(x[i]-s);
      |                            ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:13:32: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   13 |                         if(find(xx.begin(), xx.end(),x[i]-s) == xx.end())xx.push_back(x[i]-s);
      |                            ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~