akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,k;
    cin >> n >> k;
    vvi v(k+1,vi(k*2+1,0));
    auto add = [&](int x,int y){
        bool flag = false;
        if(y < k-1) {
            y += k;
            flag = true;
        }
        if(flag) {
            v[0][y-k+1]++;
            v[0][y+1]--;
            v[x+1][y-k+1]--;
            v[x+1][y+1]++;

            v[x+1][0]++;
            v[x+1][y-k+1]--;
            v[x+1][y+1]++;
            v[x+1][k*2]--;
            v[k][0]--;
            v[k][y-k+1]++;
            v[k][y+1]--;
            v[k][k*2]++;
        } else {
            v[x+1][y-k+1]++;
            v[x+1][y+1]--;
            v[k][y-k+1]--;
            v[k][y+1]++;

            v[0][0]++;
            v[0][y-k+1]--;
            v[0][y+1]++;
            v[0][k*2]--;
            v[x+1][0]--;
            v[x+1][y-k+1]++;
            v[x+1][y+1]--;
            v[x+1][k*2]++;
        }
    };
    rep(i,n) {
        int x,y;
        char c;
        cin >> x >> y >> c;
        if(c == 'B') x += k;
        int sx = x%k,sy = y%k;
        if(((x-sx)/k+(y-sy)/k)&1) sy += k;
        add(sx,sy);
    }
    int ans = 0;
    rep(i,k) rep(j,k*2) {
        chmax(ans,v[i][j]);
        v[i][j+1] += v[i][j];
        v[i+1][j] += v[i][j];
        v[i+1][j+1] -= v[i][j];
    }
    cout << ans << endl;
}


Measured memory_bytes: 10240