{"trustable":false,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"MD","content":"Being a \u0027toxic\u0027 fanboy of a football player is not as easy as it seems. You have to keep track of the performance of your favorite player, as well as their rivals. But measuring a players performance is difficult. As the famous retired footballer and commentator, Ray Hudson once said regarding the performance of a player,\n\n\u003ccenter\u003e\u003ch4\u003eIt\u0027s not the statistics, you don\u0027t measure that with statistics!\u003c/h4\u003e\u003c/center\u003e\n\nIt is true. You can\u0027t measure art with statistics. Alas, your favorite player is nothing but statistics (and a few fake publicity stunts maybe). So you have no choice but to keep track of your favorite player\u0027s performances using statistics. You do the same for your rival player. To be more specific, you keep track of the number of goals scored by the player in a match (it can be negative if the player’s team concedes more goals than the player scores). So that whenever your favorite player performs badly in a match, you can counter that by saying, \"But the rival player scored X goals in that match which is less than my favorite player!\"\n\nNow, to keep track of the \"performance\" of your rival player, you define a set **S** that supports the following operations:\n- **I X**: To store the bad performances of the rival player. If **X** is not in **S**, insert **X** into **S**\n- **D X**: To remove performances that seemed bad, but your favorite player performed worse. If **X** is in **S**, delete **X** from **S**\n\nIt also supports two types of queries:\n- **K Y**: To check if there\u0027s a performance worse than your favorite player. Return the **Y\u003csup\u003eth\u003c/sup\u003e** smallest element of **S**\n- **C X**: To find the number of performances worse than your favorite player. Return the number of elements in **S** smaller than **X**\n\nSadly, your favorite player is also lagging behind in statistics nowadays. So you have decided to at least counter the rival fans faster. Your task in this problem is to design a system that performs these operations efficiently."}},{"title":"Input","value":{"format":"MD","content":"The input starts with an integer **T (1 ≤ T ≤ 2 × 10\u003csup\u003e5\u003c/sup\u003e)**, denoting the number of operations performed.\nEach of the next **T** lines contain an operation in the format specified in the problem statement.\nHere, **0 ≤ |X|, Y ≤ 10\u003csup\u003e9\u003csup\u003e**.\n"}},{"title":"Output","value":{"format":"MD","content":"For each query operation, print the returned value in a single line. If any query is invalid, print the word ‘invalid’ (without the quotes)."}},{"title":"Sample Input","value":{"format":"MD","content":"```\n8\nI -1\nI -1\nI 2\nC 0\nK 2\nD -1\nK 1\nK 2\n```"}},{"title":"Sample Output","value":{"format":"MD","content":"```\n1\n2\n2\ninvalid\n```"}}]}