Company: UBS_VIT_Vellore
Difficulty: hard
UBS — AI Intern · VIT Vellore (On-campus) OA: 10 July 2026, 10 AM | Package: 14 LPA | CGPA cutoff: 7.5 | MTech eligible: No Eligibility: Only CSE – AI specialization You are given three integers L , R , and K . Consider the integers in the range [L, R] . An integer is called special if its binary representation (written without leading zeros) contains "101" as a subsequence — that is, there exist three bit positions i < j < k whose bits are 1, 0, and 1 respectively (the bits need not be adjacent). Find the K-th smallest special integer in [L, R] . If there are fewer than K special integers in the range, print -1 . Input Format A single line with three space-separated integers L R K . Output Format A single integer: the K-th smallest special number in [L, R] , or -1 . Constraints 1 ≤ L ≤ R ≤ 10 18 1 ≤ K ≤ 10 18 Examples Input: 1 5 1 Output: 5 5 in binary is 101 , which contains "101". It is the