func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class A, class B>   inline bool mina(A &first, B second) {     return (first > second) ? (first = second, 1) : 0;   }   template <class A, class B>   inline bool maxa(A &first, B second) {     return (first < second) ? (first = second, 1) : 0;   }   const int MAXN = 3e5 + 5;   int in[MAXN];   int N, M;   int pos[MAXN];   pair<int, int> foes[MAXN];   int main() {     scanf( %d %d , &N, &M);     for (int i = 1; i <= N; i++) {       scanf( %d , &in[i]);       pos[in[i]] = i;     }     int a, b;     for (int(i) = 0; (i) < (M); ++(i)) {       scanf( %d %d , &a, &b);       a = pos[a];       b = pos[b];       if (a < b) swap(a, b);       foes[i] = pair<int, int>(a, b);     }     sort(foes, foes + M);     long long ans = 0;     int maxx = 0;     int cur = 0;     for (int i = 1; i <= N; i++) {       while (cur < M && foes[cur].first <= i) {         maxa(maxx, foes[cur].second);         cur++;       }       ans += i - maxx;     }     cout << ans << endl;     return 0;   }   