stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define pb              push_back

#define ll              long long

#define scd(a)          scanf("%d",&a)

#define mp(a,b)         make_pair(a,b)

#define scl(w)          scanf("%lld",&w)

#define scdd(a,b)       scanf("%d %d",&a,&b)

#define srt(a)          sort(a.begin(),a.end())

#define rsrt(a)         sort(a.rbegin(),a.rend())

#define scll(a,b)       scanf("%lld %lld",&a,&b)

///4direction ->        int del_x[]={-1,0,1,0},del_y[]={0,1,0,-1};

#define input(v,n)      for (int i=0;i<n;i++){int a;cin >> a;v.push_back(a);}

#define inputll(v,n)    for (ll i=0;i<n;i++){ll a;cin >> a;v.push_back(a);}

#define vii             vector < int >

#define vll             vector < ll >

#define pii             pair < int , int >

#define pll             pair < ll , ll >

#define mk              make_pair

#define inf8            100000008



using namespace std;



vector < pll > v;



int main()

{

    ll n;

    scl(n);



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

        ll a,b;

        scll(a,b);



        v.pb({b,a});

    }

    srt(v);

    ll time = 0 , cnt = 0;



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

        time+=v[i].second;

        if (time<=v[i].first)cnt++;

    }

    cout << (cnt==n?"Yes":"No") << endl;



    return 0;

}




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

#include<algorithm>

using namespace std;

struct node{

	int a;

	int b;

}ss[200010];

int cmp(node x,node y){

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

	else return x.b<y.b;

}

int main(){

	int n;

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

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

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

		}

		sort(ss,ss+n,cmp);

		int flag=1;

		int sum=0;

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

			sum+=ss[i].a;

			if(sum>ss[i].b){

				flag=0;

				break;

			}

		}

		if(flag) printf("Yes\n");

		else printf("No\n");

	}

	return 0;

}

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

#define int long long

#define INF 1ll<<60

using namespace std;

bool cmd(pair<int,int> a,pair<int,int> b){

  return a.second<b.second;

}

signed main(){

  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  int N;

  cin>>N;

  vector<pair<int,int> >vet(N);

  int a,b;

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

    cin>>a>>b;

    vet[i]=make_pair(a,b);

  }

  sort(vet.begin(),vet.end(),cmd);

  int aux=0;

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

    if(vet[i].second-aux>=vet[i].first){

      aux+=vet[i].first;

    }

    else{

      cout<<"No"<<endl;

      return 0;

    }

  }

  cout<<"Yes"<<endl;

  return 0;

}


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

#include<algorithm>

using namespace std;

struct node{

	int a;

	int b;

}ss[200010];

int cmp(node x,node y){

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

	else return x.b<y.b;

}

int main(){

	int n;

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

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

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

		}

		sort(ss,ss+n,cmp);

		int flag=1;

		int sum=0;

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

			sum+=ss[i].a;

			if(sum>ss[i].b){

				flag=0;

				break;

			}

		}

		if(flag) printf("Yes\n");

		else printf("No\n");

	}

	return 0;

}

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

#include <numeric>

typedef long long ll;

#define vstroku() to_string()

#define vchislo() to_ulong()

#define numberof1(x) __builtin_popcount(x)

#define povsemelementam(i,mnozh) for(auto i: mnozh)

#define podotrezok(i,j) substr(i-1,j) // like prefix sum, (i,j)=s[j]-s[i-1]

#define pb push_back

#define pf push_front

#define popf pop_front

#define popb pop_back 

#define pii pair <int, int>

#define F first

#define S second

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





using namespace std;

const ll INFLL = 1e18;

const int MAXN = 3e5;

const ll INF = 1e9;

const ll kek = 998244353;



int main() {

	mipletsplay;

int n;

cin>>n;

vector <pair <ll,ll> > a(n);

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

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

ll sum=0;

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

bool ok=true;

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

{

if (sum+a[i].second<=a[i].first)

sum+=a[i].second;

else

ok=false;

}

if (ok)

cout<<"Yes";

else

cout<<"No"; }

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

#include<algorithm>

using namespace std;

struct node{

	int a;

	int b;

}ss[200010];

int cmp(node x,node y){

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

	else return x.b<y.b;

}

int main(){

	int n;

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

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

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

		}

		sort(ss,ss+n,cmp);

		int flag=1;

		int sum=0;

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

			sum+=ss[i].a;

			if(sum>ss[i].b){

				flag=0;

				break;

			}

		}

		if(flag) printf("Yes\n");

		else printf("No\n");

	}

	return 0;

}

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

/*==========================================================*/

/*    Template ver 2017-0720    |    Created by JollyBee    */

/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */

/*==========================================================*/

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

typedef vector<int> vi;

typedef pair<int,int> pii;

typedef pair<ll,ll> pll;

typedef vector<pii> vii;

const double EPS=(double)1e-9;

const double PI=(double)acos(-1.0);

#define fi first

#define se second

#define mp make_pair

#define pb push_back

#define pob pop_back

#define pf push_front

#define pof pop_front

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

#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)

#define REP(i,l,r) REPP(i,l,r,1)

#define FORD(i,n) for(int i=n-1;i>=0;i--)

#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)

#define REV(i,l,r) REVV(i,l,r,1)

//random

int irand(int lo, int hi){

    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;

}

//ll to string

string toString(ll x) {

    stringstream ss;

    ss << x;

    return ss.str();

}

//string to ll

ll toNumber(string S) {

    ll ret;

    sscanf(S.c_str(),"%lld",&ret);

    return ret;

}

// std::fill(start, end, value);

// for(auto it: DS){}



const int INF=(int)2e9;

const ll MOD=(ll)1e9+7;

/*==========================================================*/

/*                     END OF TEMPLATE                      */

/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */

/*==========================================================*/



const int N = (int)2e5;



pii dat[N+5];



int main(){

    int n; scanf("%d", &n);

    REP(i,1,n) scanf("%d %d", &dat[i].se, &dat[i].fi);

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

    //

    int timee = 0, res = 1;

    REP(i,1,n) if((timee += dat[i].se) > dat[i].fi){

        res = 0;

        break;

    }

    // print

    puts(res ? "Yes" : "No");

    return 0;

}


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

#include<algorithm>

using namespace std;

struct node{

	int a;

	int b;

}ss[200010];

int cmp(node x,node y){

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

	else return x.b<y.b;

}

int main(){

	int n;

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

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

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

		}

		sort(ss,ss+n,cmp);

		int flag=1;

		int sum=0;

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

			sum+=ss[i].a;

			if(sum>ss[i].b){

				flag=0;

				break;

			}

		}

		if(flag) printf("Yes\n");

		else printf("No\n");

	}

	return 0;

}

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

using namespace std;

#define N int(1e5 + 5)

#define MOD 1000003

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

typedef long long ll;

int main(){

    IO

    int n; cin >> n;

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

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

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

        v[i].second *= -1;

    }

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

    ll meh = 0;

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

        meh += v[i].second * -1;

        if(v[i].first < meh)

            return cout << "No", 0;

    }

    cout << "Yes";

}


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

#include<algorithm>

using namespace std;

struct node{

	int a;

	int b;

}ss[200010];

int cmp(node x,node y){

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

	else return x.b<y.b;

}

int main(){

	int n;

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

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

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

		}

		sort(ss,ss+n,cmp);

		int flag=1;

		int sum=0;

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

			sum+=ss[i].a;

			if(sum>ss[i].b){

				flag=0;

				break;

			}

		}

		if(flag) printf("Yes\n");

		else printf("No\n");

	}

	return 0;

}

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

#define pb push_back

#define fi first

#define sc second

#define inf	1000000000LL

#define MP make_pair

#define N 300005

#define MOD 1000000007 

#define orta ((a+b)/2)

using namespace std;

typedef long long int lint;

typedef pair<int,int> ii;



ii d[N];

int main()

{

	int n;

	cin >> n;



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

	{

		cin >> d[i].sc >> d[i].fi;

	}

	sort(d,d+n);

	int t=0;

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

	{

		t+=d[i].sc;

		if(t>d[i].fi)

		{

			cout << "No";

			return 0;

		}

	}

			cout << "Yes";

}

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

#include<algorithm>

using namespace std;

struct node{

	int a;

	int b;

}ss[200010];

int cmp(node x,node y){

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

	else return x.b<y.b;

}

int main(){

	int n;

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

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

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

		}

		sort(ss,ss+n,cmp);

		int flag=1;

		int sum=0;

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

			sum+=ss[i].a;

			if(sum>ss[i].b){

				flag=0;

				break;

			}

		}

		if(flag) printf("Yes\n");

		else printf("No\n");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

#define DEBUG true

#ifdef ONLINE_JUDGE

#undef DEBUG

#define DEBUG false

#endif 



using namespace std;



#define MAXN ((int)2e5+5)

#define MOD ((int)1e9 + 7)

#define INF ((int)1e9 + 9)

#define ll long long

#define _ << " " <<

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

#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;

#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;

#define pb push_back

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

#define endl "\n"

#define pii pair<int,int>

#define mid ((l+r)/2)



int n;

int a[MAXN];

int b[MAXN];

vector <pii> v;



int main()

{

	ios_base::sync_with_stdio(false);cin.tie(0);

	cin >> n;

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

	{

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

		v.pb({b[i],a[i]});

	}	

	sort(all(v));



	int cur = 0;

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

	{

		if(cur + v[i].second <= v[i].first)

		{

			cur = cur + v[i].second;

		}

		else

		{

			cout << "No\n";

			return 0;

		}

	}

	cout << "Yes\n";



}

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

#include<algorithm>

using namespace std;

struct node{

	int a;

	int b;

}ss[200010];

int cmp(node x,node y){

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

	else return x.b<y.b;

}

int main(){

	int n;

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

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

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

		}

		sort(ss,ss+n,cmp);

		int flag=1;

		int sum=0;

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

			sum+=ss[i].a;

			if(sum>ss[i].b){

				flag=0;

				break;

			}

		}

		if(flag) printf("Yes\n");

		else printf("No\n");

	}

	return 0;

}

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

#include <cstdio>

#include <algorithm>

#include <queue>

using namespace std;

#define ll long long 

struct node{

	ll l,r;

	node(ll a,ll b){

		l=a;r=b;

	}

	friend bool operator<(const node &a,const node &b){

		return a.r>b.r;

	}

};

priority_queue<node> q;

ll n,t1,t2;

int main(){

	scanf("%lld",&n);

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

		scanf("%lld%lld",&t1,&t2);

		q.push(node(t1,t2));

	}

	ll sum=0;

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

		node e=q.top();

		q.pop();

		sum+=e.l;

		if(sum>e.r){

			printf("No");

			return 0;

		}

		//cout <<e.l<<" "<<e.r<<endl;

	}

	printf("Yes");

	return 0;

}

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

#include<algorithm>

using namespace std;

struct node{

	int a;

	int b;

}ss[200010];

int cmp(node x,node y){

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

	else return x.b<y.b;

}

int main(){

	int n;

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

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

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

		}

		sort(ss,ss+n,cmp);

		int flag=1;

		int sum=0;

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

			sum+=ss[i].a;

			if(sum>ss[i].b){

				flag=0;

				break;

			}

		}

		if(flag) printf("Yes\n");

		else printf("No\n");

	}

	return 0;

}

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

#include<cstdio>

#include<algorithm>

using namespace std;

int n;

const long long maxn = 1e6;

struct Node{

	int ai,bi;

}node[maxn];

bool cmp(Node a,Node b)

{

	if(a.bi == b.bi) return a.ai < b.ai;

	return a.bi < b.bi;

}

int main(void)

{

	scanf("%d",&n);

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

		scanf("%d %d",&node[i].ai,&node[i].bi);

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

//	int ans = 0;

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

//	{

//		if((ans + node[i].ai) <= node[i].bi) ans += node[i].ai;

//		else{

//			puts("NO");

//			return 0;

//		}

//	}

//	puts("Yes");

	int ans=0;

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

	{

		if(ans+node[i].ai<=node[i].bi)

			ans+=node[i].ai;	

		else

		{

			printf("No\n");

			return 0;

		}

	}

	printf("Yes\n");

	return 0;

}

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

#include<algorithm>

using namespace std;

struct node{

	int a;

	int b;

}ss[200010];

int cmp(node x,node y){

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

	else return x.b<y.b;

}

int main(){

	int n;

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

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

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

		}

		sort(ss,ss+n,cmp);

		int flag=1;

		int sum=0;

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

			sum+=ss[i].a;

			if(sum>ss[i].b){

				flag=0;

				break;

			}

		}

		if(flag) printf("Yes\n");

		else printf("No\n");

	}

	return 0;

}

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

#include <algorithm>

using namespace std;

typedef pair<int, int> P;

int main(void){

    int n, s = 0;

    P p[200000];

    cin >> n;

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

        int a, b;

        cin >> a >> b;

        p[i] = P(b, a);

    }

    sort(p, p+n);

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

        s += p[i].second;

        if(s > p[i].first){

            cout << "No" << endl;

            return 0;

        }

    }

    cout << "Yes" << endl;

}


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

#include <algorithm>

#include <vector>

using namespace std;

typedef pair<int, int> P;

int main(void){

    int n;

    vector<P> p;

    cin >> n;

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

        int a, b;

        cin >> a >> b;

        p.push_back(P(b, a));

    }

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

    int t = 0;

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

        t += p[i].second;

        if(t > p[i].first){

            puts("No");

            return 0;

        }

    }

    puts("Yes");

    return 0;

}


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



using namespace std;

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

#define ll  long long

#define ull unsigned long long

#define mod (ll)(1000000007)

#define endl '\n'

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

#define pi double(acos(-1))

#define S second

#define F first

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

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

// freopen("output.txt","w",stdout);

ll fp(ll n , ll p )

{

    if(p==0)

        return 1 ;

    if(p==1)

        return n%mod ;

    ll res ;

    res = fp(n,p/2)%mod;

    res = (res*res)%mod ;

    if(p%2)

        res = (res*n)%mod ;

    return res;

}





int main()

{

    ENGZ;

    pair<ll,ll> arr[200005] ;

    ll n , a = 0 , b;

    cin>>n ;

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

    {

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

    }

    sort(arr,arr+n);

    bool f = 1 ;

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

    {

        a+=arr[i].S ;

        if(a>arr[i].F)

            f=0 ;

    }

    if(f)cout<<"Yes"<<endl;

    else cout<<"No" <<endl ;

}


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

#include <cstring>

#include <algorithm>

using namespace std;

const int maxd =2e5+10;

struct node

{

    int a,b;

    bool operator < (const node &other) const

    {

        if(b == other.b) return a < other.a;

        return b < other.b;

    }

}a[maxd];

int n;

int main()

{

    // freopen("a.in","r",stdin);

    // freopen("k.out","w",stdout);

    scanf("%d",&n);

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

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

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

    int now = 0;

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

    {

        if(now + a[i].a > a[i].b)

        {

            printf("No\n");

            return 0;

        }

        now += a[i].a;

    }

    printf("Yes\n");

    return 0;

}  

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

#include<algorithm>





using namespace std;

typedef struct 

{

    int finish;

    int must;

}work;

work A[300000];

bool paixu(const work& a, const work& b)

{

        return a.must < b.must;

};

int main()

{

    int n;

    cin>>n;



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

    {

        cin>>A[i].finish>>A[i].must;

    }

    sort(A,A+n,paixu);

    int last;

    last = A[n-1].must - A[n-1].finish;

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

    {

        if(last < A[i].must)

            A[i].must = last;

        else

            last = A[i].must;

        last = last - A[i].finish;

    }

    if(last >= 0)

        cout<<"Yes";

    else

    {

            cout<<"No";

    }

    

    return 0;

}

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

#include <cstring>

#include <algorithm>

using namespace std;

const int maxd =2e5+10;

struct node

{

    int a,b;

    bool operator < (const node &other) const

    {

        if(b == other.b) return a < other.a;

        return b < other.b;

    }

}a[maxd];

int n;

int main()

{

    // freopen("a.in","r",stdin);

    // freopen("k.out","w",stdout);

    scanf("%d",&n);

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

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

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

    int now = 0;

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

    {

        if(now + a[i].a > a[i].b)

        {

            printf("No\n");

            return 0;

        }

        now += a[i].a;

    }

    printf("Yes\n");

    return 0;

}  

// Fastest known solution for this problem:
// Original C++ solution (slower):
#pragma GCC optimize(2)



#include <iostream>

#include <cstdio>

#include <algorithm>



using namespace std;



const int maxn = 2e5 + 10;

const int inf = 0x3f3f3f;



typedef long long ll;



int n;



struct node

{

	int a, b;

};



node da[maxn];



int read()

{

	int x;

	scanf("%d", &x);

	return x;

}



bool cmp(node x, node y)

{

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

	else return x.a < y.a;

}



int main()

{

	n = read();

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

	{

		da[i].a = read();

		da[i].b = read();

	}

	

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

	/*

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

	{

		cout << da[i].a << " " << da[i].b << endl;

	}

	*/

	int time = 0;

	

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

	{

		if(time + da[i].a <= da[i].b)time += da[i].a;

		else 

		{

			cout << "No" << endl;

			return 0;

		}

	}

	cout << "Yes" << endl;

	return 0;

}

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

#include <cstring>

#include <algorithm>

using namespace std;

const int maxd =2e5+10;

struct node

{

    int a,b;

    bool operator < (const node &other) const

    {

        if(b == other.b) return a < other.a;

        return b < other.b;

    }

}a[maxd];

int n;

int main()

{

    // freopen("a.in","r",stdin);

    // freopen("k.out","w",stdout);

    scanf("%d",&n);

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

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

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

    int now = 0;

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

    {

        if(now + a[i].a > a[i].b)

        {

            printf("No\n");

            return 0;

        }

        now += a[i].a;

    }

    printf("Yes\n");

    return 0;

}  

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

#include <vector>

#include <set>

#include <algorithm>

#include <queue>



using namespace std;



bool DEBUG = false;



bool cmp(pair<int,int> a, pair<int,int> b) {

    return a.second > b.second || a.second == b.second && a.first > b.first;

}



int main(){

    int n,a,b;

    priority_queue<pair<int,int>, vector<pair<int,int> >, bool(*)(pair<int,int>,pair<int,int>)> pq(cmp);

    cin >>n;

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

        cin >>a >>b;

        pq.push(make_pair(a,b));

    }

    

    int time = 0;

    bool success = true;

    while(!pq.empty()){

        pair<int,int> task = pq.top();

        pq.pop();

        

        if(DEBUG){

            cout <<"Time=" <<time <<endl;

            cout <<"Task=" <<task.first <<" " <<task.second <<endl;

        }

        

        if(task.second < time + task.first){

            success = false;

            break;

        }

        else{

            time += task.first;

        }

    }

    

    if(success) cout <<"Yes";

    else cout <<"No";

    cout <<endl;

}

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

#include <cstring>

#include <algorithm>

using namespace std;

const int maxd =2e5+10;

struct node

{

    int a,b;

    bool operator < (const node &other) const

    {

        if(b == other.b) return a < other.a;

        return b < other.b;

    }

}a[maxd];

int n;

int main()

{

    // freopen("a.in","r",stdin);

    // freopen("k.out","w",stdout);

    scanf("%d",&n);

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

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

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

    int now = 0;

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

    {

        if(now + a[i].a > a[i].b)

        {

            printf("No\n");

            return 0;

        }

        now += a[i].a;

    }

    printf("Yes\n");

    return 0;

}  

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



using namespace std;



#define ll long long







int main()

{

    int n, last = 0;

    bool ok = 1;

    cin >> n;

    vector <pair <int, int>> b;

    vector <int> time(n);

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

        int x, y;

        cin >> x >> y;

        b.push_back({y, x});

    }



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



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

        time[i] = last + b[i].second;

        last = time[i];

        if (time[i] > b[i].first)

            ok = 0;

    }



    if (ok)

        cout << "Yes";

    else

        cout << "No";



    return 0;

}


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

#include <cstring>

#include <algorithm>

using namespace std;

const int maxd =2e5+10;

struct node

{

    int a,b;

    bool operator < (const node &other) const

    {

        if(b == other.b) return a < other.a;

        return b < other.b;

    }

}a[maxd];

int n;

int main()

{

    // freopen("a.in","r",stdin);

    // freopen("k.out","w",stdout);

    scanf("%d",&n);

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

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

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

    int now = 0;

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

    {

        if(now + a[i].a > a[i].b)

        {

            printf("No\n");

            return 0;

        }

        now += a[i].a;

    }

    printf("Yes\n");

    return 0;

}  

// Fastest known solution for this problem: