Getting a segmentation fault

vector< vector < int > > v ; is wrongly declared

the correct way to declare it

vector< vector < int > > v( n ) ;

since in the input loop u are accessing v[i].push_back()

thank you very much …