func_code_string: #include <bits/stdc++.h>   using namespace std;   bool check(vector<int>& v, int k, int val, int start) {     vector<int> dp(v.size());     if (v[0] <= val && start == 0) {       dp[0] = dp[1] = 1;     }     if (v[1] <= val) {       dp[1] = 1;     }     for (int i = 2; i < v.size(); ++i) {       dp[i] = dp[i - 1];       if (v[i] <= val) {         dp[i] = max(dp[i], 1 + dp[i - 2]);       }     }     int endpos = v.size() - 1;     if ((start == 1 && k % 2) || (start == 0 && k % 2 == 0)) {       endpos--;     }     if (dp[endpos] >= (k + 1 - start) / 2) {       return true;     }     return false;   }   bool checkall(vector<int>& v, int k, int val) {     return check(v, k, val, 0) || check(v, k, val, 1);   }   void solve(std::istream& in, std::ostream& out) {     int n, k;     in >> n >> k;     vector<int> v(n);     for (auto& x : v) {       in >> x;     }     int l = 1, r = 1e9 + 1;     while (r - l > 1) {       int m = (r + l) / 2;       if (checkall(v, k, m)) {         r = m;       } else {         l = m;       }     }     if (checkall(v, k, l)) {       r = l;     }     out << r << endl;   }   int main() { solve(cin, cout); }   