MAXEP:ONLY 1 TEST CASE FAILING IN MAXEP PROBLEM

question
https://www.codechef.com/problems/MAXEP

my attempt
https://www.codechef.com/viewsolution/25045961

failing in test case 16

IN CASE LINK DOESNT WORK HERE IS THE CODE

#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define inf 2000000009
using namespace std;

ll fun(ll start,ll end,ll n,ll coin,ll c)
{ end=min(n,end);
ll step=(-start+end)/7,x,k;
while(end-start>=7 )
{
k=start+step;
if(k==end)
k–;
cout<<1<<" "<<k<<endl;
coin++;

 cin>>x;
 if(x)
{ coin+=c+1;
    end=k;
    cout<<2<<endl;
     step=(-start+end)/7;
}
 else
   {coin++;
       start=k;  }

}

for(ll i=start;i<=end;i++)
{
if(i==end)
cout<<3<<" “<<i<<endl;
else
{
cout<<1<<” “<<i<<endl;
cin>>x;
if(x)
{ coin+=c+1;
cout<<2<<endl;
cout<<3<<” "<<i<<endl;
break;
}
else coin++;}}

while(coin>1000)
{

}
}

int main()
{
fast;
ll n,c,x,coin=0;
cin>>n>>c;
cout<<1<<" “<<1<<endl;
coin++;
cin>>x;
if(x)
{
cout<<2<<endl;
cout<<3<<” “<<1<<endl;
return 0;
}
ll i;
if(!x)
{
for( i=2;i<=n;i*=2)
{cout<<1<<” "<<i<<endl;
cin>>x;
if(x)
{ cout<<2<<endl;
coin+=c+1;
break;
}
else coin++;
}

}
fun(i/2,i,n,coin,c);
}

Keep tabs on the cost. The cost goes above 1000.
Here’s my solution :
https://www.codechef.com/viewsolution/21870451

yeah in one case the coins were exceeding 1000
changed the range calculation for answer from power of 2’s to power of 7’s and it worked.
thx for help:grinning: