https://www.codechef.com/LTIME85B/problems/MAXAND18

https://www.codechef.com/LTIME85B/problems/MAXAND18
#include
#include
#include<math.h>
#define MAXY 10^9
using namespace std;
int noof(int d)
{int cnt=0;
while(d!=0)
{
d=d/2;
cnt++;
}
return cnt;

}
int nofone(int e,int k)
{
long cnt1=0;
while(e!=0)
{
if(e%2!=0)
{
cnt1++;
}
e=e/2;
}
if(cnt1==k)
return 1;
else
return 0;
}

int main()
{
int t;
cin>>t;
while(t–)
{

int n,g,k,sum=0,ans=0,b;
long i,a[MAXY];
cin>>n>>k;
for(i=0;i<n;i++)
cin>>a[i];
g=*max_element(a,a+n);
int z=noof(g);
long r=pow(2,z);

 for(long j=0;j<r;j++)
 {
     int  d=nofone(j,k);
     if(d==1)
     { int cur=ans;
         sum=0;
         for(i=0;i<n;i++)
         {int f=a[i]&j;
             sum=sum+f;
         }
         ans=max(ans,sum);
         if(ans>cur)
         {
             b=j;
         }
     }
 }

cout<<b<<endl;

}
}
why i got RE ?

Format your code by enclosing it in ``` before the start and after the end. Or you can link your submission.

https://www.codechef.com/submit/MAXAND18
this is the link of my submission i got RE SIGSEGV

Nah that isn’t the link.