#include <iostream>
using namespace std;
const int N = 100000;
int tr[101010];
void add(int pos, int val) {
for (int i = pos; i <= N; i |= (i + 1)) {
tr[i] += val;
}
}
int sum(int pos) {
int res = 0;
for (int i = pos; i >= 0; i = (i&(i + 1)) - 1) {
res += tr[i];
}
return res;
}
int main() {
// your code goes here
add(0, 5);
add(7, 10);
cout << sum(0) << ' ' << sum(7) << ' ' << sum(100) << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE4gPSAxMDAwMDA7CmludCB0clsxMDEwMTBdOwp2b2lkIGFkZChpbnQgcG9zLCBpbnQgdmFsKSB7Cglmb3IgKGludCBpID0gcG9zOyBpIDw9IE47IGkgfD0gKGkgKyAxKSkgewoJCXRyW2ldICs9IHZhbDsJCQoJfQp9CmludCBzdW0oaW50IHBvcykgewoJaW50IHJlcyA9IDA7Cglmb3IgKGludCBpID0gcG9zOyBpID49IDA7IGkgPSAoaSYoaSArIDEpKSAtIDEpIHsKCQlyZXMgKz0gdHJbaV07CQoJfQoJcmV0dXJuIHJlczsKfQoKaW50IG1haW4oKSB7CgkvLyB5b3VyIGNvZGUgZ29lcyBoZXJlCglhZGQoMCwgNSk7CglhZGQoNywgMTApOwoJY291dCA8PCBzdW0oMCkgPDwgJyAnIDw8IHN1bSg3KSA8PCAnICcgPDwgc3VtKDEwMCkgPDwgZW5kbDsKCXJldHVybiAwOwp9