I feel like I've satisfied all the conditions for the question, still first 3 test cases aren't passing

#include
#include
using namespace std;
int main() {
int n;
cin>>n;
vector v;
int len=0,p=n;
while(p!=0)
{
int l_term=p%10;
p=p/10;
v.push_back(l_term);
len++;
}
bool zero=true;
for(int i=len-1;i>=0;i–)
{
if(v[i]>=5)
{
v[i]=9-v[i];
}
if(zero&&v[i]==0)
{
v[i]=9-v[i];
}
if(v[i]!=9)
{
zero=false;
}
cout<<v[i];

}
return 0;

}

@Rohanaggarwal8590
First of all , you should take input in a long long int variable as it is specified in the problem constraints that n can be as large as 100000000000000000. int cannot store such a large number.

Also , your code fails for testcases including 9’s
Input :
9999

Expected Output :
9000

Your Output :
9999