stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
/***********************

*  Date: 2018.11.28    *

*  Problem:            *

*  Author: xuziyuan    * 

***********************/



#include <bits/stdc++.h>



#define rt0 return 0

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

#define repn(i,n) for(int i=1;i<=n;i++)

#define replet(c) for(char c='a';c<='z';c++)

#define LL long long

#define pii pair <int,int>

#define pb push_back

#define fi first

#define se second

#define mpr make_pair

#define sqr(a) ((a)*(a))



using namespace std;



const LL MOD=1e9+7;



int n,m,q,co[100010],most[100010];

vector <int> g[100010];

vector <pair<int,pii> > qs;

bool vis[100010];



int main()

{

	cin>>n>>m;

	memset(most,-1,sizeof(most));

	rep(i,m)

	{

		int x,y;

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

		g[x].pb(y);

		g[y].pb(x);

	}

	cin>>q;

	rep(i,q)

	{

		int x,y,z;

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

		qs.pb({x,{y,z}});

	}

	for(int i=qs.size()-1;i>=0;i--)

	{

		//cout<<qs[i].fi<<' '<<qs[i].se.fi<<' '<<qs[i].se.se<<endl;

		memset(vis,0,sizeof(vis));

		int v=qs[i].fi,colo=qs[i].se.se,dist=qs[i].se.fi;

		queue <pii> q;

		q.push({v,0});

		while(!q.empty())

		{

			int pos=q.front().fi,dist1=q.front().se;

			//cout<<pos<<' '<<colo<<' '<<dist<<' '<<dist1<<endl;

			q.pop();

			if(vis[pos]) continue;

			if(most[pos]>=dist-dist1) continue;

			vis[pos]=true;

			most[pos]=dist-dist1;

			if(co[pos]==0) co[pos]=colo;

			if(dist1==dist) continue;

			rep(j,g[pos].size()) q.push({g[pos][j],dist1+1});

		}

	}

	repn(i,n) printf("%d\n",co[i]);

	rt0;

}

// Optimized solution to the same problem (faster):
/***********************

*  Date: 2018.11.28    *

*  Problem:            *

*  Author: xuziyuan    * 

***********************/



#include <bits/stdc++.h>



#define rt0 return 0

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

#define repn(i,n) for(int i=1;i<=n;i++)

#define replet(c) for(char c='a';c<='z';c++)

#define LL long long

#define pii pair <int,int>

#define pb push_back

#define fi first

#define se second

#define mpr make_pair

#define sqr(a) ((a)*(a))



using namespace std;



const LL MOD=1e9+7;



int n,m,q,appe[100010][20],coap[100010],len=0;//appe:appearance

int list_top[200010],val[200010],nxt[200010];



void add(int x,int y)

{

	val[++len]=y;

	nxt[len]=list_top[x];

	list_top[x]=len;

}



int main()

{

	cin>>n>>m;

	rep(i,m)

	{

		int x,y;

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

		add(x,y);

		add(y,x);

	}

	cin>>q;

	repn(i,q)

	{

		int x,y;

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

		appe[x][y]=i;

	}

	for(int i=9;i>=0;i--)//算能不能覆盖appe[j][i]之前要先算出appe[p][i+1]会不会被覆盖，所以i要倒着循环 

	{

		repn(p,n)

		{

			for(int k=list_top[p];k!=0;k=nxt[k])//i在这里代表可以控制的范围

			{

				int j=val[k];

				appe[j][i]=max(appe[j][i],appe[p][i+1]);/*远一条边距离就要加1，这里是看后者可不可以覆盖前者，

				可以说是一种dp，一个类似递归的过程，如果再之前的点把后者覆盖了，也会在前者上体现出来*/

			}	

		}	

	} 

	repn(i,n)

	{

		int lst=0;

		rep(j,11) lst=max(lst,appe[i][j]);

		cout<<coap[lst]<<endl;

	}

	rt0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
/***********************

*  Date: 2018.11.28    *

*  Problem:            *

*  Author: xuziyuan    * 

***********************/



#include <bits/stdc++.h>



#define rt0 return 0

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

#define repn(i,n) for(int i=1;i<=n;i++)

#define replet(c) for(char c='a';c<='z';c++)

#define LL long long

#define pii pair <int,int>

#define pb push_back

#define fi first

#define se second

#define mpr make_pair

#define sqr(a) ((a)*(a))



using namespace std;



const LL MOD=1e9+7;



int n,m,q,co[100010],most[100010];

vector <int> g[100010];

vector <pair<int,pii> > qs;

bool vis[100010];



void dfs(int pos,int now,int all,int colo)

{

	if(all-now<=most[pos]) return;

	most[pos]=all-now;

	if(co[pos]==0) co[pos]=colo;

	if(now==all) return;

	rep(i,g[pos].size()) dfs(g[pos][i],now+1,all,colo);

}



int main()

{

	cin>>n>>m;

	memset(most,-1,sizeof(most));

	rep(i,m)

	{

		int x,y;

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

		g[x].pb(y);

		g[y].pb(x);

	}

	cin>>q;

	rep(i,q)

	{

		int x,y,z;

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

		qs.pb({x,{y,z}});

	}

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

	rep(i,q)

	{

		dfs(qs[i].fi,0,qs[i].se.fi,qs[i].se.se);

	}

	repn(i,n) printf("%d\n",co[i]);

	rt0;

}

// Optimized solution to the same problem (faster):
/***********************

*  Date: 2018.11.28    *

*  Problem:            *

*  Author: xuziyuan    * 

***********************/



#include <bits/stdc++.h>



#define rt0 return 0

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

#define repn(i,n) for(int i=1;i<=n;i++)

#define replet(c) for(char c='a';c<='z';c++)

#define LL long long

#define pii pair <int,int>

#define pb push_back

#define fi first

#define se second

#define mpr make_pair

#define sqr(a) ((a)*(a))



using namespace std;



const LL MOD=1e9+7;



int n,m,q,appe[100010][20],coap[100010],len=0;//appe:appearance

int list_top[200010],val[200010],nxt[200010];



void add(int x,int y)

{

	val[++len]=y;

	nxt[len]=list_top[x];

	list_top[x]=len;

}



int main()

{

	cin>>n>>m;

	rep(i,m)

	{

		int x,y;

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

		add(x,y);

		add(y,x);

	}

	cin>>q;

	repn(i,q)

	{

		int x,y;

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

		appe[x][y]=i;

	}

	for(int i=9;i>=0;i--)//算能不能覆盖appe[j][i]之前要先算出appe[p][i+1]会不会被覆盖，所以i要倒着循环 

	{

		repn(p,n)

		{

			for(int k=list_top[p];k!=0;k=nxt[k])//i在这里代表可以控制的范围

			{

				int j=val[k];

				appe[j][i]=max(appe[j][i],appe[p][i+1]);/*远一条边距离就要加1，这里是看后者可不可以覆盖前者，

				可以说是一种dp，一个类似递归的过程，如果再之前的点把后者覆盖了，也会在前者上体现出来*/

			}	

		}	

	} 

	repn(i,n)

	{

		int lst=0;

		rep(j,11) lst=max(lst,appe[i][j]);

		cout<<coap[lst]<<endl;

	}

	rt0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
/***********************

*  Date: 2018.11.28    *

*  Problem:            *

*  Author: xuziyuan    * 

***********************/



#include <bits/stdc++.h>



#define rt0 return 0

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

#define repn(i,n) for(int i=1;i<=n;i++)

#define replet(c) for(char c='a';c<='z';c++)

#define LL long long

#define pii pair <int,int>

#define pb push_back

#define fi first

#define se second

#define mpr make_pair

#define sqr(a) ((a)*(a))



using namespace std;



const LL MOD=1e9+7;



int n,m,q,appe[100010][20],coap[100010];//appe:appearance

vector <int> g[100010];



int main()

{

	cin>>n>>m;

	rep(i,m)

	{

		int x,y;

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

		g[x].pb(y);

		g[y].pb(x);

	}

	cin>>q;

	repn(i,q)

	{

		int x,y;

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

		appe[x][y]=i;

	}

	for(int i=9;i>=0;i--)//算能不能覆盖appe[j][i]之前要先算出appe[p][i+1]会不会被覆盖，所以i要倒着循环 

	{

		repn(p,n)

		{

			rep(k,g[p].size())//i在这里代表可以控制的范围

			{

				int j=g[p][k];

				appe[j][i]=max(appe[j][i],appe[p][i+1]);/*远一条边距离就要加1，这里是看后者可不可以覆盖前者，

				可以说是一种dp，一个类似递归的过程，如果再之前的点把后者覆盖了，也会在前者上体现出来*/

			}	

		}	

	} 

	repn(i,n)

	{

		int lst=0;

		rep(j,11) lst=max(lst,appe[i][j]);

		cout<<coap[lst]<<endl;

	}

	rt0;

}

// Optimized solution to the same problem (faster):
/***********************

*  Date: 2018.11.28    *

*  Problem:            *

*  Author: xuziyuan    * 

***********************/



#include <bits/stdc++.h>



#define rt0 return 0

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

#define repn(i,n) for(int i=1;i<=n;i++)

#define replet(c) for(char c='a';c<='z';c++)

#define LL long long

#define pii pair <int,int>

#define pb push_back

#define fi first

#define se second

#define mpr make_pair

#define sqr(a) ((a)*(a))



using namespace std;



const LL MOD=1e9+7;



int n,m,q,appe[100010][20],coap[100010],len=0;//appe:appearance

int list_top[200010],val[200010],nxt[200010];



void add(int x,int y)

{

	val[++len]=y;

	nxt[len]=list_top[x];

	list_top[x]=len;

}



int main()

{

	cin>>n>>m;

	rep(i,m)

	{

		int x,y;

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

		add(x,y);

		add(y,x);

	}

	cin>>q;

	repn(i,q)

	{

		int x,y;

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

		appe[x][y]=i;

	}

	for(int i=9;i>=0;i--)//算能不能覆盖appe[j][i]之前要先算出appe[p][i+1]会不会被覆盖，所以i要倒着循环 

	{

		repn(p,n)

		{

			for(int k=list_top[p];k!=0;k=nxt[k])//i在这里代表可以控制的范围

			{

				int j=val[k];

				appe[j][i]=max(appe[j][i],appe[p][i+1]);/*远一条边距离就要加1，这里是看后者可不可以覆盖前者，

				可以说是一种dp，一个类似递归的过程，如果再之前的点把后者覆盖了，也会在前者上体现出来*/

			}	

		}	

	} 

	repn(i,n)

	{

		int lst=0;

		rep(j,11) lst=max(lst,appe[i][j]);

		cout<<coap[lst]<<endl;

	}

	rt0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

/*

*/



using namespace std;





int main() {

	int N;

	cin >> N;

	vector<int>D( N );

	for( size_t i = 0; i < N; i++ ) {

		cin >> D[i];

	}

	double maxans = 1, minans = 0;

	for( size_t idx = 0; idx < 100; idx++ ) {

		double midans = ( maxans + minans ) / 2;

		set<int>prev;

		prev.insert( 1 );

		for( size_t i = 0; i < N; i++ ) {

			double minvalue = D[i] * ( 1. - midans );

			double maxvalue = D[i] * ( 1. + midans );

			set<int>next;

			for( auto one : prev ) {

				for( int j = minvalue / one + 1; j <= maxvalue / one; j++ ) {

					next.insert( j*one );

				}

			}

			prev = next;

		}

		if( prev.size() ) {

			maxans = midans;

		} else {

			minans = midans;

		}



	}

	cout << fixed << setprecision( 20 ) << minans << endl;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

/*

*/



using namespace std;





int main() {

	int N;

	cin >> N;

	vector<int>D( N );

	for( size_t i = 0; i < N; i++ ) {

		cin >> D[i];

	}

	double maxans = 1, minans = 0;

	for( size_t idx = 0; idx < 28; idx++ ) {

		double midans = ( maxans + minans ) / 2;

		set<int>prev;

		prev.insert( 1 );

		for( size_t i = 0; i < N; i++ ) {

			double minvalue = D[i] * ( 1. - midans );

			double maxvalue = D[i] * ( 1. + midans );

			set<int>next;

			for( auto one : prev ) {

				for( int j = minvalue / one + 1; j <= maxvalue / one; j++ ) {

					next.insert( j*one );

				}

			}

			prev = next;

		}

		if( prev.size() ) {

			maxans = midans;

		} else {

			minans = midans;

		}



	}

	cout << fixed << setprecision( 20 ) << minans << endl;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int main() {

    int N;

    cin >> N;

    vector<int> vec(N);

    for (auto& i : vec) cin >> i;



    double l = 0., r = 1.0;

    for (int c = 0; c < 100; c++) {

        double m = (l + r) / 2.0;

        set<int> s;

        s.insert(1);



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

            int lo_n = ceil((1.0 - m) * (double)vec[i]);

            int up_n = (1.0 + m) * vec[i];



            set<int> ns;

            for (auto j : s) {

                int v = up_n / j;

                int u = ceil((double)lo_n / j);

                for (; u <= v; u++) if (u != 0) ns.insert(j * u);

            }



            s = ns;

        }



        if (s.size() > 0) r = m;

        else l = m;

    }



    printf("%.10f\n", l);



    return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;



int main() {

    int N;

    cin >> N;

    vector<int> vec(N);

    for (auto& i : vec) cin >> i;



    double l = 0., r = 1.0;

    for (int c = 0; c < 27; c++) {

        double m = (l + r) / 2.0;

        set<int> s;

        s.insert(1);



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

            int lo_n = ceil((1.0 - m) * (double)vec[i]);

            int up_n = (1.0 + m) * vec[i];



            set<int> ns;

            for (auto j : s) {

                int v = up_n / j;

                int u = ceil((double)lo_n / j);

                for (; u <= v; u++) if (u != 0) ns.insert(j * u);

            }



            s = ns;

        }



        if (s.size() > 0) r = m;

        else l = m;

    }



    printf("%.10f\n", l);



    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <vector>

#include <algorithm>

#include <utility>

#include <queue>

#include <cstdio>

#include <iostream>

#include <string>

#include <string.h>

#include <stdio.h>

#include <complex>



using namespace std;

typedef pair<int, int> PII;

typedef pair<int, PII> TIII;

#define PB push_back

#define MP make_pair

#define MT(a,b,c) MP(a, MP(b, c))

#define T1 first

#define T2 second.first

#define T3 second.second

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

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

int a[20];

int n;



bool DFS(int k, int m, double r){

	int s = ceil(a[k]-a[k]*r);

	if(s==0)s=1;

	int e = ceil(a[k]+a[k]*r);

	for(int p = ((s-1)/m+1)*m; p<e; p+=m)

		if(k==n-1)return true;

		else if(DFS(k+1, p, r))return true;



	return false;

}



bool C(double r){

	return DFS(0,1,r);

}



int main(){

	cin>>n;

	REP(i,n)scanf("%d", &a[i]);

	double u=1.0, l=0.0;

	while(u-l>1e-9){

		double mid = (u+l)*0.5;

		if(C(mid))u=mid;

		else l = mid;

	}

	printf("%.10f\n", u);

	return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <cmath>

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

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

int a[20];

int n;



bool DFS(int k, int m, double r){

	int s=ceil(a[k]*(1-r));

	int e=ceil(a[k]*(1+r));

	for(int p=((s-1)/m+1)*m;p<e;p+=m)

		if(k==n-1)return true;

		else if(DFS(k+1,p,r))return true;

	return false;

}



int main(){

	scanf("%d",&n);

	REP(i,n)scanf("%d",&a[i]);

	double u=1.0,l=0.0;

	REP(i,30){

		double m=(u+l)*0.5;

		if(DFS(0,1,m))u=m;

		else l=m;

	}

	printf("%.9f\n",u);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <vector>

#include <algorithm>

#include <set>

using namespace std;

typedef long long ll;

vector<int> DP[5001];



int main()

{

	int N, K; cin >> N >> K;

	vector<int>a(N);

	vector<bool>b(N);



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

		cin >> a[i];

	}

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

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



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

		if (a[i] >= K) {

			b[i] = true;

			continue;

		}

		for (int j = K-1; j >= 0; j--) {

			if (DP[j].size() != 0) {

				if (j + a[i] >= K) {

					while(DP[j].size()){

						if (DP[j][0] == -1) {

							DP[j].erase(DP[j].begin());

							continue;

						}

						b[DP[j][0]] = true;

						DP[j].erase(DP[j].begin());

					}

					b[i] = true;

					DP[j].push_back(-1);

					break;

				}

				else {

					for (int k = 0; k < DP[j].size(); k++) {

						DP[j + a[i]].push_back(DP[j][k]);

					}

					DP[j + a[i]].push_back(i);

					break;

				}

			}

		}

		DP[a[i]].push_back(i);

	}



	int ans = 0;

	for (int i = 0; i < N; i++)if (b[i] == false) {

		ans++;

	}

	cout << ans << endl;



    return 0;

}


// Optimized solution to the same problem (faster):
#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;



int main() {

	int n,k;

    cin>>n>>k;

    vector<int>a(n);

    for(int i=0;i<n;i++)cin>>a[i];

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

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



    int cnt=0,sum=0;

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

        if(sum+a[i]<k){

            sum+=a[i];

            cnt++;

        }

        else cnt=0;

    }



    cout<<cnt<<endl;



	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<int,int> pii;

typedef pair<long long,long long> pll;

#define ep emplace_back

#define pb push_back

#define mp make_pair

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

constexpr int mod=1000000007;

constexpr int mod1=998244353;

vector<int> dx={0,1,0,-1},dy={-1,0,1,0};

bool inside(int y,int x,int h,int w){

	if(y<h && y>=0 && x<w && x>=0) return true;

	return false;

}











int main(){

	cin.tie(0);

	ios::sync_with_stdio(false);

	int n,k;cin >> n >> k;

	vector<int> a(n);

	rep(i,n) cin >> a.at(i);

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

	vector<vector<int>> dp(n + 2, vector<int>(5010));

	dp[0][0] = 1;

	int ng = 0,ok = n + 1;

	while(ok - ng > 1){

		int mid = (ok + ng) / 2;

		if(a.at(mid - 1) >= k){

			ok = mid;

			continue;

		}

		rep(i,n + 1){

			rep(j,k + 1){

				dp[i][j] = 0;

			}

		}

		dp[0][0] = 1;

		rep(i,n){

			rep(j,k + 1){

				if(i + 1 != mid && j - a.at(i) >= 0) dp[i + 1][j] |= dp[i][j - a.at(i)];

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

			}

		}

		bool flg = false;

		for(int i = k - a.at(mid - 1); i < k; i++){

			if(dp[n][i]){

				flg = true;

				break;

			}

		}

		if(flg) ok = mid;

		else ng = mid;

	}

	cout << ng << endl;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<int,int> pii;

typedef pair<long long,long long> pll;

#define ep emplace_back

#define pb push_back

#define mp make_pair

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

constexpr int mod=1000000007;

constexpr int mod1=998244353;

vector<int> dx={0,1,0,-1},dy={-1,0,1,0};

bool inside(int y,int x,int h,int w){

	if(y<h && y>=0 && x<w && x>=0) return true;

	return false;

}











int main(){

	cin.tie(0);

	ios::sync_with_stdio(false);

	int n,k;cin >> n >> k;

	vector<int> a(n);

	rep(i,n) cin >> a.at(i);

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

	int ng = 0,ok = n + 1;

	while(ok - ng > 1){

		int mid = (ok + ng) / 2;

		if(a.at(mid - 1) >= k){

			ok = mid;

			continue;

		}

		vector<bitset<5010>> dp(n + 1);

		dp[0].set(0);

		rep(i,n){

			if(i == mid - 1) dp[i + 1] |= dp[i];

			else dp[i + 1] |= dp[i] | (dp[i] << a.at(i));

		}

		bool flg = false;

		for(int i = k - a.at(mid - 1); i < k; i++){

			if(dp[n][i]){

				flg = true;

				break;

			}

		}

		if(flg) ok = mid;

		else ng = mid;

	}

	cout << ng << endl;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define ll long long

#define maxn 100005

#define lson l,mid,rt<<1

#define rson mid+1,r,rt<<1|1

#define pb push_back

#define pii pair<int,int>

using namespace std;



int n,k;

int a[5005];



bool Check(int mid){

    if(a[mid]>=k) return 1;

    bitset<maxn> bs;

    bs[0]=1;

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

        if(i!=mid) bs|=bs<<a[i];

    }

    for(int i=k-1;i>=k-a[mid];i--){

        if(bs[i]) return 1;

    }

    return 0;

}



int main(){



    cin>>n>>k;

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

        cin>>a[i];

    }

    sort(a+1,a+n+1);

    int L=1,R=n,mid;

    while(L<=R){

        mid=L+R>>1;

        if(Check(mid)) R=mid-1;

        else L=mid+1;

    }

    cout<<R<<endl;





}






// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

#define ll long long

#define maxn 100005

#define lson l,mid,rt<<1

#define rson mid+1,r,rt<<1|1

#define pb push_back

#define pii pair<int,int>

using namespace std;



int n,k;

int a[5005];



bool Check(int mid){

    if(a[mid]>=k) return 1;

    bitset<5005> bs;

    bs[0]=1;

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

        if(a[i]>5000) break;

        if(i!=mid) {

            bs|=bs<<a[i];

        }

    }

    for(int i=k-1;i>=k-a[mid];i--){

        if(bs[i]) return 1;

    }

    return 0;

}



int main(){



    cin>>n>>k;

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

        cin>>a[i];

    }

    sort(a+1,a+n+1);

    int L=1,R=n,mid;

    while(L<=R){

        mid=L+R>>1;

        if(Check(mid)) R=mid-1;

        else L=mid+1;

    }

    cout<<R<<endl;





}






// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;



#define pb push_back

#define eb emplace_back

#define ll long long

#define pii pair < int, int >

#define fr first

#define sc second

#define mk make_pair

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

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

#define ok puts("ok");

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



const int N = 223;

const int inf = (int)1e9 + 7;



pii ar[N];

vector < int > gr[N];

bool used[N];

int mt[N];



bool kuhn(int v) {

  if (used[v]) return false;

  used[v] = 1;

  for (int to : gr[v]) {

    if (mt[to] == -1 || kuhn(mt[to])) {

      mt[to] = v;

      return true;

    }

  }

  return false;

}



main() {

  int n;

  scanf("%d", &n);

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

    scanf("%d %d", &ar[i].fr, &ar[i].sc);

  }

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

    scanf("%d %d", &ar[i].fr, &ar[i].sc);

    mt[i] = -1;

  }

  int ans = 0;

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

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

      if (ar[i].fr < ar[j].fr && ar[i].sc < ar[j].sc) {

        gr[i].pb(j);

      }

    }

  }

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

    memset(used, 0, sizeof(used));

    kuhn(i);

  }



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

    if (mt[i] != -1) {

      ans++;

//      cout << i << ' ' << mt[i] << endl;

    }

  }

  cout << ans;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include <string.h>

using namespace std;

int n,link[110][110],connect[110];

bool used[110];

bool find(int x)

{

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

    {

        if(link[x][i]&&!used[i])

        {

            used[i]=true;

            if(connect[i]==0||find(connect[i]))

            {

                connect[i]=x;

                return true;

            }

        }

    }

    return false;

}

int main(void)

{

	int a[110],b[110],c[110],d[110];

	scanf("%d",&n);

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

        scanf("%d%d",&a[i],&b[i]);

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

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

    memset(connect,0,sizeof connect);

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

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

            if(a[i]<c[j]&&b[i]<d[j])

                link[i][j]=true;

    int ans=0;

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

    {

        memset(used,false,sizeof used);

        if(find(i)) ans++;

    }

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

	return 0;

}


// Fastest known solution for this problem: