Language: C++

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

typedef vector<int> vi;
#define FOR(i,(a),(b)) for (int i=a; i<b; ++i)
#define all(a) (a).begin(), (a).end()
inline int in() {int x; cin >> x; return x;}

void solve(){
{
  int n = in(), m = in();
  vi A(n); cin >> A;
  sort(all(A));

  int lo = A.begin()-1, hi = A.end()+1;
  int ret = 0;
  int cnt = 0;
  vi AS(n+1);
  FOR(i,0,n) AS[i+1] = AS[i] + A[i];

  while (hi-lo>1) {
    int mid = (lo+hi)/2;
    ret = 0;
    cnt = 0;
    for (auto a : A) {
      auto itr = lower_bound(all(A), mid - a);
      int i = itr - A.begin();
      cnt += A.end() - itr;
      ret += AS[n] - AS[i] + (A.end() - itr) * a;
    }
    (cnt >= m ? lo : hi) = mid;
  }
  cout << ret - (cnt - m) * lo << endl;
}

#undef int
int main(){
    solve();
    return 0;
}


Compiler output:
a.cc:7:15: error: expected parameter name, found "("
    7 | #define FOR(i,(a),(b)) for (int i=a; i<b; ++i)
      |               ^
a.cc:4:13: error: template argument 1 is invalid
    4 | #define int ll;
      |             ^~
a.cc:6:16: note: in expansion of macro 'int'
    6 | typedef vector<int> vi;
      |                ^~~
a.cc:4:13: error: template argument 2 is invalid
    4 | #define int ll;
      |             ^~
a.cc:6:16: note: in expansion of macro 'int'
    6 | typedef vector<int> vi;
      |                ^~~
a.cc:6:1: warning: 'typedef' was ignored in this declaration
    6 | typedef vector<int> vi;
      | ^~~~~~~
a.cc:6:19: error: expected unqualified-id before '>' token
    6 | typedef vector<int> vi;
      |                   ^
a.cc:4:13: error: declaration does not declare anything [-fpermissive]
    4 | #define int ll;
      |             ^~
a.cc:9:8: note: in expansion of macro 'int'
    9 | inline int in() {int x; cin >> x; return x;}
      |        ^~~
a.cc:9:12: error: ISO C++ forbids declaration of 'in' with no type [-fpermissive]
    9 | inline int in() {int x; cin >> x; return x;}
      |            ^~
a.cc: In function 'int in()':
a.cc:4:13: error: declaration does not declare anything [-fpermissive]
    4 | #define int ll;
      |             ^~
a.cc:9:18: note: in expansion of macro 'int'
    9 | inline int in() {int x; cin >> x; return x;}
      |                  ^~~
a.cc:9:22: error: 'x' was not declared in this scope
    9 | inline int in() {int x; cin >> x; return x;}
      |                      ^
a.cc: In function 'void solve()':
a.cc:4:13: error: declaration does not declare anything [-fpermissive]
    4 | #define int ll;
      |             ^~
a.cc:13:3: note: in expansion of macro 'int'
   13 |   int n = in(), m = in();
      |   ^~~
a.cc:13:7: error: 'n' was not declared in this scope; did you mean 'yn'?
   13 |   int n = in(), m = in();
      |       ^
      |       yn
a.cc:13:17: error: 'm' was not declared in this scope; did you mean 'tm'?
   13 |   int n = in(), m = in();
      |                 ^
      |                 tm
a.cc:14:3: error: 'vi' was not declared in this scope
   14 |   vi A(n); cin >> A;
      |   ^~
a.cc:14:19: error: 'A' was not declared in this scope
   14 |   vi A(n); cin >> A;
      |                   ^
a.cc:4:13: error: declaration does not declare anything [-fpermissive]
    4 | #define int ll;
      |             ^~
a.cc:17:3: note: in expansion of macro 'int'
   17 |   int lo = A.begin()-1, hi = A.end()+1;
      |   ^~~
a.cc:17:7: error: 'lo' was not declared in this scope; did you mean 'log'?
   17 |   int lo = A.begin()-1, hi = A.end()+1;
      |       ^~
      |       log
a.cc:17:25: error: 'hi' was not declared in this scope
   17 |   int lo = A.begin()-1, hi = A.end()+1;
      |                         ^~
a.cc:4:13: error: declaration does not declare anything [-fpermissive]
    4 | #define int ll;
      |             ^~
a.cc:18:3: note: in expansion of macro 'int'
   18 |   int ret = 0;
      |   ^~~
a.cc:18:7: error: 'ret' was not declared in this scope
   18 |   int ret = 0;
      |       ^~~
a.cc:4:13: error: declaration does not declare anything [-fpermissive]
    4 | #define int ll;
      |             ^~
a.cc:19:3: note: in expansion of macro 'int'
   19 |   int cnt = 0;
      |   ^~~
a.cc:19:7: error: 'cnt' was not declared in this scope; did you mean 'int'?
   19 |   int cnt = 0;
      |       ^~~
      |       int
a.cc:20:5: error: expected ';' before 'AS'
   20 |   vi AS(n+1);
      |     ^~~
      |     ;
a.cc:21:7: error: 'i' was not declared in this scope; did you mean 'in'?
   21 |   FOR(i,0,n) AS[i+1] = AS[i] + A[i];
      |       ^
      |       in
a.cc:21:3: error: 'FOR' was not declared in this scope
   21 |   FOR(i,0,n) AS[i+1] = AS[i] + A[i];
      |   ^~~
a.cc:4:13: error: declaration does not declare anything [-fpermissive]
    4 | #define int ll;
      |             ^~
a.cc:24:5: note: in expansion of macro 'int'
   24 |     int mid = (lo+hi)/2;
      |     ^~~
a.cc:24:9: error: 'mid' was not declared in this scope
   24 |     int mid = (lo+hi)/2;
      |         ^~~
a.cc:4:13: error: declaration does not declare anything [-fpermissive]
    4 | #define int ll;
      |             ^~
a.cc:29:7: note: in expansion of macro 'int'
   29 |       int i = itr - A.begin();
      |       ^~~
a.cc:31:14: error: 'AS' was not declared in this scope
   31 |       ret += AS[n] - AS[i] + (A.end() - itr) * a;
      |              ^~
a.cc:39:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   39 | int main(){
      |         ^~
a.cc:39:9: note: remove parentheses to default-initialize a variable
   39 | int main(){
      |         ^~
      |         --
a.cc:39:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:39:11: error: a function-definition is not allowed here before '{' token
   39 | int main(){
      |           ^
a.cc:42:2: error: expected '}' at end of input
   42 | }
      |  ^
a.cc:11:13: note: to match this '{'
   11 | void solve(){
      |             ^