func_code_string: #include <bits/stdc++.h>   using namespace std;   long long BigMod(long long B, long long P, long long M) {     long long R = 1;     while (P > 0) {       if (P % 2 == 1) {         R = (R * B) % M;       }       P /= 2;       B = (B * B) % M;     }     return R;   }   template <class T1>   void deb(T1 e1) {     cout << e1 << endl;   }   template <class T1, class T2>   void deb(T1 e1, T2 e2) {     cout << e1 <<     << e2 << endl;   }   template <class T1, class T2, class T3>   void deb(T1 e1, T2 e2, T3 e3) {     cout << e1 <<     << e2 <<     << e3 << endl;   }   template <class T1, class T2, class T3, class T4>   void deb(T1 e1, T2 e2, T3 e3, T4 e4) {     cout << e1 <<     << e2 <<     << e3 <<     << e4 << endl;   }   template <class T1, class T2, class T3, class T4, class T5>   void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {     cout << e1 <<     << e2 <<     << e3 <<     << e4 <<     << e5 << endl;   }   template <class T1, class T2, class T3, class T4, class T5, class T6>   void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {     cout << e1 <<     << e2 <<     << e3 <<     << e4 <<     << e5 <<     << e6          << endl;   }   const int MAX = 100060;   map<int, int> mpp;   int cnt[2][MAX];   int res[MAX];   int main() {     memset(cnt, (0), sizeof(cnt));     ;     vector<int> tmp, rval;     int v;     set<int> com;     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &v);       rval.push_back((v));       tmp.push_back((v));     }     sort(tmp.begin(), tmp.end());     for (int i = 0; i < n; i++) {       mpp[tmp[i]] = i + 1;     }     v = mpp[rval[0]];     com.insert(v);     for (int i = 1; i < n; i++) {       v = mpp[rval[i]];       auto it = com.lower_bound(v);       if (it != com.begin()) {         auto it1 = it;         it1--;         int u = (*it1);         if (cnt[0][u] != -1) {           res[i] = tmp[u - 1];           com.insert(v);           cnt[0][u]--;           continue;         }       }       if (it != com.end()) {         auto it1 = it;         int u = (*it1);         if (cnt[1][u] != -2) {           res[i] = tmp[u - 1];           com.insert(v);           cnt[1][u]--;           continue;         }       }     }     for (int i = 1; i < n; i++) {       if (i != 1) printf(   );       printf( %d , res[i]);     }     printf(  n );     return 0;   }   