This documentation is automatically generated by online-judge-tools/verification-helper
#include "dp/cumulative-sum-2d.hpp"
#include <bits/stdc++.h>
using namespace std;
template <class T>
struct CumulativeSum2D {
vector<vector<T> > data;
CumulativeSum2D(int W, int H) : data(W + 1, vector<T>(H + 1, 0)) {}
void add(int x, int y, T z) {
++x, ++y;
if (x >= data.size() || y >= data[0].size()) return;
data[x][y] += z;
}
void build() {
for (int i = 1; i < data.size(); i++) {
for (int j = 1; j < data[i].size(); j++) {
data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
}
}
}
T query(int sx, int sy, int gx, int gy) const {
return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]);
}
};
#line 1 "dp/cumulative-sum-2d.hpp"
#include <bits/stdc++.h>
using namespace std;
template <class T>
struct CumulativeSum2D {
vector<vector<T> > data;
CumulativeSum2D(int W, int H) : data(W + 1, vector<T>(H + 1, 0)) {}
void add(int x, int y, T z) {
++x, ++y;
if (x >= data.size() || y >= data[0].size()) return;
data[x][y] += z;
}
void build() {
for (int i = 1; i < data.size(); i++) {
for (int j = 1; j < data[i].size(); j++) {
data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
}
}
}
T query(int sx, int sy, int gx, int gy) const {
return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]);
}
};