Language: C++

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

#define f(i,a,b) for (int i = a; i < b; i++)

int main() {
  	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
  
  int n,m; cin>>n>>m;
  int a[2*n];
  f(i,0,2*n) cin>>a[i];
  sort(a,a+2*n);
  int lo = 0, hi = n;
  auto check = [&](int x) {
  	f(i,0,2*x) if (a[i]+a[2*x-1-i] >= m)
     	return 0;
    f(i,2*x,2*n) if (a[i]+a[2*n-1-i] < m)
    	return 0;
    return 1;
  };
  while (lo<=hi) {
    int mid = (lo+hi)/2;
  	if (valid(mid)) hi = mid-1;
    else lo = mid+1;
  }
  // lo is now the breakpoint
  int ans = 0;
  f(i,0,2*lo) ans = max(ans,(a[i]+a[2*lo-1-i])%m);
  f(i,2*lo,2*n) ans = max(ans,(a[i]+a[2*n-1-i])%m);
  cout << ans << endl;
  	return 0;
}

Compiler output:
a.cc:2:7: error: expected nested-name-specifier before 'namspace'
    2 | using namspace std;
      |       ^~~~~~~~
a.cc: In function 'int main()':
a.cc:7:9: error: 'ios_base' has not been declared
    7 |         ios_base::sync_with_stdio(false);
      |         ^~~~~~~~
a.cc:8:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 |         cin.tie(NULL);
      |         ^~~
      |         std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:13:3: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   13 |   sort(a,a+2*n);
      |   ^~~~
      |   std::sort
In file included from /usr/include/c++/14/algorithm:86,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
a.cc:24:13: error: 'valid' was not declared in this scope
   24 |         if (valid(mid)) hi = mid-1;
      |             ^~~~~
a.cc:29:21: error: 'max' was not declared in this scope; did you mean 'std::max'?
   29 |   f(i,0,2*lo) ans = max(ans,(a[i]+a[2*lo-1-i])%m);
      |                     ^~~
      |                     std::max
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:30:23: error: 'max' was not declared in this scope; did you mean 'std::max'?
   30 |   f(i,2*lo,2*n) ans = max(ans,(a[i]+a[2*n-1-i])%m);
      |                       ^~~
      |                       std::max
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:31:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   31 |   cout << ans << endl;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:31:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   31 |   cout << ans << endl;
      |                  ^~~~
      |                  std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~