Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,m,q;
int f[2001][2001],h[2001][2001],g[2001][2001];
char s[N][N];
int main()
{
    cin>>n>>m>>q
    for(int i=1; i<=n; i++)
        cin>>s[i]+1;
    fill(f,f+n+1,0);
	fiil(h,h+m+1,0);
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            f[i][j]=f[i-1][j]+f[i][j-1]-f[i-1][j-1]+(s[i][j]-'0');
            int cnt[2];
            cnt[1]=cnt[2]=0;
            if(s[i][j]=='1')
            {
                if(s[i-1][j]=='1') cnt[0]++;
                if(s[i][j-1]=='1') cnt[1]++;
            }
            h[i][j]=h[i-1][j]+h[i][j-1]-h[i-1][j-1]+cnt[0];
            g[i][j]=g[i-1][j]+g[i][j-1]-g[i-1][j-1]+cnt[1];
        }
    }
    while(q--)
    {
    	int x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        int k1=f[x2][y2]-f[x2][y1-1]-f[x1-1][y2]+f[x1-1][y1-1];
        int k2=h[x2][y2]-h[x2][y1]-h[x1-1][y2]+h[x1-1][y1];
        int k3=g[x2][y2]-g[x1][y2]-g[x2][y1-1]+g[x1][y1-1];
        cout<<k1-k2-k3<<endl;
    }
    return 0;
}


Compiler output:
a.cc:5:8: error: 'N' was not declared in this scope
    5 | char s[N][N];
      |        ^
a.cc:5:11: error: 'N' was not declared in this scope
    5 | char s[N][N];
      |           ^
a.cc: In function 'int main()':
a.cc:8:17: error: expected ';' before 'for'
    8 |     cin>>n>>m>>q
      |                 ^
      |                 ;
    9 |     for(int i=1; i<=n; i++)
      |     ~~~          
a.cc:9:18: error: 'i' was not declared in this scope
    9 |     for(int i=1; i<=n; i++)
      |                  ^
a.cc:12:9: error: 'fiil' was not declared in this scope
   12 |         fiil(h,h+m+1,0);
      |         ^~~~
a.cc:17:54: error: 's' was not declared in this scope
   17 |             f[i][j]=f[i-1][j]+f[i][j-1]-f[i-1][j-1]+(s[i][j]-'0');
      |                                                      ^
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int (*)[2001]; _Tp = int; typename __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type = void]':
/usr/include/c++/14/bits/stl_algobase.h:998:21:   required from 'void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = int (*)[2001]; _Tp = int]'
  998 |     { std::__fill_a1(__first, __last, __value); }
      |       ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1029:20:   required from 'void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int (*)[2001]; _Tp = int]'
 1029 |       std::__fill_a(__first, __last, __value);
      |       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:11:9:   required from here
   11 |     fill(f,f+n+1,0);
      |     ~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:952:18: error: incompatible types in assignment of 'const int' to 'int [2001]'
  952 |         *__first = __tmp;
      |         ~~~~~~~~~^~~~~~~