stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long

#define ld long double

#define ull unsigned ll

#define ioi exit(0);

 

#define f first

#define s second

 

#define inf (int)1e9 + 7

 

#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

 

#define mp(x,y) make_pair(x,y)

 

#define lb(x) lower_bound(x)

#define ub(x) upper_bound(x)

 

#define pb push_back

#define ppb pop_back

 

#define bitcoin __builtin_popcount

 

#define endl "\n"

 

#define in(x) insert(x)

 

#define sz(x) (int)x.size()

 

#define all(x) x.begin(),x.end()

 

#define pw2(x) (1ll<<x) //2^x

 

#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)

 

#define sqr(x) ((x) * 1ll * (x))

 

#define UpdateRandom srand (time(NULL));

 

using namespace std;

 

const int N = (int)3e3 + 7, MOD = (int)1e9 + 7;



string s,t;



string dp[4][N];



int main(){

		

	NFS



	cin >> s >> t;



	for(int i=1;i<=sz(s);i++){

		for(int j=1;j<=sz(t);j++){

			if(sz(dp[2][j-1])>sz(dp[2][j]))dp[2][j]=dp[2][j-1];

			if(sz(dp[2-1][j])>sz(dp[2][j]))dp[2][j]=dp[2-1][j];

			if(sz(dp[2-1][j-1])>sz(dp[2][j]))dp[2][j]=dp[2-1][j-1];

			if(s[i-1]==t[j-1]){

				if(sz(dp[2-1][j-1])+1>sz(dp[2][j]))dp[2][j]=dp[2-1][j-1]+s[i-1];

			}

		}

		for(int j=1;j<=sz(t);j++)dp[1][j]=dp[2][j],dp[2][j].clear();

	}

	

	cout << dp[1][sz(t)] << endl;

	

	ioi

}

// Faster C++ solution for the same problem (measured speedup: 1.3903461387241338x):
#include<bits/stdc++.h>

using namespace std;

#define int  long long

#define tc(t)  int t; cin>>t; while(t--)

#define f(n)    for(int i=0;i<n;i++)

#define endl   "\n"











int common_sub(string first,string second,int i,int j,vector<vector<int>>&dp)



{

    if(i==first.size()||j==second.size()) return 0;



    if(dp[i][j]!=-1) return dp[i][j];

   // cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;



    if(first[i]==second[j]) dp[i][j]= 1+common_sub(first,second,i+1,j+1,dp);

    else{

        dp[i][j]=max(common_sub(first,second,i,j+1,dp),common_sub(first,second,i+1,j,dp));



    }

    return dp[i][j];











}



int32_t main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

     string first,second;

     cin>>first>>second;

     int n=first.size();

     int m=second.size();

     vector<vector<int>>dp(n+1,vector<int>(m+1,0));



     //cout<<common_sub(first,second,0,0,dp)<<endl;

     string answer;

     for(int i=1;i<=n;i++)

     {

         for(int j=1;j<=m;j++)

         {

          if(first[i-1]==second[j-1]) {

              dp[i][j] = 1 + dp[i - 1][j - 1];



          }

          else {

              dp[i][j]=max(dp[i-1][j],dp[i][j-1]);



          }

         }



     }



     int i=n;int j=m;

     while(i>0&&j>0)

     {

         if(first[i-1]==second[j-1])

         {

             answer+=first[i-1];

             i--;

             j--;

         } else

         {

             if(dp[i-1][j]>dp[i][j-1])

             {

                 i--;

             }

             else j--;





         }











     }

     reverse(answer.begin(),answer.end());

     cout<<answer<<endl;















}
// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long

#define ld long double

#define ull unsigned ll

#define ioi exit(0);

 

#define f first

#define s second

 

#define inf (int)1e9 + 7

 

#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

 

#define mp(x,y) make_pair(x,y)

 

#define lb(x) lower_bound(x)

#define ub(x) upper_bound(x)

 

#define pb push_back

#define ppb pop_back

 

#define bitcoin __builtin_popcount

 

#define endl "\n"

 

#define in(x) insert(x)

 

#define sz(x) (int)x.size()

 

#define all(x) x.begin(),x.end()

 

#define pw2(x) (1ll<<x) //2^x

 

#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)

 

#define sqr(x) ((x) * 1ll * (x))

 

#define UpdateRandom srand (time(NULL));

 

using namespace std;

 

const int N = (int)3e3 + 7, MOD = (int)1e9 + 7;



string s,t;



string dp[4][N];



int main(){

		

	NFS



	cin >> s >> t;



	for(int i=1;i<=sz(s);i++){

		for(int j=1;j<=sz(t);j++){

			if(sz(dp[2][j-1])>sz(dp[2][j]))dp[2][j]=dp[2][j-1];

			if(sz(dp[2-1][j])>sz(dp[2][j]))dp[2][j]=dp[2-1][j];

			if(sz(dp[2-1][j-1])>sz(dp[2][j]))dp[2][j]=dp[2-1][j-1];

			if(s[i-1]==t[j-1]){

				if(sz(dp[2-1][j-1])+1>sz(dp[2][j]))dp[2][j]=dp[2-1][j-1]+s[i-1];

			}

		}

		for(int j=1;j<=sz(t);j++)dp[1][j]=dp[2][j],dp[2][j].clear();

	}

	

	cout << dp[1][sz(t)] << endl;

	

	ioi

}

// Faster C++ solution for the same problem (measured speedup: 1.41502408247195x):
#include <bits/stdc++.h>

using namespace std;



int main() {

	string s,t;

	cin>>s>>t;

	int c[s.length()+1][t.length()+1];

	unordered_map<char,int> h;

	for(int i=0;i<=s.length();i++){

	for(int j=0;j<=t.length();j++){

	if(i==0||j==0){

	    c[i][j]=0;

	}

	else if(s[i-1]==t[j-1]){

	    c[i][j]=c[i-1][j-1]+ 1;

	}

	 else{

	    c[i][j]=c[i-1][j]>c[i][j-1]?c[i-1][j]:c[i][j-1];

	 }   

	}}

	int index=c[s.length()][t.length()];

	string lcs="";

	int i=s.length(),j=t.length();

	while(i>0&& j>0){

	    if (s[i-1] == t[j-1]) 

      { 

          lcs=s[i-1]+lcs; 

          i--; j--; index--;      

      } 

  

      

      else if (c[i-1][j] > c[i][j-1]) 

         i--; 

      else

         j--;

	}

	cout<<lcs;

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long

#define ld long double

#define ull unsigned ll

#define ioi exit(0);

 

#define f first

#define s second

 

#define inf (int)1e9 + 7

 

#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

 

#define mp(x,y) make_pair(x,y)

 

#define lb(x) lower_bound(x)

#define ub(x) upper_bound(x)

 

#define pb push_back

#define ppb pop_back

 

#define bitcoin __builtin_popcount

 

#define endl "\n"

 

#define in(x) insert(x)

 

#define sz(x) (int)x.size()

 

#define all(x) x.begin(),x.end()

 

#define pw2(x) (1ll<<x) //2^x

 

#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)

 

#define sqr(x) ((x) * 1ll * (x))

 

#define UpdateRandom srand (time(NULL));

 

using namespace std;

 

const int N = (int)3e3 + 7, MOD = (int)1e9 + 7;



string s,t;



string dp[4][N];



int main(){

		

	NFS



	cin >> s >> t;



	for(int i=1;i<=sz(s);i++){

		for(int j=1;j<=sz(t);j++){

			if(sz(dp[2][j-1])>sz(dp[2][j]))dp[2][j]=dp[2][j-1];

			if(sz(dp[2-1][j])>sz(dp[2][j]))dp[2][j]=dp[2-1][j];

			if(sz(dp[2-1][j-1])>sz(dp[2][j]))dp[2][j]=dp[2-1][j-1];

			if(s[i-1]==t[j-1]){

				if(sz(dp[2-1][j-1])+1>sz(dp[2][j]))dp[2][j]=dp[2-1][j-1]+s[i-1];

			}

		}

		for(int j=1;j<=sz(t);j++)dp[1][j]=dp[2][j],dp[2][j].clear();

	}

	

	cout << dp[1][sz(t)] << endl;

	

	ioi

}

// Faster C++ solution for the same problem (measured speedup: 1.3922353400307175x):
//(bool) ? (if true) : (if false)

#include<bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(0);cin.tie(0)

#define fst first

#define snd second

#define all(x) (x).begin(), (x).end()

#define pb push_back

#define pf push_front

#define sz size()

#define FORN(i,j,n) for(long long i=j; i<(long long)n;i++) 

#define FOR(i,n) FORN(i,0,n)

#define FORIT(i,x) for( auto i = x.begin() ; i != x.end() ; i++ )

#define LIM 262150

#define ones(x) __builtin_popcount(x)

#define trace(x)    cerr << #x << ": " << x << endl;

#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;

using namespace std;

 

typedef long long ll ;

typedef unsigned long long ull ;

typedef vector <int> vi;

typedef vector <long long> vll;

typedef pair <int,int> ii;

typedef vector <string> vs;

typedef vector <ii> vii;

string cad1,cad2;

ll dp[3005][3005];

deque<char> ans;

int main() {

	fastio;

	cin>> cad1 >> cad2 ;

	FOR(i,cad1.sz+1){

		FOR(j,cad2.sz+1){

			if (i == 0 | j == 0){ dp[i][j] = 0; continue; }

            if(cad1[i-1] == cad2[j-1]){

			    dp[i][j] = dp[i-1][j-1] + 1;

			}			

			else{

				dp[i][j] = max(dp[i][j-1],dp[i-1][j]);

			}

		}

	}

	ll a = cad1.sz; 

	ll b = cad2.sz;

	while(a>0 && b>0){

		if(dp[a][b] == dp[a][b-1]) b--;

		else if(dp[a][b] == dp[a-1][b]) a--;

		else if(dp[a][b] == dp[a-1][b-1] + 1){

			ans.pf(cad1[a-1]); 

			a--; b--;

		}

	}

	FOR(i,ans.sz){

		cout<< ans[i] ;

	}

	cout<< '\n';

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long

#define ld long double

#define ull unsigned ll

#define ioi exit(0);

 

#define f first

#define s second

 

#define inf (int)1e9 + 7

 

#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

 

#define mp(x,y) make_pair(x,y)

 

#define lb(x) lower_bound(x)

#define ub(x) upper_bound(x)

 

#define pb push_back

#define ppb pop_back

 

#define bitcoin __builtin_popcount

 

#define endl "\n"

 

#define in(x) insert(x)

 

#define sz(x) (int)x.size()

 

#define all(x) x.begin(),x.end()

 

#define pw2(x) (1ll<<x) //2^x

 

#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)

 

#define sqr(x) ((x) * 1ll * (x))

 

#define UpdateRandom srand (time(NULL));

 

using namespace std;

 

const int N = (int)3e3 + 7, MOD = (int)1e9 + 7;



string s,t;



string dp[4][N];



int main(){

		

	NFS



	cin >> s >> t;



	for(int i=1;i<=sz(s);i++){

		for(int j=1;j<=sz(t);j++){

			if(sz(dp[2][j-1])>sz(dp[2][j]))dp[2][j]=dp[2][j-1];

			if(sz(dp[2-1][j])>sz(dp[2][j]))dp[2][j]=dp[2-1][j];

			if(sz(dp[2-1][j-1])>sz(dp[2][j]))dp[2][j]=dp[2-1][j-1];

			if(s[i-1]==t[j-1]){

				if(sz(dp[2-1][j-1])+1>sz(dp[2][j]))dp[2][j]=dp[2-1][j-1]+s[i-1];

			}

		}

		for(int j=1;j<=sz(t);j++)dp[1][j]=dp[2][j],dp[2][j].clear();

	}

	

	cout << dp[1][sz(t)] << endl;

	

	ioi

}

// Faster C++ solution for the same problem (measured speedup: 1.4110020717152927x):
#include<bits/stdc++.h>

#define MAXN 1e5

//123



using namespace std;



string a1,a2;



void dp (string s1, string s2, int n, int m){

    int l[n+1][m+1];



    for (int i=0; i<=n; i++){

        for (int j=0; j<=m; j++){

            if (i==0 or j==0){

                l[i][j]=0;

            }

            else if (s1[i-1]==s2[j-1]){

                l[i][j]=l[i-1][j-1]+1;

            }

            else{

                l[i][j]=max(l[i-1][j], l[i][j-1]);

            }

        }

    }

    while (m>0 and n>0){

        if (s1[n-1]==s2[m-1]){

            a1+=s1[n-1];

            n--;

            m--;

        }

        else if (l[n-1][m]>l[n][m-1]){

            n--;

        }

        else{

            m--;

        }

    }

}



long long n,m,a,b,c;

string s1,s2;



int main(){

    cin>>s1>>s2;

    n=s1.size();

    m=s2.size();

    dp(s1, s2, n, m);

    reverse(a1.begin(), a1.end());

    cout<<a1<<endl;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



#define INF 2000000000

#define ll long long



int res;

int N, P;

vector<pair<int, int> > v;

vector<int> com;

int seg[530000];



void Init()

{

	for(int i=0; i<530000; i++)

		seg[i] = -INF;

}



int Update(int idx, int val, int n, int l, int r)

{

	if (r < idx || idx < l) return seg[n];

	if (l == r) return seg[n] = max(seg[n], val);

	int mid = l+r>>1;

	return seg[n] = max(Update(idx, val, n<<1, l, mid), Update(idx, val, n<<1|1, mid+1, r));

}



int Query(int L, int R, int n, int l, int r)

{

	if (r < L || R < l) return -INF;

	if (L <= l && r <= R) return seg[n];

	int mid = l+r>>1;

	return max(Query(L, R, n<<1, l, mid), Query(L, R, n<<1|1, mid+1, r));

}



int main()

{

	scanf("%d", &N);

	for(int i=1; i<=N; i++)

	{

		int x, y;

		scanf("%d %d", &x, &y);

		v.push_back({x, y});

		com.push_back(y);

	}

	sort(v.begin(), v.end());



	// 좌표 압축

	sort(com.begin(), com.end());

	com.erase(unique(com.begin(), com.end()), com.end());

	P = com.size();



	Init();

	vector<int> qry;

	for(int i=0; i<v.size(); i++)

	{

		int x = v[i].first, y = v[i].second;

		int idx = lower_bound(com.begin(), com.end(), y) - com.begin();

		Update(idx, -x-y, 1, 0, P-1);

		qry.push_back(i);



		if (i+1==v.size() || v[i].first != v[i+1].first)

		{

			for(int j : qry)

			{

				int x = v[j].first, y = v[j].second;

				int idx = lower_bound(com.begin(), com.end(), y) - com.begin();

				res = max(res, Query(0, idx, 1, 0, P-1)+x+y);

			}

			qry.clear();

		}

	}



	Init();

	for(int i=0; i<v.size(); i++)

	{

		int x = v[i].first, y = v[i].second;

		int idx = lower_bound(com.begin(), com.end(), y) - com.begin();

		Update(idx, -x+y, 1, 0, P-1);

		qry.push_back(i);



		if (i+1==v.size() || v[i].first != v[i+1].first)

		{

			for(int j : qry)

			{

				int x = v[j].first, y = v[j].second;

				int idx = lower_bound(com.begin(), com.end(), y) - com.begin();

				res = max(res, Query(idx, P-1, 1, 0, P-1)+x-y); // idx+1로 하면 Query가 -2e9라 음수 overflow...

			}

			qry.clear();

		}

	}



	printf("%d\n", res);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.874770913525554x):
#include<bits/stdc++.h>

using namespace std;



#define INF 2000000000

#define ll long long



int N;

int X[200201], Y[200201];



int main()

{

	scanf("%d", &N);

	int mx1 = -INF, mx2 = -INF, mx3 = -INF, mx4 = -INF;

	for(int i=1; i<=N; i++)

	{

		scanf("%d %d", &X[i], &Y[i]);

		mx1 = max(mx1, -X[i]-Y[i]);

		mx2 = max(mx2, -X[i]+Y[i]);

		mx3 = max(mx3, +X[i]-Y[i]);

		mx4 = max(mx4, +X[i]+Y[i]);

	}

	int res = 0;

	for(int i=1; i<=N; i++)

	{

		res = max(res, mx1+X[i]+Y[i]);

		res = max(res, mx2+X[i]-Y[i]);

		res = max(res, mx3-X[i]+Y[i]);

		res = max(res, mx4-X[i]-Y[i]);

	}

	printf("%d", res);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;

const int mod = 1e9+7;

int add(int a, int b) {

	return a + b < mod ? a + b : a + b - mod;

}

int mul(int a, int b) {

	return int(1LL * a * b % mod);

}

int fexp(int b, int e = mod - 2) {

	int ans = 1;

	while(e) {

		if(e & 1) ans = mul(ans, b);

		b = mul(b, b);

		e /= 2;

	}

	return ans;

}



using ll = long long;

const ll oo = 1e18;



const int N = 200005;



struct Segtree {

	ll st[2 * N];

	int n;



	ll query(int l, int r){ // [l, r]

		ll ans = -oo;

		for(l += n, r += n+1; l < r; l >>= 1, r >>= 1){

			if(l & 1) ans = max(ans, st[l++]);

			if(r & 1) ans = max(ans, st[--r]);

		}

		return ans;

	}



	void build() {

		for(int i = 0; i < 2 * N; i++) st[i] = -oo;

	}



	void update(int p, ll val){

		p += n;

		st[p] = max(st[p], val);

		while(p >>= 1) st[p] = max(st[2*p], st[2*p+1]);

	}

} up, down;



int n;

ll x[N], y[N];

ll compr[N];



int gety(ll val) {

	return int(lower_bound(compr, compr + n, val) - compr);

}

int id[N];



int main() {

	scanf("%d", &n);

	up.n = down.n = n;

	up.build(), down.build();



	for(int i = 0; i < n; i++) {

		scanf("%lld %lld", x + i, y + i);

		compr[i] = y[i];

		id[i] = i;

	}

	sort(compr, compr + n);



	sort(id, id + n, [](int i, int j) {

		if(x[i] != x[j]) return x[i] < x[j];

		return y[i] < y[j];

	});

	

	ll ans = 0;



	for(int w = 0; w < n; w++) {

		int i = id[w];



		int me = gety(y[i]);



		ans = max(ans, up.query(me, n - 1) + x[i] - y[i]);

		ans = max(ans, down.query(0, me) + x[i] + y[i]);



		up.update(me, y[i] - x[i]);

		down.update(me, -y[i] - x[i]);

	}



	printf("%lld\n", ans);

	return 0;



	for(int i = 0; i < n; i++) for(int j = i + 1; j < n; j++) {

		ll tmp = abs(x[i] - x[j]) + abs(y[i] - y[j]);

		if(tmp > ans) {

			printf("%d(%lld %lld) %d(%lld %lld)\n", i, x[i], y[i], j, x[j], y[j]);

			assert(0);

		}

	}



}


// Faster C++ solution for the same problem (measured speedup: 7.58065272213367x):
#include <bits/stdc++.h>



using namespace std;



const int N = 200005;



struct vec {

	int x, y;

	int operator*(const vec &o) const {

		return x * o.x + y * o.y;

	}

	int dist(const vec &o) const {

		return abs(x - o.x) + abs(y - o.y);

	}

} pt[N];



int n;



int main() {

	scanf("%d", &n);

	

	for(int i = 0; i < n; i++) {

		scanf("%d %d", &pt[i].x, &pt[i].y);

	}



	array<vec, 4> best{pt[0], pt[0], pt[0], pt[0]};



	for(int i = 0; i < n; i++) {

		int id = 0;

		for(int j : {-1, 1}) for(int k : {-1, 1}) {

			vec tmp{j, k};

			if(tmp * pt[i] > tmp * best[id]) best[id] = pt[i];

			id++;

		}

	}



	int ans = 0;

	for(int i = 0; i < 4; i++) for(int j = i + 1; j < 4; j++) {

		ans = max(ans, best[i].dist(best[j]));

	}



	printf("%d\n", ans);

}
// Slower C++ solution:
#include<bits/stdc++.h>



#define SORT(v) sort(v.begin(),v.end())

#define si(n) scanf("%d",&n)

#define sii(n,m) scanf("%d %d",&n,&m)

#define sl(n) scanf("%lld",&n)

#define sll(n,m) scanf("%lld %lld",&n,&m)

#define ss(cad) scanf("%s",cad)

#define PB push_back

#define fst first

#define scn second

#define DBG(x) cerr << #x << " = " << (x) << endl; 

#define M 1000000007

#define N_MAX 100010



using namespace std;



typedef long long ll;

typedef vector<int> vi;

typedef vector<bool> vb;

typedef vector<ll> vl;

typedef pair<int,int> pi;

typedef vector<pi> vp;



int main(){

	int n;

	si(n);

	vector<pair<ll, int> > v1(n), v2(n), vv1(n), vv2(n);

	for(int i = 0; i < n; i++){

		int a, b;

		sii(a, b);

		v1[i] = {(ll)2*1000000000 - a - b, i};

		v2[i] = {a + b, i};

		vv1[i] = {(ll)1000000000 - b + a, i};

		vv2[i] = {(ll)1000000000 - a + b, i};

	}

	sort(v1.begin(), v1.end());

	sort(v2.begin(), v2.end());

	sort(vv1.begin(), vv1.end());

	sort(vv2.begin(), vv2.end());

	ll ans = 0;

	if(v1[0].scn != v2[0].scn)

		ans = (ll)2*1000000000 - v1[0].fst - v2[0].fst;

	else

		ans = max((ll)2*1000000000 - v1[0].fst - v2[1].fst, (ll)2*1000000000 - v1[1].fst - v2[0].fst);



	if(vv1[0].scn != vv2[0].scn)

		ans = max(ans, (ll)2*1000000000 - vv1[0].fst - vv2[0].fst);

	else

		ans = max(ans, max((ll)2*1000000000 - vv1[0].fst - vv2[1].fst, (ll)2*1000000000 - vv1[1].fst - vv2[0].fst));

	printf("%lld\n", ans);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.217298242873868x):
#include<algorithm>

#include<string>

#include<math.h>



using namespace std;



const int N = 200010;



int n,x,y;

int a[N],b[N];

int main(){

	scanf("%d",&n);

	for(int i=0;i<n;i++){

		scanf("%d%d",&x,&y);

		a[i]=x+y;

		b[i]=x-y;

	}

	sort(a,a+n);

	sort(b,b+n);

	printf("%d",max(a[n-1]-a[0],b[n-1]-b[0]));

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);

using namespace std;

typedef long long ll;

int N;

const int maxn=2e6+10;

ll a[maxn],b[maxn];



int main()

{

	ios;

	cin>>N;

	int cnt=0;

	for(int i=1;i<=N;i++)

	{

		ll x,y;

		cin>>x>>y;

		a[cnt]=x+y;

		b[cnt++]=x-y;

	}

	sort(a,a+cnt);

	sort(b,b+cnt);

	ll maxsum=max(a[cnt-1]-a[0],b[cnt-1]-b[0]);

	cout<<maxsum<<"\n";

	return 0;

 } 

// Faster C++ solution for the same problem (measured speedup: 5.307894568322609x):
#include<algorithm>

#include<string>

#include<math.h>



using namespace std;



const int N = 200010;



int n,x,y;

int a[N],b[N];

int main(){

	scanf("%d",&n);

	for(int i=0;i<n;i++){

		scanf("%d%d",&x,&y);

		a[i]=x+y;

		b[i]=x-y;

	}

	sort(a,a+n);

	sort(b,b+n);

	printf("%d",max(a[n-1]-a[0],b[n-1]-b[0]));

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<math.h>

#include<algorithm>

typedef long long ll;



using namespace std;



ll n, a, b;

ll x[200005], y[200005], z[200005];



int main() {

	cin >> n;

	for (int i = 0; i < n; i++) {

		cin >> a >> b;

		x[i] = a + b;

		y[i] = a - b;

		z[i] = b - a;

	}

	sort(x, x + n); sort(y, y + n); sort(z, z + n);

	cout << max((x[n - 1] - x[0]), max((y[n - 1] - y[0]), (z[n - 1]-z[0])));

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.219084842651414x):
#include<algorithm>

#include<string>

#include<math.h>



using namespace std;



const int N = 200010;



int n,x,y;

int a[N],b[N];

int main(){

	scanf("%d",&n);

	for(int i=0;i<n;i++){

		scanf("%d%d",&x,&y);

		a[i]=x+y;

		b[i]=x-y;

	}

	sort(a,a+n);

	sort(b,b+n);

	printf("%d",max(a[n-1]-a[0],b[n-1]-b[0]));

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define PB push_back

#define MP make_pair

#define REP(i,n) for (int i=0;i<(n);i++)

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

#define ALL(a) (a).begin(),(a).end()

using namespace std;

typedef pair<int,int> P;

typedef long long ll;

const int INF=1e9;

int dp[100100];

int main(){

  int m,n;

  cin>>m>>n;

  int c[550],e[550];

  vector<int>p(m);

  REP(i,100100)dp[i]=INF;

  REP(i,m)cin>>p[i];

  dp[0]=0;

  int sum=0;

  REP(i,n){

    cin>>c[i]>>e[i];

    for(int j=sum;j>=0;j--){

      dp[j+c[i]]=min(dp[j+c[i]],dp[j]+e[i]);

    }

    sum+=c[i];

    sum=min(sum,20000);

  }

  for(int i=sum;i>=0;i--){

    dp[i]=min(dp[i],dp[i+1]);

  }

  sort(ALL(p),greater<int>());

  sum=0;

  int ans=0;

  REP(i,m){

    sum+=p[i];

    ans=max(ans,sum-dp[i+1]);

  }

  cout<<ans<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.246660064332083x):
#include <bits/stdc++.h>

#define PB push_back

#define MP make_pair

#define REP(i,n) for (int i=0;i<(n);i++)

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

#define ALL(a) (a).begin(),(a).end()

int INF=1e9;

int MOD=1000000007;

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

double EPS = 1e-10;

const int mod=1e9+7;

int dp[20001];

int sum[20001];

int N,M;

int C[500],E[500];

vector<int>P;

int main(){

	ios::sync_with_stdio(0);

	cin.tie(0);

	cin>>M>>N;

	P.resize(M);

	REP(i,M)cin>>P[i];

	sort(ALL(P),greater<int>());

	REP(i,M)sum[i+1]=sum[i]+P[i];

	REP(i,N)cin>>C[i]>>E[i];

	REP(i,20001)dp[i]=1e9;

	dp[0]=0;

	REP(i,N){

		for(int j=M;j>=0;j--){

			dp[j+C[i]]=min(dp[j+C[i]],dp[j]+E[i]);

		}

	}

	for(int i=20000;i>0;i--){

		dp[i-1]=min(dp[i],dp[i-1]);

	}

	int ans=0;

	REP(i,M+1)ans=max(ans,sum[i]-dp[i]);

	cout<<ans<<endl;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include<cstring>

#include<algorithm>

#include<queue>

using namespace std;

int main()

{

    long long n,m,ans;

    scanf("%lld%lld",&n,&m);

    if(n > m/2)

    {

        printf("%lld\n",m/2);

    }

    else

    {

        ans = n;

        m = m - n*2;

        ans += m/4;

        printf("%lld\n",ans);

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.202928779017632x):
#include<stdio.h>



int main(void)

{

    long long n,m;

    long long S,L;

    long long i,k,j;

    scanf("%lld%lld",&n,&m);

    k=m-n-n;

    if(k>0)

    {

        m=m-n-n;

        m=m/4;

        S=n+m;

    }

    else if(k<0)

    {

        S=m/2;

    }

    printf("%lld",S);

    return 0;

}