criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int n;
    cin>>n;
    vector<int>l(n);
    rep(i,n)cin>>l[i];
    sort(l.begin(),l.end());
    ll ans=0;
    rep(i,n){
        for(int j=i+1; j<n; ++j){
            ans+=max(0,lower_bound(l.begin(),l.end(),l[i]+l[j])-l.begin()-1-j);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:21: error: no matching function for call to 'max(int, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
   16 |             ans+=max(0,lower_bound(l.begin(),l.end(),l[i]+l[j])-l.begin()-1-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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:16:21: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'})
   16 |             ans+=max(0,lower_bound(l.begin(),l.end(),l[i]+l[j])-l.begin()-1-j);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:16:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   16 |             ans+=max(0,lower_bound(l.begin(),l.end(),l[i]+l[j])-l.begin()-1-j);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

	#include<bits/stdc++.h>
	using namespace std;
	#define xxx ios::sync_with_stdio(),cin.tie(0),cout.tie(0)
	#define rep(i,n) for(int i=0;i<n;i++)
	#define int long long
	int bp(int a, int b, int m) {
   		a %= m;
   		int res = 1;
    	while (b > 0) {
        	if (b & 1)
            	res = res * a % m;
       		a = a * a % m;
       	 	b >>= 1;
 	    }
    return res;
	}
	int max(int a, int b){
		return (a>b)?a:b;	
	}
	int csb( int n) 
{ 
    int count = 0; 
    while (n) { 
        count += n & 1; 
        n >>= 1; 
    } 
    return count; 
} 
	int solve(int x){
		int r=0;
		while(x>0){
			int t=csb(x);
			x%=t;
			r++;
		}
		return r;
	}

	signed main(){
		int test=1;
		//cin>>test;
		while(test--){
			int n;
			cin>>n;
			int a[n];
			rep(i,n) cin>>a[i];
			sort(a,a+n);
			int  s=0;
			//for(int i=0;i<n;i++){ cout<<a[i]<<" ";}
				//cout<<endl;
			rep(i,n){
				for(int j=i+1;j<n;j++){
					int lt=a[i]+a[j];
					int ind=upper_bound(a,a+n,lt-1)-a;
					if(ind==n) ind=n-1;
					if(ind<=j) continue;
					if  (a[ind]<lt){ s+=ind-j;//cout<<i<<" "<<j<<" "<<ind<<endl;}
					else if(a[ind-1]<lt && ind-1 >j){ s+=ind-j-1;//cout<<i<<" "<<j<<" "<<ind<<endl;}

				}
			}
			cout<<s<<endl;
		}
		return 0;
	}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:41: error: expected '}' before 'else'
   58 |                                         else if(a[ind-1]<lt && ind-1 >j){ s+=ind-j-1;//cout<<i<<" "<<j<<" "<<ind<<endl;}
      |                                         ^~~~
a.cc:57:56: note: to match this '{'
   57 |                                         if  (a[ind]<lt){ s+=ind-j;//cout<<i<<" "<<j<<" "<<ind<<endl;}
      |                                                        ^
a.cc:65:10: error: expected '}' at end of input
   65 |         }
      |          ^
a.cc:39:22: note: to match this '{'
   39 |         signed main(){
      |                      ^
Language: C++

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
ll m,n,vis[2005],yy[2005],hh[2005]; 

int main()
{
    std::ios::sync_with_stdio(0); std::cin.tie(0);
    cin>>m;
    for(int i=0;i<m;++i)
    {
    	cin>>n;
    	vis[n]++;
	}
	for(int i=1;i<=2000;++i)
	{
		yy[i]=yy[i-1]+min(vis[i],1);
		hh[i]=hh[i-1]+vis[i];
	}
	ll sum=0;
	for(int i=1;i<=998;++i)
	 {if(!vis[i]) continue;
	 for(int j=i+1;j<=999;++j)
	 {
	 	if(!vis[j]) continue; 
		for(int k=j+1;k<=j+i-1;++k)
		if(vis[k]) sum+=vis[i]*vis[j]*vis[k]; 
	 }} 
	 for(int i=1;i<=1000;++i)
	 {
	 	if(vis[i]==2) sum+=hh[2*i-1]-2;
	 	if(vis[i]>=3) sum+=vis[i]*(vis[i]-1)*(vis[i]-2)/6+(vis[i]*(vis[i]-1)/2)*(hh[2*i-1]-vis[i]);
	 }
	 cout<<sum;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:34: error: no matching function for call to 'min(long long int&, int)'
   18 |                 yy[i]=yy[i-1]+min(vis[i],1);
      |                               ~~~^~~~~~~~~~
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:18:34: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 |                 yy[i]=yy[i-1]+min(vis[i],1);
      |                               ~~~^~~~~~~~~~
/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:18:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |                 yy[i]=yy[i-1]+min(vis[i],1);
      |                               ~~~^~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(void){

    int input, ans = 0;
    cin >> input ;
    
    vector<int> side(input);
    for(int i = 0; i < input; i++){
        cin >> side.at(i);
    }
    
    sort(side.begin(), side.end());
    reverse(side.begin(), side.end());

    for(int i = 0; i < input; i++){
        flag = 0;
        for(int j = i + 1; j < input; j++){
            for(int k = j + 1; k < input; k++){
                if(side.at(i) < side.at(j) + side.at(k) && side.at(j) < side.at(k) + side.at(i) && side.at(k) < side.at(i) + side.at(j) ){
                    ans++;
                } else {
                    break;
                }
            }

        }
    }

    cout << ans << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:9: error: 'flag' was not declared in this scope
   17 |         flag = 0;
      |         ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using vl = vector<ll>;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
ll n;
vl l;
int main() {
	cin >> n;
	l.resize(n);
	REP(i, n){
		cin >> l[i];
	}
	sort(ALL(l));
	ll ans = 0;
	REP(i, n){
		FOR(j, i+1, n){
			auto ite = upper_bound(l.begin() + j + 1, l.end(), abs(l[i]-l[j]));
			auto ite2 = lower_bound(l.begin() + j + 1, l.end(), l[i]+l[j]);
			ans += ite2 - ite;
		}
	}
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:14: error: 'ALL' was not declared in this scope
   15 |         sort(ALL(l));
      |              ^~~
Language: C++

#include<iostream>
#include<vector>
#include<string>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}

int main(){
    //input
    ll N; cin>>N;
    vector<int> L(N+1,0);
    rep1(i,N) cin>>L[i];
    sort(all(L));
    L.pb(1000000);
    ll ans=0;

    rep1(i1,N-2){
        FOR(i2,i1+1,N){
            int tmp=L[i1]+L[i2];
            
            // 二分探索
            int l=i2+1,r=N+1;
            while(r-l>=1){
                int i=(l+r)/2;
                if(L[i]<tmp) l=i+1;
                else r=i;
            }
            ans+=max((ll)0,r-i2-1);
        }
    }

    cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   32 |     sort(all(L));
      |     ^~~~
      |     short
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値

// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
int main(){
ll n;
cin>>n;
ll aa[1010]={};
ll counter=0;
ll ca=0;
for(ll i=0; i<n; i++){
cin>>ca;
aa[ca]++;}
for(ll b=1; b<=1000; b++){
for(ll a=1; a<1000;  a++){
for(ll c=b-a+1; c-a<b; c++){
if(a==c&&b==c){
counter+=aa[a]*aa[a-1]*aa[a-2]/6;}
else if(a==b){
counter+=(aa[a]*aa[a-1]/2)*aa[c];}
else if(a==c){
counter+=(aa[a]*aa[a-1]/2)*aa[b];}
else if(b==c)
counter+=(aa[b]*aa[b-1]/2)*aa[a];}
else{
counter+=(aa[a]*aa[b]*aa[c]);}}}}

cout<<counter<<endl;}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:1: error: 'else' without a previous 'if'
   38 | else{
      | ^~~~
a.cc:39:26: error: 'c' was not declared in this scope
   39 | counter+=(aa[a]*aa[b]*aa[c]);}}}}
      |                          ^
a.cc: At global scope:
a.cc:41:1: error: 'cout' does not name a type
   41 | cout<<counter<<endl;}
      | ^~~~
a.cc:41:21: error: expected declaration before '}' token
   41 | cout<<counter<<endl;}
      |                     ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値

// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
int main(){
ll n;
cin>>n;
ll aa[1010]={};
ll counter=0;
ll ca=0;
for(ll i=0; i<n; i++){
cin>>ca;
aa[ca]++;}
dp[i][0]=p;}

for(ll b=1; b<=1000; b++){
for(ll a=1; a<1000;  a++){
for(ll c=b-a+1; c-a<b; c++){
if(a==c&&b==c){
counter+=aa[a]*aa[a-1]*aa[a-2]/6;}
else if(a==b){
counter+=(aa[a]*aa[a-1]/2)*aa[c];}
else if(a==c){
counter+=(aa[a]*aa[a-1]/2)*aa[b];}
else if(b==c)
counter+=(aa[b]*aa[b-1]/2)*aa[a];}
else{
counter+=(aa[a]*aa[b]*aa[c]);}}}}

cout<<counter<<endl;}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:1: error: 'dp' was not declared in this scope; did you mean 'dup'?
   27 | dp[i][0]=p;}
      | ^~
      | dup
a.cc:27:4: error: 'i' was not declared in this scope
   27 | dp[i][0]=p;}
      |    ^
a.cc:27:10: error: 'p' was not declared in this scope
   27 | dp[i][0]=p;}
      |          ^
a.cc: At global scope:
a.cc:29:1: error: expected unqualified-id before 'for'
   29 | for(ll b=1; b<=1000; b++){
      | ^~~
a.cc:29:13: error: 'b' does not name a type
   29 | for(ll b=1; b<=1000; b++){
      |             ^
a.cc:29:22: error: 'b' does not name a type
   29 | for(ll b=1; b<=1000; b++){
      |                      ^
a.cc:41:33: error: expected declaration before '}' token
   41 | counter+=(aa[a]*aa[b]*aa[c]);}}}}
      |                                 ^
a.cc:43:1: error: 'cout' does not name a type
   43 | cout<<counter<<endl;}
      | ^~~~
a.cc:43:21: error: expected declaration before '}' token
   43 | cout<<counter<<endl;}
      |                     ^
Language: C++

#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#define rep(i,n) for (int i=0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
    int n, sum=0;
    cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    for(int i=0; i<n-2; i++){
        for(int j=i+1; j<n-1; j++){
            for(int k=j+1; k<n; k++){
                if(l[i]<l[j]+l[k] && l[j] < l[i]+l[k] && l[k]<l[j]+l[i]) sum++;
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:5: error: 'cin' was not declared in this scope
   12 |     cin >> n;
      |     ^~~
a.cc:6:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    5 | #include <iomanip>
  +++ |+#include <iostream>
    6 | #define rep(i,n) for (int i=0; i < (n); ++i)
a.cc:22:5: error: 'cout' was not declared in this scope
   22 |     cout << sum << endl;
      |     ^~~~
a.cc:22:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include <bits/stdc++.h>
using namespace std;


int main() {

  int n;
  cin>>n;

  vector<int> L(n);
  for(int i=0;i<n;i++){
    cin>>L.at(i);
  }

  sort(L.begin(),L.end());

  vector<vector<vector<char>>> data(n,vector<vector<char>>(n, vector<char>(n,0)));
//  int cnt=0;
//  for(int i=0;i<n;i++){
//    for(int j=0;j<n;j++){
//      for(int k=0;k<n;k++){
//        if(i!=j&&j!=k&&i!=k&&L.at(i)<L.at(j)+L.at(k)&&L.at(j)<L.at(k)+L.at(i)&&L.at(k)<L.at(i)+L.at(j))
//        {
//          if(data.at(i).at(j).at(k)==0&&data.at(i).at(k).at(j)==0&&data.at(k).at(i).at(j)==0&&data.at(k).at(j).at(i)==0&&data.at(j).at(i).at(k)==0&&data.at(j).at(k).at(i)==0){
            cnt++;
//            data.at(i).at(j).at(k)=1;
//            data.at(i).at(k).at(j)=1;
//            data.at(k).at(i).at(j)=1;
//            data.at(k).at(j).at(i)=1;
//            data.at(j).at(i).at(k)=1;
//            data.at(j).at(k).at(i)=1;
//          }
//        }
//      }
//    }
//  }

  cout<<cnt<<endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:13: error: 'cnt' was not declared in this scope; did you mean 'int'?
   25 |             cnt++;
      |             ^~~
      |             int
Language: C++

#include <bits/stdc++.h>
using namespace std;


int main() {

  int n;
  cin>>n;

  vector<int> L(n);
  for(int i=0;i<n;i++){
    cin>>L.at(i);
  }

  sort(L.begin(),L.end());

  vector<vector<vector<char>>> data(n,vector<vector<char>>(n, vector<char>(n,0)));
//  int cnt=0;
//  for(int i=0;i<n;i++){
//    for(int j=0;j<n;j++){
//      for(int k=0;k<n;k++){
//        if(i!=j&&j!=k&&i!=k&&L.at(i)<L.at(j)+L.at(k)&&L.at(j)<L.at(k)+L.at(i)&&L.at(k)<L.at(i)+L.at(j))
        {
//          if(data.at(i).at(j).at(k)==0&&data.at(i).at(k).at(j)==0&&data.at(k).at(i).at(j)==0&&data.at(k).at(j).at(i)==0&&data.at(j).at(i).at(k)==0&&data.at(j).at(k).at(i)==0){
            cnt++;
//            data.at(i).at(j).at(k)=1;
//            data.at(i).at(k).at(j)=1;
//            data.at(k).at(i).at(j)=1;
//            data.at(k).at(j).at(i)=1;
//            data.at(j).at(i).at(k)=1;
//            data.at(j).at(k).at(i)=1;
//          }
//        }
//      }
//    }
//  }

  cout<<cnt<<endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:13: error: 'cnt' was not declared in this scope; did you mean 'int'?
   25 |             cnt++;
      |             ^~~
      |             int
a.cc:41:2: error: expected '}' at end of input
   41 | }
      |  ^
a.cc:5:12: note: to match this '{'
    5 | int main() {
      |            ^
Language: C++

#include <iostream>
#include <vector>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;

int main() {

  int N;
  cin >> N;

  vector<int> L(N);
  rep(i, N) cin >> L[i];

  sort(L.begin(), L.end());
  //rep(i, N) cout << L[i] << endl;

  int a, b;
  int cnt = 0;
  rep(i, N) {
	for (int j=i+1; j<N; ++j) {
	  a = L[i];
	  b = L[j];

	  int ab = a+b;

	  int r = lower_bound(L.begin(), L.end(), ab) - L.begin();  // right side

	  int l =  j+1;  // left side
	  // c in [l, r)
	  cnt += max(0, r-l);
	}
  }

  cout << cnt << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   14 |   sort(L.begin(), L.end());
      |   ^~~~
      |   short
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,l[2000],a=0;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>l[i];
	sort(l,l+n);
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++){
			long long k=j,r=N;
			while(r-k>1){
				long long m=(k+r)/2;
				if(l[m]<l[i]+l[j])
					k=m;
				else
					r=m;
			}
			a+=k-j;
		}
	cout<<a<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:41: error: 'N' was not declared in this scope
   11 |                         long long k=j,r=N;
      |                                         ^
Language: C++

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main () {
    int n;
    vector<int> sticks;

    cin >> n;
    for (int i = 0; i < n; i++) {
        int l; cin >> l;
        sticks.push_back(l);
    }

    sort(sticks.begin(), sticks.end());

    int count = 0;

    for(int i = n - 1; i >= 0; i--) {
        for(int j = i - 1; j >= 0; j--) {
            if (sticks[j] * 2 < sticks[i]) break;
            for (int k = j - 1; k >=0; k--) {
                if (sticks[k] + sticks[j] > sticks[i]) count++;
                else break;
            }
        }
    }

    cout << count << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   17 |     sort(sticks.begin(), sticks.end());
      |     ^~~~
      |     short
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,N) for(int i=0; i<n; i++){    ;
int main() {
int N;
cin>>N;
int answer=0;
vector<int>A(N);
rep(i,N)
cin>>A.at(i);
}
for(int i=2; i<N; i++){
    for(int j=1; j<i; j++){
        for(int k=0; k<j; k++){
            int a=A.at(i);
            int b=A.at(j);
            int c=A.at(k);
            if(a<b+c&&b<c+a&&c<a+b){
                answer++;
            }
        }
    }
}
cout<<answer<<endl;
 }


Compiler output:
a.cc: In function 'int main()':
a.cc:4:33: error: 'n' was not declared in this scope
    4 | #define rep(i,N) for(int i=0; i<n; i++){    ;
      |                                 ^
a.cc:10:1: note: in expansion of macro 'rep'
   10 | rep(i,N)
      | ^~~
Language: C++

#include<stdio.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
int main() {
    int n; cin >> n;
    int l[n];
    rep(i, n) cin >> l[i];
    int ans = 0;
    for(int i = 0; i <= n-3; i++){
        for(int j = i+1; j <= n-2; j++){
            for(int k = j+1; k < n; k++){
                if(i == k || j == k) continue;
                if(l[i] < l[j]+l[k] && l[j] < l[i]+l[k] && l[k] < l[i]+l[j]){
                    // cout << i << j << k << endl;
                    ans++;
                }
            }
        }
    }
    printf("%d", ans);

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:4:12: error: 'cin' was not declared in this scope
    4 |     int n; cin >> n;
      |            ^~~
Language: Java

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int[] l = new int[n];
		for (int i = 0; i < n; i++) {
			l[i] = sc.nextInt();
		}
		
		int cnt=0;
		for (int a = 0; a < n-2; a++) {
			for (int b = a+1; b < n-1; b++) {
				for (int c = b+1; c < n; c++) {
					boolean ba = l[a] < l[b]  + l[c];
					boolean bb = l[b] < l[c]  + l[a];
					boolean bc = l[c] < l[a]  + l[b];
					if( ba && bb && bc ) {
						cnt++;
					}
				}
			}
		}
		
		System.out.println(cnt);
		
	}


Compiler output:
Main.java:30: error: reached end of file while parsing
	}
	 ^
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>L(N);
  for(int i=0;i<N;i++)
    cin>>L.at(i);
  sort(L.begin(),L.end());
  int ans=0;
  for(int i=0;i<N-2;i++){
  for(int j=i+1;i<N-1;j++){
   int c=L.at(i)+L.at(j);
    auto itr=lower_bound(L.begin()+j+1,L.end(),c);
    int k=distance(L.begin()+j+1,itr);
    ans+=k;
  
  }
  
  }cout<<k<<endl;
   return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:10: error: 'k' was not declared in this scope
   20 |   }cout<<k<<endl;
      |          ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define int long long 
typedef pair<int,int>pii;
const int mxN=2e5,M=1e9+7;
int n,x;
int v[mxN],a[1005];
// LONG LONG CASE
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    sort(v,v+n);
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            auto it=lower_bound(v,v+n,v[i]+v[j]);
            //cout<<it-v<<"\n";
            ans+=(it-v)-j-1;
            //cout<<v[i]<<" "<<v[j]<<" "<<j<<"\n";
        }
    }
    cout<<ans;
    
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n; cin >> n;
    vector<int> L(n);
    rep(i,n) cin >> L[i];
    sort(L.begin(),L.end());
    int ans = 0;
    rep(i,n) rep(j,i) {
        int ij = L[i]+L[j];
        int r = lower_bound(L.begin(), L.end(), ij) - L.begin();
        int l = i + 1;
        ans += max(0,r-1);

    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:19: error: no matching function for call to 'max(int, long long int)'
   22 |         ans += max(0,r-1);
      |                ~~~^~~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:22:19: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   22 |         ans += max(0,r-1);
      |                ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:22:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   22 |         ans += max(0,r-1);
      |                ~~~^~~~~~~
Language: C

#include<stdio.h>
void swap(int *a,int *b)
{
int temp;
temp=*a;
*a=*b;
*b=temp;
return;  
}
int main(void)
{
int a,c,i,j,k;
  
scanf("%d",&a);
  int num[a];
  
  for(i=0;i<a;++i)
  {
  scanf("%d",&num[i]);
  }
    
  for(i=2;i<a;i++)
  {
   for(j=1;j<i;j++)
   {
    for(k=0;k<j;k++)
    {
    if(num[i]+num[k]>num[j] && num[i]+num[j]>num[k] && num[j]+num[k]>num[i]) c++
    }
   }
  }
  printf("%d",c);

return 0;
}

Compiler output:
main.c: In function 'main':
main.c:28:81: error: expected ';' before '}' token
   28 |     if(num[i]+num[k]>num[j] && num[i]+num[j]>num[k] && num[j]+num[k]>num[i]) c++
      |                                                                                 ^
      |                                                                                 ;
   29 |     }
      |     ~
Language: C++

int main() {
  ll n;
  cin >> n;
  vector<ll>l(n);
  rep(i,n) cin >> l[i];
  sort(all(l));
  reverse(all(l));
  ll ans = 0;
  rep(i,n) for(ll j=i+1;j<n;j++) for(ll k=j+1;k<n;k++){
    if(l[i]<l[j]+l[k]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:2:3: error: 'll' was not declared in this scope
    2 |   ll n;
      |   ^~
a.cc:3:3: error: 'cin' was not declared in this scope
    3 |   cin >> n;
      |   ^~~
a.cc:3:10: error: 'n' was not declared in this scope
    3 |   cin >> n;
      |          ^
a.cc:4:3: error: 'vector' was not declared in this scope
    4 |   vector<ll>l(n);
      |   ^~~~~~
a.cc:4:13: error: 'l' was not declared in this scope
    4 |   vector<ll>l(n);
      |             ^
a.cc:5:7: error: 'i' was not declared in this scope
    5 |   rep(i,n) cin >> l[i];
      |       ^
a.cc:5:3: error: 'rep' was not declared in this scope
    5 |   rep(i,n) cin >> l[i];
      |   ^~~
a.cc:6:8: error: 'all' was not declared in this scope
    6 |   sort(all(l));
      |        ^~~
a.cc:6:3: error: 'sort' was not declared in this scope; did you mean 'short'?
    6 |   sort(all(l));
      |   ^~~~
      |   short
a.cc:7:3: error: 'reverse' was not declared in this scope
    7 |   reverse(all(l));
      |   ^~~~~~~
a.cc:8:5: error: expected ';' before 'ans'
    8 |   ll ans = 0;
      |     ^~~~
      |     ;
a.cc:9:25: error: 'j' was not declared in this scope
    9 |   rep(i,n) for(ll j=i+1;j<n;j++) for(ll k=j+1;k<n;k++){
      |                         ^
a.cc:9:47: error: 'k' was not declared in this scope
    9 |   rep(i,n) for(ll j=i+1;j<n;j++) for(ll k=j+1;k<n;k++){
      |                                               ^
a.cc:12:3: error: 'cout' was not declared in this scope
   12 |   cout << ans << endl;
      |   ^~~~
a.cc:12:11: error: 'ans' was not declared in this scope
   12 |   cout << ans << endl;
      |           ^~~
a.cc:12:18: error: 'endl' was not declared in this scope
   12 |   cout << ans << endl;
      |                  ^~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> L(n);
  rep(i,n) cin >> L[i];
  sort(L.begin(), L.end());
  int ans = 0;
  rep(b,n)rep(a,b) {
    int ab = L[a]+L[b];
    int r = lower_bound(L.begin(), L.end(), ab) - L.begin();//ab以上の要素を二分探索で検索。イテレータが返るからL.begin()を引くと添字に変換可能。
    // c = [l,r)
    ans += max(0,r-l);
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:20: error: 'l' was not declared in this scope
   17 |     ans += max(0,r-l);
      |                    ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main(){
	int n;
	cin >> n;
	vector<int> l;
	rep(i, n) cin >> l.at(i);
	sort(l.begin(), l.end());
	
	int ans = 0;
	rep(b, n) rep(a, b) {
		int sum = l.at(a) + l.at(b);
		int max = lower_bound(l.begin(), l.end(), sum);
		ans += max - b - 1;
	}
	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:38: error: cannot convert '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'int' in initialization
   16 |                 int max = lower_bound(l.begin(), l.end(), sum);
      |                           ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
      |                                      |
      |                                      __gnu_cxx::__normal_iterator<int*, std::vector<int> >
Language: C++

#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
//#define ll long long 
#define all(v) v.begin(),v.end()
#define int long long
using namespace std;
// index が条件を満たすかどうか
bool isOK(int index, vector<int>& a, int b, int c) {
    if (a[index] > abs(a[b]-a[c])) return true;
    else return false;
}
// 二分探索
int binary_search(vector<int>& a, int b,int c) {
    int left = b; //「index = b+1」が条件を満たすこともあるので、初期値は -1
    int right = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;
        if (isOK(mid, a , b, c)) right = mid;
        else left = mid;
    }
    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}


// index が条件を満たすかどうか
bool isOK2(int index, vector<int>& a, int b, int c) {
    if (a[index] < a[b]+a[c]) return true;
    else return false;
}
// 二分探索（上から押さえる）
int binary_search2(vector<int>& a, int b,int c) {
    int left = b; //「index = b+1」が条件を満たすこともあるので、初期値は -1
    int right = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;
        if (isOK2(mid, a , b, c)) left = mid;
        else right = mid;
    }
    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return left;
}


int main(){
  int n; cin >>n;
  vector<int> L(n);
  rep(i,n) cin >>L[i];
  int ans=0;
  sort(all(L));
  rep(i,n-2){
    rep2(j,i+1,n-1){
        if((binary_search(L,i,j)!=n)&&binary_search2(L,i,j)!=j) ans+=binary_search2(L,i,j)-binary_search(L,i,j)+1;
  }
  }
  cout <<ans/2<<endl;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
#define int long long
using namespace std;
// index が条件を満たすかどうか
bool isOK(int index, vector<int>& a, int b, int c) {
    if (a[index] > abs(a[b]-a[c])) return true;
    else return false;
}
// 二分探索
int binary_search(vector<int>& a, int b,int c) {
    int left = b; //「index = b+1」が条件を満たすこともあるので、初期値は -1
    int right = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;
        if (isOK(mid, a , b, c)) right = mid;
        else left = mid;
    }
    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}


// index が条件を満たすかどうか
bool isOK2(int index, vector<int>& a, int b, int c) {
    if (a[index] < a[b]+a[c]) return true;
    else return false;
}
// 二分探索（上から押さえる）
int binary_search2(vector<int>& a, int b,int c) {
    int left = b; //「index = b+1」が条件を満たすこともあるので、初期値は -1
    int right = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;
        if (isOK2(mid, a , b, c)) left = mid;
        else right = mid;
    }
    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return left;
}


int main(){
  ll n; cin >>n;
  vector<int> L(n);
  rep(i,n) cin >>L[i];
  ll ans=0;
  sort(all(L));
  rep(i,n-2){
    rep2(j,i+1,n-1){
        if((binary_search(L,i,j)!=n)&&binary_search2(L,i,j)!=j) ans+=binary_search2(L,i,j)-binary_search(L,i,j)+1;
  }
  }
  cout <<ans/2<<endl;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;

int main() {
  int n;
  cin >> n;
  int l[n];
  rep(i,n) cin >> l[i];
  
  sort(l.begin(),l.end());
  
  int ans = 0;
  
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      for (int k = j+1; k < n; k++) {
        if (l[i] + l[j] > l[k]) ans++;
      }
    }
  }
  
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:10: error: request for member 'begin' in 'l', which is of non-class type 'int [n]'
   11 |   sort(l.begin(),l.end());
      |          ^~~~~
a.cc:11:20: error: request for member 'end' in 'l', which is of non-class type 'int [n]'
   11 |   sort(l.begin(),l.end());
      |                    ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N; cin >> N;
  vector<int> L(N);
  for(int i = 0; i < N; i++) cin >> L.at(i);
  sort(L.begin(), L.end());
  ll cnt = 0;
  for(int i = 0; i < N; i++) {
    for(int j = i + 1; j < N; j++) {
      int a = L.at(i), b = L.at(j);
      int l = j, r = N;
      while(r -l > 1) {
        int mid = (l + r) / 2;
        if(L.at(mid) < a + b) l = mid;
        else r = mid;
      }
      int x = j, y = N;
      while(y - x > 1) {
        int MID = (x + y) / 2;
        if(L.at(MID) > max(a - b, b - a)) y = MID;
        else x = MID;
      }
      if(l == j) l++;
      if(y == N) y--;
      cnt += max(l - y + 1);
    }
  }
  cout << cnt << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:17: error: no matching function for call to 'max(int)'
   27 |       cnt += max(l - y + 1);
      |              ~~~^~~~~~~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   template argument deduction/substitution failed:
a.cc:27:17: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   27 |       cnt += max(l - y + 1);
      |              ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   candidate expects 2 arguments, 1 provided
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n
    cin >> n;
    std::vector<int> l;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        l.push_back(tmp);
    }
    std::sort(l.begin(), l.end());
    
    int sum = 0;
    std::vector<int>::iterator itr;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            int tmp = l[i]+l[j];
            itr = std::lower_bound(l.begin()+(j+1), l.end(), tmp);
            sum += std::distance(l.begin()+(j+1), itr);
        }
    }

    cout << sum << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: expected initializer before 'cin'
   10 |     cin >> n;
      |     ^~~
a.cc:12:20: error: 'n' was not declared in this scope
   12 |     for(int i=0; i<n; i++){
      |                    ^
a.cc:21:20: error: 'n' was not declared in this scope
   21 |     for(int i=0; i<n; i++){
      |                    ^
Language: Java

import java.util.*;

public class Answer {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] L = new int[N];
		for (int i = 0; i < N; i++) {
			L[i] = sc.nextInt();
		}
		sc.close();
		// 配列のソート
		Arrays.sort(L);

		int ans = 0;
		for (int i = 0; i < N - 2; i++) {
			for (int j = i + 1; j < N - 1; j++) {
				int l = j;
				int r = N;
				while(r - l > 1) {
					int m = (l + r) / 2;
					if (L[i] + L[j] > L[m]) {
						l = m;
					} else {
						r = m;
					}
				}
				ans += l - j;
			}
		}
		System.out.println(ans);
	}
}


Compiler output:
Main.java:3: error: class Answer is public, should be declared in a file named Answer.java
public class Answer {
       ^
1 error
Language: C++

#include <iostream>
#include <vector>

using namespace std;
using int64 = long long;

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for (int i=0; i<n; i++) cin >> l[i];
    sort(l.begin(), l.end());

    int ans = 0;
    for (int i=0; i<n-2; i++) {
        for (int j=i+1; j<n-1; j++) {
            for (int k=j+1; k<n; k++) {
                if (l[k] < l[i]+l[j]) ans++;
            }
        }
    }

    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   12 |     sort(l.begin(), l.end());
      |     ^~~~
      |     short
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>L(N);
  for(int i=0;i<N;i++)
    cin>>L.at(i);
  sort(L.begin(),L.end());
  int ans=0;
  for(int i=0;i<N-2;i++){
  for(int j=i+1;j<N-1;j++){
   int x=L.at(i)+L.at(j);
    int left=j+1;
    int right N;
    int mid;
    while(left<right){
     mid=(left+right)/2;
      if(L.at(mid)<=x)
        left=mid+1;
      else
        right=mid;
        } ans+(mid-j);
  }
  }cout<<ans<<endl;

   return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:15: error: expected initializer before 'N'
   15 |     int right N;
      |               ^
a.cc:17:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   17 |     while(left<right){
      |           ~~~~^~~~~~
a.cc:18:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   18 |      mid=(left+right)/2;
      |           ~~~~^~~~~~
a.cc:18:22: error: invalid operands of types 'std::ios_base& (*)(std::ios_base&)' and 'int' to binary 'operator/'
   18 |      mid=(left+right)/2;
      |          ~~~~~~~~~~~~^~
      |               |       |
      |               |       int
      |               std::ios_base& (*)(std::ios_base&)
a.cc:22:14: error: assignment of function 'std::ios_base& std::right(ios_base&)'
   22 |         right=mid;
      |         ~~~~~^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<int> L(N);

  for(int i = 0; i < N; i++) {
    cin >> L[i];
  }

  sort(L.begin(). L.end());
  ll ans = 0;
  // a < b < c
  for(int i = 0; i < L.size(); i++) {
    for(int j = i + 1; j < L.size(); j++) {
      int res = lower_bound(L.begin(), L.end(), L[i] + L[j]) - L.begin();
    ans += res - L[j];
    }

  }

  cout << ans << endl;
  return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:19: error: 'std::vector<int>::iterator' has no member named 'L'
   14 |   sort(L.begin(). L.end());
      |                   ^
Language: C++

import java.util.*;
import java.util.ArrayDeque;
import java.util.Queue;
import java.math.RoundingMode;
import java.math.BigDecimal;


public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String S = sc.next();
		char[] s = S.toCharArray();
		List<Integer> R = new ArrayList<Integer>();
		List<Integer> B = new ArrayList<Integer>();
		List<Integer> G = new ArrayList<Integer>();
		long ans = 0;
		for(int i = 0; i < n; i++) {
			if(s[i] =='R') {
				R.add(i);
			}
			else if(s[i] =='B') {
				B.add(i);
			}
			else if(s[i] =='G') {
				G.add(i);
			}
		}
		ans = R.size()*B.size()*G.size();
		long sub = 0;
		while(!R.isEmpty()) {
			int nowR = R.remove(0);
			for(int i = 0; i < B.size(); i++) {
				int nowB = B.get(i);
				int l = Math.abs(nowR-nowB);
				if(G.contains((nowR+nowB)/2)&&l%2==0) {
					sub++;
				}
				if(nowR<nowB) {
					if(G.contains(nowB+l)&&nowB+l<s.length-1) {
						sub++;
					}
					if(G.contains(nowR-l)&&nowR-l>=0) {
						sub++;
					}
					
				}
				else {
					if(G.contains(nowR+l)&&nowR+l<s.length-1) {
						sub++;
					}
					if(G.contains(nowB-l)&&nowB-l>=0) {
						sub++;
					}
				}		
			}
		}
		System.out.println(ans-sub);
	}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.ArrayDeque;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.Queue;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.math.RoundingMode;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
    5 | import java.math.BigDecimal;
      | ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:1: error: expected unqualified-id before 'public'
    8 | public class Main{
      | ^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int i,j,k;

int main(){
    ll n;cin>>n;
    vector<ll> length(n);//棒の長さ
    for(i=0;i<n;i++){cin>>length[i];}
    
    sort(length.begin(),length.end());//降順sort

    pre_process(length,sum);//累積和の作成

    ll ans=0;
    int number;
    for(i=n-1;i>=2;i--){
        for(j=i-1;j>=1;j--){
            //binary search
            number=length[i]-length[j];
            int key;
            vector<long long int>::iterator position;
            position=upper_bound(length.begin(),length.begin()+j,number);
            //他の2辺を固定して、最後の辺になり得る最小値を探す
            key=distance(length.begin(),position);//最小で可能な辺の位置
            ans+=(j-key);
        }
    }

    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:24: error: 'sum' was not declared in this scope
   14 |     pre_process(length,sum);//累積和の作成
      |                        ^~~
a.cc:14:5: error: 'pre_process' was not declared in this scope
   14 |     pre_process(length,sum);//累積和の作成
      |     ^~~~~~~~~~~
Language: C++

 #include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(lint i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009

typedef pair<int, int> P;

int n; 
vector<int> l;
bool isOK(int index, int key){
	if(l[index] >= key) return true;
	else return false;
}
int binary_search(int key){
	int ng = -1;
	int ok = (int)l.size();

	while(abs(ok-ng)>1){
		int mid = (ok + ng) /2;

		if(isOK(mid,key)) ok = mid;
		else ng = mid;
	}
	return ok;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	cin>>n;
	l.resize(n);
	REP(i,n) cin>>l[i];
	sort(all(l));
	int ans = 0;
	REP(i,n-1){
		FOR(j,i+1,n){
			int a = l[i];
			int b = l[j];
			int left = binary_search(max(a-b,b-a)+1);
			int right = binary_search(a+b);
			if(left<=i&&i<right) ans--;
			if(left<=j&&j<right) ans--;
			ans += right - left;
		}
	}
	cout<<ans/3<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:24: error: 'lint' was not declared in this scope; did you mean 'uint'?
   10 | #define FOR(i,a,b) for(lint i=(a);i<(b);i++)
      |                        ^~~~
a.cc:11:18: note: in expansion of macro 'FOR'
   11 | #define REP(i,n) FOR(i,0,n)
      |                  ^~~
a.cc:43:9: note: in expansion of macro 'REP'
   43 |         REP(i,n) cin>>l[i];
      |         ^~~
a.cc:43:13: error: 'i' was not declared in this scope
   43 |         REP(i,n) cin>>l[i];
      |             ^
a.cc:10:35: note: in definition of macro 'FOR'
   10 | #define FOR(i,a,b) for(lint i=(a);i<(b);i++)
      |                                   ^
a.cc:43:9: note: in expansion of macro 'REP'
   43 |         REP(i,n) cin>>l[i];
      |         ^~~
a.cc:10:24: error: 'lint' was not declared in this scope; did you mean 'uint'?
   10 | #define FOR(i,a,b) for(lint i=(a);i<(b);i++)
      |                        ^~~~
a.cc:11:18: note: in expansion of macro 'FOR'
   11 | #define REP(i,n) FOR(i,0,n)
      |                  ^~~
a.cc:46:9: note: in expansion of macro 'REP'
   46 |         REP(i,n-1){
      |         ^~~
a.cc:46:13: error: 'i' was not declared in this scope
   46 |         REP(i,n-1){
      |             ^
a.cc:10:35: note: in definition of macro 'FOR'
   10 | #define FOR(i,a,b) for(lint i=(a);i<(b);i++)
      |                                   ^
a.cc:46:9: note: in expansion of macro 'REP'
   46 |         REP(i,n-1){
      |         ^~~
a.cc:47:21: error: expected ';' before 'j'
   47 |                 FOR(j,i+1,n){
      |                     ^
a.cc:10:29: note: in definition of macro 'FOR'
   10 | #define FOR(i,a,b) for(lint i=(a);i<(b);i++)
      |                             ^
a.cc:47:21: error: 'j' was not declared in this scope
   47 |                 FOR(j,i+1,n){
      |                     ^
a.cc:10:35: note: in definition of macro 'FOR'
   10 | #define FOR(i,a,b) for(lint i=(a);i<(b);i++)
      |                                   ^