func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 3005;   const int mod = 1e9 + 7;   int dp1[N][N], dp2[N][N], a[N];   int main() {     int t;     scanf( %d , &t);     while (t--) {       int n;       scanf( %d , &n);       for (int i = 1; i <= n; i++) {         scanf( %d , &a[i]);       }       memset(dp1, 0, sizeof(dp1));       memset(dp2, 0, sizeof(dp2));       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= n; j++) {           dp1[i][j] = dp1[i - 1][j];         }         dp1[i][a[i]]++;       }       for (int i = n; i >= 1; i--) {         for (int j = 1; j <= n; j++) {           dp2[i][j] = dp2[i + 1][j];         }         dp2[i][a[i]]++;       }       long long ans = 0;       for (int i = 2; i <= n; i++) {         for (int j = i + 1; j < n; j++) {           ans += dp1[i - 1][a[j]] * dp2[j + 1][a[i]];         }       }       printf( %lld n , ans);     }     return 0;   }   