#include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> a = {1, 2, 1, 4, 1, 2, 1};
vector<int> pref_sum(a.size() + 1), pref_xor(a.size() + 1);
partial_sum(a.begin(), a.end(), pref_sum.begin() + 1);
partial_sum(a.begin(), a.end(), pref_xor.begin() + 1, bit_xor<int>());
for (auto vec : {pref_sum, pref_xor}) {
for (int x : vec) {
cout << x << " ";
}
cout << "\n";
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCXZlY3RvcjxpbnQ+IGEgPSB7MSwgMiwgMSwgNCwgMSwgMiwgMX07Cgl2ZWN0b3I8aW50PiBwcmVmX3N1bShhLnNpemUoKSArIDEpLCBwcmVmX3hvcihhLnNpemUoKSArIDEpOwoJcGFydGlhbF9zdW0oYS5iZWdpbigpLCBhLmVuZCgpLCBwcmVmX3N1bS5iZWdpbigpICsgMSk7CglwYXJ0aWFsX3N1bShhLmJlZ2luKCksIGEuZW5kKCksIHByZWZfeG9yLmJlZ2luKCkgKyAxLCBiaXRfeG9yPGludD4oKSk7CgkKCWZvciAoYXV0byB2ZWMgOiB7cHJlZl9zdW0sIHByZWZfeG9yfSkgewoJCWZvciAoaW50IHggOiB2ZWMpIHsKCQkJY291dCA8PCB4IDw8ICIgIjsKCQl9CgkJY291dCA8PCAiXG4iOwoJfQoJCglyZXR1cm4gMDsKfQ==