void pop() { if(left.empty()) { while(!right.empty()) { left.push(right.top()); right.pop(); } } left.pop(); }
int top() { if(left.empty()) { while(!right.empty()) { left.push(right.top()); right.pop(); } } return left.top(); }
int min() { if(left.empty()) return right.min(); if(right.empty()) return left.min(); if(left.min() < right.min()) return left.min(); else return right.min(); }
int max() { if(left.empty()) return right.max(); if(right.empty()) return left.max(); if(left.max() > right.max()) return left.max(); else return right.max(); }
int empty() { if(left.empty() && right.empty()) return 1; else return 0; }