IN D ; cin>>N
IN D ; cin>>Q
MOV B 1
ADD D B ; Q++
;E-l,F-r,G-x 
IN A ; cin>>t;
IN E ; cin>>l
IN F ; cin>>R
MOV B 1
CMP A B ; t>1 
JZ 27 ; to t=2
;t=1
IN G ;cin>>x
MOV B 40000 
ADD E B ; l+=4e4
LOAD E H ;loop1 H=m[l]
ADD H G ; H+=x
STORE E H ;m[l]=x+m[l]
MOV B 2 ; for /=2
DIV E B ; l/=2
MOV B 0 
;ERR E
CMP E B ; E<=B ? 
JZ 15; No, E>0
; stop loop1
MOV RES 0
JZ 70 ; continue
;t=2
MOV B 40000
ADD E B
MOV B 40001
ADD F B
MOV H 0 ; sum=0
;ERR E F; start loop  for (; l < r; l >>= 1, r >>= 1) 
MOV A E ; a=l
MOV B 2 ; b=2
DIV A B ; a/=2
MUL A B ; a*=2
CMP E A
JNZ 46 ; l%2==0
; if (l & 1)
LOAD E A ; A=m[l]
;ERR H A
ADD H A ; sum+=A
MOV A 1 ; A=1
ADD E A ; l++;
; endif
MOV A F ; A=r
MOV B 2
DIV A B
MUL A B
CMP F A ; r<=A
JNZ 58 ;yes, go to endif
; if (r & 1)
MOV B 1
SUB F B
LOAD F A
ADD H A
; endif
MOV B 2
DIV E B
DIV F B
;ERR E F
CMP F E
JZ 33

OUT H ; stop t=2



MOV B 1
SUB D B
CMP D B
JZ 5

