Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSR(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n,m;
int vec[200005];

struct maintain_interval{
	int bit[(1<<18)+5];
	void init(){
		memset(bit,0,sizeof(bit));
	}
	int f(int x)
	{
		return x&-x;
	}
	void add(int i,int x)
	{
		for(int s=i;s<=(1<<18);s+=f(s)) bit[s]+=x;
	}
	int sum(int i)
	{
		int res=0;
		for(int s=i;s>0;s-=f(s)) res+=bit[s];
		return res;
	}
}mt;

P forbid[200005][2];
bool ok[200005],ok2[200005];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<2*n;i++){
		scanf("%d",&vec[i]);
	}
	sort(vec,vec+2*n);
	
	int lb = -1,ub = m-1;
	while(ub-lb > 1){
		int mid = (lb+ub)/2;
		for(int i=0;i<2*n;i++){
			//vec[i]と足してmod mでmidより大な区間
			for(int j=0;j<2;j++){
				//[mid+1+m*j,m*(j+1)-1]
				int L = mid+1+m*j-vec[i];
				int R = m*(j+1)-1-vec[i];
				L = POSL(vec,L);
				R = POSR(vec,R); R--;
				if(L <= R) forbid[i][j] = mp(L+i,R+i);
				else forbid[i][j] = mp(-1,-1);
			}
		}
		mt.init();
		for(int i=0;i<2*n;i++){
			for(int j=0;j<2;j++) if(forbid[i][j].fi >= 0){
				mt.add((forbid[i][j].fi+2)/2,1);
				mt.add((forbid[i][j].sc+1)/2+1,-1);
			}
			if(i%2 == 1){
				ok[i] = !mt.sum((i+1)/2);
			}
		}
		mt.init();
		for(int i=2*n-1;i>=0;i--){
			for(int j=0;j<2;j++) if(forbid[i][j].fi >= 0){
				mt.add((forbid[i][j].fi+2)/2,1);
				mt.add((forbid[i][j].sc+1)/2+1,-1);
			}
			if(i%2 == 0){
				ok2[i] = !mt.sum((2*n+i)/2);
			}
		}
		ok2[2*n] = true;
		bool flag = 0;
		for(int i=0;i<2*n;i++){
			if(i%2 == 1){
				if(ok[i] && ok2[i+1]){
					flag = 1;
					break;
				}
			}
		}
		if(flag) ub = mid;
		else lb = mid;
	}
	cout << ub << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:34: error: request for member 'begin' in 'vec', which is of non-class type 'int [200005]'
   19 | #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
      |                                  ^~~~~
a.cc:64:37: note: in expansion of macro 'POSL'
   64 |                                 L = POSL(vec,L);
      |                                     ^~~~
a.cc:19:44: error: request for member 'end' in 'vec', which is of non-class type 'int [200005]'
   19 | #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
      |                                            ^~~
a.cc:64:37: note: in expansion of macro 'POSL'
   64 |                                 L = POSL(vec,L);
      |                                     ^~~~
a.cc:19:55: error: request for member 'begin' in 'vec', which is of non-class type 'int [200005]'
   19 | #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
      |                                                       ^~~~~
a.cc:64:37: note: in expansion of macro 'POSL'
   64 |                                 L = POSL(vec,L);
      |                                     ^~~~
a.cc:20:34: error: request for member 'begin' in 'vec', which is of non-class type 'int [200005]'
   20 | #define POSR(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
      |                                  ^~~~~
a.cc:65:37: note: in expansion of macro 'POSR'
   65 |                                 R = POSR(vec,R); R--;
      |                                     ^~~~
a.cc:20:44: error: request for member 'end' in 'vec', which is of non-class type 'int [200005]'
   20 | #define POSR(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
      |                                            ^~~
a.cc:65:37: note: in expansion of macro 'POSR'
   65 |                                 R = POSR(vec,R); R--;
      |                                     ^~~~
a.cc:20:55: error: request for member 'begin' in 'vec', which is of non-class type 'int [200005]'
   20 | #define POSR(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
      |                                                       ^~~~~
a.cc:65:37: note: in expansion of macro 'POSR'
   65 |                                 R = POSR(vec,R); R--;
      |                                     ^~~~