Language: C++

#include <bits/stdc++.h>
using namespace std;
 
//long long
using ll = long long;
 
// pair<int, int>
using PII = pair<int, int>;
 
//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
 
//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()
 
//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
 
//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}
 
// a = max(a, b), a = min(a, b)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
// 階乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}
 
 
 
// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う
 
// テーブルを作る前処理
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};

bool han(int a){
    for(int i = 2; i * i <= a; i++){
        if(a % i == 0){
            return false;
        }
    }
    return a != 1;
}


bool d2017(int n){
    if(n == 1 || n == 2) return false;
    else if(n % 2 == 0) return false;
    else {
        if(han(n) && han((n + 1) / 2)) {
            return true;
        }
    }
    return false;
}


int main(){
    int N;
    cin >> N;
    vector<int> a(100001);
    for(int i = 0; i <= 100000; i++){
        if(d2017(i)) a[i] = 1;
        else a[i] = 0;
    }

    vector<int> sum(100002);
    rui[0] = 0;
    for(int i = 0; i <= 100000; i++){
        sum[i+1] = sum[i] + a[i];
    }

    for(int i=0; i<q; i++){
        int r, l;
        cin >> r >> l
        cout << sum[r + 1] - rui[l] << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:124:5: error: 'rui' was not declared in this scope
  124 |     rui[0] = 0;
      |     ^~~
a.cc:129:20: error: 'q' was not declared in this scope
  129 |     for(int i=0; i<q; i++){
      |                    ^
a.cc:131:22: error: expected ';' before 'cout'
  131 |         cin >> r >> l
      |                      ^
      |                      ;
  132 |         cout << sum[r + 1] - rui[l] << endl;
      |         ~~~~