func_code_string: #include <bits/stdc++.h>   using namespace std;   long long EPS = 1000000007;   const int INF = 1000000000;   double PI = 3.14159265358979323846;   const int MAXN = 1000040;   long long abss(long long h) { return max(h, -h); }   double fabss(double h) { return max(h, -h); }   long long ceill(long long x, long long y) {     if (x % y != 0) return (x / y) + 1;     return x / y;   }   string itos(long long num) {     string str =   ;     if (num == 0) return  0 ;     while (num != 0) {       str += ((num % 10) +  0 );       num /= 10;     }     reverse(str.begin(), str.end());     return str;   }   long long sstoi(string num) {     long long count = 1;     for (int i = 0; i < (int)num.size() - 1; i++) {       count *= 10;     }     long long ans = 0;     for (int i = 0; i < (int)num.size(); i++) {       ans += (num[i] -  0 ) * count;       count /= 10;     }     return ans;   }   long long n, m, k, h;   pair<char, int> a[MAXN];   int b[MAXN];   int c[MAXN];   pair<char, int> t[MAXN];   void build(int v, int tl, int tr) {     if (tl == tr) {       t[v].first = a[tl].first;       t[v].second = a[tl].second;     } else {       int tm = (tl + tr) / 2;       build(v * 2, tl, tm);       build(v * 2 + 1, tm + 1, tr);       if (t[v * 2].first > t[v * 2 + 1].first) {         t[v] = t[v * 2 + 1];       } else if (t[v * 2].first < t[v * 2 + 1].first) {         t[v] = t[v * 2];       } else if (t[v * 2].first == t[v * 2 + 1].first &&                  t[v * 2].second > t[v * 2 + 1].second) {         t[v] = t[v * 2];       } else {         t[v] = t[v * 2 + 1];       }     }   }   pair<char, int> sum(int v, int tl, int tr, int l, int r) {     if (l > r) return make_pair( z , -1);     if (l == tl && r == tr) return t[v];     int tm = (tl + tr) / 2;     pair<char, int> q1 = sum(v * 2, tl, tm, l, min(r, tm));     pair<char, int> q2 = sum(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);     if (q1.first > q2.first) {       return q2;     } else if (q1.first < q2.first) {       return q1;     } else if (q1.first == q2.first && q1.second > q2.second) {       return q1;     } else {       return q2;     }   }   int counter[30];   int main() {     int m;     cin >> m;     string str;     cin >> str;     int n = str.size();     for (int i = 0; i < n; i++) {       a[i].first = str[i];       a[i].second = i;       counter[str[i] -  a ]++;     }     build(1, 0, n - 1);     int index = 0;     vector<char> answer;     char maxChar =  a ;     while (true) {       pair<char, int> w = sum(1, 0, n - 1, index, index + m - 1);       answer.push_back(w.first);       maxChar = max(maxChar, w.first);       index = w.second;       if (index + m - 1 >= n - 1) {         break;       }       index++;     }     sort(answer.begin(), answer.end());     for (char i =  a ; i <=  z ; i++) {       if (i != maxChar) {         for (int j = 0; j < counter[i -  a ]; j++) {           cout << i;         }       } else {         for (int j = 0; j < answer.size(); j++) {           if (answer[j] == maxChar) {             cout << maxChar;           }         }         break;       }     }   }   