Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, m, q, x1[200000], y1[200000], x2[200000], y2[200000];
string s[2000];

int c[2001][2001];
int v[2001][2001];
int h[2001][2001];

int main() {
	cin >> n >> m >> q;
	inc(i, n) { cin >> s[i]; }
	inc(i, q) { scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]); }
	
	inc1(i, n) {
	inc1(j, m) {
		c[i][j] = s[i - 1][j - 1] - '0';
		v[i][j] = (j < 2 ? 0 : s[i - 1][j - 1] == '1' && s[i - 1][j - 2] == '1');
		h[i][j] = (i < 2 ? 0 : s[i - 1][j - 1] == '1' && s[i - 2][j - 1] == '1');
	}
	}
	inc1(i, n) {
	inc1(j, m) {
		c[i][j] += c[i - 1][j];
		v[i][j] += v[i - 1][j];
		h[i][j] += h[i - 1][j];
	}
	}
	inc1(i, n) {
	inc1(j, m) {
		c[i][j] += c[i][j - 1];
		v[i][j] += v[i][j - 1];
		h[i][j] += h[i][j - 1];
	}
	}
	
	inc(i, q) {
		x1[i]--;
		y1[i]--;
		
		#define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
		int C = R(c, x1[i]    , y1[i]    , x2[i], y2[i]);
		int V = R(v, x1[i]    , y1[i] + 1, x2[i], y2[i]);
		int H = R(h, x1[i] + 1, y1[i]    , x2[i], y2[i]);
		
		printf("%d\n", C - V - H);
	}
	
	return 0;
}


Compiler output:
a.cc:42:35: error: 'int y1 [200000]' redeclared as different kind of entity
   42 | int n, m, q, x1[200000], y1[200000], x2[200000], y2[200000];
      |                                   ^
In file included from /usr/include/features.h:523,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
                 from /usr/include/c++/14/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33,
                 from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
  257 | __MATHCALL (y1,, (_Mdouble_));
      | ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:52:52: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   52 |         inc(i, q) { scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]); }
      |                                                    ^
a.cc:78:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   78 |                 y1[i]--;
      |                     ^
a.cc:78:21: warning: ISO C++ forbids decrementing a pointer of type 'double (*)(double) noexcept' [-Wpointer-arith]
   78 |                 y1[i]--;
      |                 ~~~~^
a.cc:78:21: error: lvalue required as decrement operand
   78 |                 y1[i]--;
      |                     ^
a.cc:81:45: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   81 |                 int C = R(c, x1[i]    , y1[i]    , x2[i], y2[i]);
      |                                             ^
a.cc:80:77: note: in definition of macro 'R'
   80 |                 #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
      |                                                                             ^~
a.cc:80:76: error: invalid types 'int [2001][double(double) noexcept]' for array subscript
   80 |                 #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
      |                                                                            ^
a.cc:81:25: note: in expansion of macro 'R'
   81 |                 int C = R(c, x1[i]    , y1[i]    , x2[i], y2[i]);
      |                         ^
a.cc:81:45: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   81 |                 int C = R(c, x1[i]    , y1[i]    , x2[i], y2[i]);
      |                                             ^
a.cc:80:89: note: in definition of macro 'R'
   80 |                 #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
      |                                                                                         ^~
a.cc:80:88: error: invalid types 'int [2001][double(double) noexcept]' for array subscript
   80 |                 #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
      |                                                                                        ^
a.cc:81:25: note: in expansion of macro 'R'
   81 |                 int C = R(c, x1[i]    , y1[i]    , x2[i], y2[i]);
      |                         ^
a.cc:82:45: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   82 |                 int V = R(v, x1[i]    , y1[i] + 1, x2[i], y2[i]);
      |                                             ^
a.cc:80:77: note: in definition of macro 'R'
   80 |                 #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
      |                                                                             ^~
a.cc:82:47: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   82 |                 int V = R(v, x1[i]    , y1[i] + 1, x2[i], y2[i]);
      |                                         ~~~~~~^~~
a.cc:80:77: note: in definition of macro 'R'
   80 |                 #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
      |                                                                             ^~
a.cc:80:76: error: invalid types 'int [2001][double (*)(double) noexcept]' for array subscript
   80 |                 #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
      |                                                                            ^
a.cc:82:25: note: in expansion of macro 'R'
   82 |                 int V = R(v, x1[i]    , y1[i] + 1, x2[i], y2[i]);
      |                         ^
a.cc:82:45: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   82 |                 int V = R(v, x1[i]    , y1[i] + 1, x2[i], y2[i]);
      |                                             ^
a.cc:80:89: note: in definition of macro 'R'
   80 |                 #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
      |                                                                                         ^~
a.cc:82:47: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   82 |                 int V = R(v, x1[i]    , y1[i] + 1, x2[i], y2[i]);
      |                                         ~~~~~~^~~
a.cc:80:89: note: in definition of macro 'R'
   80 |                 #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
      |                                                                                         ^~
a.cc:80:88: error: invalid types 'int [2001][double (*)(double) noexcept]' for array subscript
   80 |                 #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
      |                                                                                        ^
a.cc:82:25: note: in expansion of macro 'R'
   82 |                 int V = R(v, x1[i]    , y1[i] + 1, x2[i], y2[i]);
      |                         ^
a.cc:83:45: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   83 |                 int H = R(h, x1[i] + 1, y1[i]    , x2[i], y2[i]);
      |                                             ^
a.cc:80:77: note: in definition of macro 'R'
   80 |                 #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
      |                                                                             ^~
a.cc:80:76: error: invalid types 'int [2001][double(double) noexcept]' for array subscript
   80 |                 #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
      |                                                                            ^
a.cc:83:25: note: in expansion of macro 'R'
   83 |                 int H = R(h, x1[i] + 1, y1[i]    , x2[i], y2[i]);
      |                         ^
a.cc:83:45: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   83 |                 int H = R(h, x1[i] + 1, y1[i]    , x2[i], y2[i]);
      |                                             ^
a.cc:80:89: note: in definition of macro 'R'
   80 |                 #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
      |                                                                                         ^~
a.cc:80:88: error: invalid types 'int [2001][double(double) noexcept]' for array subscript
   80 |                 #define R(a, x1, y1, x2, y2) (a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1])
      |                                                                                        ^
a.cc:83:25: note: in expansion of macro 'R'
   83 |                 int H = R(h, x1[i] + 1, y1[i]    , x2[i], y2[i]);
      |                         ^