{"problem":{"name":"Plus and AND","description":{"content":"You are given a sequence of $N$ non-negative integers: $A=(A_1,A_2,\\dots,A_N)$. You may perform the following operation at most $M$ times (possibly zero): *   choose an integer $i$ such that $1 \\le i","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":5000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc146_b"},"statements":[{"statement_type":"Markdown","content":"You are given a sequence of $N$ non-negative integers: $A=(A_1,A_2,\\dots,A_N)$. You may perform the following operation at most $M$ times (possibly zero):\n\n*   choose an integer $i$ such that $1 \\le i \\le N$ and add $1$ to $A_i$.\n\nThen, you will choose $K$ of the elements of $A$.\nFind the maximum possible value of the bitwise $\\mathrm{AND}$ of the elements you choose.\nWhat is bitwise ${\\rm AND}$?The bitwise ${\\rm AND}$ of non-negative integers $A$ and $B$, $A\\ \\mathrm{AND}\\ B$, is defined as follows:\n\n*   When $A\\ {\\rm AND}\\ B$ is written in base two, the digit in the $2^k$'s place ($k \\geq 0$) is $1$ if both of the digits in that place of $A$ and $B$ are $1$, and $0$ otherwise.\n\nFor example, $3\\ {\\rm AND}\\ 5 = 1$. (In base two, $011\\ {\\rm AND}\\ 101 = 001$.)  \nGenerally, the bitwise ${\\rm AND}$ of $k$ non-negative integers $p_1, p_2, p_3, \\dots, p_k$ is defined as $(\\dots ((p_1\\ \\mathrm{AND}\\ p_2)\\ \\mathrm{AND}\\ p_3)\\ \\mathrm{AND}\\ \\dots\\ \\mathrm{AND}\\ p_k)$. We can prove that this value does not depend on the order of $p_1, p_2, p_3, \\dots, p_k$.\n\n​\n\n## Constraints\n\n*   $1 \\le K \\le N \\le 2 \\times 10^5$\n*   $0 \\le M < 2^{30}$\n*   $0 \\le A_i < 2^{30}$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $M$ $K$\n$A_1$ $A_2$ $\\dots$ $A_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc146_b","tags":[],"sample_group":[["4 8 2\n1 2 4 8","10\n\nIf you do the following, the bitwise $\\mathrm{AND}$ of the elements you choose will be $10$.\n\n*   Perform the operation on $A_3$ six times. Now, $A_3 = 10$.\n*   Perform the operation on $A_4$ twice. Now, $A_4 = 10$.\n*   Choose $A_3$ and $A_4$, whose bitwise $\\mathrm{AND}$ is $10$.\n\nThere is no way to choose two elements whose bitwise $\\mathrm{AND}$ is greater than $10$, so the answer is $10$."],["5 345 3\n111 192 421 390 229","461"]],"created_at":"2026-03-03 11:01:14"}}