func_code_string: #include <bits/stdc++.h>   using namespace std;   using LL = long long;   using LD = long double;   void err() { cerr <<   033[39;0m  << endl; }   template <typename T, typename... A>   void err(T a, A... x) {     cerr << a <<    ;     err(x...);   }   const int N = 1e6 + 10;   struct Node {     map<int, Node*> link;     Node* fa;     int count;   } pool[N];   int cnt;   Node* new_node(Node* fa) {     Node* ret = pool + cnt++;     ret->fa = fa;     ret->link.clear();     ret->count = 0;     return ret;   }   int stk[N], top;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int T;     cin >> T;     while (T--) {       int n;       cin >> n;       top = 0;       LL ans = 0;       auto cur = new_node(nullptr);       cur->count = 1;       for (decay<decltype(n)>::type i = (0), _i = (n); i < _i; ++i) {         int c;         cin >> c;         if (top == 0 || stk[top - 1] != c) {           if (!cur->link[c]) {             cur->link[c] = new_node(cur);           }           cur = cur->link[c];           ans += cur->count++;           stk[top++] = c;         } else {           cur = cur->fa;           ans += cur->count++;           --top;         }       }       cout << ans << endl;     }     return 0;   }   