🏡 index : github.com/captn3m0/codechef.git

---
{"category_name":"easy","problem_code":"MEXOR","problem_name":"MEX-OR","problemComponents":{"constraints":"- $1 \\leq T \\leq 10^5$\n- $0 \\leq X \\leq 10^9$\n","constraintsState":true,"subtasks":"**Subtask 1 (100 points):** Original constraints","subtasksState":true,"inputFormat":"- The first line contains $T$ denoting the number of test cases. Then the test cases follow.\n- Each test case contains a single integer $X$ on a single line.\n","inputFormatState":true,"outputFormat":"For each test case, output on a single line the maximum possible MEX of the array satisfying the given property.","outputFormatState":true,"sampleTestCases":{"0":{"id":1,"input":"4\n0\n1\n2\n5\n","output":"1\n2\n2\n4\n","explanation":"**Test case $1$:** The array could be $[0]$. \n\n**Test case $2$:** The array could be $[0, 1]$. Here the bitwise OR of $0$ and $1$ is $1$ and the MEX of the array is $2$ as both $0$ and $1$ belongs to the array.\n\n**Test case $4$:** The array could be $[1, 0, 3, 2]$. Here the bitwise OR of all integers in the array is $3$ and the MEX of the array is $4$.","isDeleted":false}}},"video_editorial_url":"https://youtu.be/zBrxqhWafuY","languages_supported":{"0":"CPP14","1":"C","2":"JAVA","3":"PYTH 3.6","4":"CPP17","5":"PYTH","6":"PYP3","7":"CS2","8":"ADA","9":"PYPY","10":"TEXT","11":"PAS fpc","12":"NODEJS","13":"RUBY","14":"PHP","15":"GO","16":"HASK","17":"TCL","18":"PERL","19":"SCALA","20":"LUA","21":"kotlin","22":"BASH","23":"JS","24":"LISP sbcl","25":"rust","26":"PAS gpc","27":"BF","28":"CLOJ","29":"R","30":"D","31":"CAML","32":"FORT","33":"ASM","34":"swift","35":"FS","36":"WSPC","37":"LISP clisp","38":"SQL","39":"SCM guile","40":"PERL6","41":"ERL","42":"CLPS","43":"ICK","44":"NICE","45":"PRLG","46":"ICON","47":"COB","48":"SCM chicken","49":"PIKE","50":"SCM qobi","51":"ST","52":"SQLQ","53":"NEM"},"max_timelimit":1,"source_sizelimit":50000,"problem_author":"soumyadeep_21","problem_tester":"","date_added":"19-09-2021","tags":{"0":"easy","1":"oct21","2":"soumyadeep_21"},"problem_difficulty_level":"Unavailable","best_tag":"","editorial_url":"https://discuss.codechef.com/problems/MEXOR","time":{"view_start_date":1633944600,"submit_start_date":1633944600,"visible_start_date":1633944600,"end_date":1735669800},"is_direct_submittable":false,"problemDiscussURL":"https://discuss.codechef.com/search?q=MEXOR","is_proctored":false,"visitedContests":{},"layout":"problem"}
---
### Read problem statements in [Bengali](https://www.codechef.com/download/translated/OCT21/bengali/MEXOR.pdf), [Mandarin Chinese](https://www.codechef.com/download/translated/OCT21/mandarin/MEXOR.pdf), [Russian](https://www.codechef.com/download/translated/OCT21/russian/MEXOR.pdf), and [Vietnamese](https://www.codechef.com/download/translated/OCT21/vietnamese/MEXOR.pdf) as well.

The *MEX* (minimum excluded) of an array is the smallest non-negative integer that does not belong to the array. For instance:

- The MEX of $[2, 2, 1]$ is $0$, because $0$ does not belong to the array.
- The MEX of $[3, 1, 0, 1]$ is $2$, because $0$ and $1$ belong to the array, but $2$ does not.
- The MEX of $[0, 3, 1, 2]$ is 4 because $0, 1, 2$ and $3$ belong to the array, but $4$ does not.

Find the maximum possible MEX of an array of non-negative integers such that the [bitwise OR](https://en.wikipedia.org/wiki/Bitwise_operation#OR) of the elements in the array does not exceed $X$.

<aside style='background: #f8f8f8;padding: 10px 15px;'><div>All submissions for this problem are available.</div></aside>