Language: C++

#include<bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const int inf = 1ll<<31;
const int mod = 1e9+7;

void show(vvi b){
  rep(i, sz(b)){
    rep(j, sz(b[i])){
      if(b[i][j] >= 0) cout << " ";
      cout << b[i][j];
    }
    cout << endl;
  }
  cout << endl;
}

main(){
  int n,k; cin >> n >> k;
  int size = 6 * k;
  vvi b(size, vi(size));
  rep(i,n){
    int x, y; char c;
    cin >> x >> y >> c;
    if(c == 'W') y += k;
    x %= 2 * k;
    y %= 2 * k;
    // 条件を満たす"右下"マスの集合を考える
    rep(j,2){
      rep(z, 2) rep(w, 2){
	  b[x + 2 * z * k][y + 2 * w * k]++;
	  b[x + 2 * z * k][y + k + 2 * w * k]--;
	  b[x + k + 2 * z * k][y + 2 * w * k]--;
	  b[x + k +  2 * z * k][y + k + 2 * w * k]++;
      }
      x += k; y += k;
    }
    //show(b);
  }
  //show(b);

  // 累積和
  rep(i, size) rep(j, size - 1) b[i][j + 1] += b[i][j];
  rep(i, size - 1) rep(j, size) b[i + 1][j] += b[i][j];
  //show(b);

  int ans = 0;
  FOR(i,2*k,4*k) FOR(j,2*k,4*k) ans = max(ans, b[i][j]);
  cout << ans << endl;
}

Compiler output:
a.cc:43:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   43 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:73:42: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)'
   73 |   FOR(i,2*k,4*k) FOR(j,2*k,4*k) ans = max(ans, b[i][j]);
      |                                       ~~~^~~~~~~~~~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:73:42: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   73 |   FOR(i,2*k,4*k) FOR(j,2*k,4*k) ans = max(ans, b[i][j]);
      |                                       ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:73:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   73 |   FOR(i,2*k,4*k) FOR(j,2*k,4*k) ans = max(ans, b[i][j]);
      |                                       ~~~^~~~~~~~~~~~~~