Language: C++

#include<iostream>
#include<cstdio>
using namespace std;
const int N=2005;
int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
char ch[10];
int main()
{
	scanf("%d%d",&n,&k);
	k<<=1;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d %s",&x,&y,ch);
		if(ch[0]=='W')
			w[x%k][y%k]++;
		else
			b[x%k][y%k]++;
	}
	for(int i=0;i<k;i++)
	{
		sum=0;
		for(int j=0;j<k/2;j++)
			sum+=b[i][j];
		bh[i][0]=sum;
		for(int j=1;j<k;j++)
		{
			sum=sum-b[i][j-1]+b[i][(j+k/2-1)%k];
			bh[i][j]=sum;
		}
	}
	for(int i=0;i<k;i++)
	{
		sum=0;
		for(int j=0;j<k/2;j++)
			sum+=w[i][j];
		wh[i][0]=sum;
		for(int j=1;j<k;j++)
		{
			sum=sum-w[i][j-1]+w[i][(j+k/2-1)%k];
			wh[i][j]=sum;
		}
	}
	// for(int i=0;i<k;i++)
	// {
		// for(int j=0;j<k;j++)
			// cout<<b[i][j]<<" ";
		// cout<<endl;
	// }
		// cout<<endl;
	// for(int i=0;i<k;i++)
	// {
		// for(int j=0;j<k;j++)
			// cout<<bh[i][j]<<" ";
		// cout<<endl;
	// }
		// cout<<endl;
	// for(int i=0;i<k;i++)
	// {
		// for(int j=0;j<k;j++)
			// cout<<w[i][j]<<" ";
		// cout<<endl;
	// }
		// cout<<endl;
	// for(int i=0;i<k;i++)
	// {
		// for(int j=0;j<k;j++)
			// cout<<wh[i][j]<<" ";
		// cout<<endl;
	// }
		// cout<<endl;
	// for(int i=0;i<k;i++)
	// {
		// sum=0;
		// for(int j=0;j<k/2;j++)
			// sum+=b[j][i];
		// bs[0][i]=sum;
		// for(int j=1;j<k;j++)
		// {
			// sum=sum-b[(j+k-1)%k][i]+b[(j+k/2)%k][i];
			// bs[j][i]=sum;
		// }
	// }
	// for(int i=0;i<k;i++)
	// {
		// sum=0;
		// for(int j=0;j<k/2;j++)
			// sum+=w[j][i];
		// whs[0][i]=sum;
		// for(int j=1;j<k;j++)
		// {
			// sum=sum-w[(j+k-1)%k][i]+w[(j+k/2)%k][i];
			// whs[j][i]=sum;
		// }
	// }
	for(int i=0;i<k;i++)
	{
		for(int j=0;j<k;j++)
			c[j]=bh[j][i],d[j]=wh[j][i],e[j]=bh[j][(i+k/2)%k],f[j]=wh[j][(i+k/2)%k];
		int s1=0,s2=0;
		for(int j=0;j<k/2;j++)
			s1=s1+c[j]+d[j+k/2],s2=s2+f[j]+e[j+k/2];
		ans=max(ans,s1+s2);
		for(int j=1;j<k;j++)
		{
			s1=s1-c[j-1]+c[(j+k/2-1)%k]-d[(j+k/2-1)%k]+d[(j+k-1)%k];
			s2=s2-f[j-1]+f[(j+k/2-1)%k]-e[(j+k/2-1)%k]+e[(j+k-1)%k];
			ans=max(ans,s1+s2);
		}
	}
	printf("%d\n",ans);
	return 0;
}#include<iostream>
#include<cstdio>
using namespace std;
const int N=2005;
int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
char ch[10];
int main()
{
	scanf("%d%d",&n,&k);
	k<<=1;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d %s",&x,&y,ch);
		if(ch[0]=='W')
			w[x%k][y%k]++;
		else
			b[x%k][y%k]++;
	}
	for(int i=0;i<k;i++)
	{
		sum=0;
		for(int j=0;j<k/2;j++)
			sum+=b[i][j];
		bh[i][0]=sum;
		for(int j=1;j<k;j++)
		{
			sum=sum-b[i][j-1]+b[i][(j+k/2-1)%k];
			bh[i][j]=sum;
		}
	}
	for(int i=0;i<k;i++)
	{
		sum=0;
		for(int j=0;j<k/2;j++)
			sum+=w[i][j];
		wh[i][0]=sum;
		for(int j=1;j<k;j++)
		{
			sum=sum-w[i][j-1]+w[i][(j+k/2-1)%k];
			wh[i][j]=sum;
		}
	}
	// for(int i=0;i<k;i++)
	// {
		// for(int j=0;j<k;j++)
			// cout<<b[i][j]<<" ";
		// cout<<endl;
	// }
		// cout<<endl;
	// for(int i=0;i<k;i++)
	// {
		// for(int j=0;j<k;j++)
			// cout<<bh[i][j]<<" ";
		// cout<<endl;
	// }
		// cout<<endl;
	// for(int i=0;i<k;i++)
	// {
		// for(int j=0;j<k;j++)
			// cout<<w[i][j]<<" ";
		// cout<<endl;
	// }
		// cout<<endl;
	// for(int i=0;i<k;i++)
	// {
		// for(int j=0;j<k;j++)
			// cout<<wh[i][j]<<" ";
		// cout<<endl;
	// }
		// cout<<endl;
	// for(int i=0;i<k;i++)
	// {
		// sum=0;
		// for(int j=0;j<k/2;j++)
			// sum+=b[j][i];
		// bs[0][i]=sum;
		// for(int j=1;j<k;j++)
		// {
			// sum=sum-b[(j+k-1)%k][i]+b[(j+k/2)%k][i];
			// bs[j][i]=sum;
		// }
	// }
	// for(int i=0;i<k;i++)
	// {
		// sum=0;
		// for(int j=0;j<k/2;j++)
			// sum+=w[j][i];
		// whs[0][i]=sum;
		// for(int j=1;j<k;j++)
		// {
			// sum=sum-w[(j+k-1)%k][i]+w[(j+k/2)%k][i];
			// whs[j][i]=sum;
		// }
	// }
	for(int i=0;i<k;i++)
	{
		for(int j=0;j<k;j++)
			c[j]=bh[j][i],d[j]=wh[j][i],e[j]=bh[j][(i+k/2)%k],f[j]=wh[j][(i+k/2)%k];
		int s1=0,s2=0;
		for(int j=0;j<k/2;j++)
			s1=s1+c[j]+d[j+k/2],s2=s2+f[j]+e[j+k/2];
		ans=max(ans,s1+s2);
		for(int j=1;j<k;j++)
		{
			s1=s1-c[j-1]+c[(j+k/2-1)%k]-d[(j+k/2-1)%k]+d[(j+k-1)%k];
			s2=s2-f[j-1]+f[(j+k/2-1)%k]-e[(j+k/2-1)%k]+e[(j+k-1)%k];
			ans=max(ans,s1+s2);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Compiler output:
a.cc:112:2: error: stray '#' in program
  112 | }#include<iostream>
      |  ^
a.cc:112:3: error: 'include' does not name a type
  112 | }#include<iostream>
      |   ^~~~~~~
a.cc:115:11: error: redefinition of 'const int N'
  115 | const int N=2005;
      |           ^
a.cc:4:11: note: 'const int N' previously defined here
    4 | const int N=2005;
      |           ^
a.cc:116:5: error: redefinition of 'int n'
  116 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |     ^
a.cc:5:5: note: 'int n' previously declared here
    5 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |     ^
a.cc:116:7: error: redefinition of 'int k'
  116 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |       ^
a.cc:5:7: note: 'int k' previously declared here
    5 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |       ^
a.cc:116:9: error: redefinition of 'int x'
  116 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |         ^
a.cc:5:9: note: 'int x' previously declared here
    5 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |         ^
a.cc:116:11: error: redefinition of 'int y'
  116 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |           ^
a.cc:5:11: note: 'int y' previously declared here
    5 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |           ^
a.cc:116:13: error: redefinition of 'int w [2005][2005]'
  116 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |             ^
a.cc:5:13: note: 'int w [2005][2005]' previously declared here
    5 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |             ^
a.cc:116:21: error: redefinition of 'int b [2005][2005]'
  116 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |                     ^
a.cc:5:21: note: 'int b [2005][2005]' previously declared here
    5 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |                     ^
a.cc:116:29: error: redefinition of 'int bh [2005][2005]'
  116 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |                             ^~
a.cc:5:29: note: 'int bh [2005][2005]' previously declared here
    5 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |                             ^~
a.cc:116:38: error: redefinition of 'int wh [2005][2005]'
  116 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |                                      ^~
a.cc:5:38: note: 'int wh [2005][2005]' previously declared here
    5 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |                                      ^~
a.cc:116:47: error: redefinition of 'int sum'
  116 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |                                               ^~~
a.cc:5:47: note: 'int sum' previously declared here
    5 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |                                               ^~~
a.cc:116:51: error: redefinition of 'int c [2005]'
  116 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |                                                   ^
a.cc:5:51: note: 'int c [2005]' previously declared here
    5 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |                                                   ^
a.cc:116:56: error: redefinition of 'int d [2005]'
  116 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |                                                        ^
a.cc:5:56: note: 'int d [2005]' previously declared here
    5 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |                                                        ^
a.cc:116:61: error: redefinition of 'int e [2005]'
  116 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |                                                             ^
a.cc:5:61: note: 'int e [2005]' previously declared here
    5 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |                                                             ^
a.cc:116:66: error: redefinition of 'int f [2005]'
  116 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |                                                                  ^
a.cc:5:66: note: 'int f [2005]' previously declared here
    5 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |                                                                  ^
a.cc:116:71: error: redefinition of 'int ans'
  116 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |                                                                       ^~~
a.cc:5:71: note: 'int ans' previously declared here
    5 | int n,k,x,y,w[N][N],b[N][N],bh[N][N],wh[N][N],sum,c[N],d[N],e[N],f[N],ans;//,bs[N][N],whs[N][N]
      |                                                                       ^~~
a.cc:117:6: error: redefinition of 'char ch [10]'
  117 | char ch[10];
      |      ^~
a.cc:6:6: note: 'char ch [10]' previously declared here
    6 | char ch[10];
      |      ^~
a.cc:118:5: error: redefinition of 'int main()'
  118 | int main()
      |     ^~~~
a.cc:7:5: note: 'int main()' previously defined here
    7 | int main()
      |     ^~~~