SUMSUM  Enjoy Sum with Operations
You are given N numbers of the array (N <= 100000), all less than 10^8 and greater than 0.
Now, you are given 2 queries:
 "1 x i" : Change the ith number to x. (0 <= x <= 10^8)
 "2 Op i1 i2": Compute the sum of all two elements taken at a time within index i1 to i2 (both inclusive) under the operation Op. Op could be XOR, OR or AND.
For example, let N=4, Query=3 and "10 20 30 40" be the Initial array.
Query:
2 OR 1 3 1 0 1 2 OR 1 3
Answer:
2 OR 1 3> (10 OR 20) + (20 OR 30) + (10 OR 30) 1 0 1 > Now array becomes 0 20 30 40 2 OR 1 3> (0 OR 20) + (20 OR 30) + (0 OR 30)
Example
Input: 4 3 10 20 30 40 2 OR 1 3 1 0 1 2 OR 1 3 Output 90 80
NOTE: If i1 is equal to i2, always output 0.
hide comments
sankalp_7:
20221122 14:55:28
@codercodecoder You haven't even tried it... And you are writing, ac in one go, XD 

depressedboy:
20220120 10:24:04
Extremely Brilliant Problem one must try this problem


codercodecoder:
20200419 16:47:40
ac in one go madharchod 

learnerinblack:
20180607 12:49:36
AC in one go :D BIT + bitmasking => learnt a lot 

arpit728:
20180417 06:46:33
@kaushal yadav


amit_ranjan:
20180102 20:00:06
My 180 :) 

Tanmoy Tapos Datta:
20171028 23:25:25
Can be done with segment tree or BIT and some combinatorics. Here is an editorial for this problem


sas1905:
20170626 01:32:25
2 WA for skipping the note part..:( 

akt_1998:
20170625 21:37:16
BIT+bitmasking > AC in one go 

amit_gh:
20160313 02:26:39
Take care of output limits. Java solution gave TLE whereas same c++ solution got AC. I used same i/o functions in java that I have been using to successfully solve other problems in java. I think admin should increase time limit for java solutions. 
Added by:  devu 
Date:  20130830 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 
Resource:  Own Problem 