Language: C++

#include<bits/stdc++.h>
#define LL long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define For(i,a,b) for(int i=a;i>=b;i--)
#define debug
#define MaxL 1000
#define int LL

using namespace std;

int read(){
    char c=getchar(); int flag=1, x=0;
    while(!isdigit(c)){ if(c=='-') flag=-1; c=getchar(); }
    while( isdigit(c)){ x=x*10+(c-'0'); c=getchar(); }
    return flag*x;
}

int n;
int H[MaxL+10];
int Sum[MaxL+10];

signed main(){

    n=read();
    FOR(i,1,n){
        int a=read(); H[a]++;
    }

    FOR(i,1,1002) Sum[i]=Sum[i-1]+H[i];


    int Ans=0;
    //ABC
    FOR(i,1,1000) FOR(j,i+1,1000){
        if(H[i]<=0||H[j]<=0) continue;
        // cout<<"ABC "<<i<<" "<<j<<" "<<min(i+j-1,1000)<<endl;
        // cout<<" "<<( H[i]*H[j]* (Sum[min(1000,i+j-1)]-Sum[j]) )<<endl;
        Ans+=( H[i]*H[j]* (Sum[min(1001,i+j-1)]-Sum[j]) );
    }
    //AAB
    FOR(i,1,1000){
        if(H[i]<=1) continue;
        Ans+=( H[i]*(H[i]-1)/2 * (Sum[min(1001,i*2-1)]-H[i]) );
    }
    
    //AAA
    FOR(i,1,1000){
        if(H[i]<=2) continue;
        Ans+=( H[i]*(H[i]-1)*(H[i]-2)/6 );
    }

    cout<<Ans<<endl;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:35: error: no matching function for call to 'min(int, long long int)'
   38 |         Ans+=( H[i]*H[j]* (Sum[min(1001,i+j-1)]-Sum[j]) );
      |                                ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:38:35: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   38 |         Ans+=( H[i]*H[j]* (Sum[min(1001,i+j-1)]-Sum[j]) );
      |                                ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:38:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   38 |         Ans+=( H[i]*H[j]* (Sum[min(1001,i+j-1)]-Sum[j]) );
      |                                ~~~^~~~~~~~~~~~
a.cc:43:42: error: no matching function for call to 'min(int, long long int)'
   43 |         Ans+=( H[i]*(H[i]-1)/2 * (Sum[min(1001,i*2-1)]-H[i]) );
      |                                       ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:43:42: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   43 |         Ans+=( H[i]*(H[i]-1)/2 * (Sum[min(1001,i*2-1)]-H[i]) );
      |                                       ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:43:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   43 |         Ans+=( H[i]*(H[i]-1)/2 * (Sum[min(1001,i*2-1)]-H[i]) );
      |                                       ~~~^~~~~~~~~~~~