text: class Solution
  {
    unordered_map<int, int> m;
  
  public:
    int getKth(int lo, int hi, int k)
    {
      vector<pair<int, int>> nums;
      for (; lo <= hi; ++lo)
      {
        nums.emplace_back(make_pair(getP(lo), lo));
      }
      nth_element(nums.begin(), nums.begin() + k - 1, nums.end());
      return nums[k - 1].second;
    }
    int getP(int x)
    {
      int ret = 0;
      while (x != 1)
      {
        if (x % 2 == 0)
        {
          x >>= 1;
        }
        else
        {
          x = 3 * x + 1;
        }
        ret++;
      }
      return ret;
    }
  };