Language: C++

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
bool is_prime(long long n) {  //素数判定
  for(int64_t i = 2; i * i <= n; i++) {
    if(n % i == 0) return false;
  }
  return true;
}
int solve(){
  int q;
  cin >> q;
  vector<int>v(100002),sum(100003);
  REP(i,1,100001){
    if(i % 2 != 0){
      if(is_prime(i) && is_prime((i + 1) / 2))v[i]++;
    }
  }
  REP(i,2,100002){
    sum[i] += sum[i - 1] + v[i];
  }
  rep(_,q){
    int l,r;
    cin >> l >> r;
    cout << sum[r] - sum[l - 1] << endl;
  }
  return 0;
}
int ma#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
bool is_prime(long long n) {  //素数判定
  for(int64_t i = 2; i * i <= n; i++) {
    if(n % i == 0) return false;
  }
  return true;
}
int solve(){
  int q;
  cin >> q;
  vector<int>v(100002),sum(100003);
  REP(i,1,100001){
    if(i % 2 != 0){
      if(is_prime(i) && is_prime((i + 1) / 2))v[i]++;
    }
  }
  REP(i,2,100002){
    sum[i] += sum[i - 1] + v[i];
  }
  rep(_,q){
    int l,r;
    cin >> l >> r;
    cout << sum[r] - sum[l - 1] << endl;
  }
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} in(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} 

Compiler output:
a.cc:41:7: error: stray '#' in program
   41 | int ma#pragma GCC optimize("Ofast")
      |       ^
a.cc:41:8: error: expected initializer before 'pragma'
   41 | int ma#pragma GCC optimize("Ofast")
      |        ^~~~~~
a.cc:52:31: error: redefinition of 'template<class T> bool chmax(T&, T)'
   52 | template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
      |                               ^~~~~
a.cc:12:31: note: 'template<class T> bool chmax(T&, T)' previously declared here
   12 | template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
      |                               ^~~~~
a.cc:53:31: error: redefinition of 'template<class T> bool chmin(T&, T)'
   53 | template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
      |                               ^~~~~
a.cc:13:31: note: 'template<class T> bool chmin(T&, T)' previously declared here
   13 | template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
      |                               ^~~~~
a.cc:54:4: error: redefinition of 'll gcd(ll, ll)'
   54 | ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
      |    ^~~
a.cc:14:4: note: 'll gcd(ll, ll)' previously defined here
   14 | ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
      |    ^~~
a.cc:55:4: error: redefinition of 'll lcm(ll, ll)'
   55 | ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
      |    ^~~
a.cc:15:4: note: 'll lcm(ll, ll)' previously defined here
   15 | ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
      |    ^~~
a.cc:56:6: error: redefinition of 'bool is_prime(long long int)'
   56 | bool is_prime(long long n) {  //素数判定
      |      ^~~~~~~~
a.cc:16:6: note: 'bool is_prime(long long int)' previously defined here
   16 | bool is_prime(long long n) {  //素数判定
      |      ^~~~~~~~
a.cc:62:5: error: redefinition of 'int solve()'
   62 | int solve(){
      |     ^~~~~
a.cc:22:5: note: 'int solve()' previously defined here
   22 | int solve(){
      |     ^~~~~
a.cc:86:3: error: ISO C++ forbids declaration of 'in' with no type [-fpermissive]
   86 | } in(){
      |   ^~