Language: C++

#include <iostream>
#include <set>
using namespace std;
int main(){
    /*エラトステネスの篩----------------*/
    int i, j, k=0;
    int n[100000], p[10000];
    set<int> p_like_2017;
    for(i=0; i<100000; i++) n[i] = i;

    for(i=2; i<333; i++)
        if(n[i])
            for(j=2; i*j<100000; j++)
                n[i*j] = 0;

    for(i=2; i<100000; i++)
        if(n[i])
            p[k++] = i;
    /*--------------------------------*/

    for(i=1; i<k; i++){
        if(n[(p[i]+1)/2]){
            p_like_2017.insert(p[i]);
        }
    }


    int Q, l, r;
    cin >> Q;
    for(i=0; i<Q; i++){
        cin >> l >> r;
        decltype(p_like_2017)::iterator it = s.lower_bound(l);
        decltype(p_like_2017)::iterator last = s.upper_bound(r);
        decltype(p_like_2017)::iterator count = last-it+1;
        cout << (int)count << endl;
    }

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:46: error: 's' was not declared in this scope
   32 |         decltype(p_like_2017)::iterator it = s.lower_bound(l);
      |                                              ^
a.cc:34:53: error: no match for 'operator-' (operand types are 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} and 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'})
   34 |         decltype(p_like_2017)::iterator count = last-it+1;
      |                                                 ~~~~^~~
      |                                                 |    |
      |                                                 |    _Rb_tree_const_iterator<[...]>
      |                                                 _Rb_tree_const_iterator<[...]>
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:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  618 |     operator-(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note:   template argument deduction/substitution failed:
a.cc:34:54: note:   'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::reverse_iterator<_Iterator>'
   34 |         decltype(p_like_2017)::iterator count = last-it+1;
      |                                                      ^~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1790 |     operator-(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note:   template argument deduction/substitution failed:
a.cc:34:54: note:   'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::move_iterator<_IteratorL>'
   34 |         decltype(p_like_2017)::iterator count = last-it+1;
      |                                                      ^~
a.cc:35:17: error: invalid cast from type 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} to type 'int'
   35 |         cout << (int)count << endl;
      |                 ^~~~~~~~~~