func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 300010;   int p1[maxn], p2[maxn], q[maxn];   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) {       scanf( %d , &p1[i]);       p1[i]--;       p2[p1[i]] = i;       q[i] = n;     }     for (int i = 0; i < m; i++) {       int x, y;       scanf( %d%d , &x, &y);       x--;       y--;       x = p2[x];       y = p2[y];       if (x > y) swap(x, y);       q[x] = min(q[x], y);     }     int r = n - 1;     long long ans = 0;     for (int i = n - 1; i >= 0; i--) {       r = min(q[i] - 1, r);       ans += r - i + 1;     }     printf( %lld n , ans);     return 0;   }   