func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 355001;   const int SQRTN = 320;   const int LOGN = 20;   const long double PI = acos(-1);   const long double TAU = 2 * PI;   int n, a[N], idx[N], last, m, an[N];   long long ans;   signed main() {     cin >> n >> m;     for (int i = 1; i <= n; i++) {       scanf( %d , a + i);       idx[a[i]] = i;       an[i] = n + 1;     }     for (int j = 0, x, y; j < m; j++) {       scanf( %d%d , &x, &y);       if (idx[x] > idx[y]) swap(x, y);       an[idx[x]] = min(an[idx[x]], idx[y]);     }     int x = n + 1;     ans = -(n * 1ll * (n + 1)) >> 1;     for (int i = n; i > 0; i--) x = min(x, an[i]), ans += x;     cout << ans << endl;   }   