C++ 8ms 100%
\nclass Solution {\npublic:\n    int numTeams(vector<int>& rating) {\n     \n        int n = rating.size() ;\n        \n        int ans = 0 ;\n        \n       
```\nclass Solution {\npublic:\n    int numTeams(vector<int>& rating) {\n     \n        int n = rating.size() ;\n        \n        int ans = 0 ;\n        \n        for( int j=1 ; j<n-1 ; j++ ){\n            \n            int i_small = 0 , i_big = 0 , k_small = 0 , k_big = 0 ;\n            \n            for( int i=0 ; i<j ; i++ ){\n                if(rating[i]<rating[j]) i_small++ ;\n                else if(rating[i]>rating[j]) i_big++ ;\n            }\n            \n            for( int k=j+1 ; k<n ; k++ ){\n                if(rating[j]<rating[k]) k_big++ ;\n                else if(rating[j]>rating[k]) k_small++ ;\n            }\n            \n            ans += (i_small*k_big) + (i_big*k_small) ;\n            \n        }\n        return ans ;\n    }\n};\n```
['C++']