{"raw_statement":[{"iden":"problem statement","content":"We have a multiset of integers $S$, which is initially empty.\nGiven $Q$ queries, process them in order. Each query is of one of the following types.\n\n*   `1 x`: Insert an $x$ into $S$.\n    \n*   `2 x c`: Remove an $x$ from $S$ $m$ times, where $m = \\mathrm{min}(c,($ the number of $x$'s contained in $S))$.\n    \n*   `3` : Print $($ maximum value of $S)-($ minimum value of $S)$. It is guaranteed that $S$ is not empty when this query is given."},{"iden":"constraints","content":"*   $1 \\leq Q \\leq 2\\times 10^5$\n*   $0 \\leq x \\leq 10^9$\n*   $1 \\leq c \\leq Q$\n*   When a query of type `3` is given, $S$ is not empty.\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$Q$\n$\\mathrm{query}_1$\n$\\vdots$\n$\\mathrm{query}_Q$\n\n$\\mathrm{query}_i$, which denotes the $i$\\-th query, is in one of the following formats:\n\n$1$ $x$\n\n$2$ $x$ $c$\n\n$3$"},{"iden":"sample input 1","content":"8\n1 3\n1 2\n3\n1 2\n1 7\n3\n2 2 3\n3"},{"iden":"sample output 1","content":"1\n5\n4\n\nThe multiset $S$ transitions as follows.\n\n*   $1$\\-st query: insert $3$ into $S$. $S$ is now $\\lbrace 3 \\rbrace$.\n*   $2$\\-nd query: insert $2$ into $S$. $S$ is now $\\lbrace 2, 3 \\rbrace$.\n*   $3$\\-rd query: the maximum value of $S = \\lbrace 2, 3\\rbrace$ is $3$ and its minimum value is $2$, so print $3-2=1$.\n*   $4$\\-th query: insert $2$ into $S$. $S$ is now $\\lbrace 2,2,3 \\rbrace$.\n*   $5$\\-th query: insert $7$ into $S$. $S$ is now $\\lbrace 2, 2,3, 7\\rbrace$.\n*   $6$\\-th query: the maximum value of $S = \\lbrace 2,2,3, 7\\rbrace$ is $7$ and its minimum value is $2$, so print $7-2=5$.\n*   $7$\\-th query: since there are two $2$'s in $S$ and $\\mathrm{min(2,3)} = 2$, remove $2$ from $S$ twice. $S$ is now $\\lbrace 3, 7\\rbrace$.\n*   $8$\\-th query: the maximum value of $S = \\lbrace 3, 7\\rbrace$ is $7$ and its minimum value is $3$, so print $7-3=4$."},{"iden":"sample input 2","content":"4\n1 10000\n1 1000\n2 100 3\n1 10"},{"iden":"sample output 2","content":"If the given queries do not contain that of type $3$, nothing should be printed."}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}