#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool myfunction(int i, int j){
return (i<j);
}
int main()
{
//1
vector<int> myvector;
//2
for(int i=0; i<10; i++) myvector.push_back(i);
cout<<"size"<<myvector.size()<<"\n";
cout<<"capacity: "<<myvector.capacity()<<"\n";
for(int i=0; i<7; i++){
int n;
cin>>n;
myvector.push_back(n);
}
//3
vector<int>::iterator it2;
it2=myvector.begin();
it2+=2;
cout<<*it2;
it2=myvector.end();
cout<<*it2;
for(vector<int>::iterator it=myvector.begin(); it!=myvector.end(); ++it)
cout<<' '<<*it;
cout<<endl;
//4
myvector.pop_back();
for(vector<int>::iterator it=myvector.begin(); it!=myvector.end(); ++it)
cout<<' '<<*it;
//5
cout<<endl<<myvector.front()<<" "<<myvector.back()<<endl;
//6
sort(myvector.begin(), myvector.end(), myfunction);
for(vector<int>::iterator it=myvector.begin(); it!=myvector.end(); ++it)
cout<<' '<<*it;
//7
cout<<endl;
cout<<myvector.size()<<endl;
//8
bool comp=false;
int x=3;
for(vector<int>::iterator it=myvector.begin(); it!=myvector.end(); ++it){
if(*it==x){
comp=true;
}
}
cout<<comp<<endl;
//9
myvector.clear();
cout<<myvector.size();
/*
cout<<"size"<<myvector.size()<<"\n";
cout<<"capacity: "<<myvector.capacity()<<"\n";
cout<<"max-size: "<<myvector.max_size()<<"\n";
for(int i=0; i<7; i++){
myvector.pop_back();
cout<<"size"<<myvector.size()<<"\n";
cout<<"capacity: "<<myvector.capacity()<<"\n";
}
*/
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwogYm9vbCBteWZ1bmN0aW9uKGludCBpLCBpbnQgail7CiAgIHJldHVybiAoaTxqKTsKICB9CmludCBtYWluKCkKewogLy8xCiAgdmVjdG9yPGludD4gbXl2ZWN0b3I7CiAgLy8yCiAgZm9yKGludCBpPTA7IGk8MTA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