func_code_string: #include <bits/stdc++.h>   using namespace std;   using ll = long long;   const int N = 3 * 100002;   int a[N], pr[N];   ll cnt[N];   map<int, int> s[N];   int main() {     int q;     cin >> q;     while (q--) {       ll ans = 0;       int n;       cin >> n;       for (int i = 0; i <= n; i++) {         pr[i] = -1;         s[i].clear();       }       for (int i = 1; i <= n; i++) {         cnt[i] = 0;         cin >> a[i];         if (i != 1) {           if (pr[i - 1] != -1) {             swap(s[i], s[pr[i - 1]]);             s[i][a[pr[i - 1] - 1]] = pr[i - 1] - 1;           }           if (s[i][a[i]])             pr[i] = s[i][a[i]];           else             pr[i] = -1;           if (a[i] == a[i - 1]) pr[i] = i - 1;         }         if (pr[i] != -1) cnt[i] = cnt[pr[i] - 1] + 1;         ans += cnt[i];       }       cout << ans <<   n ;     }     return 0;   }   