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

#define endl '\n';

typedef long long ll;

const ll INF = 1e17 + 1;

const ll MAX = 2147483647;

const ll MOD = 1000003;



using namespace std;



ll min(ll x, ll y, ll z)

{

    return min(min(x, y), z);

}

ll max(ll x, ll y, ll z)

{

    return max(max(x, y), z);

}



ll min(ll x, ll y, ll z, ll o)

{

    return min(min(x, y, z), o);

}



ll _power(ll b, ll p)

{

    ll res = 1;

    while (p)

    {

        if (p % 2)

            res = (res * b) % MOD;

        b = (b * b) % MOD;

        p /= 2;

    }

    return res;

}



int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int n;

    cin >> n;

    vector<int> duration(n + 1), end(n + 1);

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

        cin >> duration[i] >> end[i];

    vector<int> indices;

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

        indices.push_back(i);

    sort(indices.begin(), indices.end(), [&](int f, int s) {

        return end[f] < end[s];

    });



    int time = 0;

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

    {

        int d = duration[indices[i]];

        int e = end[indices[i]];

        time += d;

        if(time > e )

        {

            cout << "No\n";

            return 0;

        }

    }

    cout << "Yes\n";

    return 0;

}


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

#include<algorithm>

using namespace std;

#define ll long long 

struct look{

	ll a,b;

}m[200005];



bool cmp(look e,look f)

{

	return e.b<f.b;

}



int main()

{

	int n;

	while(~scanf("%d",&n))

	{

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

		{

			scanf("%lld%lld",&m[i].a,&m[i].b);

		}

		sort(m,m+n,cmp);

		ll num=0;

		int flag=0;

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

		{

			num+=m[i].a;

			if(num>m[i].b)

			{

				flag=1;

				break;

			}

		}

		if(flag==0)

		printf("Yes\n");

		else

		printf("No\n");

	 } 

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

using namespace std;

typedef long long ll;

typedef long double ld;



const int N = 2e5 + 5;

int arr[N];

int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    int n;

    cin >> n;

    vector<pair<ll, ll>> vec;

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

        ll a, b;

        cin >> a >> b;

        vec.push_back({b, a});

    }

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

    ll curr = 0;

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

        curr += vec[i].second;

        if (curr > vec[i].first)

            return cout << "No", 0;

    }

    cout << "Yes";

    return 0;

}


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

#include<algorithm>

using namespace std;

#define ll long long 

struct look{

	ll a,b;

}m[200005];



bool cmp(look e,look f)

{

	return e.b<f.b;

}



int main()

{

	int n;

	while(~scanf("%d",&n))

	{

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

		{

			scanf("%lld%lld",&m[i].a,&m[i].b);

		}

		sort(m,m+n,cmp);

		ll num=0;

		int flag=0;

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

		{

			num+=m[i].a;

			if(num>m[i].b)

			{

				flag=1;

				break;

			}

		}

		if(flag==0)

		printf("Yes\n");

		else

		printf("No\n");

	 } 

}
// Slower C++ solution:
/// Code By t_bone_289 (Tushar Singh)

/// An Immature Programmer.... I'm still developing !!

#include<bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/trie_policy.hpp>

using namespace std;

using namespace __gnu_pbds;

#define pll pair<ll,ll>

#define fi first

#define se second

#define mp make_pair

#define pb emplace_back

#define endl '\n'

#define M 1000000007

#define error(x) cout << #x << " = " << x << endl;

#define pi 3.14159265358979323846

typedef long long ll;

typedef long double ld;

template <typename T>

void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}

ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}

ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}

bool cmp(pll a,pll b)

{

    if(a.se == b.se)

    {

        return (a.fi <= b.fi);

    }

    return (a.se<b.se);

}

int main()

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    ll n;

    cin>>n;

    vector<pll> v(n);

    for(auto &x:v)

    {

        cin>>x.fi>>x.se;

    }

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

    ll cs = 0;

    for(ll i=0;i<n;i++)

    {

        cs += v[i].fi;

        if(cs > v[i].se)

        {

            cout<<"No";

            return 0;

        }

    }

    cout<<"Yes";

    return 0;

}

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

#include<algorithm>

using namespace std;

#define ll long long 

struct look{

	ll a,b;

}m[200005];



bool cmp(look e,look f)

{

	return e.b<f.b;

}



int main()

{

	int n;

	while(~scanf("%d",&n))

	{

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

		{

			scanf("%lld%lld",&m[i].a,&m[i].b);

		}

		sort(m,m+n,cmp);

		ll num=0;

		int flag=0;

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

		{

			num+=m[i].a;

			if(num>m[i].b)

			{

				flag=1;

				break;

			}

		}

		if(flag==0)

		printf("Yes\n");

		else

		printf("No\n");

	 } 

}
// Slower C++ solution:
#define mod 1000000007

#define PI acos(-1)

#include<time.h>

#include<stdio.h>

#include<string.h>

#include<math.h>

#include<map>

#include<queue>

#include<iostream>

#include<vector>

#include<algorithm>

using namespace std;

typedef long long ll;

const ll INF=0x7fffffffffffffff;

const int inf=0x7fffffff;

const int N=4e5+5;

clock_t start,finish;

void time_in(){start=clock();}

void time_out(){finish=clock();double tim=(double)(finish-start)/CLOCKS_PER_SEC;printf("Running time is %lf\n",tim);}

inline ll mul(ll a,ll b){ll s=0;while(b){if(b&1)s=(s+a)%mod;a=(a<<1)%mod;b>>=1;}return s%mod;}

inline ll pow_mul(ll a,ll b){ll s=1;while(b){if(b&1)s=mul(s,a);a=mul(a,a);b>>=1;}return s;}

inline ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}

inline bool read(int &ret){char c=getchar();int sgn;if(c==EOF)return 0;while(c!='-'&&(c<'0'||c>'9'))c=getchar();

	sgn=((c=='-')?-1:1);ret=((c=='-')?0:(c-'0'));while(c=getchar(),c>='0'&&c<='9')ret=ret*10+(c-'0');ret*=sgn;return 1;}

inline void write(int x){if(x>9)write(x/10);putchar(x%10+'0');}

int fact[10]={1,1,2,6,24,120,720,5040,40320,362880};

int st[4][2]={1,0,0,1,-1,0,0,-1};

int t,cas;

int n,m,k;

struct xxx{ll x,y;}a[N];

bool cmp(xxx b,xxx c)

{

	return b.y<c.y;

}

int main()

{

	while(~scanf("%d",&n))

	{

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

		{

			scanf("%lld%lld",&a[i].x,&a[i].y);

		}

		sort(a,a+n,cmp);

		ll ans=0;

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

		{

			ans+=a[i].x;

			if(ans>a[i].y){printf("No\n");goto e;}

		}

		printf("Yes\n");

		e:;

	}

}




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

#include<algorithm>

using namespace std;

#define ll long long 

struct look{

	ll a,b;

}m[200005];



bool cmp(look e,look f)

{

	return e.b<f.b;

}



int main()

{

	int n;

	while(~scanf("%d",&n))

	{

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

		{

			scanf("%lld%lld",&m[i].a,&m[i].b);

		}

		sort(m,m+n,cmp);

		ll num=0;

		int flag=0;

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

		{

			num+=m[i].a;

			if(num>m[i].b)

			{

				flag=1;

				break;

			}

		}

		if(flag==0)

		printf("Yes\n");

		else

		printf("No\n");

	 } 

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

using namespace std;

const int maxn=2e5+10;

const int mod=1e6+3;

typedef long long ll;

map<int,int>mp,mmp;

#define inf 0x3f3f3f3f

#define mem(a,b) memset(a,b,sizeof(a))

#define pi acos(-1.0)

void read(int &x)

{

	int f=1;x=0;

	char ch=getchar();

	while(ch<'0'||ch>'9')

	{

		if(ch=='-')f=-1;

		ch=getchar();

	}

	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();

	x*=f;

}

struct one

{

	int a,b;

}uu[maxn];

bool cmp(one x,one y)

{

	if(x.b==y.b)return x.a<y.a;

	return x.b<y.b;

}

int main()

{

   int n,i,j;

   read(n);

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

   {

   	read(uu[i].a);read(uu[i].b);

   }

   sort(uu,uu+n,cmp);

   int tim=0;

   bool ok=1;

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

   {

   	tim+=uu[i].a;

   	if(tim>uu[i].b)

   	{

   		ok=0;break;

   	}

   }

   if(ok)puts("Yes");

   else puts("No");

}

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

#include<algorithm>

using namespace std;

#define ll long long 

struct look{

	ll a,b;

}m[200005];



bool cmp(look e,look f)

{

	return e.b<f.b;

}



int main()

{

	int n;

	while(~scanf("%d",&n))

	{

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

		{

			scanf("%lld%lld",&m[i].a,&m[i].b);

		}

		sort(m,m+n,cmp);

		ll num=0;

		int flag=0;

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

		{

			num+=m[i].a;

			if(num>m[i].b)

			{

				flag=1;

				break;

			}

		}

		if(flag==0)

		printf("Yes\n");

		else

		printf("No\n");

	 } 

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

#include <sstream>

#include <vector>

#include <cmath>

#include <cstdio>

#include <queue>

#include <set>

#include <map>

#include <cstdlib>

#include <cstring>

#include <algorithm>

using namespace std;

struct node{

int a,b,c;

}aa[200005];

int comp(const node t,node tt)

{

if(t.b==tt.b)

return t.c<tt.c;

else

return t.b<tt.b;





}

int main()

{

int n;

scanf("%d",&n);

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

{

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

aa[i].c=aa[i].b-aa[i].a;

}

sort(aa,aa+n,comp);

int sum=0;

int f=0;

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

{

sum+=aa[i].a;

//printf("%d %d",sum,aa[i].b);

if(sum>aa[i].b)

{f=1;

break;

}



}

if(f==0)

printf("Yes\n");

else

printf("No\n");

}


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

#include<algorithm>

using namespace std;

#define ll long long 

struct look{

	ll a,b;

}m[200005];



bool cmp(look e,look f)

{

	return e.b<f.b;

}



int main()

{

	int n;

	while(~scanf("%d",&n))

	{

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

		{

			scanf("%lld%lld",&m[i].a,&m[i].b);

		}

		sort(m,m+n,cmp);

		ll num=0;

		int flag=0;

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

		{

			num+=m[i].a;

			if(num>m[i].b)

			{

				flag=1;

				break;

			}

		}

		if(flag==0)

		printf("Yes\n");

		else

		printf("No\n");

	 } 

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

#include <algorithm>

using namespace std;

const int maxn=2*100001;

struct WORK{

	int a;

	int b;

};

WORK w[maxn];



bool cmp(WORK x,WORK y){

	return x.b<y.b;

}



int main(){

	int n,t=0;

	cin>>n;

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

		cin>>w[i].a>>w[i].b;

	}

	sort(w+1,w+n+1,cmp);

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

		t+=w[i].a;

		if (t>w[i].b){

			cout<<"No"<<endl;

			return 0;

		}

	}

	cout<<"Yes"<<endl;

	return 0;

}

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

#include<algorithm>

using namespace std; 

struct f{

	int a,b;

}a[1000000];

bool cmp(f d,f e)

{

	return d.b<e.b;

}

int main()

{

	 int n,i,p=0;

	 scanf("%d",&n);

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

	 {

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

	 }

	 sort(a,a+n,cmp);

	 long long int s=0;

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

	 {

	 	s+=a[i].a;

	 	if(s>a[i].b)

	 	{

		 p=1;

		 break;

		}

     }

     if(p==0)

     printf("Yes\n");

     else

     printf("No\n"); 

	 

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

using namespace std;

int n,atleast;

struct mis{

	int t;

	int atl;

};

bool cmp(mis a,mis b){

	return a.atl<b.atl;

}

mis a[2000005];

int main(){

	cin>>n;

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

		cin>>a[i].t>>a[i].atl;

	}

	sort(a,a+n,cmp);

	atleast=a[n-1].atl-a[n-1].t;

	for(int i=n-2;i>=0;i--){

		if(atleast<a[i].atl){

			a[i].atl=atleast;

		}

		else atleast=a[i].atl;

		atleast-=a[i].t;

	}

	if(atleast>=0){

		cout<<"Yes";

	}

	else cout<<"No";

	return 0;

}

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

#include<algorithm>

using namespace std; 

struct f{

	int a,b;

}a[1000000];

bool cmp(f d,f e)

{

	return d.b<e.b;

}

int main()

{

	 int n,i,p=0;

	 scanf("%d",&n);

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

	 {

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

	 }

	 sort(a,a+n,cmp);

	 long long int s=0;

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

	 {

	 	s+=a[i].a;

	 	if(s>a[i].b)

	 	{

		 p=1;

		 break;

		}

     }

     if(p==0)

     printf("Yes\n");

     else

     printf("No\n"); 

	 

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



using namespace std;

typedef long long ll;

//#define int ll

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

#define RALL(a) a.rbegin(), a.rend()

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



typedef pair<int, int> pii;

typedef pair<double, int> pdi;



const int INF = 1000 * 1000 * 1000 + 10;

const ll INFLL = 1000ll * 1000 * 1000 * 1000 * 1000 * 1000;



signed main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);



#ifdef LOCAL

    freopen("input.txt", "r", stdin);

#endif



    int n;

    cin >> n;



    vector<pii> ps;

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

        int a, b;

        cin >> a >> b;

        ps.emplace_back(b, a);

    }



    sort(ALL(ps));



    int t = 0;

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

        int a, b;

        tie(b, a) = ps[i];



        if (t + a > b) {

            cout << "No\n";

            return 0;

        }

        t += a;

    }



    cout << "Yes\n";

}

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

#include<algorithm>

using namespace std; 

struct f{

	int a,b;

}a[1000000];

bool cmp(f d,f e)

{

	return d.b<e.b;

}

int main()

{

	 int n,i,p=0;

	 scanf("%d",&n);

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

	 {

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

	 }

	 sort(a,a+n,cmp);

	 long long int s=0;

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

	 {

	 	s+=a[i].a;

	 	if(s>a[i].b)

	 	{

		 p=1;

		 break;

		}

     }

     if(p==0)

     printf("Yes\n");

     else

     printf("No\n"); 

	 

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



using namespace std;



int main()

{

#ifdef LOCAL

    freopen("input.txt", "r", stdin);

#endif // LOCAL

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    int n;

    cin >> n;

    vector <pair<int, int>> p;

    vector <int> a(n);

    vector <int> b(n);

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

        cin >> a[i] >> b[i];

        p.emplace_back(b[i], i);

    }

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

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

//        cout << p[i].first << " " << p[i].second << " " << a[p[i].second] << endl;

//    }

    long long t = 0;

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

        if (t + a[p[i].second] > b[p[i].second]) {

//            cout << i << endl;

            cout << "No";

            return 0;

        }

        t += a[p[i].second];

    }

    cout << "Yes";

    return 0;

}


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

#include<algorithm>

using namespace std; 

struct f{

	int a,b;

}a[1000000];

bool cmp(f d,f e)

{

	return d.b<e.b;

}

int main()

{

	 int n,i,p=0;

	 scanf("%d",&n);

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

	 {

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

	 }

	 sort(a,a+n,cmp);

	 long long int s=0;

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

	 {

	 	s+=a[i].a;

	 	if(s>a[i].b)

	 	{

		 p=1;

		 break;

		}

     }

     if(p==0)

     printf("Yes\n");

     else

     printf("No\n"); 

	 

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

using namespace std;



typedef pair<int,int> pii;



const int N = 2e5;



pii li[N+5];

int n;

int main(){

	cin >> n;

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

		cin >> li[i].second >> li[i].first;

	}

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

	int cur = li[n].first;

	for(int i=n;i>=1;i--){

		int lambat = li[i].first - li[i].second;

		cur -= li[i].second;

		cur = min(lambat,cur);

//		cout << cur << endl;

	}

	if(cur < 0) cout << "No\n";

	else cout << "Yes\n";

	return 0;

}


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

#include<algorithm>

using namespace std; 

struct f{

	int a,b;

}a[1000000];

bool cmp(f d,f e)

{

	return d.b<e.b;

}

int main()

{

	 int n,i,p=0;

	 scanf("%d",&n);

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

	 {

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

	 }

	 sort(a,a+n,cmp);

	 long long int s=0;

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

	 {

	 	s+=a[i].a;

	 	if(s>a[i].b)

	 	{

		 p=1;

		 break;

		}

     }

     if(p==0)

     printf("Yes\n");

     else

     printf("No\n"); 

	 

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

#define F first

#define S second

using namespace std;

typedef long long ll;

ll n, t;

int main()

{

    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n;

    vector< pair<int, int> >v(n);

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

        cin >> v[i].S >> v[i].F;

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

    for(auto it : v)

    {

        t += it.S;

        if(t > it.F)

            return cout << "No", 0;

    }

    cout << "Yes";

    return 0;

}


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

#include<algorithm>

using namespace std; 

struct f{

	int a,b;

}a[1000000];

bool cmp(f d,f e)

{

	return d.b<e.b;

}

int main()

{

	 int n,i,p=0;

	 scanf("%d",&n);

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

	 {

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

	 }

	 sort(a,a+n,cmp);

	 long long int s=0;

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

	 {

	 	s+=a[i].a;

	 	if(s>a[i].b)

	 	{

		 p=1;

		 break;

		}

     }

     if(p==0)

     printf("Yes\n");

     else

     printf("No\n"); 

	 

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

using namespace std;

#define ll long long

#define f first

#define s second

int main()

{

    int n,nw=0,f=1;cin>>n;

    pair<int,int>p[n];

    for(int i = 0 ;i<n;i++)cin>>p[i].s>>p[i].f;

    sort(p,p+n);

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

            nw+=p[i].s;

        if(nw>p[i].f)f=0;

    }

    if(f)cout<<"Yes";

    else cout<<"No";

}


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

#include<algorithm>

using namespace std; 

struct f{

	int a,b;

}a[1000000];

bool cmp(f d,f e)

{

	return d.b<e.b;

}

int main()

{

	 int n,i,p=0;

	 scanf("%d",&n);

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

	 {

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

	 }

	 sort(a,a+n,cmp);

	 long long int s=0;

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

	 {

	 	s+=a[i].a;

	 	if(s>a[i].b)

	 	{

		 p=1;

		 break;

		}

     }

     if(p==0)

     printf("Yes\n");

     else

     printf("No\n"); 

	 

}
// Slower C++ solution:
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

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

#define S second

#define F first

#define ll long long

#define ld long double



using namespace std;



const int N = 2e5 + 5, mod = 1e9 + 7;



pair<ll, ll> p[N];



int main()

{

    ll n, sum = 0;

    bool valid = 1;

    cin>>n;

    for(int i = 0 ; i < n ; i++) cin>>p[i].S>>p[i].F;

    sort(p, p+n);

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

    {

        sum += p[i].S;

        if(sum > p[i].F) valid = 0;

    }

    valid ? cout<<"Yes" : cout<<"No";

}


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

#include<algorithm>

using namespace std; 

struct f{

	int a,b;

}a[1000000];

bool cmp(f d,f e)

{

	return d.b<e.b;

}

int main()

{

	 int n,i,p=0;

	 scanf("%d",&n);

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

	 {

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

	 }

	 sort(a,a+n,cmp);

	 long long int s=0;

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

	 {

	 	s+=a[i].a;

	 	if(s>a[i].b)

	 	{

		 p=1;

		 break;

		}

     }

     if(p==0)

     printf("Yes\n");

     else

     printf("No\n"); 

	 

}
// Slower C++ solution:
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

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

typedef long long ll;

using namespace std;

ll n,t;

pair<ll,ll>arr[200005];

int main()

{

    abdelrahman001

    cin >> n;

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

        cin >> arr[i].second >> arr[i].first;

    sort(arr,arr+n);

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

    {

        t+=arr[i].second;

        if(t > arr[i].first)

            return cout << "No",0;

    }

    cout << "Yes";

    return 0;

}


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

#include<algorithm>

using namespace std; 

struct f{

	int a,b;

}a[1000000];

bool cmp(f d,f e)

{

	return d.b<e.b;

}

int main()

{

	 int n,i,p=0;

	 scanf("%d",&n);

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

	 {

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

	 }

	 sort(a,a+n,cmp);

	 long long int s=0;

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

	 {

	 	s+=a[i].a;

	 	if(s>a[i].b)

	 	{

		 p=1;

		 break;

		}

     }

     if(p==0)

     printf("Yes\n");

     else

     printf("No\n"); 

	 

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

#define endl '\n';

typedef long long ll;

const ll INF = 1e17 + 1;

const ll MAX = 2147483647;

const ll MOD = 1000003;



using namespace std;



ll min(ll x, ll y, ll z)

{

    return min(min(x, y), z);

}

ll max(ll x, ll y, ll z)

{

    return max(max(x, y), z);

}



ll min(ll x, ll y, ll z, ll o)

{

    return min(min(x, y, z), o);

}



ll _power(ll b, ll p)

{

    ll res = 1;

    while (p)

    {

        if (p % 2)

            res = (res * b) % MOD;

        b = (b * b) % MOD;

        p /= 2;

    }

    return res;

}



int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int n;

    cin >> n;

    vector<int> duration(n + 1), end(n + 1);

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

        cin >> duration[i] >> end[i];

    vector<int> indices;

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

        indices.push_back(i);

    sort(indices.begin(), indices.end(), [&](int f, int s) {

        return end[f] < end[s];

    });



    int time = 0;

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

    {

        int d = duration[indices[i]];

        int e = end[indices[i]];

        time += d;

        if(time > e )

        {

            cout << "No\n";

            return 0;

        }

    }

    cout << "Yes\n";

    return 0;

}


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

#include<algorithm>

using namespace std; 

struct f{

	int a,b;

}a[1000000];

bool cmp(f d,f e)

{

	return d.b<e.b;

}

int main()

{

	 int n,i,p=0;

	 scanf("%d",&n);

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

	 {

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

	 }

	 sort(a,a+n,cmp);

	 long long int s=0;

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

	 {

	 	s+=a[i].a;

	 	if(s>a[i].b)

	 	{

		 p=1;

		 break;

		}

     }

     if(p==0)

     printf("Yes\n");

     else

     printf("No\n"); 

	 

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

using namespace std;

typedef long long ll;

typedef long double ld;



const int N = 2e5 + 5;

int arr[N];

int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    int n;

    cin >> n;

    vector<pair<ll, ll>> vec;

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

        ll a, b;

        cin >> a >> b;

        vec.push_back({b, a});

    }

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

    ll curr = 0;

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

        curr += vec[i].second;

        if (curr > vec[i].first)

            return cout << "No", 0;

    }

    cout << "Yes";

    return 0;

}


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

#include<algorithm>

using namespace std; 

struct f{

	int a,b;

}a[1000000];

bool cmp(f d,f e)

{

	return d.b<e.b;

}

int main()

{

	 int n,i,p=0;

	 scanf("%d",&n);

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

	 {

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

	 }

	 sort(a,a+n,cmp);

	 long long int s=0;

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

	 {

	 	s+=a[i].a;

	 	if(s>a[i].b)

	 	{

		 p=1;

		 break;

		}

     }

     if(p==0)

     printf("Yes\n");

     else

     printf("No\n"); 

	 

}