Language: C++

#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
Pair<int, bool> dp[101000];
bool  is_prime(int n){
    if (n == 1) return false;
    if (dp[n].first != INF) return dp[n].second;
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) { 
              dp[n].first = 0;
              dp[n].second = false;
              return false;
    }
      dp[n].first = 0;
              dp[n].second = true;
    return true;
}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int Q;
    cin >> Q;
    vi a(Q);
   Pair<int, bool> p = make_pair<INF, false>;
   fill(dp, dp+101000, p);
    rep(i, 0, Q) {
        int res = 0;
        int l, r;
        cin >> l >> r;
        rep(k, l, r+1) {
            if (k % 2 != 0) {
               if (is_prime(k)) {
                   if (is_prime((k+1)*0.5)) {
                       ++res;
                   }
               } else {
                   continue;
               }
            }
        }
        a[i] = res;
    }
    rep(i, 0, Q) {
        cout << a[i] << endl;
    }
    return 0;
}


Compiler output:
a.cc:26:1: error: 'Pair' does not name a type
   26 | Pair<int, bool> dp[101000];
      | ^~~~
a.cc: In function 'bool is_prime(int)':
a.cc:29:9: error: 'dp' was not declared in this scope; did you mean 'p'?
   29 |     if (dp[n].first != INF) return dp[n].second;
      |         ^~
      |         p
a.cc:32:15: error: 'dp' was not declared in this scope; did you mean 'p'?
   32 |               dp[n].first = 0;
      |               ^~
      |               p
a.cc:36:7: error: 'dp' was not declared in this scope; did you mean 'p'?
   36 |       dp[n].first = 0;
      |       ^~
      |       p
a.cc:42:28: error: a function-definition is not allowed here before '{' token
   42 | int findSumOfDigits(int n) {
      |                            ^
a.cc:51:1: error: a template declaration cannot appear at block scope
   51 | template<class T> inline bool chmin(T& a, T b) {
      | ^~~~~~~~
a.cc:66:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   66 | int main() {
      |         ^~
a.cc:66:9: note: remove parentheses to default-initialize a variable
   66 | int main() {
      |         ^~
      |         --
a.cc:66:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:66:12: error: a function-definition is not allowed here before '{' token
   66 | int main() {
      |            ^
a.cc:93:2: error: expected '}' at end of input
   93 | }
      |  ^
a.cc:27:22: note: to match this '{'
   27 | bool  is_prime(int n){
      |                      ^