C++ STL

pair<int,int> p = {1,2};
p.first
p.second

pair<int,pair<int,int>>
vector<int> v;
v.push_back(1); 
v.emplace_back(1);
vector<int> v(5, 100);

emplace_back directly inserts the element
push_back creates a new container of the increased size and copies all the elements

vector<int>::iterator it = v.begin() -> points to the memory

v.end() -> space after the last element;
v.rend() -> space before the first element;
v.rbegin() -> last element

v.erase(v.begin() + 1);
v.erase(V.begin() + 2, v.begin() + 4);

v.insert(v.begin(), 300) -> inserting at the start
v.insert(v.begin(), 200) -> inserting at the second index

v.pop_back() -> pops the last element 
list -> similar to vector with front operations

list -> doubly linked list
vector -> singly linked list

list<int> ls;
ls.push_back();
ls.push_front();

ls.emplace_front();
deque -> similar to list and vector
stack<int> s;
s.push();
s.pop();
s.top();
queue<int> q;
q.push();
q.emplace();
q.back();
q.front();
priority_queue<int> pq;
pq.push();
pq.emplace(); MAX HEAP
pq.top() -> MAX ELEMENT
pq.pop();

priority_queue<int, vector<int>,  greater<int>> pq;
pq.push();
pq.push();
pq.emplace();

pq.top();
set<int> st; set -> TREE (every operations take LOG)
st.insert()
st.emplace();
st.find();
st.erase(element); (log time)
st.count(element)
multiset<int> ms; (sorted, but multiple occurence)
ms.insert();
ms.emplace();
ms.erase();
ms.count();
ms.erase(ms.find(1)); -> removes the first occurence
unordered_set<int> st -> unique, O(1)
st.insert(element)
st.erase();
map<int,int> mp; -> keys and values (sorted)
mp.insert({1,2});
important stuff

lower_bound (<=)
upper_bound (>)

vector<int> v;
auto it = lower_bound(v.begin(), v.end(), val);
cout << *it << endl;

# map 
mp.lower_bound(val);
# sorting 

sort(v.begin, v.end());,
sort(v.begin, v.end(), greater<int>);
sort(a+2, a+4) -> a+4 is the next element of the last sorted element

sort(a, a+n, comp) comp return true of false
next_permutation(s.begin(), s.end());
int maxi = *max_element(a, a + n);