#include using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) template bool chmax(T &a, const T &b) { if(a bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;} //------------------------------------------------------- int N; ll X,Y; vector Xs,Ys; ll hoge(vector P,ll L) { int i; vector cand; vector S={0}; sort(ALL(P)); FOR(i,N) { cand.push_back(P[i]-L/2); cand.push_back(P[i]+L/2); P.push_back(P[i]+L); } FOR(i,2*N) S.push_back(S.back()+P[i]); ll ret=-1; FORR(c,cand) { if(c-L/2<=0) c+=L; if(c+L/2>=2*L) c-=L; ll PL,PR; if(L%2) { PL=c-L/2; PR=c+L/2; } else { PL=c-L/2; PR=c+L/2-1; } ll sum=0; { int a=lower_bound(ALL(P),PL)-P.begin(); int b=lower_bound(ALL(P),c)-P.begin(); sum+=c*(b-a)-(S[b]-S[a]); } { int a=lower_bound(ALL(P),c+1)-P.begin(); int b=lower_bound(ALL(P),PR+1)-P.begin(); sum+=(S[b]-S[a])-c*(b-a); } ret=max(ret,sum); } return ret; } void solve() { int i,j,k,l,r,x,y; string s; cin>>N>>X>>Y; FOR(i,N) { cin>>x>>y; Xs.push_back(x-1); Ys.push_back(y-1); } ll ret=hoge(Xs,X)+hoge(Ys,Y); cout<