func_code_string: #include <bits/stdc++.h>   using namespace std;   inline int Abs(int x) { return x > 0 ? x : -x; }   set<int> peo;   set<int>::iterator p1, p2;   bool vis[200050], boy[200050];   char s[200050];   int a[200050];   struct node {     int l, r;     int val;     node(int a = 0, int b = 0, int c = 0) : l(a), r(b), val(c) {}     bool operator<(const node &x) const {       if (val != x.val) return x.val > val;       if (x.l != l) return x.l > l;       return x.r > r;     }   };   set<node> myset;   set<node>::iterator it;   vector<node> ans;   void work() {     while (myset.size()) {       it = myset.begin();       node u = *it;       myset.erase(it);       if (vis[u.l] || vis[u.r]) continue;       vis[u.l] = vis[u.r] = 1;       ans.push_back(u);       p1 = peo.find(u.l);       if (p1 == peo.begin()) {         peo.erase(p1);         peo.erase(u.r);         continue;       }       p2 = peo.find(u.r);       p2++;       if (p2 == peo.end()) {         peo.erase(p1);         peo.erase(u.r);         continue;       }       p1--;       peo.erase(u.l);       peo.erase(u.r);       u.l = *p1;       u.r = *p2;       if (boy[u.l] == boy[u.r]) continue;       u.val = Abs(a[u.l] - a[u.r]);       myset.insert(u);     }   }   int n;   int main() {     int i, j;     while (cin >> n) {       myset.clear();       peo.clear();       scanf( %s , s + 1);       for (i = 1; i <= n; i++) scanf( %d , &a[i]);       boy[1] = (s[1] ==  B );       for (i = 1; i <= n; i++) {         peo.insert(i);         boy[i + 1] = (s[i + 1] ==  B );         if (i < n && boy[i] != boy[i + 1])           myset.insert(node(i, i + 1, Abs(a[i] - a[i + 1])));       }       memset(vis, 0, sizeof vis);       ans.clear();       work();       cout << ans.size() << endl;       for (i = 0; i < ans.size(); i++) printf( %d %d n , ans[i].l, ans[i].r);     }     return 0;   }   