can’t figure out the solution please help
Playing with cards in stack
vector <stack <int> > a;
This creates a vector of vectors-of-ints, but initially there are no vectors-of-int elements. Despite that, you call a[q - 1].push(data) which - for any value of q , immediately accesses a non-existant element.
definingthe vector as
vector<stack<int>> a(1000);
should solve your problem