include[HTML_REMOVED]
include[HTML_REMOVED]
include[HTML_REMOVED]
int w, r, m, n, i, j, c[10], cntl,cnt1, cnt2, k, la, xb, yb, x, y;
long long cnt, sum;
int f[6000][6000];
int a[1000005], maxx, maxy;
char s[100000];
int cmp(const void a ,const void b);
void dfs(int r);
long long max(int a, int b);
int main()
{
scanf(“%d%d”, &n, &r);
for(i=1;i<=n;i){
scanf(“%d%d%d”, &x, &y, &w);
f[x+1][y+1] += w;
}
for(i=1;i<5010;i){
for(j=1;j<5010;j){
f[i][j] = f[i-1][j]+f[i][j-1]-f[i-1][j-1]+f[i][j];
}
}
if(r>=5010) sum = f[n-1][n-1];
for(i=r;i<5010;i){
for(j=r;j<5010;j++){
sum = max(sum, f[i][j]-f[i-r][j]-f[i][j-r]+f[i-r][j-r]);
}
}
printf(“%lld”, sum);
return 0;
}
int cmp(const void a ,const void b)
{
return (int )a - (int )b ;
}
long long max(int a, int b){
if(a>b) return a;
else return b;
}