Language: C++

int main(){

        int n;
        cin >> n;
        vector<int> l(n), r(n), sum(n);
        for (int i=0; i < n; ++i) {
                        cin >> l[i] >> r[i];
        }

        int MAX = 101010;
        vector<int> is_prime(MAX, 1);
        is_prime[0] = 0;
        is_prime[1] = 0;
        for (int i = 2; i < MAX; ++i) {
                if (!is_prime[i]) continue;
                for (int j = i*2; j < MAX; j += i) is_prime[j] = 0;
        }

        vector<int> a(MAX, 0);
        for (int i = 0; i < MAX; ++i){
                if (i % 2 == 0) continue;
                if (is_prime[i] && is_prime[(i+1)/2]) a[i] = 1;
        }

        vector<int> s(MAX+1, 0);
        for (int i = 0; i < MAX; i++) s[i+1] = s[i] + a[i];

        for (int i = 0; i < n; i++) {
                if (r[i] == l[i] && is_prime[r[i]]) cout << '1' << endl;
                else cout << s[r[i]] - s[l[i]] << endl;
        }


Compiler output:
a.cc: In function 'int main()':
a.cc:4:9: error: 'cin' was not declared in this scope
    4 |         cin >> n;
      |         ^~~
a.cc:5:9: error: 'vector' was not declared in this scope
    5 |         vector<int> l(n), r(n), sum(n);
      |         ^~~~~~
a.cc:5:16: error: expected primary-expression before 'int'
    5 |         vector<int> l(n), r(n), sum(n);
      |                ^~~
a.cc:7:32: error: 'l' was not declared in this scope
    7 |                         cin >> l[i] >> r[i];
      |                                ^
a.cc:7:40: error: 'r' was not declared in this scope
    7 |                         cin >> l[i] >> r[i];
      |                                        ^
a.cc:11:16: error: expected primary-expression before 'int'
   11 |         vector<int> is_prime(MAX, 1);
      |                ^~~
a.cc:12:9: error: 'is_prime' was not declared in this scope
   12 |         is_prime[0] = 0;
      |         ^~~~~~~~
a.cc:19:16: error: expected primary-expression before 'int'
   19 |         vector<int> a(MAX, 0);
      |                ^~~
a.cc:22:55: error: 'a' was not declared in this scope
   22 |                 if (is_prime[i] && is_prime[(i+1)/2]) a[i] = 1;
      |                                                       ^
a.cc:25:16: error: expected primary-expression before 'int'
   25 |         vector<int> s(MAX+1, 0);
      |                ^~~
a.cc:26:39: error: 's' was not declared in this scope
   26 |         for (int i = 0; i < MAX; i++) s[i+1] = s[i] + a[i];
      |                                       ^
a.cc:26:55: error: 'a' was not declared in this scope
   26 |         for (int i = 0; i < MAX; i++) s[i+1] = s[i] + a[i];
      |                                                       ^
a.cc:29:21: error: 'r' was not declared in this scope
   29 |                 if (r[i] == l[i] && is_prime[r[i]]) cout << '1' << endl;
      |                     ^
a.cc:29:29: error: 'l' was not declared in this scope
   29 |                 if (r[i] == l[i] && is_prime[r[i]]) cout << '1' << endl;
      |                             ^
a.cc:29:53: error: 'cout' was not declared in this scope
   29 |                 if (r[i] == l[i] && is_prime[r[i]]) cout << '1' << endl;
      |                                                     ^~~~
a.cc:29:68: error: 'endl' was not declared in this scope
   29 |                 if (r[i] == l[i] && is_prime[r[i]]) cout << '1' << endl;
      |                                                                    ^~~~
a.cc:30:22: error: 'cout' was not declared in this scope
   30 |                 else cout << s[r[i]] - s[l[i]] << endl;
      |                      ^~~~
a.cc:30:30: error: 's' was not declared in this scope
   30 |                 else cout << s[r[i]] - s[l[i]] << endl;
      |                              ^
a.cc:30:51: error: 'endl' was not declared in this scope
   30 |                 else cout << s[r[i]] - s[l[i]] << endl;
      |                                                   ^~~~
a.cc:31:10: error: expected '}' at end of input
   31 |         }
      |          ^
a.cc:1:11: note: to match this '{'
    1 | int main(){
      |           ^