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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;

vector<ll> b;

int		main(void)
{
	ll n, m;
	cin >> n >> m;
	vector<ll>  a(n);
	for (ll i = 0; i < n; i++)
		cin >> a[i];
	b = new vector<ll>(pow(n, 2));
	ll k = 0;
	for (ll i = 0; i < n; i++)
	{
		for (ll j = 0; j < n; j++)
		{
			b[k] = a[i] + a[j];
			k++;
		}
	}
	sort(b.begin(), b.end(), greater<ll>());
	ll h = 0;
	for (ll i = 0; i < m; i++)
		h += b[i];
	cout << h << endl;
	return (0);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:37: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<long long int>*')
   18 |         b = new vector<ll>(pow(n, 2));
      |                                     ^
In file included from /usr/include/c++/14/vector:72,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'std::vector<long long int>*' to 'const std::vector<long long int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'std::vector<long long int>*' to 'std::vector<long long int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'std::vector<long long int>*' to 'std::initializer_list<long long int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
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 ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001001;
const int NMAX=8;
const int MOD=1000000007;
const int dbase=80*160;

int main()
{
	int n,m;
	cin>>n>>m;
	vector<int> a(n);
	rep(i,n)cin>>a[i];
	sort(a.begin(),a.end());
	int l=0;
	int r=m*2*100000;
	while (l+1<r){
		int c=(l+r)/2;
//	int c=30;
		//c以上の手になるひとの数
		int now=0;
		rep(i,n){
			int temp=c-a[i];
			int id=lower_bound(a.begin(),a.end(),temp)-a.begin();
		//	cout<<n-id<<'n'<<c<<'c'<<i<<'i'<<endl;
			now+=n-id;
		}
		if (now<m)r=c;
		else l=c;
	}
//	cout<<r<<endl;
	int ans=0;
	priority_queue<int>q;
	rep(i,n){
	//	if (cnt>=m)break;
	 int id=lower_bound(a.begin(),a.end(),temp)-a.begin();
		for(int i=id;i<n;i++){
			q.push(a[i]+a[j]);
		}
	}
	int cnt=0;
	while (cnt<m and !q.empty()){
		ans+=q.top();
		q.pop();
		cnt++;
	}

cout<<ans<<endl;


}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:47: error: 'temp' was not declared in this scope; did you mean 'tm'?
   40 |          int id=lower_bound(a.begin(),a.end(),temp)-a.begin();
      |                                               ^~~~
      |                                               tm
a.cc:42:39: error: 'j' was not declared in this scope
   42 |                         q.push(a[i]+a[j]);
      |                                       ^
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 ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001001;
const int NMAX=8;
const int MOD=1000000007;
const int dbase=80*160;

int main()
{
	int n,m;
	cin>>n>>m;
	vector<int> a(n);
	rep(i,n)cin>>a[i];
	sort(a.begin(),a.end());
	int l=0;
	int r=m*2*100000;
	while (l+1<r){
		int c=(l+r)/2;
//	int c=30;
		//c以上の手になるひとの数
		int now=0;
		rep(i,n){
			int temp=c-a[i];
			int id=lower_bound(a.begin(),a.end(),temp)-a.begin();
		//	cout<<n-id<<'n'<<c<<'c'<<i<<'i'<<endl;
			now+=n-id;
		}
		if (now<m)r=c;
		else l=c;
	}
//	cout<<r<<endl;
	int ans=0;
	priority_queue<int>q;
	rep(i,n)){
	//	if (cnt>=m)break;
	 int id=lower_bound(a.begin(),a.end(),temp)-a.begin();
		for(int i=id;i<n;i++){
			q.push(a[i]+a[j]);
		}
	}
	int cnt=0;
	while (cnt<m and !q.empty()){
		ans+=q.top();
		q.pop();
		cnt++;
	}

cout<<ans<<endl;


}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:17: error: expected primary-expression before ')' token
   38 |         rep(i,n)){
      |                 ^
Language: C++

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

int main () {
  int N;
  long long M;
  cin >> N >> M;
  
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a, a+N, greater<int>());
  
  int happiness = 0;
  
  for (int i = 0; i < M; i++) {
    if (i % 3 == 0) happiness += a[i/3] * 2;
    if (i % 3 == 1) happiness += a[i/3] + a[i/3 + 1];
    if (i % 3 == 2) happiness += a[i/3 + 1] * 2;
  }
 
  cout << happiness << endl;
}

Compiler output:
a.cc:1:10: fatal error: bits/stdc++: No such file or directory
    1 | #include <bits/stdc++>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

def main():
    import bisect

    n,k = map(int,input().split())
    l = list(map(int,input().split()))
    l.sort()
    def bise(x):
        count = 0

        for i in l:
            count += n-bisect.bisect_left(l,x-i)

        return count

    left = -1
    right = l[-1]*2+1

    while right > left+1:
        mid = (right+left)//2
        
        if bise(mid) > k:
            left = mid
        else:
            right = mid
    ans = []
    for i in l:
        for j in l:
            if i+j >= left:
                ans.append(i+j)
    ans.sort(reverse=True)
    
    print(sum(ans[0:k]))
if __name__ == "__main__":
    main()

Compiler output:
a.cc:1:1: error: 'def' does not name a type
    1 | def main():
      | ^~~
Language: Java


import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class E {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    int N;
    long M;
    int[] as;
    long[] ss;

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        N = sc.nextInt();
        M = sc.nextLong();
        as = new int[N];
        ss = new long[N + 1];
        for (int i = 0; i < N; i++) {
            as[i] = sc.nextInt();
        }
        Arrays.sort(as);
        for (int i = 0; i < N; i++) {
            ss[i + 1] = ss[i] + as[i];
        }

        out.println(ans());

        out.flush();
    }

    long ans() {
        int l = 0, r = 1000000;

        while (r - l > 1) {
            int X = (r + l) / 2;
            if (ok(X)) {
                l = X;
            } else {
                r = X;
            }
        }

        long sum = 0;
        long cnt = 0;
        for (int i = 0; i < N; i++) {
            int t = l - as[i];
            int x = lowerBound(as, t);
            sum += (N - x) * as[i] + ss[N] - ss[x];
            cnt += N - x;
        }
        return sum - (cnt - M) * l;
    }

    boolean ok(int X) {
        long sum = 0;
        for (int i = 0; i < N; i++) {
            int t = X - as[i];
            int x = lowerBound(as, t);
            sum += N - x;
        }
        return sum >= M;
    }

    public int upperBound(int[] array, int value) {
        int left = -1;
        int right = array.length;
        while (right - left > 1) {
            int middle = (right + left) / 2;
            if (array[middle] > value) {
                right = middle;
            } else {
                left = middle;
            }
        }
        return right;
    }

    public int lowerBound(int[] array, int value) {
        int left = -1;
        int right = array.length;
        while (right - left > 1) {
            int middle = (right + left) / 2;
            if (array[middle] >= value) {
                right = middle;
            } else {
                left = middle;
            }
        }
        return right;
    }


    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Compiler output:
Main.java:14: error: invalid method declaration; return type required
    public Main() {
           ^
Main.java:18: error: invalid method declaration; return type required
    public Main(InputStream in, OutputStream out) {
           ^
2 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
int N,M;
vi A;
int func(int X){
  int ret=0;
  rep(i,0,N){
    int P=dislow(A,X-A[i]);
    ret+=N-P;
  }
  return ret;
}
signed main(){
  cin>>N>>M;
  rep(i,0,N){
    int X; cin>>X;
    A.pb(X);
  }
  sort(ALL(A));
  A.pb(INF);
  int left=0,right=INF;
  while(left+1<right){
    int mid=(left+right)/2;
    if(func(mid)<=M) right=mid;
    else left=mid;
  }
  vi dp(N+1);
  REP(i,1,N) dp[N-i]=dp[N-i+1]+A[N-i];
  int ans=0;
  if(func(left)==M){
    int X=left;
    rep(i,0,N){
      int Q=dislow(A,X-A[i]);
      ans+=dp[Q]+(N-Q)*A[i];
    }
  }
  else if(func(right)==M){
    int X=right;
    rep(i,0,N){
      int Q=dislow(A,X-A[i]);
      ans+=dp[Q]+(N-Q)*A[i];
    }
  }
  else if(func(left)>M){
    int X=left;
    int memo=INF;
    rep(i,0,N){
      int Q=dislow(A,X-A[i]);
      ans+=dp[Q]+(N-Q)*A[i];
      memo=min(memo,A[Q]+A[i]);
    }
    ans-=memo;
  }
  else{
    X=right;
    int memo=INF;
    rep(i,0,N){
      int Q=dislow(A,X-A[i]);
      ans+=dp[Q]+(N-Q)*A[i];
      memo=min(memo,A[Q]+A[i]);
    }
    ans-=memo;
  }
  cout<<ans<<endl;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:71:5: error: 'X' was not declared in this scope
   71 |     X=right;
      |     ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
int N,M;
vi A;
int func(X){
  int ret=0;
  rep(i,0,N){
    int P=dislow(A,X-A[i]);
    ret+=N-P;
  }
  return ret;
}
signed main(){
  cin>>N>>M;
  rep(i,0,N){
    int X; cin>>X;
    A.pb(X);
  }
  sort(ALL(A));
  A.pb(INF);
  int left=0,right=INF;
  while(left+1<right){
    int mid=(left+right)/2;
    if(func(mid)<=M) right=mid;
    else left=mid;
  }
  vi dp(N+1);
  REP(i,1,N) dp[N-i]=dp[N-i+1]+A[N-i];
  int ans=0;
  if(func(left)==M){
    int X=left;
    rep(i,0,N){
      int Q=dislow(A,X-A[i]);
      ans+=dp[Q];
    }
  }
  else{
    int X=right;
    rep(i,0,N){
      int Q=dislow(A,X-A[i]);
      ans+=dp[Q];
    }
  }
  cout<<ans<<endl;
  }


Compiler output:
a.cc:21:10: error: 'X' was not declared in this scope
   21 | int func(X){
      |          ^
a.cc: In function 'int main()':
a.cc:40:12: error: 'func' cannot be used as a function
   40 |     if(func(mid)<=M) right=mid;
      |        ~~~~^~~~~
a.cc:46:10: error: 'func' cannot be used as a function
   46 |   if(func(left)==M){
      |      ~~~~^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
int N,M;
vi A;
int func(X){
  int ret=0;
  rep(i,0,N){
    int P=dislow(A,X-A[i]);
    ret+=N-P;
  }
  return ret;
}
signed main(){
  cin>>N>>M;
  rep(i,0,N){
    int X; cin>>X;
    A.pb(X);
  }
  sort(ALL(A));
  A.pb(INF);
  int left=0,right=INF;
  while(left+1<right){
    int mid=(left+right)/2;
    if(func(mid)<=M) right=mid;
    else left=mid;
  }
  vi dp(N+1);
  REP(i,1,N) dp[N-i]=dp[N-i+1]+A[N-i];
  int ans=0;
  if(func(left)==M){
    int X=left;
    rep(i,0,N){
   　　 int P=dislow(A,X-A[i]);
    　　ans+=dp[P];
    }
  }
  else{
    int X=right;
    rep(i,0,N){
   　　 int P=dislow(A,X-A[i]);
    　　ans+=dp[P];
    }
  }
  }


Compiler output:
a.cc:49:4: error: extended character 　 is not valid in an identifier
   49 |    　　 int P=dislow(A,X-A[i]);
      |    ^
a.cc:49:4: error: extended character 　 is not valid in an identifier
a.cc:50:5: error: extended character 　 is not valid in an identifier
   50 |     　　ans+=dp[P];
      |     ^
a.cc:50:5: error: extended character 　 is not valid in an identifier
a.cc:56:4: error: extended character 　 is not valid in an identifier
   56 |    　　 int P=dislow(A,X-A[i]);
      |    ^
a.cc:56:4: error: extended character 　 is not valid in an identifier
a.cc:57:5: error: extended character 　 is not valid in an identifier
   57 |     　　ans+=dp[P];
      |     ^
a.cc:57:5: error: extended character 　 is not valid in an identifier
a.cc:21:10: error: 'X' was not declared in this scope
   21 | int func(X){
      |          ^
a.cc: In function 'int main()':
a.cc:40:12: error: 'func' cannot be used as a function
   40 |     if(func(mid)<=M) right=mid;
      |        ~~~~^~~~~
a.cc:46:10: error: 'func' cannot be used as a function
   46 |   if(func(left)==M){
      |      ~~~~^~~~~~
a.cc:49:4: error: '\U00003000\U00003000' was not declared in this scope
   49 |    　　 int P=dislow(A,X-A[i]);
      |    ^~~~
a.cc:50:5: error: '\U00003000\U00003000ans' was not declared in this scope
   50 |     　　ans+=dp[P];
      |     ^~~~~~~
a.cc:50:17: error: 'P' was not declared in this scope
   50 |     　　ans+=dp[P];
      |                 ^
a.cc:56:4: error: '\U00003000\U00003000' was not declared in this scope
   56 |    　　 int P=dislow(A,X-A[i]);
      |    ^~~~
a.cc:57:5: error: '\U00003000\U00003000ans' was not declared in this scope
   57 |     　　ans+=dp[P];
      |     ^~~~~~~
a.cc:57:17: error: 'P' was not declared in this scope
   57 |     　　ans+=dp[P];
      |                 ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
int N,M;
vi A;
int func(X){
  int ret=0;
  rep(i,0,N){
    int P=dislow(A,X-A[i]);
    ret+=N-P;
  }
  return ret;
}
signed main(){
  cin>>N>>M;
  rep(i,0,N){
    int X; cin>>X;
    A.pb(X);
  }
  sort(ALL(A));
  A.pb(INF);
  int left=0,right=INF;
  while(left+1<right){
    int mid=(left+right)/2;
    if(func(mid)<=M) right=mid;
    else left=mid;
  }
  vi dp(N+1);
  REP(i,1,N) dp[N-i]=dp[N-i+1]+A[N-i];
  int ans=0;
  if(func(left)==M){
    int X=left;
    rep(i,0,N){
   　　 int P=dislow(A,X-A[i]);
    　　ans+=dp[P];
    }
  }
  else{
    rep(i,0,N){
   　　 int P=dislow(A,X-A[i]);
    　　ans+=dp[P];
    }
  }
  }


Compiler output:
a.cc:49:4: error: extended character 　 is not valid in an identifier
   49 |    　　 int P=dislow(A,X-A[i]);
      |    ^
a.cc:49:4: error: extended character 　 is not valid in an identifier
a.cc:50:5: error: extended character 　 is not valid in an identifier
   50 |     　　ans+=dp[P];
      |     ^
a.cc:50:5: error: extended character 　 is not valid in an identifier
a.cc:55:4: error: extended character 　 is not valid in an identifier
   55 |    　　 int P=dislow(A,X-A[i]);
      |    ^
a.cc:55:4: error: extended character 　 is not valid in an identifier
a.cc:56:5: error: extended character 　 is not valid in an identifier
   56 |     　　ans+=dp[P];
      |     ^
a.cc:56:5: error: extended character 　 is not valid in an identifier
a.cc:21:10: error: 'X' was not declared in this scope
   21 | int func(X){
      |          ^
a.cc: In function 'int main()':
a.cc:40:12: error: 'func' cannot be used as a function
   40 |     if(func(mid)<=M) right=mid;
      |        ~~~~^~~~~
a.cc:46:10: error: 'func' cannot be used as a function
   46 |   if(func(left)==M){
      |      ~~~~^~~~~~
a.cc:49:4: error: '\U00003000\U00003000' was not declared in this scope
   49 |    　　 int P=dislow(A,X-A[i]);
      |    ^~~~
a.cc:50:5: error: '\U00003000\U00003000ans' was not declared in this scope
   50 |     　　ans+=dp[P];
      |     ^~~~~~~
a.cc:50:17: error: 'P' was not declared in this scope
   50 |     　　ans+=dp[P];
      |                 ^
a.cc:55:4: error: '\U00003000\U00003000' was not declared in this scope
   55 |    　　 int P=dislow(A,X-A[i]);
      |    ^~~~
a.cc:56:5: error: '\U00003000\U00003000ans' was not declared in this scope
   56 |     　　ans+=dp[P];
      |     ^~~~~~~
a.cc:56:17: error: 'P' was not declared in this scope
   56 |     　　ans+=dp[P];
      |                 ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
int N,M;
vi A;
int func(X){
  int ret=0;
  rep(i,0,N){
    int P=dislow(A,X-A[i]);
    ret+=N-P;
  }
}
signed main(){
  cin>>N>>M;
  rep(i,0,N){
    int X; cin>>X;
    A.pb(X);
  }
  sort(ALL(A));
  A.pb(INF);
  int left=0,right=INF;
  while(left+1<right){
    int mid=(left+right)/2;
    if(func(mid)<=M) right=mid;
    else left=mid;
  }
  vi dp(N+1);
  REP(i,1,N) dp[N-i]=dp[N-i+1]+A[N-i];
  int ans=0;
  if(func(left)==M){
    int X=left;
    rep(i,0,N){
   　　 int P=dislow(A,X-A[i]);
    　　ans+=dp[P];
    }
  }
  else{
    rep(i,0,N){
   　　 int P=dislow(A,X-A[i]);
    　　ans+=dp[P];
    }
  }
  }


Compiler output:
a.cc:48:4: error: extended character 　 is not valid in an identifier
   48 |    　　 int P=dislow(A,X-A[i]);
      |    ^
a.cc:48:4: error: extended character 　 is not valid in an identifier
a.cc:49:5: error: extended character 　 is not valid in an identifier
   49 |     　　ans+=dp[P];
      |     ^
a.cc:49:5: error: extended character 　 is not valid in an identifier
a.cc:54:4: error: extended character 　 is not valid in an identifier
   54 |    　　 int P=dislow(A,X-A[i]);
      |    ^
a.cc:54:4: error: extended character 　 is not valid in an identifier
a.cc:55:5: error: extended character 　 is not valid in an identifier
   55 |     　　ans+=dp[P];
      |     ^
a.cc:55:5: error: extended character 　 is not valid in an identifier
a.cc:21:10: error: 'X' was not declared in this scope
   21 | int func(X){
      |          ^
a.cc: In function 'int main()':
a.cc:39:12: error: 'func' cannot be used as a function
   39 |     if(func(mid)<=M) right=mid;
      |        ~~~~^~~~~
a.cc:45:10: error: 'func' cannot be used as a function
   45 |   if(func(left)==M){
      |      ~~~~^~~~~~
a.cc:48:4: error: '\U00003000\U00003000' was not declared in this scope
   48 |    　　 int P=dislow(A,X-A[i]);
      |    ^~~~
a.cc:49:5: error: '\U00003000\U00003000ans' was not declared in this scope
   49 |     　　ans+=dp[P];
      |     ^~~~~~~
a.cc:49:17: error: 'P' was not declared in this scope
   49 |     　　ans+=dp[P];
      |                 ^
a.cc:54:4: error: '\U00003000\U00003000' was not declared in this scope
   54 |    　　 int P=dislow(A,X-A[i]);
      |    ^~~~
a.cc:55:5: error: '\U00003000\U00003000ans' was not declared in this scope
   55 |     　　ans+=dp[P];
      |     ^~~~~~~
a.cc:55:17: error: 'P' was not declared in this scope
   55 |     　　ans+=dp[P];
      |                 ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
int N,M,A[100001];
int func(X){
  int ret=0;
  rep(i,0,N){
    int P=distance(A,lower_bound(A,A+N+1,X-A[i]));
    ret+=N-P;
  }
}
signed main(){
  cin>>N>>M;
  rep(i,0,N) cin>>A[i];
  sort(A,A+N);
  A[N]=INF;
  int left=0,right=INF;
  while(left+1<right){
    int mid=(left+right)/2;
    if(func(mid)<=M) right=mid;
    else left=mid;
  }
  vi dp(N+1);
  REP(i,1,N) dp[N-i]=dp[N-i+1]+A[N-i];
  int ans=0;
  if(func(left)==M){
    int X=left;
    rep(i,0,N){
   　　 int P=distance(A,lower_bound(A,A+N+1,X-A[i]));
    　　ans+=dp[P];
    }
  }
  else{
    rep(i,0,N){
   　　 int P=distance(A,lower_bound(A,A+N+1,X-A[i]));
    　　ans+=dp[P];
    }
  }
  }


Compiler output:
a.cc:44:4: error: extended character 　 is not valid in an identifier
   44 |    　　 int P=distance(A,lower_bound(A,A+N+1,X-A[i]));
      |    ^
a.cc:44:4: error: extended character 　 is not valid in an identifier
a.cc:45:5: error: extended character 　 is not valid in an identifier
   45 |     　　ans+=dp[P];
      |     ^
a.cc:45:5: error: extended character 　 is not valid in an identifier
a.cc:50:4: error: extended character 　 is not valid in an identifier
   50 |    　　 int P=distance(A,lower_bound(A,A+N+1,X-A[i]));
      |    ^
a.cc:50:4: error: extended character 　 is not valid in an identifier
a.cc:51:5: error: extended character 　 is not valid in an identifier
   51 |     　　ans+=dp[P];
      |     ^
a.cc:51:5: error: extended character 　 is not valid in an identifier
a.cc:20:10: error: 'X' was not declared in this scope
   20 | int func(X){
      |          ^
a.cc: In function 'int main()':
a.cc:35:12: error: 'func' cannot be used as a function
   35 |     if(func(mid)<=M) right=mid;
      |        ~~~~^~~~~
a.cc:41:10: error: 'func' cannot be used as a function
   41 |   if(func(left)==M){
      |      ~~~~^~~~~~
a.cc:44:4: error: '\U00003000\U00003000' was not declared in this scope
   44 |    　　 int P=distance(A,lower_bound(A,A+N+1,X-A[i]));
      |    ^~~~
a.cc:45:5: error: '\U00003000\U00003000ans' was not declared in this scope
   45 |     　　ans+=dp[P];
      |     ^~~~~~~
a.cc:45:17: error: 'P' was not declared in this scope
   45 |     　　ans+=dp[P];
      |                 ^
a.cc:50:4: error: '\U00003000\U00003000' was not declared in this scope
   50 |    　　 int P=distance(A,lower_bound(A,A+N+1,X-A[i]));
      |    ^~~~
a.cc:51:5: error: '\U00003000\U00003000ans' was not declared in this scope
   51 |     　　ans+=dp[P];
      |     ^~~~~~~
a.cc:51:17: error: 'P' was not declared in this scope
   51 |     　　ans+=dp[P];
      |                 ^
Language: C++

/*
首先二分单次操作中所获得的最小幸福值，记作𝑚𝑖𝑑 ，然后计算，以此值作为幸福值的边界，
可以握多少次手，如果握手次数大于𝑀则扩大这个𝑚𝑖𝑑 ，否则缩小。
对于每次二分得到的𝑚𝑖𝑑 ，针对每一个𝑎[𝑖]计算另一个值𝑚𝑖𝑑−𝑎[𝑖]的下标𝑝𝑜𝑠。
所以目前就获得了 𝑛−𝑝𝑜𝑠+1 对握手，然后把这些握手得到的幸福值加到𝑟𝑒𝑠 中
𝑠𝑢𝑚 是前缀和数组，𝑠𝑢𝑚[𝑛]−𝑠𝑢𝑚[𝑝𝑜𝑠−1] 得到 𝑛−𝑝𝑜𝑠 这些值的和再加上𝑛−𝑝𝑜𝑠+1个𝑎[𝑖]
因为𝑐𝑛𝑡 最后不一定刚等于𝑚 ，𝑐𝑛𝑡 只是第一次二分的𝑐ℎ𝑒𝑐𝑘 函数 ，有可能大于 𝑚
所以最后在减去多余的即可
*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
const int N = 1e5 + 10;
#define endl '\n'
typedef long long LL;
LL sum[N],a[N],m,n;
int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin >> n >> m;
    for(int i = 1;i <= n; ++i) cin >> a[i];
    sort(a+1,a+1+n);
    for(int i = 1;i <= n; ++i) sum[i] = sum[i - 1] + a[i];
    LL l = 0,r = 2*N,ans,res,cnt;
    while(l < r) {
        LL mid = l + r + 1 >> 1;
        res = cnt = 0;
        for(int i = 1;i <= n; ++i) {
            LL pos = lower_bound(a+1,a+1+n,mid-a[i]) - a;
            cnt += n - pos + 1;
            res += sum[n] - sum[pos - 1] + a[i] * (n - pos + 1);
        }
        if(cnt >= m) l = mid;
        else r = mid - 1;
    }
    cout << res - (cnt - m) * l << endl;
}}

Compiler output:
a.cc:38:2: error: expected declaration before '}' token
   38 | }}
      |  ^
Language: C++

#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <unordered_set>
using namespace std;

int Count(int d, int A[], int N){
    int p, q, ans;
    p = 0; q = N-1; ans = 0;
    while(p <= q){
        if(A[p]+A[q] < d){
            p++;
        }else{
            ans += 2*(q-p)+1;
            q--;
        }
    }
    return ans;
}
long Sum(int d, int A[], int N){
    int S[N+1];
    S[0] = 0;
    for(int i = 1; i <= N; i++){
        S[i] = S[i-1] + A[i-1];
    }
    int p, q;
    long sum;
    p = 0; q = N-1;
    sum = 0;
    while(p <= q){
        if(A[p]+A[q] < d){
            p++;
        }else{
            sum += 2*(S[q]-S[p]+(q-p)*A[q])+2*A[q];
            q--;
        }
    }
    return sum;
}
int bs(int M, int A[], int N){
    int bottom = 0;
    int top = 2*A[N-1];
    int mid;
    int m;
    while(bottom < top){
        mid = (bottom+top+1)/2;
        m = Count(mid, A, N);
        if(m >= M){
            bottom = mid;
        }else {
            top = mid - 1;
        }
    }
    return top;
}

int main(void){
    int N, M, d;
    cin >> N >> M;
    int A[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    sort(A, A+N);
    if(M%2 != 0){
        d = bs(M, A, N);
        cout << Sum(d, A, N) << endl;
    }else{
        d = bs(M+1, A, N);
        cout << Sum(d, A, N)-d << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:68:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   68 |     sort(A, A+N);
      |     ^~~~
      |     sqrt
Language: C++


// E - Handshake

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int MOD = 1e9 + 7;

const int MAX = 100000;

ll A[MAX];
ll A_csum[MAX]; // 値が大きい側からの累積和
ll N, M;

// t <= Ax + Ay となる組み合わせの数を求める
// Ax = A[i]ごとに二分探索で数を求めて合計する -> O(NlogN)
ll get_n_comb(ll t) {
	ll result = 0;
	for (int i=0; i<N; i++) {
		ll Ay = t - A[i];
		ll idx = lower_bound(A, A+N, Ay) - A; // t <= Ax + Ay となる最初のインデックス
		result += (N - idx);
	}

	//cout << "t=" << t << " -> comb=" << result << endl;

	return result;
}

// t <= Ax + Ay となる組み合わせの数がk以上となる最大のtを求める
ll get_max_t(ll k) {
	ll lower = 0;
	ll upper = MAX + 1;
	while(lower + 1 < upper) {
		ll mid = (lower + upper) / 2;

		if (get_n_comb(mid) >= k) {
			lower = mid;
		} else {
			upper = mid;
		}
	}

	return lower;
}

// t <= Ax + Ay となる組み合わせについて総和を求める
ll get_sum_ge(ll t) {
	ll result = 0;
	for (int i=0; i<N; i++) {
		ll Ay = t - A[i];
		ll idx = lower_bound(A, A+N, Ay) - A; // t <= Ax + Ay となる最初のインデックス
		result += (A[i] * (N - idx)) + A_csum[idx]; // Axの和 + Ayの和
	}

	//cout << "t=" << t << " sum=" << result << endl; // **** debug ****

	return result;
}

int main() {

	cin >> N >> M;

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

	sort(A, A+N);

	// 値が大きい側からの累積和を作成（get_sum_ge()で用いる）
	A_csum[N-1] = A[N-1];
	for (int i=N-2; i>=0; i--) {
		A_csum[i] = A[i] + A_csum[i+1];
	}

	// t <= Ax + Ay となる組み合わせの数がM以上となる最大のtを求める
	ll max_t = get_max_t(M);
	//cout << "max_t = " << max_t << endl; // **** debug ****

	// get_sum_ge(t)では t == Ax + Ay となる握手が複数存在する場合に余分な握手が含まれてしまうので
	// （(t == max_t) の和） + （(t >= max_t + 1) の和）で求める
	//ll n_max_t = M - get_n_comb(max_t + 1); // t == max_t となる場合の数
	//ll ans = (max_t * n_max_t) + get_sum_ge(max_t + 1);
	ll ans = (M - get_combination(max_t + 1)) * max_t + get_sum(max_t + 1);

	cout << ans << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:85:23: error: 'get_combination' was not declared in this scope
   85 |         ll ans = (M - get_combination(max_t + 1)) * max_t + get_sum(max_t + 1);
      |                       ^~~~~~~~~~~~~~~
a.cc:85:61: error: 'get_sum' was not declared in this scope
   85 |         ll ans = (M - get_combination(max_t + 1)) * max_t + get_sum(max_t + 1);
      |                                                             ^~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <complex>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

const double M_PI = 3.141592653589793;
vector<complex<double>> fft(vector<complex<double>> a, bool inverse = false) {
    int n = a.size();
    int h = 0; // h = log_2(n)
    for (int i = 0; 1 << i < n; i++) h++;

    for (int i = 0; i < n; i++) {
        int j = 0;
        for (int k = 0; k < h; k++) j |= (i >> k & 1) << (h - 1 - k);
        if (i < j) swap(a[i], a[j]);
    }

    for (int b = 1; b < n; b *= 2) {
        for (int j = 0; j < b; j++) {
            complex<double> w =
                polar(1.0, (2 * M_PI) / (2 * b) * j * (inverse ? 1 : -1));
            for (int k = 0; k < n; k += b * 2) {
                complex<double> s = a[j + k];         
                complex<double> t = a[j + k + b] * w;
                a[j + k] = s + t;                   
                a[j + k + b] = s - t;            
            }
        }
    }
    if (inverse)
        for (int i = 0; i < n; i++) a[i] /= n;
    return a;
}

vector<complex<double>> fft(vector<double> a, bool inverse = false) {
    vector<complex<double>> a_complex(a.size());
    for (int i = 0; i < a.size(); i++) a_complex[i] = complex<double>(a[i], 0);
    return fft(a_complex, inverse);
}

vector<double> convolve(vector<double> a, vector<double> b) {
    int s = a.size() + b.size() - 1;
    int t = 1; 
    while (t < s) t *= 2;
    a.resize(t); 
    b.resize(t);
    vector<complex<double>> A = fft(a);
    vector<complex<double>> B = fft(b);
    for (int i = 0; i < t; i++) {
        A[i] *= B[i]; 
    }
    A = fft(A, true); 
    a.resize(s);     
    for (int i = 0; i < s; i++) a[i] = A[i].real(); 
    return a;
}

int main(){
    int N,M;
    cin >> N >> M;
    vector<double> a(1e5+1,0),b(1e5+1,0);
    a[0] = b[0] = 0;
    rep(i,N){
        int tmp;
        cin >> tmp;
        a[tmp] += 1.0;
    }

    rep(i,1e5+1){ 
        b[i] = a[i];
    }

    vector<double> ans = convolve(a,b);    
    ll Ans = 0;
    
    for(int j = ans.size(); j > 0; j--){
        int cnt = (int)(ans[j]+0.5);
        Ans += j * min(cnt, M);
        M -= cnt;
        if(M <= 0) break;
    }

    cout << Ans << endl;

    return 0;
} 

Compiler output:
In file included from /usr/include/c++/14/cmath:47,
                 from a.cc:5:
a.cc:14:14: error: expected unqualified-id before numeric constant
   14 | const double M_PI = 3.141592653589793;
      |              ^~~~
Language: C++

#include <iostream>
using namespace std;
typedef long long ll;
ll N, M;
ll happiness[100005];
ll psa[100005];

ll numberGreater(ll m){
    ll l = 0, r = N-1;
    ll ans = 0;
    while (l <= r){
        if (happiness[l] + happiness[r] >= m) {
            ans += 2*(r-l)+1;
            r--;
        }
        else l++;
    }
    return ans;
}

int main() {
    cin >> N >> M;
    for (int i=0; i<N; i++) scanf("%lld", &happiness[i]);
    sort(happiness, happiness+N);
//    for (int i=0; i<N; i++) cout << happiness[i] << " ";
//    cout << endl;
    for (int i=1; i<=N; i++) psa[i] = psa[i-1]+happiness[i-1];
    ll l = 0, r = 100001, m;
    while (l < r){
        m = (l+r)/2;
        if (numberGreater(m) < M) r = m;
        else l = m+1;
    }
    ll x = r-1;
    l = 0, r = N-1;
    ll ans = 0;

    while (l <= r){
        if (happiness[l] + happiness[r] >= x) {
            ans += (2*(r-l)+2)*happiness[r] + 2*(psa[r]-psa[l]);
            r--;
        }
        else l++;
    }
    if (numberGreater(x) > M) ans -= x*(numberGreater(x)-M);
    cout << ans << endl;
    return 0;
}


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

#include <iostream>
#include <vector>

using namespace std;

long binary_search(long lower, long upper, bool (* f)(long, long, long*, long), long N, long * A, long M){ 
    long middle;
    while(upper - lower > 1){
        middle = (lower + upper) / 2;
        if(f(middle, N, A, M)){
            lower = middle;
        }
        else{
            upper = middle;
        }
    }
    return lower;
}

long count_pair_over_m(long X, long N, long * A){  //A is in ascend order
    long sum = 0;
    long j = 0;
    long temp = 0;
    for(int i =0; i<N; i++){
        while(A[i] + A[N-1-j] >= X && j < N){
            j++;
        }
        sum += j;
    }
    return sum;
}

bool f(long X, long N, long * A, long M){
    if(count_pair_over_m(X, N, A) >= M) return true;
    else return false;
}

long sum(long X, long N, long * A, long M){  //A is in ascend order
    long ans = 0;
    long sum = 0;
    long j = 0;
    long temp = 0;
    int cnt = 0;
    for(int i =0; i<N; i++){
        while(A[i] + A[N-1-j] >= X && j < N && cnt < M){
            sum += A[N-1-j];
            j++;
        }
        cnt += j;
        ans += sum + A[i] * j;
    }
    if(cnt > M) {
        ans -= X * (cnt-M);
    }
    return ans;
}

int main(){
    long N, M;
    cin >> N >> M;
    long A[N];
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    sort(A, A + N);  // a is in ascend order
    long min_happy = binary_search(-1, 2000001, f, N, A, M);
    long ans = sum(min_happy, N, A, M);
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:65:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   65 |     sort(A, A + N);  // a is in ascend order
      |     ^~~~
      |     short
Language: C++

\//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  ll N,M;
  cin >> N >> M;
  vector<ll> a(N);
  rep(i,N) cin >> a[i];
  sort(all(a));
  vector<ll> s(N+1);
  s[0]=0;
  rep(i,N+1) s[i+1]=s[i]+a[i];
  ll l=0,r=2e5+1;
  ll cnt;
  while(r-l!=1){
    ll mid=(l+r)/2;
    bool flag=false;
    cnt=0;
    for(int i=0;i<N;i++){
      ll j=lower_bound(all(a),mid-a[i])-a.begin();
      cnt+=N-j;
    }
    if(cnt>=M) flag=1;
    if(flag) l=mid;
    else r=mid;
  }
  int x=l;
  ll ans=0;
  cnt=0;
  rep(i,N){
    ll j=lower_bound(all(a),x-a[i])-a.begin();
    ans+=a[i]*(N-j)+s[N]-s[j];
    cnt+=N-j;
  }
  ans-=(cnt-M)*x;
  cout << ans << endl;
}

Compiler output:
a.cc:1:1: error: stray '\' in program
    1 | \//#define _GLIBCXX_DEBUG
      | ^
Language: C++

#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;
ll n,suff[200100],cnt[200100],suffval[200100],a[2س00100];

int main()
{
    ll m;
    cin >> n >> m;
    for(ll i = 0; i<n; i++)  cin >> a[i],cnt[a[i]]++;
    sort(a, a + n);
    for(ll i = 1e5; i>=0; i--)  suff[i] = cnt[i] + suff[i + 1];
    for(ll i = 1e5; i>=0; i--)  suffval[i] = suffval[i + 1] + (cnt[i] * i);
    ll Start = 0, End = 2e5 , canSum = 0;
    while(Start <= End){
        ll mid = (Start + End)/2;
        ll needSum = mid + 1;
        ll Res = 0;
        for(ll i = 0;i<n;i++){
          Res+=(suff[max((ll)0 , needSum - a[i])] - (needSum - a[i] <= a[i] ? cnt[a[i]] : 0));
          if(needSum - a[i] <= a[i])  Res+=cnt[a[i]];
        }
        if(Res <= m)  canSum = mid , End = mid - 1;
        else  Start = mid + 1;
    }
    ll Ans = 0;
    canSum++;
    for(ll i = 0;i<n;i++){
        Ans+=suffval[max((ll)0 , canSum - a[i])];
        ll Ways = 0;
        Ways+=(suff[max((ll)0 , canSum - a[i])] - (canSum - a[i] <= a[i] ? cnt[a[i]] : 0));
        if(canSum - a[i] <= a[i])  Ways+=cnt[a[i]];
        m-=Ways;
        Ans+=a[i] * Ways;
    }
    cout << Ans + m * (canSum - 1);
    return 0;
}


Compiler output:
a.cc:6:49: error: unable to find numeric literal operator 'operator""\U0000063300100'
    6 | ll n,suff[200100],cnt[200100],suffval[200100],a[2س00100];
      |                                                 ^~~~~~~
a.cc: In function 'int main()':
a.cc:12:37: error: 'a' was not declared in this scope
   12 |     for(ll i = 0; i<n; i++)  cin >> a[i],cnt[a[i]]++;
      |                                     ^
a.cc:13:10: error: 'a' was not declared in this scope
   13 |     sort(a, a + n);
      |          ^
Language: C++

using namespace std;
typedef long long ll;
ll MOD=1000000007;


int main (){   
    int N;
  	ll M;
 	cin >> N >> M;
    vector<ll> A(N);
    for (auto& x : A) cin >> x;
    sort(A.begin(), A.end());
    ll pass = 0, fail = 2 * 1e5 + 10;
    while (fail - pass > 1) {
      ll X = (pass + fail) / 2;
      ll cnt = 0;
      int j = N - 1;
      for (int i = 0; i < N; i++) {
        while (j >= 0 && A[i] + A[j] >= X) --j;
        cnt += N - j - 1;
      }
      if (cnt >= M) {
        pass = X;
      } else {
        fail = X;
      }
    }
    ll res = 0;
    ll sum = 0, rem = M;
  int j = N - 1;
    for (int i = 0; i < N; i++) {
      
      while (j >= 0 && A[i] + A[j] > pass) {
        sum += A[j];
        --j;
      }
      ll c = N - j - 1;
      rem -= c;
      res += sum + c * A[i];
    }
    res += pass * rem;
    cout << res << endl;
  
 
}





Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'cin' was not declared in this scope
    9 |         cin >> N >> M;
      |         ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:10:5: error: 'vector' was not declared in this scope
   10 |     vector<ll> A(N);
      |     ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | using namespace std;
a.cc:10:14: error: expected primary-expression before '>' token
   10 |     vector<ll> A(N);
      |              ^
a.cc:10:16: error: 'A' was not declared in this scope
   10 |     vector<ll> A(N);
      |                ^
a.cc:12:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   12 |     sort(A.begin(), A.end());
      |     ^~~~
      |     short
a.cc:42:5: error: 'cout' was not declared in this scope
   42 |     cout << res << endl;
      |     ^~~~
a.cc:42:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:42:20: error: 'endl' was not declared in this scope
   42 |     cout << res << endl;
      |                    ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
ll arr[maxn], prefix[maxn];
ll check(int val, int n) {
    ll cnt = 0;
    for (int i = 1; i <= n; ++i) {
        int pos = lower_bound(arr + 1, arr + 1 + n, val - arr[i]) - arr;
        cnt += n + 1 - pos;
    }
    return cnt;
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n; ll m; cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> arr[i];
    sort(arr + 1, arr + 1 + n);
    for (int i = 1; i <= n; ++i) prefix[i] = prefix[i - 1] + arr[i];
    int left = 0, right = 2 * maxn; res = 0;
    while (left <= right) {
        ll mid = (left + right) / 2; ll cnt;
        if ((cnt = check(mid, n)) < m)
            right = mid - 1;
        else {
            left = mid + 1, res = 0;
            for (int i = 1; i <= n; ++i) {
                int pos = lower_bound(arr + 1, arr + 1 + n, mid - arr[i]) - arr;
                res += (ll)(n + 1 - pos) * arr[i] + prefix[n] - prefix[pos - 1];
            }
            if (cnt > m) res -= (cnt - m) * mid;
        }
    }
    cout << res << '\n';
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:37: error: 'res' was not declared in this scope
   20 |     int left = 0, right = 2 * maxn; res = 0;
      |                                     ^~~
Language: C++

#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

#include <cassert>
#include <complex>
#include <vector>
namespace fft {

using Real = long double;
using Complex = std::complex<Real>;
using VecC = std::vector<Complex>;
const Real PI = 3.1415926535897932384626433832795028841971;
void FFT(VecC &a, bool inv = false) {
  int n = a.size();
  int h = 0;
  while ((1 << h) < n)
    h++;
  assert((1 << h) == n);
  // ビットリバース順に
  for (int i = 0; i < n; i++) {
    int j = 0;
    for (int k = 0; k < h; k++) {
      j |= (i >> k & 1) << (h - 1 - k);
    }
    if (i < j) {
      swap(a[i], a[j]);
    }
  }
  // バタフライ演算
  for (int b = 1; b < n; b <<= 1) {
    for (int j = 0; j < b; j++) {
      Complex w = std::polar(1.0, (2 * PI) / (2 * b) * j * (inv ? -1 : 1));
      for (int k = 0; k < n; k += b * 2) {
        Complex s = a[j + k];
        Complex t = a[j + k + b] * w;
        a[j + k] = s + t;
        a[j + k + b] = s - t;
      }
    }
  }
  if (inv) {
    for (int i = 0; i < n; i++) {
      a[i] /= n;
    }
  }
}

VecC Conv(VecC a, VecC b) {
  int m = a.size() + b.size() - 1;
  int sz = 1;
  while (m > sz)
    sz <<= 1;
  a.resize(sz);
  b.resize(sz);
  FFT(a);
  FFT(b);
  for (int i = 0; i < sz; i++) {
    a[i] *= b[i];
  }
  FFT(a, true);
  a.resize(m);
  return a;
}

std::vector<int> Conv(std::vector<int> &a, std::vector<int> &b) {
  VecC ac(a.size()), bc(b.size());
  for (int i = 0; i < a.size(); i++)
    ac[i] = Complex(a[i], 0);
  for (int i = 0; i < b.size(); i++)
    bc[i] = Complex(b[i], 0);
  auto c = Conv(ac, bc);
  std::vector<int> res(c.size());
  for (int i = 0; i < c.size(); i++) {
    res[i] = (int)(c[i].real() + 0.1);
  }
  return res;
}
} // namespace fft
using ll = long long;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(1e5 + 1, 0);
  for (int i = 0; i < n; i++) {
    int ai;
    cin >> ai;
    a[ai]++;
  }
  auto c = fft::Conv(a, a);
  ll ans = 0;
  for (int i = c.size() - 1; i >= 0; i--) {
    if (m >= c[i]) {
      ans += c[i] * i;
      m -= c[i];
    } else {
      ans += m * i;
      break;
    }
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'void fft::FFT(VecC&, bool)':
a.cc:34:29: error: no matching function for call to 'polar(double, fft::Real)'
   34 |       Complex w = std::polar(1.0, (2 * PI) / (2 * b) * j * (inv ? -1 : 1));
      |                   ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from a.cc:7:
/usr/include/c++/14/complex:967:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::polar(const _Tp&, const _Tp&)'
  967 |     polar(const _Tp& __rho, const _Tp& __theta)
      |     ^~~~~
/usr/include/c++/14/complex:967:5: note:   template argument deduction/substitution failed:
a.cc:34:29: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'fft::Real' {aka 'long double'})
   34 |       Complex w = std::polar(1.0, (2 * PI) / (2 * b) * j * (inv ? -1 : 1));
      |                   ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <set>
#include <iostream>
#include <queue>
using namespace std;

struct Node {
    int val;
    int x;
    int y;
    bool operator < (const Node& nd) const {
        return val < nd.val;
    }
};

int main() {
    int N = 0, M = 0;
    cin >> N >> M;
    vector<int> A;
    int val = 0;
    for (int i = 0; i < N; ++i) {
        cin >> val;
        A.push_back(val);
    }
    sort(A.rbegin(), A.rend());
    vector<vector<bool>> vis(N, vector<bool>(N));
    priority_queue<Node> pq;
    pq.push(Node({A[0] + A[0], 0, 0}));
    vis[0][0] = 1;
    long ans = 0;
    while (M--) {
        auto pr = pq.top();
        pq.pop();
        int x = pr.x;
        int y = pr.y;
        ans += pr.val;
        if (x + 1 < N && vis[x+1][y] == 0) {
            pq.push(Node({A[x+1] + A[y], x+1, y}));
        }
        if (y + 1 < N && vis[x][y+1] == 0) {
            pq.push(Node({A[x] + A[y+1], x, y+1}));
        }
    }
    cout << ans;

    return 0;
}

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

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

#define FOR(n) for(int i=0;i<n;i++)
#define ll long long

using namespace std;
int main()
{ int n,m;
 cin>>n>>m;
 int a[m];int sum=0;int k=m;
 FOR(m)
  cin>>a[i];
 sort(a,a+m,greater<int>);
for(int i=0;i<m;i++)
{sum=sum+a[i]*2;
  for(int j=i+1;j<m;j++)
  { if(k!=0) sum+=a[i]+a[j],k--;
    if(k!=0) sum+=a[i]+a[j],k--;
  }
  if(k!=0)
    continue;
  else 
    break;
}

cout<<sum;


return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:25: error: expected primary-expression before ')' token
   14 |  sort(a,a+m,greater<int>);
      |                         ^