Language: C++

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

//二次元累積和を用いた解法

int main(){
  int N,M,Q;
  cin >> N >> M >> Q;
  vector<int> L(M);
  vector<int> R(M);
  vector<vector<int>> sum;
  sum = vector<vector<int>>(N+1,vector<int>(N+1,0));
  for(int i = 0; i < M; i++){
    scanf("%d %d",&L[i], &R[i]);
    sum[L[i]][R[i]] ++;
  }
  vector<int> p(Q);
  vector<int> q(Q);

  for(int i = 0; i < Q; i++) scanf("%d %d",&p[i], &q[i]);

  for(int i = 1; i <= N ; i++){
    for(int j = 1; j <= N; j++){
      sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
    }
  }

  for(int i = 0; i < Q; i++){
    int L = p[i];
    int R = q[i];
    printf("%d\n",sum[R][R] - sum[R][L-1] - sum[L-1][R] + sum[L-1][L-1]);
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   27 |   cin >> N >> M >> Q;
      |   ^~~
      |   std::cin
In file included from a.cc:13:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:28:3: error: 'vector' was not declared in this scope
   28 |   vector<int> L(M);
      |   ^~~~~~
a.cc:28:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:28:10: error: expected primary-expression before 'int'
   28 |   vector<int> L(M);
      |          ^~~
a.cc:29:10: error: expected primary-expression before 'int'
   29 |   vector<int> R(M);
      |          ^~~
a.cc:30:17: error: expected primary-expression before 'int'
   30 |   vector<vector<int>> sum;
      |                 ^~~
a.cc:31:3: error: 'sum' was not declared in this scope
   31 |   sum = vector<vector<int>>(N+1,vector<int>(N+1,0));
      |   ^~~
a.cc:31:23: error: expected primary-expression before 'int'
   31 |   sum = vector<vector<int>>(N+1,vector<int>(N+1,0));
      |                       ^~~
a.cc:33:20: error: 'L' was not declared in this scope
   33 |     scanf("%d %d",&L[i], &R[i]);
      |                    ^
a.cc:33:27: error: 'R' was not declared in this scope
   33 |     scanf("%d %d",&L[i], &R[i]);
      |                           ^
a.cc:36:10: error: expected primary-expression before 'int'
   36 |   vector<int> p(Q);
      |          ^~~
a.cc:37:10: error: expected primary-expression before 'int'
   37 |   vector<int> q(Q);
      |          ^~~
a.cc:39:45: error: 'p' was not declared in this scope
   39 |   for(int i = 0; i < Q; i++) scanf("%d %d",&p[i], &q[i]);
      |                                             ^
a.cc:39:52: error: 'q' was not declared in this scope
   39 |   for(int i = 0; i < Q; i++) scanf("%d %d",&p[i], &q[i]);
      |                                                    ^
a.cc:48:13: error: 'p' was not declared in this scope
   48 |     int L = p[i];
      |             ^
a.cc:49:13: error: 'q' was not declared in this scope
   49 |     int R = q[i];
      |             ^