Language: C++

#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int maxsize(0);
	vector<int> input;

	while (1)
	{
		int tmp;

		cin >> tmp;

		(maxsize < tmp) ? (maxsize = tmp) : (0);
	}

	vector<int> prime, ans;

	for (int i(1); i <= maxsize; ++i)
	{
		for (vector<int>::iterator i2(prime.begin()), n2(prime.end()); i2 != n2; ++i2)
		{
			if (i % *i2 == 0)
			{
				prime.push_back(i);
				if (i2 != prime.begin())
				{
					if (*(--i2) == i)
					{
						ans.push_back(i);
					}
				}
				break;
			}
		}
	}

	for (vector<int>::iterator i(input.begin()), n(input.end()); i != n; ++i)
	{
		int out(*i);

		for (vector<int>::iterator i2(ans.rbegin()), n2(ans.rend()); i2 != n2; ++i2)
		{
			if (*i2 <= out)
			{
				cout << (*i2 - 2) << ' ' << (*i2) << endl;
			}
		}
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:59: error: no matching function for call to '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::__normal_iterator(std::vector<int>::reverse_iterator)'
   43 |                 for (vector<int>::iterator i2(ans.rbegin()), n2(ans.rend()); i2 != n2; ++i2)
      |                                                           ^
In file included from /usr/include/c++/14/string:48,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:1074:9: note: candidate: 'template<class _Iter, class> __gnu_cxx::__normal_iterator<_Iterator, _Container>::__normal_iterator(const __gnu_cxx::__normal_iterator<_Iter, _Container>&) [with <template-parameter-2-2> = _Iter; _Iterator = int*; _Container = std::vector<int>]'
 1074 |         __normal_iterator(const __normal_iterator<_Iter, _Container>& __i)
      |         ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1074:9: note:   template argument deduction/substitution failed:
a.cc:43:59: note:   'std::vector<int>::reverse_iterator' {aka 'std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >'} is not derived from 'const __gnu_cxx::__normal_iterator<_Iter, std::vector<int> >'
   43 |                 for (vector<int>::iterator i2(ans.rbegin()), n2(ans.rend()); i2 != n2; ++i2)
      |                                                           ^
/usr/include/c++/14/bits/stl_iterator.h:1067:7: note: candidate: '__gnu_cxx::__normal_iterator<_Iterator, _Container>::__normal_iterator(const _Iterator&) [with _Iterator = int*; _Container = std::vector<int>]'
 1067 |       __normal_iterator(const _Iterator& __i) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1067:42: note:   no known conversion for argument 1 from 'std::vector<int>::reverse_iterator' {aka 'std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >'} to 'int* const&'
 1067 |       __normal_iterator(const _Iterator& __i) _GLIBCXX_NOEXCEPT
      |                         ~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_iterator.h:1063:26: note: candidate: 'constexpr __gnu_cxx::__normal_iterator<_Iterator, _Container>::__normal_iterator() [with _Iterator = int*; _Container = std::vector<int>]'
 1063 |       _GLIBCXX_CONSTEXPR __normal_iterator() _GLIBCXX_NOEXCEPT
      |                          ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1063:26: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/stl_iterator.h:1038:11: note: candidate: 'constexpr __gnu_cxx::__normal_iterator<int*, std::vector<int> >::__normal_iterator(const __gnu_cxx::__normal_iterator<int*, std::vector<int> >&)'
 1038 |     class __normal_iterator
      |           ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1038:11: note:   no known conversion for argument 1 from 'std::vector<int>::reverse_iterator' {aka 'std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >'} to 'const __gnu_cxx::__normal_iterator<int*, std::vector<int> >&'
/usr/include/c++/14/bits/stl_iterator.h:1038:11: note: candidate: 'constexpr __gnu_cxx::__normal_iterator<int*, std::vector<int> >::__normal_iterator(__gnu_cxx::__normal_iterator<int*, std::vector<int> >&&)'
/usr/include/c++/14/bits/stl_iterator.h:1038:11: note:   no known conversion for argument 1 from 'std::vector<int>::reverse_iterator' {aka 'std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >'} to '__gnu_cxx::__normal_iterator<int*, std::vector<int> >&&'
a.cc:43:75: error: no matching function for call to '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::__normal_iterator(std::vector<int>::reverse_iterator)'
   43 |                 for (vector<int>::iterator i2(ans.rbegin()), n2(ans.rend()); i2 != n2; ++i2)
      |                                                                           ^
/usr/include/c++/14/bits/stl_iterator.h:1074:9: note: candidate: 'template<class _Iter, class> __gnu_cxx::__normal_iterator<_Iterator, _Container>::__normal_iterator(const __gnu_cxx::__normal_iterator<_Iter, _Container>&) [with <template-parameter-2-2> = _Iter; _Iterator = int*; _Container = std::vector<int>]'
 1074 |         __normal_iterator(const __normal_iterator<_Iter, _Container>& __i)
      |         ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1074:9: note:   template argument deduction/substitution failed:
a.cc:43:75: note:   'std::vector<int>::reverse_iterator' {aka 'std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >'} is not derived from 'const __gnu_cxx::__normal_iterator<_Iter, std::vector<int> >'
   43 |                 for (vector<int>::iterator i2(ans.rbegin()), n2(ans.rend()); i2 != n2; ++i2)
      |                                                                           ^
/usr/include/c++/14/bits/stl_iterator.h:1067:7: note: candidate: '__gnu_cxx::__normal_iterator<_Iterator, _Container>::__normal_iterator(const _Iterator&) [with _Iterator = int*; _Container = std::vector<int>]'
 1067 |       __normal_iterator(const _Iterator& __i) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1067:42: note:   no known conversion for argument 1 from 'std::vector<int>::reverse_iterator' {aka 'std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >'} to 'int* const&'
 1067 |       __normal_iterator(const _Iterator& __i) _GLIBCXX_NOEXCEPT
      |                         ~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_iterator.h:1063:26: note: candidate: 'constexpr __gnu_cxx::__normal_iterator<_Iterator, _Container>::__normal_iterator() [with _Iterator = int*; _Container = std::vector<int>]'
 1063 |       _GLIBCXX_CONSTEXPR __normal_iterator() _GLIBCXX_NOEXCEPT
      |                          ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1063:26: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/stl_iterator.h:1038:11: note: candidate: 'constexpr __gnu_cxx::__normal_iterator<int*, std::vector<int> >::__normal_iterator(const __gnu_cxx::__normal_iterator<int*, std::vector<int> >&)'
 1038 |     class __normal_iterator
      |           ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1038:11: note:   no known conversion for argument 1 from 'std::vector<int>::reverse_iterator' {aka 'std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >'} to 'const __gnu_cxx::__normal_iterator<int*, std::vector<int> >&'
/usr/include/c++/14/bits/stl_iterator.h:1038:11: note: candidate: 'constexpr __gnu_cxx::__normal_iterator<int*, std::vector<int> >::__normal_iterator(__gnu_cxx::__normal_iterator<int*, std::vector<int> >&&)'
/usr/include/c++/14/bits/stl_iterator.h:1038:11: note:   no known conversion for argument 1 from 'std::vector<int>::reverse_iterator' {aka 'std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >'} to '__gnu_cxx::__normal_iterator<int*, std::vector<int> >&&'