WA in ANDSUBAR

I am getting WA with my code. But I am unable to see at which testcase my code would fail. I even ran the accepted solution and my solution in parallel, however I was unable to find any problems.

    #include <iostream>
    #include <cmath>

    using namespace std;

    int main()
    {
        long long t;
        cin>>t;;

        while(t--)
        {
            long long i, result(0);
            long long n;
            cin>>n;

            for( i = 0; pow(2, i) < n ; ++i )
            {}

            result = (n - pow(2,i-1));

            if(n <=2 )
            {
                cout<<1<<endl;
            }

            else if(pow(2, i) == n)
            {
                cout<<result<<endl;
            }
            
            else if( result < pow(2, i -2) && n>7)
            {
                cout<<pow(2, i-2)<<endl;
            }

            else{
            cout<<result+1<<endl;
            }
        }
    }

Consider the test input:

1
2097153