func_code_string: #include <bits/stdc++.h>   #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math )   using namespace std;   const int N = 3e5 + 100;   set<pair<int, int> > s[N];   int a[N];   int nxt[N];   int dp[N];   int mol[N];   int n;   void add(long long int v, long long int u) {     long long int m = mol[u];     if (m != n + 2) s[m].insert({a[v], v});     mol[v] = mol[u];   }   int tt;   void Main(long long int oo) {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       nxt[i] = n + 2;       s[i].clear();       dp[i] = 0;     }     s[n + 1].clear();     s[n + 2].clear();     a[n + 1] = -1;     a[n + 2] = -1;     dp[n + 2] = 0;     dp[n + 1] = 0;     nxt[n + 2] = n + 2;     mol[n + 2] = n + 2;     nxt[n + 1] = n + 1;     for (int i = 1; i <= n + 1; i++) {       mol[i] = n + 1;     }     vector<int> pashm;     for (int i = n; i; i--) {       if (a[i] == a[i + 1]) {         nxt[i] = i + 2;         add(i, i + 2);       } else {         long long int z = mol[nxt[i + 1]];         if (z == n + 3) z = n + 2;         auto y = s[z].lower_bound({a[i], 0});         if (y != s[z].end() && y->first == a[i]) {           long long int p = y->second;           nxt[i] = p + 1;           add(i, p + 1);         } else {           mol[i] = i;           nxt[i] = n + 2;           add(i, i);         }       }     }     long long int ans = 0;     for (int i = n; i; i--) {       if (nxt[i] != n + 2) {         dp[i] = 1 + dp[nxt[i]];       }       ans += dp[i];     }     cout << ans <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> tt;     for (int i = 1; i <= tt; i++) Main(i);   }   