func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 10;   const int inf = 1e9;   int arr[N], pos[N], rMax[N];   int main() {     int n, m;     scanf( %d %d , &n, &m);     for (int i = 0; i < n; i++) {       scanf( %d , arr + i);       pos[arr[i]] = i;     }     fill(rMax, rMax + N, n - 1);     while (m--) {       int a, b;       scanf( %d %d , &a, &b);       if (pos[a] < pos[b]) {         rMax[a] = min(pos[b] - 1, rMax[a]);       } else {         rMax[b] = min(pos[a] - 1, rMax[b]);       }     }     long long ans = 1;     for (int i = n - 2; i >= 0; i--) {       int k = arr[i];       int j = arr[i + 1];       rMax[k] = min(rMax[k], rMax[j]);       ans += rMax[k] - i + 1;     }     cout << ans << endl;   }   