func_code_string: #include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const int MaxN = 3e5 + 5;   map<int, int> mp;   struct node {     int x, y;   } arr[MaxN], brr[MaxN];   struct qnode {     int x, y;     bool operator>(const qnode &p) const { return p.y > y; }   } st;   bool cmp(node b, node c) {     if (b.x == c.x) return b.y < c.y;     return b.x < c.x;   }   int main() {     int n, m, u, v, pp;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %d , &pp), mp[pp] = i;     int x = -1, y = inf;     for (int i = 0; i < m; i++) {       scanf( %d%d , &u, &v);       arr[i].x = min(mp[u], mp[v]);       arr[i].y = max(mp[u], mp[v]);     }     sort(arr, arr + m, cmp);     priority_queue<qnode, vector<qnode>, greater<qnode> > pq;     for (int i = 0; i < m; i++) {       if (pq.empty()) {         st.x = arr[i].x, st.y = arr[i].y;         pq.push(st);         continue;       }       while (!pq.empty() && arr[i].y <= pq.top().y) {         pq.pop();       }       st.x = arr[i].x, st.y = arr[i].y;       pq.push(st);     }     int num = 0;     while (!pq.empty()) {       st = pq.top();       pq.pop();       brr[num].x = st.x, brr[num].y = st.y, num++;     }     long long p = (long long)(brr[num - 1].x) * (n - brr[num - 1].y + 1);     for (int i = num - 1; i >= 1; i--)       p += (long long)(brr[i - 1].x - brr[i].x) * (n - brr[i - 1].y + 1);     long long ans = (long long)n + (long long)n * (n - 1) / 2;     printf( %I64d n , ans - p);   }   