int size=sizeof(sequence);
You probably meant
int size=sequence.size();
which actually returns the number of elements in the std::vector container.
vector <int> s1;
for(i=0;i<size;i++)
{
s1[i]=stoi(sequence[i]);
}
Here the problem is that the vector s1 is initialized as empty, so that you cannot change the i-th value (because it does not exist). Give the std::vector directly the correct size.
vector <int> s1(size);
for(i=0;i<size;i++)
{
s1[i]=stoi(sequence[i]);
}