func_code_string: #include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   const double eps = 1e-9;   const long long INF = 100000000000000000;   const int MAXN = 3 * 100000;   struct T {     int left, right, diff;     bool operator>(const T& other) {       if (diff != other.diff) return diff < other.diff;       return left < other.left;     }     bool operator<(const T& other) const {       if (diff != other.diff) return diff > other.diff;       return left > other.left;     }   };   priority_queue<T> q;   vector<pair<int, int> > ans;   char s[MAXN];   bool u[MAXN];   int a[MAXN];   int l[MAXN];   int r[MAXN];   int n;   int main() {     cin >> n;     scanf( %s , s);     for (int i = 0; i < n; ++i) {       scanf( %d , &a[i]);       l[i] = i - 1;       r[i] = i + 1;       if (i + 1 == n) r[i] = -1;     }     for (int i = 0; i < n - 1; ++i)       if (s[i] != s[i + 1]) {         T t;         t.left = i;         t.right = i + 1;         t.diff = abs(a[i] - a[i + 1]);         q.push(t);       }     while (!q.empty()) {       int left = q.top().left;       int right = q.top().right;       q.pop();       if (u[left] || u[right]) continue;       u[left] = u[right] = true;       ans.push_back(pair<int, int>(left + 1, right + 1));       left = l[left];       right = r[right];       if (left != -1) r[left] = right;       if (right != -1) l[right] = left;       if (left != -1 && right != -1 && s[left] != s[right]) {         T t;         t.left = left;         t.right = right;         t.diff = abs(a[left] - a[right]);         q.push(t);       }     }     cout << ans.size() << endl;     for (int i = 0; i < (long long)(ans).size(); ++i) {       printf( %d %d n , ans[i].first, ans[i].second);     }   }   