Language: C++

#include <iostream>
#include <cmath>
#include <list>

using namespace std;

bool
prime(int n)
{
        if (n == 1) {
                return false;
        }
        if (n == 2 || n == 3) {
                return true;
        }
        if (n % 2 == 0) {
                return false;
        }
        double sqrtn = sqrt(n);
        for (int i = 3; i <= (int)sqrtn; i += 2) {
                if (n % i == 0) {
                        return false;
                }
        }
        return true;
}

void
prime_list(list<int> &p)
{
        list<int> b;
        for (int i = 2; i < 100001; ++i) {
                b.push_back(i);
        }
        int end = sqrt(100001);
        for (int i = 2; i < end; ++i) {
                int s = b.front();
                b.pop_front();
                if (prime(s)) {
                        p.push_back(s);
                }
                for (list<int>::iterator it = b.begin(); it != b.end();) {
                        if (*it % s == 0) {
                                it = b.erase(it);
                        }
                        else {
                                ++it;
                        }
                }
        }
}

int
main()
{
        int n;
        cin >> n;
        int l[n], r[n];
        for (int i = 0; i < n; ++i) {
                cin >> l[i] >> r[i];
        }

        list<int> p;
        prime_list(p);

        for (int i = 0; i < n; ++i) {
                int cnt = 0;
                for (int j = l[i]; j <= r[i]; j += 2) {
                        int n = (j + 1) / 2;
                        if (find(p.begin(), p.end(), n) != p.end()) {
                                if (find(p.begin(), p.end(), j) != p.end()) {
                                        ++cnt;
                                }
                        }
                }
                cout << cnt << endl;
        }
        return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:70:33: error: no matching function for call to 'find(std::__cxx11::list<int>::iterator, std::__cxx11::list<int>::iterator, int&)'
   70 |                         if (find(p.begin(), p.end(), n) != p.end()) {
      |                             ~~~~^~~~~~~~~~~~~~~~~~~~~~~
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:70:33: note:   'std::_List_iterator<int>' is not derived from 'std::istreambuf_iterator<_CharT>'
   70 |                         if (find(p.begin(), p.end(), n) != p.end()) {
      |                             ~~~~^~~~~~~~~~~~~~~~~~~~~~~
a.cc:71:41: error: no matching function for call to 'find(std::__cxx11::list<int>::iterator, std::__cxx11::list<int>::iterator, int&)'
   71 |                                 if (find(p.begin(), p.end(), j) != p.end()) {
      |                                     ~~~~^~~~~~~~~~~~~~~~~~~~~~~
/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:71:41: note:   'std::_List_iterator<int>' is not derived from 'std::istreambuf_iterator<_CharT>'
   71 |                                 if (find(p.begin(), p.end(), j) != p.end()) {
      |                                     ~~~~^~~~~~~~~~~~~~~~~~~~~~~