func_code_string: #include <bits/stdc++.h>   using namespace std;   char *student;   int *arr;   struct node {     int x;     int y;     int val;   };   std::vector<node> v;   std::vector<node> out;   struct edge {     int v;     edge *left;     edge *right;   };   edge *ed;   bool *flag;   bool comp(node &a, node &b) {     return (!(a.val < b.val || (a.val == b.val && a.x < b.x)));   }   void make_node(int x, int y) {     if (student[x] ^ student[y]) {       node temp;       temp.x = x;       temp.y = y;       temp.val = abs(arr[x] - arr[y]);       v.push_back(temp);       push_heap(v.begin(), v.end(), comp);     }   }   void print() {     for (std::vector<node>::iterator it = out.begin(); it != out.end(); ++it) {       node temp = *it;       cout << temp.x + 1 <<     << temp.y + 1 << endl;     }   }   void select() {     while (true) {       int l = -1, r = -1;       while (v.size() > 0) {         node temp = v.front();         pop_heap(v.begin(), v.end(), comp);         v.pop_back();         l = temp.x;         r = temp.y;         if (flag[l] || flag[r]) {           l = -1;           r = -1;           continue;         } else {           flag[l] = true;           flag[r] = true;           out.push_back(temp);           break;         }       }       if (l == -1) break;       edge *lt = ed[l].left;       edge *rt = ed[r].right;       if (lt != NULL) {         lt->right = rt;       }       if (rt != NULL) {         rt->left = lt;       }       if (lt != NULL && rt != NULL) make_node(lt->v, rt->v);     }   }   int main() {     std::cout << std::fixed << std::setprecision(10);     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     student = new char[n];     arr = new int[n];     flag = new bool[n];     string s;     cin >> s;     for (int i = 0; i < n; i++) {       student[i] = s[i];       int x;       cin >> x;       arr[i] = x;       flag[i] = false;     }     for (int i = 0; i < n - 1; i++) {       make_node(i, i + 1);     }     ed = new edge[n];     for (int i = 0; i < n; i++) {       ed[i].v = i;       ed[i].left = i > 0 ? &ed[i - 1] : NULL;       ed[i].right = i < n - 1 ? &ed[i + 1] : NULL;     }     select();     cout << out.size() << endl;     print();   }   