Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
// head
 
 
 
int main() {
  int n,m,q;
	scanf("%d %d %d",&n,&m,&q);
	char ch[n][m];
  string s;
	rep(i,0,n){cin >> s;
    rep(j,0,m){
      ch[i][j] = s[j];
    }
	}
  int tyo[n+1][m+1] = {};
  rep(i,1,n+1){
    rep(j,1,m+1){
      tyo[i][j]= tyo[i-1][j] + tyo[i][j-1] - tyo[i-1][j-1];
      if(ch[i-1][j-1] == '1'){
        tyo[i][j] += 1;
      }
    }
  }
  int hen[n+1][m+1] = {};
  rep(i,1,n+1){
    rep(j,1,m+1){
      hen[i][j]= hen[i-1][j] + hen[i][j-1] - hen[i-1][j-1];
      if((ch[i-1][j-1] == '1') && (ch[i-1][j] == '1') && (j <= m-1)){
        hen[i][j] += 1;
      }
    }
  }
  int hen2[n+1][m+1] = {};
  rep(i,1,n+1){
    rep(j,1,m+1){
      hen2[i][j]= hen2[i-1][j] + hen2[i][j-1] - hen2[i-1][j-1];
      if((ch[i-1][j-1] == '1') && (ch[i][j-1] == '1') && (i <= n-1)){
        hen2[i][j] += 1;
      }
    }
  }
  std::vector<std::vector<int>> query;
  rep(i,0,q){
    std::vector<int> v;
    int x1,y1,x2,y2;
    scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
    v = {x1,y1,x2,y2};
    query.pb(v);
  }
  int ans = 0;
  for(auto $q:query){
    ans = tyo[q[2]][q[3]] - tyo[q[2]][q[1]-1] - tyo[q[0]-1][q[3]] + tyo[q[0]-1][q[1]-1];
    ans -= (hen[q[2]][q[3]-1] - hen[q[2]][q[1]-1] - hen[q[0]-1][q[3]-1] + hen[q[0]-1][q[1]-1]);
    ans -= (hen2[q[2]-1][q[3]] - hen2[q[2]-1][q[1]-1] - hen2[q[0]-1][q[3]] + hen2[q[0]-1][q[1]-1]);
    std::cout << ans << '\n';
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:70:16: error: invalid types 'int[int]' for array subscript
   70 |     ans = tyo[q[2]][q[3]] - tyo[q[2]][q[1]-1] - tyo[q[0]-1][q[3]] + tyo[q[0]-1][q[1]-1];
      |                ^
a.cc:70:22: error: invalid types 'int[int]' for array subscript
   70 |     ans = tyo[q[2]][q[3]] - tyo[q[2]][q[1]-1] - tyo[q[0]-1][q[3]] + tyo[q[0]-1][q[1]-1];
      |                      ^
a.cc:70:34: error: invalid types 'int[int]' for array subscript
   70 |     ans = tyo[q[2]][q[3]] - tyo[q[2]][q[1]-1] - tyo[q[0]-1][q[3]] + tyo[q[0]-1][q[1]-1];
      |                                  ^
a.cc:70:40: error: invalid types 'int[int]' for array subscript
   70 |     ans = tyo[q[2]][q[3]] - tyo[q[2]][q[1]-1] - tyo[q[0]-1][q[3]] + tyo[q[0]-1][q[1]-1];
      |                                        ^
a.cc:70:54: error: invalid types 'int[int]' for array subscript
   70 |     ans = tyo[q[2]][q[3]] - tyo[q[2]][q[1]-1] - tyo[q[0]-1][q[3]] + tyo[q[0]-1][q[1]-1];
      |                                                      ^
a.cc:70:62: error: invalid types 'int[int]' for array subscript
   70 |     ans = tyo[q[2]][q[3]] - tyo[q[2]][q[1]-1] - tyo[q[0]-1][q[3]] + tyo[q[0]-1][q[1]-1];
      |                                                              ^
a.cc:70:74: error: invalid types 'int[int]' for array subscript
   70 |     ans = tyo[q[2]][q[3]] - tyo[q[2]][q[1]-1] - tyo[q[0]-1][q[3]] + tyo[q[0]-1][q[1]-1];
      |                                                                          ^
a.cc:70:82: error: invalid types 'int[int]' for array subscript
   70 |     ans = tyo[q[2]][q[3]] - tyo[q[2]][q[1]-1] - tyo[q[0]-1][q[3]] + tyo[q[0]-1][q[1]-1];
      |                                                                                  ^
a.cc:71:18: error: invalid types 'int[int]' for array subscript
   71 |     ans -= (hen[q[2]][q[3]-1] - hen[q[2]][q[1]-1] - hen[q[0]-1][q[3]-1] + hen[q[0]-1][q[1]-1]);
      |                  ^
a.cc:71:24: error: invalid types 'int[int]' for array subscript
   71 |     ans -= (hen[q[2]][q[3]-1] - hen[q[2]][q[1]-1] - hen[q[0]-1][q[3]-1] + hen[q[0]-1][q[1]-1]);
      |                        ^
a.cc:71:38: error: invalid types 'int[int]' for array subscript
   71 |     ans -= (hen[q[2]][q[3]-1] - hen[q[2]][q[1]-1] - hen[q[0]-1][q[3]-1] + hen[q[0]-1][q[1]-1]);
      |                                      ^
a.cc:71:44: error: invalid types 'int[int]' for array subscript
   71 |     ans -= (hen[q[2]][q[3]-1] - hen[q[2]][q[1]-1] - hen[q[0]-1][q[3]-1] + hen[q[0]-1][q[1]-1]);
      |                                            ^
a.cc:71:58: error: invalid types 'int[int]' for array subscript
   71 |     ans -= (hen[q[2]][q[3]-1] - hen[q[2]][q[1]-1] - hen[q[0]-1][q[3]-1] + hen[q[0]-1][q[1]-1]);
      |                                                          ^
a.cc:71:66: error: invalid types 'int[int]' for array subscript
   71 |     ans -= (hen[q[2]][q[3]-1] - hen[q[2]][q[1]-1] - hen[q[0]-1][q[3]-1] + hen[q[0]-1][q[1]-1]);
      |                                                                  ^
a.cc:71:80: error: invalid types 'int[int]' for array subscript
   71 |     ans -= (hen[q[2]][q[3]-1] - hen[q[2]][q[1]-1] - hen[q[0]-1][q[3]-1] + hen[q[0]-1][q[1]-1]);
      |                                                                                ^
a.cc:71:88: error: invalid types 'int[int]' for array subscript
   71 |     ans -= (hen[q[2]][q[3]-1] - hen[q[2]][q[1]-1] - hen[q[0]-1][q[3]-1] + hen[q[0]-1][q[1]-1]);
      |                                                                                        ^
a.cc:72:19: error: invalid types 'int[int]' for array subscript
   72 |     ans -= (hen2[q[2]-1][q[3]] - hen2[q[2]-1][q[1]-1] - hen2[q[0]-1][q[3]] + hen2[q[0]-1][q[1]-1]);
      |                   ^
a.cc:72:27: error: invalid types 'int[int]' for array subscript
   72 |     ans -= (hen2[q[2]-1][q[3]] - hen2[q[2]-1][q[1]-1] - hen2[q[0]-1][q[3]] + hen2[q[0]-1][q[1]-1]);
      |                           ^
a.cc:72:40: error: invalid types 'int[int]' for array subscript
   72 |     ans -= (hen2[q[2]-1][q[3]] - hen2[q[2]-1][q[1]-1] - hen2[q[0]-1][q[3]] + hen2[q[0]-1][q[1]-1]);
      |                                        ^
a.cc:72:48: error: invalid types 'int[int]' for array subscript
   72 |     ans -= (hen2[q[2]-1][q[3]] - hen2[q[2]-1][q[1]-1] - hen2[q[0]-1][q[3]] + hen2[q[0]-1][q[1]-1]);
      |                                                ^
a.cc:72:63: error: invalid types 'int[int]' for array subscript
   72 |     ans -= (hen2[q[2]-1][q[3]] - hen2[q[2]-1][q[1]-1] - hen2[q[0]-1][q[3]] + hen2[q[0]-1][q[1]-1]);
      |                                                               ^
a.cc:72:71: error: invalid types 'int[int]' for array subscript
   72 |     ans -= (hen2[q[2]-1][q[3]] - hen2[q[2]-1][q[1]-1] - hen2[q[0]-1][q[3]] + hen2[q[0]-1][q[1]-1]);
      |                                                                       ^
a.cc:72:84: error: invalid types 'int[int]' for array subscript
   72 |     ans -= (hen2[q[2]-1][q[3]] - hen2[q[2]-1][q[1]-1] - hen2[q[0]-1][q[3]] + hen2[q[0]-1][q[1]-1]);
      |                                                                                    ^
a.cc:72:92: error: invalid types 'int[int]' for array subscript
   72 |     ans -= (hen2[q[2]-1][q[3]] - hen2[q[2]-1][q[1]-1] - hen2[q[0]-1][q[3]] + hen2[q[0]-1][q[1]-1]);
      |                                                                                            ^