On compilation, (1) produces (2). What to do? How to fight?
Answer 1, authority 100%
You cannot apply an indexing operator to a vector that has no elements yet.
Therefore, you should write before the loops
cin & gt; & gt; str;
cin & gt; & gt; stb;
vect.resize (str, std :: vector & lt; int & gt; (stb));
That is, you first need to create the elements of the vector, and then only access them by index.
Answer 2
As a variant of initialization (when creating, you can specify the dimension):
int a, b;
cin & gt; & gt; a & gt; & gt; b;
vector & lt; vector & lt; int & gt; & gt; mas (a, vector & lt; int & gt; (b));
size_t size = mas.size ();
for (size_t i = 0; i & lt; size; ++ i) {
for_each (mas [i] .begin (), mas [i] .end (), [] (int & amp; k) {cin & gt; & gt; k;});
}