C++ FenWick Tree solution
\tclass FenWickTree{\n\t\tpublic:\n\t\tvector cnt;\n\t\tFenWickTree(int n):cnt(n+1,0){\n\n\t\t}\n\n\t\tvoid update(int i, int delt){\n\t\t\twhile(i0){\n\t\t\t\t
\tclass FenWickTree{\n\t\tpublic:\n\t\tvector<int> cnt;\n\t\tFenWickTree(int n):cnt(n+1,0){\n\n\t\t}\n\n\t\tvoid update(int i, int delt){\n\t\t\twhile(i<cnt.size()){\n\t\t\t\tcnt[i]+=delt;\n\t\t\t\ti+=lowbit(i);\n\t\t\t}\n\t\t}\n\n\t\tint query(int a){\n\t\t\tint sum=0;\n\t\t\twhile(a>0){\n\t\t\t\tsum+=cnt[a];\n\t\t\t\ta-=lowbit(a);\n\t\t\t}\n\n\t\t\treturn sum;\n\t\t}\n\n\n\t\tint lowbit(int x){\n\t\t\treturn (x) & (-x);\n\t\t}\n\t};\n\n\n\tclass NumArray {\n\tpublic:\n\t\tFenWickTree FW;\n\t\tvector<int> num;\n\t\tNumArray(vector<int>& nums):FW(nums.size()){\n\t\t\tint n=nums.size();\n\t\t\tnum=nums;\n\n\t\t\tfor(int i=0;i<n;i++){\n\t\t\t\tFW.update(i+1,num[i]);\n\t\t\t}\n\t\t}\n\n\t\tvoid update(int i, int val) {\n\t\t\tFW.update(i+1,val-num[i]);\n\t\t\tnum[i]=val;\n\t\t}\n\n\t\tint sumRange(int i, int j) {\n\t\t\treturn FW.query(j+1)-FW.query(i);\n\t\t}\n\t};
['Tree', 'C', 'C++']