Language: C++

#include<math.h>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
//AtCoderC++.cpp

using namespace std;

auto _prime = vector<int>(1000000,-1);
bool is_prime(int n) {
	if (_prime[n] != -1)return _prime[n] == 1;
	for (size_t i = 2; i < n; i++) {
		if (n%i == 0) {
			_prime[n] = 0;
			return false;
		}
	}
	_prime[n] = 1;
	return true;
}

bool is_2017_family(int n) {
	return  is_prime(n) && is_prime((n + 1) / 2);
}

int main() {
	int Q; cin >> Q;
	_prime[0] = 0; _prime[1] = 0;_prime[2] =1; _prime[3] = 1;
	using range = tuple<int, int,int>;
	auto rs = vector<range>(Q);
	int l, r;
	for (size_t i = 0; i < Q; i++) {
		cin >> l >> r;
		rs[i] = make_tuple(l, r, i);
	}
	sort(rs.begin(), rs.end());
	int count = 0;
	auto answers = vector< pair<int, int>>(Q);
	for (size_t i = 0; i < Q; i++) {
		count = 0;
		l = rs[i]._Myfirst._Val;
		r = rs[i]._Get_rest()._Myfirst._Val;
		for (size_t j = l; j <= r; j++) count += is_2017_family(j) ? 1 : 0;
		answers[i] = { rs[i]._Get_rest()._Get_rest()._Myfirst._Val,count };
	}
	sort(answers.begin(), answers.end());
	for (size_t i = 0; i < Q; i++) {
		cout << answers[i].second << endl;
	}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:48:27: error: '__gnu_cxx::__alloc_traits<std::allocator<std::tuple<int, int, int> >, std::tuple<int, int, int> >::value_type' {aka 'class std::tuple<int, int, int>'} has no member named '_Myfirst'
   48 |                 l = rs[i]._Myfirst._Val;
      |                           ^~~~~~~~
a.cc:49:27: error: '__gnu_cxx::__alloc_traits<std::allocator<std::tuple<int, int, int> >, std::tuple<int, int, int> >::value_type' {aka 'class std::tuple<int, int, int>'} has no member named '_Get_rest'
   49 |                 r = rs[i]._Get_rest()._Myfirst._Val;
      |                           ^~~~~~~~~
a.cc:51:38: error: '__gnu_cxx::__alloc_traits<std::allocator<std::tuple<int, int, int> >, std::tuple<int, int, int> >::value_type' {aka 'class std::tuple<int, int, int>'} has no member named '_Get_rest'
   51 |                 answers[i] = { rs[i]._Get_rest()._Get_rest()._Myfirst._Val,count };
      |                                      ^~~~~~~~~
a.cc:51:82: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and '<brace-enclosed initializer list>')
   51 |                 answers[i] = { rs[i]._Get_rest()._Get_rest()._Myfirst._Val,count };
      |                                                                                  ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/bits/specfun.h:43,
                 from /usr/include/c++/14/cmath:3906,
                 from /usr/include/c++/14/math.h:36,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:946:9: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, const _U1&>, std::is_assignable<_T2&, const _U2&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U2 = _U1; _T1 = int; _T2 = int]'
  946 |         operator=(const pair<_U1, _U2>& __p)
      |         ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:946:9: note:   template argument deduction/substitution failed:
a.cc:51:82: note:   couldn't deduce template parameter '_U1'
   51 |                 answers[i] = { rs[i]._Get_rest()._Get_rest()._Myfirst._Val,count };
      |                                                                                  ^
/usr/include/c++/14/bits/stl_pair.h:957:9: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, _U1&&>, std::is_assignable<_T2&, _U2&&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U2 = _U1; _T1 = int; _T2 = int]'
  957 |         operator=(pair<_U1, _U2>&& __p)
      |         ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:957:9: note:   template argument deduction/substitution failed:
a.cc:51:82: note:   couldn't deduce template parameter '_U1'
   51 |                 answers[i] = { rs[i]._Get_rest()._Get_rest()._Myfirst._Val,count };
      |                                                                                  ^
/usr/include/c++/14/bits/stl_pair.h:921:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(std::__conditional_t<((bool)std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value), const std::pair<_T1, _T2>&, const std::__nonesuch&>) [with _T1 = int; _T2 = int; std::__conditional_t<((bool)std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value), const std::pair<_T1, _T2>&, const std::__nonesuch&> = const std::pair<int, int>&]'
  921 |       operator=(__conditional_t<__and_<is_copy_assignable<_T1>,
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:923:65: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::__conditional_t<true, const std::pair<int, int>&, const std::__nonesuch&>' {aka 'const std::pair<int, int>&'}
  921 |       operator=(__conditional_t<__and_<is_copy_assignable<_T1>,
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
  922 |                                        is_copy_assignable<_T2>>::value,
      |                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  923 |                                 const pair&, const __nonesuch&> __p)
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_pair.h:931:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(std::__conditional_t<((bool)std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value), std::pair<_T1, _T2>&&, std::__nonesuch&&>) [with _T1 = int; _T2 = int; std::__conditional_t<((bool)std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value), std::pair<_T1, _T2>&&, std::__nonesuch&&> = std::pair<int, int>&&]'
  931 |       operator=(__conditional_t<__and_<is_move_assignable<_T1>,
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:933:55: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::__conditional_t<true, std::pair<int, int>&&, std::__nonesuch&&>' {aka 'std::pair<int, int>&&'}
  931 |       operator=(__conditional_t<__and_<is_move_assignable<_T1>,
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  932 |                                        is_move_assignable<_T2>>::value,
      |                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  933 |                                 pair&&, __nonesuch&&> __p)
      |                                 ~~~~~~~~~~~~~~~~~~~~~~^~~