Easy Fibonacci (Help)

Can anyone please help me figure out why my code is failing for large inputs…?

#include<bits/stdc++.h>
#include
#define ll long long
using namespace std;

ll power(ll x, ll y, ll mod){

ll result = 1;
x = x % mod;

while(y > 0){
if(y&1){
result = (resultx)%mod;
}
x = (x
x)%mod;
y = y>>1;
}
return result;
}

int main(){

ll t; cin>>t;
int first = 0, second = 1, third;
vector series;
series.push_back(first);
series.push_back(second);

third = first+second;
first = second;
second = third;
series.push_back(third);

while(true){

first = second%10;
second = third%10;

if(first == 0  && second == 1){
    break;
 }

third = (first+second)%10;
series.push_back(third);

}

ll len = series.size()-2;

/*for(int i=0;i<series.size();i++){
cout<<series[i]<<" ";
}
cout<<endl;

cout<<"LEN "<<len<<endl; */

while(t–){

ll n; cin>>n;
ll a = floor(log2(n));
ll term = power(2,a,len);

//cout<<"TERM "<<term<<endl;

cout<<series[term-1]<<endl;

}

return 0;
}

https://www.codechef.com/viewsolution/26664510