What's wrong?

problem code=BAADSHAH
#include
using namespace std;
#include<bits/stdc++.h>

void update(int i,long long value, long long* bits,int n){
while(i<n)
{
bits[i]+=value;
i+=(i&(-i));

}

}

long long Sum(int i, long long* bits,int n){
long long s=0;
while(i>0){
s+=bits[i];
i=i-(i&(-i));
}
return s;
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin>>n>>m;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
long long bits[n+1];
for(int i=0;i<=n;i++){
bits[i]=0;
}
for(int i=0;i<n;i++){
update(i+1,arr[i],bits,n+1);
}
while(m–){
int option;
cin>>option;
int p;
long long q;
long long s;
if(option==1){
cin>>p>>q;
update(p,q-arr[p-1],bits,n+1);

	}
	if(option==2){
		cin>>s;
		bool flag=false;
		int start=1;
		int end=n;
		while(start<=end){
	
		    int mid=(start+end)/2;
		    
		    long long int y=Sum(mid,bits,n+1);
		   
		    if(s==y){
		        cout<<"Found "<<mid<<endl;
		        flag=true;
		        break;
		    }
		     else if(s>y)
		    {
		       start=mid+1;
		    }
		    else{
		        end=mid-1;
		    }
		}
		
		if(flag==false){
		cout<<"Not Found"<<endl;
	    }

		
	}

}
//your code goes here
return 0;
}