criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>

using namespace std;
void bad() {
    cout << "No\n";
    exit(0);
}
int main() {
    ios_base::sync_with_stdio(0);
    int n;
    int cx = 0, cy = 0, ct = 0;
    for (int i = 1; i <= n; i++) {
        cin >> x >> y >> t;
        if (abs(x - cx) + abs(y - cy) > t - ct) bad();
        if ((abs(x - cx) + abs(y - cy)) % 2 != (t - ct) % 2) bad();
        cx = x, cy = y, ct = t;
    }
    cout << "Yes\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: error: 'x' was not declared in this scope
   13 |         cin >> x >> y >> t;
      |                ^
a.cc:13:21: error: 'y' was not declared in this scope
   13 |         cin >> x >> y >> t;
      |                     ^
a.cc:13:26: error: 't' was not declared in this scope
   13 |         cin >> x >> y >> t;
      |                          ^
Language: C++

#include<bits/stdc++.h>
#define pb push_back
#define ins insert
#define F first
#define S second
#define var auto
using namespace std;
typedef long long ll;
const int Max = 5e3 + 10;
const int Mod = 1e9 + 7;

int whiteScore[Max][Max];
int blackScore[Max][Max];
pair<int,int> bs[Max][Max];//F: white S: black
pair<int,int> ls[Max][Max];

int main()
{
	int n , k;cin >> n >> k;
	for(int i = 0; i < n ; i++)
	{
		int x , y;cin >> x >> y;
		char ch;cin >> ch;
		x %= 2*k;	y %= 2*k;
		x += k;		y += k;

		if(ch == 'B')
			blackScore[x][y]++;
		else
			whiteScore[x][y]++;
	}

	for(int i = 0; i < 3 * k; i++)
	{
		for(int j = 1; j < 3 * k; j++)
		{
			ls[i][j] = {ls[i][j - 1].F + whiteScore[i][j + k - 1] - whiteScore[i][j - 1]
					  , ls[i][j - 1].S + blackScore[i][j + k - 1] - blackScore[i][j - 1]};
		}
	}
	
	for(int i = 1; i < 3 * k;i++)
	{
		for(int j = 1; j < 3 * k;j++)
		{
			bs[i][j] = {bs[i - 1][j].F + ls[i + k - 1][j].F - ls[i - 1][j].F
					  , bs[i - 1][j].S + ls[i + k - 1][j].S - ls[i - 1][j].S};
		}
	}

	int ANS = 0;
	for(int i = 0; i < k ; i++)
	{
		for(int j = 0; j < k; j++)
		{
			int ans = 0;
			ans = bs[i][j].S + bs[i + k][j + k].S + bs[i][j + 2 * k].S + bs[i + 2 * k][j + 2 * k].S + bs[i + 2 * k][j].S +
				  bs[i + k][j].F + bs[i][j + k].F + bs[i + 2 * k][j + k].F + bs[i + k][j + 2 * k].F;
			int ansprim = 0;
			ansprim = bs[i][j].F + bs[i + k][j + k].F + bs[i][j + 2 * k].F + bs[i + 2 * k][j + 2 * k].F + bs[i + 2 * k][j].F +
					  bs[i + k][j].S + bs[i][j + k].S + bs[i + 2 * k][j + k].S + bs[i + k][j + 2 * k].S;
			ans = man(ans , ansprim);
			ANS = max(ans , ANS);
		}
	}
	cout << ANS << '\n';
}



Compiler output:
a.cc: In function 'int main()':
a.cc:62:31: error: 'man' was not declared in this scope; did you mean 'tan'?
   62 |                         ans = man(ans , ansprim);
      |                               ^~~
      |                               tan
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repf(i,j,n) for(int i=(j);i<(n);i++)

signed main(){
	int n,k;cin>>n>>k;
	vector<int> x(n),y(n);
	vector<char> c(n);
	rep(i,n)cin>>x[i]>>y[i]>>c[i];
	rep(i,n){
	x[i]%=2*k;
	y[i]%=2*k;
	if(c[i]=='B')(x[i]+=k)%=2*k;
	}
	vector<vector<int>>s(4*k+10,vector<int>(4*k+10,0));
	rep(i,n)s[x[i]+1][y[i]+1]++;
	rep(i,2*k+2)rep(j,2*k+2)s[i+2*k][j]+=s[i][j];
	rep(i,4*k+2)rep(j,2*k+2)s[i][j+2*k]+=s[i][j];
	int ret=0;
	rep(i,2*k+1)rep(j,2*k+1){ret=max(ret,s[i+k][j+k]-s[i+k][j]-s[i][j+*k]+s[i][j]+s[i+2*k][j+2*k]-s[i+k][j+2*k]-s[i+2*k][j+k]-s[i+k][j+k]);}
	cout<<ret<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:75: error: invalid type argument of unary '*' (have 'long long int')
   22 |         rep(i,2*k+1)rep(j,2*k+1){ret=max(ret,s[i+k][j+k]-s[i+k][j]-s[i][j+*k]+s[i][j]+s[i+2*k][j+2*k]-s[i+k][j+2*k]-s[i+2*k][j+k]-s[i+k][j+k]);}
      |                                                                           ^~
Language: C++


//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)



//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

#define int long long

const int MAXH=2010;
int tb[2010][2010] = {};
int s[2011][2011] = {};

int get(int y2, int x2, int y1, int x1) {
	return s[y2][x2] - s[y2][x1] - s[y1][x2] + s[y1][x1];
}

int main() {

	int n, k; cin >> n >> k;
	for (int i = 0; i < n; i++) {
		int x,y; char c; cin >> x >> y >> c;
		if (c == 'W')y += k;

		y %= (2 * k);
		x %= (2 * k);
		
		tb[y][x]++;
	}

	for (int i = 0; i < MAXH; i++) {
		for (int j = 0; j < MAXH; j++) {
			s[i + 1][j + 1] = s[i][j + 1] + s[i + 1][j] - s[i][j] + tb[i][j];
		}
	}

	int ans = 0;
	for (int i = 0; i < k+1; i++) {
		for (int j = 0; j < k+1; j++) {
			int a = get(i, j, 0, 0);
			int b = get(i, 2 * k, 0, j + k);
			int c = get(i + k, j + k, i, j);
			int d = get(2 * k, j, i + k, 0);
			int e = get(2 * k, 2 * k, i + k, j + k);

			ans = max(ans, a + b + c + d + e);
		}
	}

	cout << ans << endl;

	return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  int w[k+k][k+k],b[k+k][k+k];
  for(int i=0;i<k+k;i++){
    fill(w[i],w[i]+k+k,0);
    fill(b[i],b[i]+k+k,0);
  }
  for(int i=0;i<n;i++){
    int x,y;cin>>x>>y;
    char c;cin>>c;
    if(c=='B')b[y%(2*k)][x%(2*k)]++;
    if(c=='W')w[y%(2*k)][x%(2*k)]++;
  }
  int sb[k+k+1][k+k+1],sw[k+k+1][k+k+1];
  sb[0][0]=0;
  sw[0][0]=0;
  for(int i=0;i<=k+k;i++){
    sb[0][i]=0;
    sb[i][0]=0;
    sw[i][0]=0;
    sw[0][i]=0;
  }
  for(int i=1;i<=k+k;i++){
    for(int j=1;j<=k+k;j++){
      sb[i][j]=sb[i-1][j]+sb[i][j-1]-sb[i-1][j-1];
      sw[i][j]=sw[i-1][j]+sw[i][j-1]-sw[i-1][j-1];
      sb[i][j]+=b[i-1][j-1];
      sw[i][j]+=w[i-1][j-1];
    }
  }
  int ans=0;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      int sum=sw[i][j];
      sum+=sb[i][j+k]-sb[i][j];
      sum+=sb[i+k][j]-sb[i][j];
      sum+=sw[i+k][j+k]-sw[i][j+k]-sw[i+k][j]+sw[i][j];
      sum+=sw[i][k+k]-sw[i][j+k];
      sum+=sb[i+k][k+k]-sb[i][k+k]-sb[i+k][j+k]+sb[i][j+k];
      sum+=sw[k+k][k+k]-sw[i+k][k+k]-sw[k+k][j+k]+sw[i+k][j+k];
      sum+=sb[k+k][j+k]-sb[i+k][j+k]-sb[k+k][j]+sb[i+k][j];
      sum+=sw[k+k][j]-sw[i+k][j];
      ans=max(ans,sum);
      int summ=sb[i][j];
      summ+=sw[i][j+k]-sw[i][j];
      summ+=sw[i+k][j]-sw[i][j];
      summ+=sb[i+k][j+k]-sb[i][j+k]-sb[i+k][j]+sb[i][j];
      summ+=sb[i][k+k]-sb[i][j+k];
      summ+=sw[i+k][k+k]-sw[i][k+k]-sw[i+k][j+k]+sw[i][j+k];
      summ+=sb[k+k][k+k]-sb[i+k][k+k]-sb[k+k][j+k]+sb[i+k][j+k];
      summ+=sw[k+k][j+k]-sw[i+k][j+k]-sw[k+k][j]+sw[i+k][j];
      summ+=sb[k+k][j]-sb[i+k][j]
      ans=max(ans,summ);
    }
  }
  cout<<ans<<endl;
}
      

Compiler output:
a.cc: In function 'int main()':
a.cc:54:34: error: expected ';' before 'ans'
   54 |       summ+=sb[k+k][j]-sb[i+k][j]
      |                                  ^
      |                                  ;
   55 |       ans=max(ans,summ);
      |       ~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  int w[k+k][k+k],b[k+k][k+k];
  for(int i=0;i<k+k;i++){
    fill(w[i],w[i]+k+k,0);
    fill(b[i],b[i]+k+k,0);
  }
  for(int i=0;i<n;i++){
    int x,y;cin>>x>>y;
    char c;cin>>c;
    if(c=='B')b[y%(2*k)][x%(2*k)]++;
    if(c=='W')w[y%(2*k)][x%(2*k)]++;
  }
  int sb[k+k+1][k+k+1],sw[k+k+1][k+k+1];
  sb[0][0]=0;
  sw[0][0]=0;
  for(int i=0;i<=k+k;i++){
    sb[0][i]=0;
    sb[i][0]=0;
    sw[i][0]=0;
    sw[0][i]=0;
  }
  for(int i=1;i<=k+k;i++){
    for(int j=1;j<=k+k;j++){
      sb[i][j]=sb[i-1][j]+sb[i][j-1]-sb[i-1][j-1];
      sw[i][j]=sw[i-1][j]+sw[i][j-1]-sw[i-1][j-1];
      sb[i][j]+=b[i-1][j-1];
      sw[i][j]+=w[i-1][j-1];
    }
  }
  int ans=0;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      int sum=sw[i][j];
      sum+=sb[i][j+k]-sb[i][j];
      sum+=sb[i+k][j]-sb[i][j];
      sum+=sw[i+k][j+k]-sw[i][j+k]-sw[i+k][j]+sw[i][j];
      sum+=sw[i][k+k]-sw[i][j+k];
      sum+=sb[i+k][k+k]-sb[i][k+k]-sb[i+k][j+k]+sb[i][j+k];
      sum+=sw[k+k][k+k]-sw[i+k][k+k]-sw[k+k][j+k]+sw[i+k][j+k];
      sum+=sb[k+k][j+k]-sb[i+k][j+k]-sb[k+k][j]+sb[i+k][j];
      sum+=sw[k+k][j]-sw[i+k][j];
      ans=max(ans,sum);
      int summ=sb[i][j];
      summ+=sw[i][k+k]-sw[i][j];
      summ+=sw[k+k][j]-sw[i][j];
      summ+=sb[k+k][k+k]-sb[i][k+k]-sb[k+k][j]+sb[i][j];
      summ+=sb[i][k+k]-sb[i][j+k];
      summ+=sw[i+k][k+k]-sw[i][k+k]-sw[i+k][j+k]+sw[i][j+k];
      summ+=sb[k+k][k+k]-sb[i+k][k+k]-sb[k+k][j+k]+sb[i+k][j+k];
      summ+=sw[k+k][j+k]-sw[i+k][j+k]-sw[k+k][j]+sw[i+k][j];
      summ+=sb[k+k][j]-sb[i+k][j]
      ans=max(ans,summ);
    }
  }
  cout<<ans<<endl;
}
      

Compiler output:
a.cc: In function 'int main()':
a.cc:54:34: error: expected ';' before 'ans'
   54 |       summ+=sb[k+k][j]-sb[i+k][j]
      |                                  ^
      |                                  ;
   55 |       ans=max(ans,summ);
      |       ~~~
Language: C++

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<map>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
int box[1005],las[100005],edv[100005],cnt=0;
void adde(int u,int v)
{
	las[++cnt]=box[u];
	box[u]=cnt;
	edv[cnt]=v;
}
char str[10];
int n,k;
int x[100005];
int y[100005];
bool st[100005];
int check(int stx,int sty,int id)
{
	return ((((x[id]-stx+10*k)/k)&1)^(((y[id]-sty+10*k)/k)&1))==st[id];
}
int main()
{
	read(n);
	read(k);
	for(int i=0;i<n;i++)
	{
		read(x[i]);
		read(y[i]);
		scanf("%s",str);
		st[i]=(str[0]=='B');
		adde(y[i]%k,i);
	}
	int ans=0;
	int ggans=0,ggans2=0;//for(int i=0;i<n;i++)	cout<<"NOD"<<i<<' '<<check(3,0,i)<<endl;
	for(int i=0;i<k;i++)
	{//fir white
		ggans1=0;
		ggans2=0;
		for(int j=0;j<n;j++)
			ggans1+=check(i,0,j);
		for(int j=0;j<n;j++)
			ggans2+=check(i+k,0,j);
		ans=max(ans,ggans1);
		ans=max(ans,ggans2);
		for(int j=1;j<2*k;j++)
		{
			for(int gg=box[(j-1)%k];gg;gg=las[gg])
				ggans1=ggans1-check(i,j-1,edv[gg])+check(i,j,edv[gg]);
			if(k!=1)
				for(int gg=box[j%k];gg;gg=las[gg])
					ggans1=ggans1-check(i,j-1,edv[gg])+check(i,j,edv[gg]);
			ans=max(ans,ggans1);
			for(int gg=box[(j-1)%k];gg;gg=las[gg])
				ggans2=ggans2-check(i+k,j-1,edv[gg])+check(i+k,j,edv[gg]);
			if(k!=1)
				for(int gg=box[j%k];gg;gg=las[gg])
					ggans2=ggans2-check(i+k,j-1,edv[gg])+check(i+k,j,edv[gg]);
			ans=max(ans,ggans2);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:17: error: 'ggans1' was not declared in this scope; did you mean 'ggans2'?
   50 |                 ggans1=0;
      |                 ^~~~~~
      |                 ggans2
Language: C++

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e9;
// typedef std::pair<int,int> P;
struct edge {int to,cost;};
#define VMAX 100000

ll N,K,ans=0;
ll X[100010],Y[100010];
ll W_[3010][3010],B[3010][3010];
auto W = W_+3, B = B_ + 3;
char C[100010];
//yxyx
ll imos(int a,int b,int c,int d,int mode){
        if(mode==0) return W[c][d]-W[c][b-1]-W[a-1][d]+W[a-1][b-1];
        else        return B[c][d]-B[c][b-1]-B[a-1][d]+B[a-1][b-1];
}

int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N>>K;
    REP(i,N){
        cin>>X[i]>>Y[i]>>C[i];
        X[i]%=2*K,Y[i]%=2*K;
        if(C[i]=='W')W[Y[i]][X[i]]=1;
        else B[Y[i]][X[i]]=1;
    }
    REP(i,2*K)REP(j,2*K){
        W[i][j+1]+=W[i][j];
        B[i][j+1]+=B[i][j];
    }
    REP(i,2*K)REP(j,2*K){
        W[i+1][j]+=W[i][j];
        B[i+1][j]+=B[i][j];
    }

    REP(i,K)REP(j,K)REP(k,2){
      ll tans=0;
        tans+=imos(0,0,i-1,j-1,(k==0?0:1));
        tans+=imos(0,j,i-1,j+K-1,(k!=0?0:1));
        tans+=imos(0,j+K,i-1,2*K-1,(k==0?0:1));
        tans+=imos(i,0,i+K-1,j-1,(k!=0?0:1));
        tans+=imos(i,j,i+K-1,j+K-1,(k==0?0:1));
        tans+=imos(i,j+K,i+K-1,2*K-1,(k!=0?0:1));
        tans+=imos(K+i,0,2*K-1,j-1,(k==0?0:1));
        tans+=imos(K+i,j,2*K-1,j+K-1,(k!=0?0:1));
        tans+=imos(K+i,j+K,2*K-1,2*K-1,(k==0?0:1));
        ans=max(tans,ans);
    }
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc:45:16: error: conflicting declaration 'auto B'
   45 | auto W = W_+3, B = B_ + 3;
      |                ^
a.cc:44:19: note: previous declaration as 'll B [3010][3010]'
   44 | ll W_[3010][3010],B[3010][3010];
      |                   ^
a.cc:45:20: error: 'B_' was not declared in this scope; did you mean 'W_'?
   45 | auto W = W_+3, B = B_ + 3;
      |                    ^~
      |                    W_
a.cc:45:1: error: inconsistent deduction for 'auto': 'long long int (*)[3010]' and then '<type error>'
   45 | auto W = W_+3, B = B_ + 3;
      | ^~~~
Language: C++

object Main extends App {
  val Array(n, k) = io.StdIn.readLine().split(' ').map(_.toInt)
  val k2 = k * 2
  val list = for (i <- 1 to n) yield {
    val Array(x, y, color) = io.StdIn.readLine().split(' ')
    Array(x.toInt % k2, (y.toInt + (if (color == "B") 0 else k)) % k2)
  }
  val max = (for { 
      i <- (0 to k - 1)
      j <- (0 to k - 1)
    } yield {
      val cnt = list.count { arr =>
        val x = (arr(0) + i) % k2
        val y = (arr(1) + j) % k2
        ( (x < k && y < k) || (x >= k && y >= k))
      }
      Math.max(cnt, n - cnt)
    }).max
  print(max)
}


Compiler output:
a.cc:1:1: error: 'object' does not name a type
    1 | object Main extends App {
      | ^~~~~~
Language: C

#include<map>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>

#define mp make_pair

using namespace std;

const int Mxn=100005;
const int Mxm=1005;
int sum[Mxm*4][Mxm*4];
struct eeee{
	int x,y;
	char c;
}a[Mxn];
inline int find(int x,int y,int X,int Y){
	return sum[x][y]-sum[x][Y+1]-sum[X+1][y]+sum[X+1][Y+1];
}
int main(){
	int n,m,tm,fm;
	cin>>n>>m;
	tm=m*2;
	fm=tm*2;
	int i,j;
	for(i=1;i<=n;i++) cin>>a[i].x>>a[i].y>>a[i].c;
	for(i=1;i<=n;i++){
		if(a[i].c=='B') sum[a[i].x%tm][a[i].y%tm]++;
		else sum[(a[i].x+m)%tm][a[i].y%tm]++;
	}
	for(i=1;i<=tm;i++) for(j=1;j<=tm;j++){
		sum[i][j+tm]=sum[i][j];
		sum[i+tm][j]=sum[i][j];
		sum[i+tm][j+tm]=sum[i][j];
	}
	for(i=fm-1;i>-1;i--) for(j=fm-1;j>-1;j--) sum[i][j]=sum[i][j]+sum[i+1][j]+sum[i][j+1]-sum[i+1][j+1];
	int ans=0;
	for(i=1;i<=tm;i++) for(j=1;j<=tm;j++) ans=max(ans,find(i,j,i+m-1,j+m-1)+find(i+m,j+m,i+tm-1,j+tm-1));
	cout<<ans<<endl;
	return 0;
}

Compiler output:
main.c:1:9: fatal error: map: No such file or directory
    1 | #include<map>
      |         ^~~~~
compilation terminated.
Language: C

#include<map>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>

#define mp make_pair

using namespace std;

const int Mxn=100005;
const int Mxm=1005;
int sum[Mxm*4][Mxm*4];
struct in{
	int x,y;
	char c;
}a[Mxn];
inline int find(int x,int y,int X,int Y){
	return sum[x][y]-sum[x][Y+1]-sum[X+1][y]+sum[X+1][Y+1];
}
int main(){
	int n,m,tm,fm;
	cin>>n>>m;
	tm=m*2;
	fm=tm*2;
	int i,j;
	for(i=1;i<=n;i++) cin>>a[i].x>>a[i].y>>a[i].c;
	for(i=1;i<=n;i++){
		if(a[i].c=='B') sum[a[i].x%tm][a[i].y%tm]++;
		else sum[(a[i].x+m)%tm][a[i].y%tm]++;
	}
	for(i=1;i<=tm;i++) for(j=1;j<=tm;j++){
		sum[i][j+tm]=sum[i][j];
		sum[i+tm][j]=sum[i][j];
		sum[i+tm][j+tm]=sum[i][j];
	}
	for(i=fm-1;i>-1;i--) for(j=fm-1;j>-1;j--) sum[i][j]=sum[i][j]+sum[i+1][j]+sum[i][j+1]-sum[i+1][j+1];
	int ans=0;
	for(i=1;i<=tm;i++) for(j=1;j<=tm;j++) ans=max(ans,find(i,j,i+m-1,j+m-1)+find(i+m,j+m,i+tm-1,j+tm-1));
	cout<<ans<<endl;
	return 0;
}

Compiler output:
main.c:1:9: fatal error: map: No such file or directory
    1 | #include<map>
      |         ^~~~~
compilation terminated.
Language: Java


import java.util.Arrays;
import java.util.Scanner;

public class D {

	public static void main(String[] args) {
		D d = new D();
		d.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {
		int n = sc.nextInt();
		int k = sc.nextInt();

		int x[] = new int[n];
		int y[] = new int[n];
		int worb[] = new int[n];

		for (int i = 0; i < n; i++) {
			x[i] = (sc.nextInt()) % (2 * k);
			y[i] = (sc.nextInt()) % (2 * k);
			worb[i] = sc.next().startsWith("W") ? 1 : -1;
		}

		int nn = k * 2;
		int mapW[][] = new int[nn][nn];
		int mapB[][] = new int[nn][nn];
		for (int i = 0; i < n; i++) {
			mapW[x[i]][y[i]] += worb[i] == 1 ? 1 : 0;
			mapB[x[i]][y[i]] += worb[i] == -1 ? 1 : 0;
		}

//		System.out.println(Arrays.deepToString(mapW));
//		System.out.println(Arrays.deepToString(mapB));
		
		int m2[][] = new int[nn][nn];

		for (int i = 0; i < nn; i++) {

			int init = 0;
			for (int j = 0; j < nn; j++) {
				init += (j < k) ? mapW[i][j] : mapB[i][j];
			}

			m2[i][0] = init;

			for (int j = 0; j < nn - 1; j++) {
				int j2 = (j + k) % nn;
				m2[i][j + 1] = m2[i][j] - mapW[i][j] + mapB[i][j] + mapW[i][j2] - mapB[i][j2];
			}
		}
		
//		System.out.println(Arrays.deepToString(m2));
		

		int m3[][] = new int[nn][nn];

		for (int j = 0; j < nn; j++) {
			int init = 0;
			for (int i = 0; i < nn; i++) {
				int j2 = (i < k ? j : j + k) % nn;
				init += m2[i][j2];
			}
			m3[0][j] = init;

			for (int i = 0; i < nn - 1; i++) {
				int i2 = (i + k) % nn;
				int j2 = (j + k) % nn;
				m3[i + 1][j] = m3[i][j] - m2[i][j2] + m2[i][j2] + m2[i2][j2] - m2[i2][j2];
			}
		}
//		System.out.println(Arrays.deepToString(m2));

		int max = 0;
		for (int i = 0; i < nn; i++) {
			for (int j = 0; j < nn; j++) {
				max = Math.max(max, m3[i][j]);
			}
		}
		System.out.println(max);

	}

}


Compiler output:
Main.java:5: error: class D is public, should be declared in a file named D.java
public class D {
       ^
1 error
Language: C++

#include <bits/stdc++.h>
#define rep(i,a,b)	for(int i=a;i<=b;i++)
using namespace std;
const int N=2e5+5,M=6008;
int n,k,x,y,m;
string c;
int f[M][M];
int calc(int x1,int y1)
{
	int x2=x1+k-1,y2=y1+k-1;
	x1=max(1,x1),y1=max(1,y1);
	x2=min(x2,m),y2=min(y2,,m);
	if(x2<1||y2<1)
		return 0;
	return f[x2][y2]-f[x1-1][y2]-f[x2][y1-1]+f[x1-1][y1-1];
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k;	
	m=2*k;
	memset(f,0,sizeof(f));
	rep(i,1,n)
	{
		cin>>x>>y>>c;
		if(c=="W")
			y+=k;
		x%=m,y%=m;
		x++,y++;
		f[x][y]++;
	}
	for(int i=1;i<=2*m;i++)
		for(int j=1;j<=2*m;j++)
			f[i][j]=f[i][j]+f[i][j-1]+f[i-1][j]-f[i-1][j-1];
	int res=0;
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=m;j++)
		{
			int cnt=calc(i,j);
			cnt+=calc(i-k,j-k)+calc(i-k,j+k)+calc(i+k,j-k)+calc(i+k,j+k);
		//	cnt+=calc(i,j+m)+calc(i+m,j);
			cnt+=calc(i-m,j)+calc(i+m,j)+calc(i,j-m)+calc(i,j+m);
			res=max(res,cnt);
		}
	}
	cout<<res<<endl;
	return 0;
	
}

Compiler output:
a.cc: In function 'int calc(int, int)':
a.cc:12:32: error: expected primary-expression before ',' token
   12 |         x2=min(x2,m),y2=min(y2,,m);
      |                                ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int c[2010][2010]={0},num[2010][2010]={0},n,k;
inline int sum(x1,y1,x2,y2){
	return num[x2][y2]-num[x1-1][y2]-num[x2][y1-1]+num[x1-1][y1-1];
}
int main(){
	int i,j,l,x,y,ans=0,now;
	char a;
	cin>>n>>k;
	for(i=0;i<n;i++)
	{
		cin>>x>>y>>a;
		if(a=='W')	y+=k;
		c[x%(2*k)+1][y%(2*k)+1]++;
	}
	for(i=1;i<2010;i++){
		for(j=1;j<2010;j++){
			num[i][j]=num[i-1][j]+num[i][j-1]-num[i-1][j-1]+c[i][j];
		}
	}
	for(i=1;i<=2*k;i++){
		for(j=1;j<=2*k;j++){
			now=sum(i,j,i+k-1,j+k-1)+sum(i+k,j+k,2*k-1,2*k-1)+sum(i+k,0,2*k-1,j-1)+sum(0,0,i-1,j-1)+sum(0,j+k,i-1,2*k-1);
			if(now>ans)	ans=now;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc:4:16: error: 'x1' was not declared in this scope; did you mean 'y1'?
    4 | inline int sum(x1,y1,x2,y2){
      |                ^~
      |                y1
a.cc:4:22: error: 'x2' was not declared in this scope
    4 | inline int sum(x1,y1,x2,y2){
      |                      ^~
a.cc:4:25: error: 'y2' was not declared in this scope; did you mean 'yn'?
    4 | inline int sum(x1,y1,x2,y2){
      |                         ^~
      |                         yn
a.cc:4:27: error: expression list treated as compound expression in initializer [-fpermissive]
    4 | inline int sum(x1,y1,x2,y2){
      |                           ^
a.cc: In function 'int main()':
a.cc:24:32: error: 'sum' cannot be used as a function
   24 |                         now=sum(i,j,i+k-1,j+k-1)+sum(i+k,j+k,2*k-1,2*k-1)+sum(i+k,0,2*k-1,j-1)+sum(0,0,i-1,j-1)+sum(0,j+k,i-1,2*k-1);
      |                             ~~~^~~~~~~~~~~~~~~~~
a.cc:24:53: error: 'sum' cannot be used as a function
   24 |                         now=sum(i,j,i+k-1,j+k-1)+sum(i+k,j+k,2*k-1,2*k-1)+sum(i+k,0,2*k-1,j-1)+sum(0,0,i-1,j-1)+sum(0,j+k,i-1,2*k-1);
      |                                                  ~~~^~~~~~~~~~~~~~~~~~~~~
a.cc:24:78: error: 'sum' cannot be used as a function
   24 |                         now=sum(i,j,i+k-1,j+k-1)+sum(i+k,j+k,2*k-1,2*k-1)+sum(i+k,0,2*k-1,j-1)+sum(0,0,i-1,j-1)+sum(0,j+k,i-1,2*k-1);
      |                                                                           ~~~^~~~~~~~~~~~~~~~~
a.cc:24:99: error: 'sum' cannot be used as a function
   24 |                         now=sum(i,j,i+k-1,j+k-1)+sum(i+k,j+k,2*k-1,2*k-1)+sum(i+k,0,2*k-1,j-1)+sum(0,0,i-1,j-1)+sum(0,j+k,i-1,2*k-1);
      |                                                                                                ~~~^~~~~~~~~~~~~
a.cc:24:116: error: 'sum' cannot be used as a function
   24 |                         now=sum(i,j,i+k-1,j+k-1)+sum(i+k,j+k,2*k-1,2*k-1)+sum(i+k,0,2*k-1,j-1)+sum(0,0,i-1,j-1)+sum(0,j+k,i-1,2*k-1);
      |                                                                                                                 ~~~^~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
using namespace std;
const int N=1e5+5;
int x[N],y[N];
char c[N];
int sx[N],sy[N],s[N][N],n,k,ans;
int main(){Accel
	cin>>n>>k;
	int cnt=0;
	REP(i,n){
		cin>>x[i]>>y[i]>>c[i];
		int g=(c[i]=='B');
		int d=(x[i]/k+y[i]/k)&1==g?1:-1;		
		x[i]%=k,y[i]%=k;
		sx[x[i]]+=d;
		sy[y[i]]+=d;
		s[x[i]][y[i]]+=d;
		if(d<0)cnt++;
	}
	
	for(int i=k-1;i>=0;i--)sx[i]+=sx[i+1],sy[i]+=sy[i+1];
	for(int i=k-1;i>=0;i--){
		for(int j=k-1;j>=0;j--)s[i][j]+=s[i][j+1];
		for(int j=k-1;j>=0;j--)s[i][j]+=s[i+1][j];	
		
	}
	ans=cnt;
	REP(i,k){
		REP(j,k){
			ans=max(ans,cnt+sx[i]+sy[i]-s[i][j]*2);
			ans=max(ans,n-(cnt+sx[i]+sy[i]-s[i][j]*2));
		
		}
		
	}
	cout<<ans<<endl;
}


Compiler output:
/tmp/cc94zJRV.o: in function `main':
a.cc:(.text+0x3d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc94zJRV.o
a.cc:(.text+0x59): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cc94zJRV.o
a.cc:(.text+0x11a): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cc94zJRV.o
a.cc:(.text+0x13c): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cc94zJRV.o
a.cc:(.text+0x17e): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cc94zJRV.o
a.cc:(.text+0x1b7): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cc94zJRV.o
a.cc:(.text+0x340): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc94zJRV.o
a.cc:(.text+0x34f): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cc94zJRV.o
a.cc:(.text+0x404): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cc94zJRV.o
a.cc:(.text+0x415): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cc94zJRV.o
a.cc:(.text+0x4ac): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<cstdio>

int MAXN=1e5+5,MAXK=1e3+5;

int n,k;

int f[MAXK<<1][MAXK<<1];

inline void mtAdd(int x1,int y1,int x2,int y2)
{f[x1][y1]++,f[x1+1][y1+1]++,f[x1][y2+1]--,f[x2+1][y1]--;}

int main()
{
	int i,j;scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)
	{
		char s[10];
		int x,y,c;scanf("%d%d%s",&x,&y,s);if(s[0]=='B') c=1;
		if(c==(x/k&1)^(y/k&1))
		{
			mtAdd(0,0,x,y),mtAdd(x+1,y+1,x+k,y+k),mtAdd(x+k+1,y+k+1,2*k-1,2*k-1);
		}
		else
		{
			mtAdd(0,y+1,x,y+k),mtAdd
		}
	}
	return 0;
}

Compiler output:
a.cc:8:20: error: size of array 'f' is not an integral constant-expression
    8 | int f[MAXK<<1][MAXK<<1];
      |                ~~~~^~~
a.cc:8:11: error: size of array 'f' is not an integral constant-expression
    8 | int f[MAXK<<1][MAXK<<1];
      |       ~~~~^~~
a.cc: In function 'int main()':
a.cc:26:49: error: expected ';' before '}' token
   26 |                         mtAdd(0,y+1,x,y+k),mtAdd
      |                                                 ^
      |                                                 ;
   27 |                 }
      |                 ~
Language: C++

/* ***********************************************
Author        :yang12138
Created Time  :2018年01月21日 星期日 21时14分45秒
File Name     :D.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)
 
const int N=2005;
 
int B[N][N],W[N][N];
 
void add(int bit[N][N],int x,int y){
	bit[x][y]++;
}
 
int sum(int bit[N][N],int x,int y){
	return bit[x][y];
}
 
int get(int bit[N][N],int x1,int y1,int x2,int y2){
	if(!(x1<=x2 && y1<=y2)) return 0;
	return sum(bit,x2,y2)-sum(bit,x2,y1-1)-sum(bit,x1-1,y2)+sum(bit,x1-1,y1-1);
}
 
void solve(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		int x,y;
		char ch;
		scanf("%d %d %c",&x,&y,&ch);
		if(ch=='B') x+=k;
		x%=2*k,y%=2*k;
		x++,y++;
		add(W,x,y);
		/*
		if(ch=='W') add(W,x,y);
		else add(B,x,y);
		*/
	}
 
	for(int i=1;i<=2*k;i++){
		for(int j=1;j<=2*k;j++){
			W[i][j]+=W[i][j-1];
			B[i][j]+=B[i][j-1];
		}
	}
	for(int j=1;j<=2*k;j++){
		for(int i=1;i<=2*k;i++){
			W[i][j]+=W[i-1][j];
			B[i][j]+=B[i-1][j];
		}
	}
 
 
	int ans=0;
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			int tmp=0;
			tmp+=get(W,1,1,i,j)+get(W,i+1,j+1,i+k,j+k);
			tmp+=get(W,i+k+1,j+k+1,2*k,2*k)+get(W,1,j+k+1,i,2*k)+get(W,i+k+1,1,2*k,j);
			ans=max(ans,max(tmp,(n-tmp)));
			/*
			tmp+=get(B,1,j+1,i,j+k)+get(B,i+k+1,j+1,2*k,j+k);
			tmp+=get(B,i+1,1,i+k,j)+get(B,i+1,j+k+1,i+k,2*k);
			ans=max(ans,tmp);
 
			tmp=0;
			tmp+=get(B,1,1,i,j)+get(B,i+1,j+1,i+k,i+k);
			tmp+=get(B,i+k+1,j+k+1,2*k,2*k)+get(B,1,j+k+1,i,2*k)+get(B,i+k+1,1,2*k,j);
			tmp+=get(W,1,j+1,i,j+k)+get(W,i+k+1,j+1,2*k,j+k);
			tmp+=get(W,i+1,1,i+k,j)+get(W,i+1,j+k+1,i+k,2*k);
			ans=max(ans,tmp);
			*/
		}
	}
 
	printf("%d\n",ans);
}
 
int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    
	solve();
    return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:102:14: error: expected '}' at end of input
  102 |     return 0;
      |              ^
a.cc:97:11: note: to match this '{'
   97 | int main(){
      |           ^
Language: Java

import static java.lang.Math.*;
import java.util.Scanner;
*
public class Main {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            int N = scanner.nextInt();
            int K = scanner.nextInt();
            int [] x = new int[N];
            int [] y = new int[N];
            char [] c = new char[N];
            
            for (int i=0; i<N; i++){
                x[i] = scanner.nextInt();
                y[i] = scanner.nextInt();
                c[i] = scanner.next().charAt(0);
            }

            int nhopeMax = 0;
            int nhope = 0;
            int basex;
            int basey;
            for (int i=K; i>0; i--){
                for (int j=K; j>0; j--){
                    basex = x[0]-i;
                    basey = y[0]-j;
                    for(int l=0; l<N; l++){
                        int distx = abs(x[l]-basex);
                        int disty = abs(y[l]-basey);
                        if ((((distx / K)+(disty / K)) % 2)==0){
                            if (c[0] == c[l]) nhope++;
                        } else {
                            if (c[0] != c[l]) nhope++;
                        }
                        //System.out.println("dx="+distx+" xy="+disty+" x="+x[l]+" y="+y[l]+" col="+c[l]+" nhope="+nhope);
                    }
                    if (nhopeMax < nhope) nhopeMax = nhope;
                    nhope=0;
                    if (nhopeMax == N) break;
                }
                if (nhopeMax == N) break;
            }
            System.out.println(nhopeMax);
        }
}

Compiler output:
Main.java:3: error: class, interface, enum, or record expected
*
^
1 error
Language: C++

int n, k, count[2][2001][2001] = { 0 };
int area_count(int co, int off_x, int off_y) {
	if (off_x <= k) {
		if (off_y <= k)
			return count[co][off_x + k][off_y + k] + count[co][off_x][off_y] - count[co][off_x + k][off_y] - count[co][off_x][off_y + k];
		else {
			int r1 = count[co][off_x + k][k * 2] + count[co][off_x][off_y] - count[co][off_x + k][off_y] - count[co][off_x][k * 2];
			int r2 = count[co][off_x + k][off_y - k] - count[co][off_x][off_y - k];
			return r1 + r2;
		}
	}
	else {
		if (off_y <= k) {
			int r1 = count[co][k * 2][off_y + k] + count[co][off_x][off_y] - count[co][k * 2][off_y] - count[co][off_x][off_y + k];
			int r2 = count[co][off_x - k][off_y + k] - count[co][off_x - k][off_y];
			return r1 + r2;
		}
		else {
			int r1 = count[co][k * 2][k * 2] + count[co][off_x][off_y] - count[co][k * 2][off_y] - count[co][off_x][k * 2];
			int r2 = count[co][off_x - k][off_y - k];
			int r3 = count[co][k * 2][off_y - k] - count[co][off_x][off_y - k];
			int r4 = count[co][off_x - k][k * 2] - count[co][off_x - k][off_y];
			return r1 + r2 + r3 + r4;
		}
	}
}
int main() {
	int black_count = 0, white_count = 0;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) {
		char c;
		int x, y;
		scanf("%d %d %c", &x, &y, &c);
		(c == 'W' ? white_count : black_count)++;
		count[c != 'W'][x % (k * 2) + 1][y % (k * 2) + 1]++;
	}
	for (int i = 1; i <= k * 2; i++) {
		count[0][i][0] = count[1][i][0] = 0;
		for (int j = 1; j <= k * 2; j++) {
			count[0][i][j] += count[0][i][j - 1];
			count[1][i][j] += count[1][i][j - 1];
		}
		for (int j = 1; j <= k * 2; j++) {
			count[0][i][j] += count[0][i - 1][j];
			count[1][i][j] += count[1][i - 1][j];
		}
	}
	int max_match = 0;
	for (int i = 0; i < k; i++)
		for (int j = 0; j < k; j++) {
			int match = area_count(0, i, j) + area_count(0, (i + k) % (k * 2), (j + k) % (k * 2));
			match += black_count - (area_count(1, i, j) + area_count(1, (i + k) % (k * 2), (j + k) % (k * 2)));
			max_match = std::max(max_match, match);
		}
	printf("%d\n", max_match);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:9: error: 'scanf' was not declared in this scope
   29 |         scanf("%d %d", &n, &k);
      |         ^~~~~
a.cc:53:42: error: 'max' is not a member of 'std'
   53 |                         max_match = std::max(max_match, match);
      |                                          ^~~
a.cc:55:9: error: 'printf' was not declared in this scope
   55 |         printf("%d\n", max_match);
      |         ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | int n, k, count[2][2001][2001] = { 0 };
Language: C++

#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <string>
#include <tuple>
#include <cmath>
#include <unordered_map>
 
using namespace std;
typedef long long ll;

int N, K;
int X[100001];
int Y[100001];
int C[100001];

unordered_multimap<int, int> x_to_indices;
unordered_multimap<int, int> y_to_indices;

int color(int x, int y) {
    int xx = floor((double)x / K);
    int yy = floor((double)y / K);
    return (xx ^ yy) & 1;
}

int mod(int x, int m) {
    return ((x % m) + m) % m;
}

int solve(int px, int py) {
    int num = 0;
    for (int i = 0; i < N; i ++) {
        if (color(X[i] - px, Y[i] - py) == C[i]) {
            num ++;
        }
    }
    return num;
}

int reflect_diff_x(int px, int py) {
    int num = 0;
    auto p = x_to_indices.equal_range(px);
    for (auto it = p.first; it != p.second; ++it) {
        int index = it->second;
        if (color(X[index] - px, Y[index] - py) == C[index]) {
            num -= 1;
        } else {
            num += 1;
        }
    }
    p = x_to_indices.equal_range((px + K) % (2*K));
    for (auto it = p.first; it != p.second; ++it) {
        int index = it->second;
        if (color(X[index] - px, Y[index] - py) == C[index]) {
            num -= 1;
        } else {
            num += 1;
        }
    }
    return num;
}

int reflect_diff_y(int px, int py) {
    int num = 0;
    auto p = y_to_indices.equal_range(py);
    for (auto it = p.first; it != p.second; ++it) {
        int index = it->second;
        if (color(X[index] - px, Y[index] - py) == C[index]) {
            num -= 1;
        } else {
            num += 1;
        }
    }
    p = y_to_indices.equal_range((py + K) % (2*K));
    for (auto it = p.first; it != p.second; ++it) {
        int index = it->second;
        if (color(X[index] - px, Y[index] - py) == C[index]) {
            num -= 1;
        } else {
            num += 1;
        }
    }
    return num;
}

signed main() {
    cin >> N >> K;
    for (int i = 0; i < N; i ++) {
        char c;
        cin >> X[i] >> Y[i] >> c;
        X[i] = mod(X[i], 2 * K);
        Y[i] = mod(Y[i], 2 * K);
        C[i] = c == 'B' ? 1 : 0;
        x_to_indices.emplace(X[i], i);
        y_to_indices.emplace(Y[i], i);
    }
    int value1 = solve(0, 0);
    int value2 = solve(K, K);
    int ans = max(value1, value2);
    for (int px = 0; px < 2 * K; px ++) {
        int v1 = value1;
        int v2 = value2;
        for (int py = 0; py < K; py ++) {
            int r = reflect_diff_y(px, py);
            value1 += r;
            value2 += r;
            ans = max(ans, value1);
            ans = max(ans, value2);
        }
        int r = reflect_diff_y(px, py);
        value1 = v1 + r;
        value2 = v2 + r;
        ans = max(ans, value1);
        ans = max(ans, value2);
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:112:36: error: 'py' was not declared in this scope; did you mean 'px'?
  112 |         int r = reflect_diff_y(px, py);
      |                                    ^~
      |                                    px
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
const int MAXN = 2000 + 10;
int cnt[MAXN][MAXN],tmp[MAXN][MAXN];
int n;
void update(int x1, int x2, int y1, int y2) {
    while (x2 <= 0) {
        x2 += n;
        x1 += n;
    }
    while (y2 <= 0) {
        y2 += n;
        y1 += n;
    }
    if (x1 < 0) {
        update(0, x2, y1, y2);
        update(n+x1, n, y1, y2);
        return;
    }
    if (y1 < 0) {
        update(x1, x2, 0, y2);
        update(x1, x2, n+y1, n);
        return;
    }
    cnt[x1][y1]++;
    cnt[x1][y2]--;
    cnt[x2][y1]--;
    cnt[x2][y2]++;

    return;
}

int main() {
//    freopen("test.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int q; cin >> q;
    int k; cin >> k;
    n = 2*k;
    int x, y;
    char c;
    while (q--) {
        cin >> x >> y >> c;
        x = x % n; y = y % n;
        if (c == 'W') {
            update(-x, k-x, k-y, n-y);
            update(k-x, n-x, -y, k-y);
        }
        else {
            update(-x, k-x, -y, k-y);
            update(k-x, n-x, k-y, n-y);
        }

    }
    for (int i = 0; i < n; i++) {
        for (int j = 1; j < n; j++) {
            cnt[i][j] += cnt[i][j-1];
        }
    }

    for (int j = 0; j < n; j++) {
        for (int i = 1; i < n; i++) {
            cnt[i][j] += cnt[i-1][j];
        }
    }
    int ret = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            ret = max(ret, cnt[i][j]);
    }
    cout << ret << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:75:2: error: expected '}' at end of input
   75 | }
      |  ^
a.cc:34:12: note: to match this '{'
   34 | int main() {
      |            ^
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
const int MAXN = 2000 + 10;
int cnt[MAXN][MAXN],tmp[MAXN][MAXN];
int n;
void update(int x1, int x2, int y1, int y2) {
    while (x2 <= 0) {
        x2 += n;
        x1 += n;
    }
    while (y2 <= 0) {
        y2 += n;
        y1 += n;
    }
    if (x1 < 0) {
        update(0, x2, y1, y2);
        update(n+x1, n, y1, y2);
        return;
    }
    if (y1 < 0) {
        update(x1, x2, 0, y2);
        update(x1, x2, n+y1, n);
    }
    cnt[x1][y1]++;
    cnt[x1][y2]--;
    cnt[x2][y1]--;
    cnt[x2][y2]++;

    return;
}

int main() {
//    freopen("test.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int q; cin >> q;
    int k; cin >> k;
    n = 2*k;
    int x, y;
    char c;
    while (q--) {
        cin >> x >> y >> c;
        x = x % n; y = y % n;
        if (c == 'W') {
            update(-x, k-x, k-y, n-y);
            update(k-x, n-x, -y, k-y);
        }
        else {
            update(-x, k-x, -y, k-y);
            update(k-x, n-x, k-y, n-y);
        }

    }
    for (int i = 0; i < n; i++) {
        for (int j = 1; j < n; j++) {
            cnt[i][j] += cnt[i][j-1];
        }
    }

    for (int j = 0; j < n; j++) {
        for (int i = 1; i < n; i++) {
            cnt[i][j] += cnt[i-1][j];
        }
    }
    int ret = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            ret = max(ret, cnt[i][j]);
    }
    cout << ret << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:74:2: error: expected '}' at end of input
   74 | }
      |  ^
a.cc:33:12: note: to match this '{'
   33 | int main() {
      |            ^
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;

const int SMAX = 1000;
const int MAX = 100000;
int main() {
	int N, K;
	cin >> N >> K;
	static int x, y, cum[SMAX][SMAX], map[SMAX][SMAX], wish = 0, BX[SMAX], BY[SMAX];
	char c;
	memset(map, 0, sizeof(char) * SMAX * SMAX);
	memset(BX, 0, sizeof(int) * SMAX);
	memset(BY, 0, sizeof(int) * SMAX);
	for (int i = 0;i < N;i ++) {
		cin >> x >> y >> c;
		x %= K << 1;
		y %= K << 1;
		if (x >= K) {
			x %= K;
			c = (c == 'B' ? 'W' : 'B');
		}
		if (y >= K) {
			y %= K;
			c = (c == 'B' ? 'W' : 'B');
		}
		map[y][x] += (c == 'B' ? 1 : -1);
		if (c == 'B') wish ++;
		BX[y] += (c == 'B' ? -1 : 1);
		BY[x] += (c == 'B' ? -1 : 1);
	}
	
	cum[0][0] = wish;
	for (int j = 1;j < K;j ++) {
		cum[0][j] = cum[0][j - 1] + BY[j - 1];
	}
	for (int i = 1;i < K;i ++) {
		cum[i][0] = cum[i - 1][0] + BX[i - 1];
		for (int j = 1;j < K;j ++) {
			cum[i][j] = cum[i][j - 1] + BY[j - 1] + (map[i - 1][j - 1] << 1);
		}
	}
	// デバッグ
	/*
	for (int i = K - 1;i >= 0;i --) {
		for (int j = 0;j < K;j ++) {
			cout << map[i][j];
		}
		cout << endl;
	}
	cout << endl;
	
	for (int i = K - 1;i >= 0;i --) {
		for (int j = 0;j < K;j ++) {
			cout << cum[i][j];
		}
		cout << endl;
	}
	cout << endl;
	*/
	// ここまで
	
	int ma = 0;
	for (int i = 0;i < K;i ++) {
		for (int j = 0;j < K;j ++) {
			ma = max(ma, cum[i][j]);
			ma = max(ma, N - cum[i][j]);
		}
	}
	cout << ma;
	return 0;
}
/*
K<=1000より、値が小さいことに着目。
まず、市松模様なので(x,y)=(x+K,y)=(x,y+K)が成り立つので、座標を圧縮できる
この時0<=xi<Kが成立できる
次に、この時x座標だけで考えると、ある座標を基準に黒/白を分断することが分かる
これはy座標についても同様
つまり、このある座標を求めれば良い
ちなみに、ある座標を含む右上と左下が黒、左上と右下が白な 問題例だと(4,2)
ある座標は全部でK^2通り考えられるので、それぞれについて何個の希望を満たせるかを考える
ここで、0からある座標までに点が何個あるかを求める二次元累積和があったとする
これを利用すれば、それぞれのある座標における希望の叶えられる数をO(1)で求められる
因みに反転系も考えるので、二次元累積和の値はN-その値も比較するようにね

ごめん考察直す時間ない、またあとで
*/

Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'memset' was not declared in this scope
   12 |         memset(map, 0, sizeof(char) * SMAX * SMAX);
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include<algorithm>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

vector<pair<int,int>> v[1010];
int cntx[1010],cnty[1010],n,k,ans,vx[1010],vy[1010],t[1010];

solve(int tip)
{
    int sol=0;
    for(int i=1;i<=k;i++)
    {
        v[i].clear();
        cntx[i]=0;cnty[i]=0;
    }
    for(int i=1;i<=n;i++)
    {
        int a=vx[i]/k,b=vy[i]/k,p=0;
        int d1=(a+1)*k-vx[i],d2=(b+1)*k-vy[i];
        if(a%2==0 && b%2==0) {if(t[i]==tip) {sol++;p=1;}}
        else if(a%2==1 && b%2==1) {if(t[i]==tip) {sol++;p=1;}}
        else if(t[i]==1-tip) {sol++;p=1;}
        if(p==1) {cntx[d1]--;cnty[d2]--;v[d1].push_back({d2,2});}
        else {cntx[d1]++;cnty[d2]++;v[d1].push_back({d2,-2});}
    }
    for(int i=0;i<=k;i++)
    {
        sol+=cntx[i];
        for(int j=0;j<v[i].size();j++) cnty[v[i][j].first]+=v[i][j].second;
        for(int j=0;j<=k;j++)
        {
            sol+=cnty[j];
            ans=max(ans,sol);
        }
        for(int j=0;j<=k;j++) sol-=cnty[j];
    }
}

int main()
{
    //freopen("file.in","r",stdin);
    //freopen("file.out","w",stdout);
    char c;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        if(i==n) scanf("%d%d %c",&vx[i],&vy[i],&c);
        else scanf("%d%d %c\n",&vx[i],&vy[i],&c);
        if(c=='W') t[i]=0;
        else t[i]=1;
    }
    solve(0);
    solve(1);
    printf("%d",ans);
    return 0;
}


Compiler output:
a.cc:10:1: error: ISO C++ forbids declaration of 'solve' with no type [-fpermissive]
   10 | solve(int tip)
      | ^~~~~
a.cc: In function 'int solve(int)':
a.cc:39:1: warning: no return statement in function returning non-void [-Wreturn-type]
   39 | }
      | ^
Language: C++

#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

vector<pair<int,int>> v[1010];
int cntx[1010],cnty[1010],n,k,ans,vx[1010],vy[1010],t[1010];

solve(int tip)
{
    int sol=0;
    for(int i=1;i<=k;i++)
    {
        v[i].clear();
        cntx[i]=0;cnty[i]=0;
    }
    for(int i=1;i<=n;i++)
    {
        int a=vx[i]/k,b=vy[i]/k,p=0;
        int d1=(a+1)*k-vx[i],d2=(b+1)*k-vy[i];
        if(a%2==0 && b%2==0) {if(t[i]==tip) {sol++;p=1;}}
        else if(a%2==1 && b%2==1) {if(t[i]==tip) {sol++;p=1;}}
        else if(t[i]==1-tip) {sol++;p=1;}
        if(p==1) {cntx[d1]--;cnty[d2]--;v[d1].push_back({d2,2});}
        else {cntx[d1]++;cnty[d2]++;v[d1].push_back({d2,-2});}
    }
    for(int i=0;i<=k;i++)
    {
        sol+=cntx[i];
        for(int j=0;j<v[i].size();j++) cnty[v[i][j].first]+=v[i][j].second;
        for(int j=0;j<=k;j++)
        {
            sol+=cnty[j];
            ans=max(ans,sol);
        }
        for(int j=0;j<=k;j++) sol-=cnty[j];
    }
}

int main()
{
    //freopen("file.in","r",stdin);
    //freopen("file.out","w",stdout);
    char c;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d %c\n",&vx[i],&vy[i],&c);
        if(c=='W') t[i]=0;
        else t[i]=1;
    }
    solve(0);
    solve(1);
    printf("%d",ans);
    return 0;
}


Compiler output:
a.cc:10:1: error: ISO C++ forbids declaration of 'solve' with no type [-fpermissive]
   10 | solve(int tip)
      | ^~~~~
a.cc: In function 'int solve(int)':
a.cc:39:1: warning: no return statement in function returning non-void [-Wreturn-type]
   39 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int n,m,i,j,a[2005][2005],x[100005],y[100005],ans,op[100005];
int main()
{
	cin>>n>>m;
	for (i=1;i<=n;i++)
	{
		cin>>x[i]>>y[i];
		x%=(m*2);
		y%=(m*2);
		char c;
		cin>>c;
		op[i]=((c=='B')?1:-1);
	}
	for (i=0;i<m;i++)
	{
		for (j=0;j<m;j++)
		{
			memset(a,0,sizeof(a));
			int t=0;
			int k,l;
			for (k=0;k<i;k++)
			{
				for (l=0;l<j;l++)
				{
					a[k][l]=1;
				}
			}
			for (k=0;k<i;k++)
			{
				for (l=j+m;l<=2000;l+=m*2)
				{
					a[k][l]=1;
				}
			}
			for (k=0;k<j;k++)
			{
				for (l=i+m;l<=2000;l+=m*2)
				{
					a[l][k]=1;
				}
			}
			for (k=i;k<=2000;k+=m*2)
			{
				for (l=j;l<=2000;l+=m*2)
				{
					a[k][l]=m;
				}
			}
			for (k=i+m;k<=2000;k+=m*2)
			{
				for (l=j+m;l<=2000;l+=m*2)
				{
					a[k][l]=m;
				}
			}
			for (k=0;k<=2000;k++)
			{
				for (l=0;l<=2000;l++)
				{
					if (k) a[k][l]=max(a[k][l],a[k-1][l]-1);
					if (l) a[k][l]=max(a[k][l],a[k][l-1]-1);
				}
			}
			for (k=1;k<=n;k++)
			{
				if (a[x[k]][y[k]]&&op[k]==1) t++;
				if (a[x[k]][y[k]]==0&&op[k]==-1) t++;
			}
			ans=max(ans,t);
		}
	}
	cout<<ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:18: error: invalid operands of types 'int [100005]' and 'int' to binary 'operator%'
   10 |                 x%=(m*2);
      |                 ~^~~~~~~
a.cc:10:18: note:   in evaluation of 'operator%=(int [100005], int)'
a.cc:11:18: error: invalid operands of types 'int [100005]' and 'int' to binary 'operator%'
   11 |                 y%=(m*2);
      |                 ~^~~~~~~
a.cc:11:18: note:   in evaluation of 'operator%=(int [100005], int)'