Language: C++

//Code by 27.
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const int MOD=19260817;
int x[100001],y[100001];
string st[100001];
int c1[10001][10001];
int c2[10001][10001];
int s1[10001][10001];
int s2[10001][10001];
int n,m;
int get1(int x1,int y1,int x2,int y2)
{
	int s=0;
	if(x1>0&&y1>0)s+=s1[x1-1][y1-1];
	if(x1>0)s-=s1[x1-1][y2];
	if(y1>0)s-=s1[x2][y1-1];
	s+=s1[x2][y2];
	return s;
}
int get2(int x1,int y1,int x2,int y2)
{
	int s=0;
	if(x1>0&&y1>0)s+=s2[x1-1][y1-1];
	if(x1>0)s-=s2[x1-1][y2];
	if(y1>0)s-=s2[x2][y1-1];
	s+=s2[x2][y2];
	return s;
}
int ypa1(int x1,int y1,int x2,int y2)
{
	if(x1>=2*m)
	{
		x1-=2*m;
		x2-=2*m;
	}
	if(y1>=2*m)
	{
		y1-=2*m;
		y2-=2*m;
	}
	if(y2>=2*m)
	{
		if(x2>=2*m)
		{
			return get1(0,0,x2%((2*m)),y2%((2*m)))+get1(x1,y1,(2*m)-1,(2*m)-1);
		}
		else
		{
			return get1(x1,y1,x2,2*m-1)+get1(x1,0,x2,y2%(2*m));
		}
	}
	else
	{
		if(x2>=2*m)
		{
			return get1(x1,y1,2*m-1,y2)+get1(0,y1,x2%(2*m),y2);
		}
		else
		{
			return get1(x1,y1,x2,y2);
		}
	}
	
}
int ypa2(int x1,int y1,int x2,int y2)
{
	if(x1>=2*m)
	{
		x1-=2*m;
		x2-=2*m;
	}
	if(y1>=2*m)
	{
		y1-=2*m;
		y2-=2*m;
	}
	if(y2>=2*m)
	{
		if(x2>=2*m)
		{
			return get2(0,0,x2%((2*m)),y2%((2*m)))+get2(x1,y1,(2*m)-1,(2*m)-1);
		}
		else
		{
			return get2(x1,y1,x2,2*m-1)+get2(x1,0,x2,y2%(2*m));
		}
	}
	else
	{
		if(x2>=2*m)
		{
			return get2(x1,y1,2*m-1,y2)+get2(0,y1,x2%(2*m),y2);
		}
		else
		{
			return get2(x1,y1,x2,y2);
		}
	}
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i]>>y[i]>>st[i];
		x[i]=x[i]%(2*m);
		y[i]=y[i]%(2*m);
		if(st[i][0]=='W')c1[x[i]][y[i]]++;
		else c2[x[i]][y[i]]++;
	}
	for(int i=0;i<2*m;i++)
	{
		for(int j=0;j<2*m;j++)
		{
			//s1[i][j]=s1[i-1][j]+s1[i][j-1]-s1[i-1][j-1]+(c[i][j]=='W');
			if(i>0)
			{
				s1[i][j]+=s1[i-1][j];
			}
			if(j>0)
			{
				s1[i][j]+=s1[i][j-1];
			}
			if(i>0&&j>0)
			{
				s1[i][j]-=s1[i-1][j-1];
			}
			s1[i][j]+=c1[i][j];
			//s2[i][j]=s2[i-1][j]+s2[i][j-1]-s2[i-1][j-1]+(c[i][j]=='W');
			if(i>0)
			{
				s2[i][j]+=s2[i-1][j];
			}
			if(j>0)
			{
				s2[i][j]+=s2[i][j-1];
			}
			if(i>0&&j>0)
			{
				s2[i][j]-=s2[i-1][j-1];
			}
			s2[i][j]+=c2[i][j];
		}
	}f
	/*
	for(int i=0;i<m*2;i++)
	{
		for(int j=0;j<2*m;j++)
		{
			cout<<s1[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<endl;
	for(int i=0;i<m*2;i++)
	{
		for(int j=0;j<2*m;j++)
		{
			cout<<s2[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<endl;
	*/
	int mx=0;
	for(int i=0;i<=m;i++)
	{
		for(int j=0;j<=m;j++)
		{
			//cout<<mx<<endl;
			mx=max(mx,ypa1(i,j,i+m-1,j+m-1)+ypa1(i+m,j+m,i+m+m-1,j+m+m-1)+ypa2(i,j+m,i+m-1,j+m+m-1)+ypa2(i+m,j,i+m+m-1,j+m-1));
		}
	}
	cout<<mx;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:164:10: error: 'f' was not declared in this scope
  164 |         }f
      |          ^
a.cc:191:25: error: 'mx' was not declared in this scope; did you mean 'x'?
  191 |                         mx=max(mx,ypa1(i,j,i+m-1,j+m-1)+ypa1(i+m,j+m,i+m+m-1,j+m+m-1)+ypa2(i,j+m,i+m-1,j+m+m-1)+ypa2(i+m,j,i+m+m-1,j+m-1));
      |                         ^~
      |                         x
a.cc:194:15: error: 'mx' was not declared in this scope; did you mean 'x'?
  194 |         cout<<mx;
      |               ^~
      |               x