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



using namespace std;



int main()

{

    long long sum=0;

    int a[300009]={0},n,i,ind;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+(3*n));

    ind=3*n-2;

    for(i=3*n-2;i>=n;i-=2)

    {

        sum+=(long long)a[i];

    }

    cout<<sum;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 2.1394878671837803x):
/**Which of the favors of your Lord will you deny ?**/



#include<bits/stdc++.h>

using namespace std;



#define LL long long

#define PII pair<int,int>

#define PLL pair<LL,LL>

#define MP make_pair

#define F first

#define S second

#define INF INT_MAX



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

#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl



#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;



template<class TIn>

using indexed_set = tree<

                    TIn, null_type, less<TIn>,

                    rb_tree_tag, tree_order_statistics_node_update>;



/*

PBDS

-------------------------------------------------

1) insert(value)

2) erase(value)

3) order_of_key(value) // 0 based indexing

4) *find_by_order(position) // 0 based indexing



*/



inline void optimizeIO()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

}



const int nmax = 3e5+7;

const LL LINF = 1e17;



string to_str(LL x)

{

    stringstream ss;

    ss<<x;

    return ss.str();

}



//bool cmp(const PII &A,const PII &B)

//{

//

//}



LL ara[nmax];



int main()

{

    optimizeIO();



    LL n;

    cin>>n;



    LL v = 3*n;



    for(LL i=1;i<=v;i++)

    {

        cin>>ara[i];

    }



    sort(ara+1,ara+v+1);



    LL ans = 0;



    for(LL i=n+1;i<=v;i+=2)

        ans += ara[i];



    cout<<ans<<endl;



    return 0;

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



using namespace std;



int main()

{

    long long sum=0;

    int a[300009]={0},n,i,ind;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+(3*n));

    ind=3*n-2;

    for(i=3*n-2;i>=n;i-=2)

    {

        sum+=(long long)a[i];

    }

    cout<<sum;

    return 0;

}


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

using namespace std;

using ll = long long;

//>:(

void solve() {

    int N;

    cin >> N;

    vector<ll> v(3*N);

    for(int i=0;i<3*N;i++) cin >> v[i];

    sort(v.begin(),v.end(),greater<ll>());

    ll sum=0;

    for(int i=0,j=1;i<N;i++,j+=2) sum+=v[j];

    cout << sum << "\n";

}



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);



    solve();

    return 0;

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



using namespace std;



int main()

{

    long long sum=0;

    int a[300009]={0},n,i,ind;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+(3*n));

    ind=3*n-2;

    for(i=3*n-2;i>=n;i-=2)

    {

        sum+=(long long)a[i];

    }

    cout<<sum;

    return 0;

}


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

using namespace std;

using ll = long long;



void solve() {

    int N;

    cin >> N;

    vector<ll> v(3*N);

    for(int i=0;i<3*N;i++) cin >> v[i];

    sort(v.begin(),v.end(),greater<ll>());

    ll sum=0;

    for(int i=0,j=1;i<N;i++,j+=2) sum+=v[j];

    cout << sum << "\n";

}



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);



    solve();

    return 0;

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



using namespace std;



int main()

{

    long long sum=0;

    int a[300009]={0},n,i,ind;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+(3*n));

    ind=3*n-2;

    for(i=3*n-2;i>=n;i-=2)

    {

        sum+=(long long)a[i];

    }

    cout<<sum;

    return 0;

}


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



using namespace std;



#define LL           long long

#define ULL          long long unsigned

#define LD           long double

#define ff              first

#define ss              second

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

#define FLR(i,n)     for(LL i=0;i<n;i++)

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

#define RFLR(i,n)    for(LL i=n-1;i>=0;i--)

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

#define repl(i,a,b)  for(LL i=a;i<=b;i++)

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

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

#define ABS(x)       ((x)<0?-(x):(x))

#define NL           "\n"

#define pb           push_back

#define mk              make_pair

#define pi           acos(-1.0)

#define prec(n)      fixed << setprecision(n)

#define sq(a)          (a)*(a)

#define asi          cout<<"check"<<" ";

#define all_set(arr,val) memset(arr,val,sizeof(arr))



int main()

{

    fast;

    LL i,j,k,x,sum=0,n,kount=0;

    vector<LL>vec;

    cin>>n;

    FLR(i,3*n){

        cin>>x;

        vec.pb(x);

    }

    sort(all(vec));

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

        sum+=vec[i];

        kount++;

        //cout<<vec[i]<<NL;

        if(kount==n)break;

    }

    cout<<sum;

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



using namespace std;



int main()

{

    long long sum=0;

    int a[300009]={0},n,i,ind;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+(3*n));

    ind=3*n-2;

    for(i=3*n-2;i>=n;i-=2)

    {

        sum+=(long long)a[i];

    }

    cout<<sum;

    return 0;

}


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



using namespace std;



int main()

{

    long long n;

    cin >> n;



    vector<long long> participant(3 * n);



    for (long long &strength : participant)

        cin >> strength;



    sort(participant.begin(), participant.end(), greater<int>());



    long long answer = 0;

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

        answer += participant[2 * i + 1];



    cout << answer << endl;

    

    return 0;

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



using namespace std;



int main()

{

    long long sum=0;

    int a[300009]={0},n,i,ind;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+(3*n));

    ind=3*n-2;

    for(i=3*n-2;i>=n;i-=2)

    {

        sum+=(long long)a[i];

    }

    cout<<sum;

    return 0;

}


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

#include<math.h>

using namespace std;

int main()

{

    long long int n,sum=0;

    cin>>n;

    long long int arr[3*n+1];

    for(long long int i=0;i<3*n;i++)

    {

        cin>>arr[i];

    }

    sort(arr,arr+3*n,greater<long long>());

    for(long long int i=1;i<=2*n;i=i+2)

    {

        sum=sum+arr[i];



    }

    cout<<sum<<endl;



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



using namespace std;



int main()

{

    long long sum=0;

    int a[300009]={0},n,i,ind;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+(3*n));

    ind=3*n-2;

    for(i=3*n-2;i>=n;i-=2)

    {

        sum+=(long long)a[i];

    }

    cout<<sum;

    return 0;

}


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

#define fr(i,j,n)   for(int i=j;i<n;i++)

#define pb          push_back

#define rf(i,j,p)   for(int i=p;i>=j;i--)

#define vi          vector<int>

#define vll         vector<long long>

#define ll          long long

#define hmm         "\n"

#define sp          " "

#define srt(v)      sort(v.begin(), v.end());

#define down        cout<<hmm;

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

using namespace std;

int main()

{

 int n ; cin >> n ;

 int a[3*n];

 fr(i,0,3*n)cin>>a[i];

 sort(a,a+3*n);

 int i = 2 ; ll sum = 0, cnt=0 ;

 while(cnt<n)

 {

     sum+=a[3*n-i];

     i+=2;

     cnt++;

     

 }

cout<<sum<<hmm;

 //return main();

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



using namespace std;



int main()

{

    long long sum=0;

    int a[300009]={0},n,i,ind;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+(3*n));

    ind=3*n-2;

    for(i=3*n-2;i>=n;i-=2)

    {

        sum+=(long long)a[i];

    }

    cout<<sum;

    return 0;

}


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

using namespace std;



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

#define ll long long 

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

#define Debug cout<<endl<<"I AM IRONMAN"<<endl



int main ()

{

    fastio;

    vector<ll> v;

    ll sum=0;

    int n;

    cin >> n;

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

    {

        int t;

        cin >> t;

        v.push_back(t);

    }

    sort(v.begin(),v.end(),greater<int>());

    int j=1;

    for(auto i: v)

    {

        if(j%2==0)

        {

            sum+=i;

        }

        if(j==(n*2))

        {

            break;

        }

        j++;

    }

    cout << sum;

    return 0;

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



using namespace std;



int main()

{

    long long sum=0;

    int a[300009]={0},n,i,ind;

    scanf("%d",&n);

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

    {

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

    }

    sort(a,a+(3*n));

    ind=3*n-2;

    for(i=3*n-2;i>=n;i-=2)

    {

        sum+=(long long)a[i];

    }

    cout<<sum;

    return 0;

}


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

#include <bits/stdc++.h>

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

#define endl '\n'

using namespace std;

int main()

{

    fastio;

    long long n,i,sum=0,temp=0;

    cin>>n;

    long long a[3*n];

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

    {

        cin>>a[i];

    }

    sort(a,a+3*n);

    for(i=3*n-2; ;i=i-2)

    {

        if(temp==n)

        {

            break;

        }

        sum=sum+a[i];

        temp++;

    }

    cout<<sum;

    return 0;

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

#include<iomanip>

#include<math.h>

#include<vector>

#include<algorithm>

#include<set>

#include<map>

#include<queue>

#include<stack>

#include<string>

#define INF 1000000000ll

#define MOD 1000000007ll

#define EPS 1e-8

#define REP(i,m) for(long long i=0; i<m; ++i)

#define FOR(i,n,m) for(long long i=n; i<m; ++i)

#define DUMP(n,a) for(long long i=0; i<n; ++i) { cout<<a[i]; if(i!=n-1) cout<<" "; else cout<<endl; }

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

#define pb push_back

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

typedef long double ld;

typedef vector<int> vi;

typedef vector<vector<int> > vii;

typedef vector<long long> vl;

typedef vector<vector<long long> > vll;

typedef vector<P> vp;

typedef vector<vector<P> > vpp;

int main() {

	ios::sync_with_stdio(false);

	int n;

	cin>>n;

	vector<ll> a(3*n);

	REP(i,3*n) cin>>a[i];

	sort(ALL(a));

	ll res=0;

	REP(i,n) {

		res+=a[3*n-2-2*i];

	}

	cout<<res<<endl;

}


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

#include<algorithm>



using namespace std;



int N;

int A[300005];



int main(){

	scanf("%d", &N);

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

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

	}

	sort(A, A+3*N);

	long long tot = 0;

	for(int i=N;i<3*N;i+=2){

		tot += (long long)A[i];

	}

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

	return 0;

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

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

#define INF 1<<30

#define LINF 1LL<<60



int main(void) {

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

    ll N; cin >> N;

    vector<ll> a(3*N);

    for(auto &in:a)cin >> in;

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

    ll res = 0;

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

        res += a[3*N - 2*(i+1)];

    }

    cout << res << endl;

    return 0;

}


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

#include<algorithm>



using namespace std;



int N;

int A[300005];



int main(){

	scanf("%d", &N);

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

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

	}

	sort(A, A+3*N);

	long long tot = 0;

	for(int i=N;i<3*N;i+=2){

		tot += (long long)A[i];

	}

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

	return 0;

}
// Slower C++ solution:
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

#include <sstream>

#include <iomanip>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <cctype>

#include <cstring>

#include <vector>

#include <list>

#include <queue>

#include <deque>

#include <stack>

#include <map>

#include <set>

#include <algorithm>

#include <iterator>

#include <bitset>

#include <ctime>

#include<complex>

using namespace std;



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

#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)

#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define FILL(a,value) memset(a, value, sizeof(a))



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

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

#define PB push_back

#define MP make_pair



typedef long long LL;

typedef vector<int> VI;

typedef pair<int, int> PII;



const double PI = acos(-1.0);

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

const LL LINF = INF * (LL)INF;



const int MAX = 3 * 1000 * 100 + 47;



int A[MAX];



int main()

{

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

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

	//ios::sync_with_stdio(false); cin.tie(0);

	int n;

	cin >> n;

	FOR(i, 0, 3 * n) cin >> A[i];

	sort(A, A + 3 * n);

	reverse(A, A + 3 * n);

	LL s = 0;

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

	{

		s += A[i];

	}



	cout << s << endl;	

}

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

#include<algorithm>



using namespace std;



int N;

int A[300005];



int main(){

	scanf("%d", &N);

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

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

	}

	sort(A, A+3*N);

	long long tot = 0;

	for(int i=N;i<3*N;i+=2){

		tot += (long long)A[i];

	}

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

	return 0;

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

#include<algorithm>

#include<string>

#include<vector>

#include<math.h>

#include<map>

#include<functional>

#include<queue>

#include<stack>

using namespace std;

int main(){

    int n;

    cin>>n;

    int a[364364]={};

    long long int ans=0;

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

        cin>>a[i];

    }

    sort(a,a+(3*n),greater<int>());

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

        ans+=a[i];

    }

    cout<<ans<<endl;

}   






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

using namespace std;

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

typedef long long int ll;

typedef pair<int,int> P;

const ll MOD=1000000007;

const ll INF=1000000010;

const ll LINF=4000000000000000010LL;

const int MAX=310;

const double EPS=1e-9;

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

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

int main(){

	int n;cin>>n;

	ll a[300010];

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

		cin>>a[i];

	}

	sort(a,a+3*n);

	ll ans=0;

	for(int i=n;i<3*n-1;i+=2){

		ans+=a[i];

	}

	cout<<ans<<endl;

	return 0;

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

#include<string>

#include<algorithm>	

#include<cmath>

using namespace std;

int main() {

	long long n, sum = 0; cin >> n;

	int a[300000] = { 0 };

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

		cin >> a[i];

	}

	sort(a, a + n * 3);

	for (int h = n; h < n * 3; h++) {

		sum += a[h];

		h++;

	}

	cout << sum << endl;

	cin >> n;

}

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

#include<string>

#include<algorithm>    

#include<cmath>

#include<map>

#include<vector>

#include<math.h>

#include<stdio.h>

#include<stack>

#include<queue>

#include<tuple>

#include<cassert>

#include<set>

#define int long long

#define mod(int)(1000000007)

using namespace std;

int test[313456];

signed main() {

	int n, m = 0, a, ans = 0; cin >> n;

	for (int h = 0; h < n * 3; h++) {

		cin >> test[h];

	}

	sort(test, test + (n * 3));

	m = (n * 3 - 2) % 2;

	for (int h = n * 3 - 2; h >= n; h--) {

		if (h % 2 == m) {

			ans += test[h];

		}

	}

	cout << ans << endl;

	return 0;

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

#include <vector>

#include <algorithm>

using namespace std;



int n;



struct Task

{

    int TimeLong = -1;

    int Limit = -1;

    Task(int timeLong, int limit)

    {

        TimeLong = timeLong;

        Limit = limit;

    }

};

vector<Task> vec;



int main(int argc, char *argv[])

{

    cin >> n;

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

    {

        int timeLong, limit;

        cin >> timeLong >> limit;

        vec.emplace_back(Task(timeLong, limit));

    }

    sort(vec.begin(), vec.end(), [](Task x, Task y)->bool{

        return x.Limit < y.Limit;

    });

    int sum = 0;

    for (Task item : vec)

    {

        sum += item.TimeLong;

    }

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

    {

        if (sum > vec[i].Limit)

        {

            cout << "No" << endl;

            return 0;

        }

        sum -= vec[i].TimeLong;

    }

    cout << "Yes" << endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.234779128735484x):
#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;

}
// Slower C++ solution:
#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;

}




// Faster C++ solution for the same problem (measured speedup: 5.216918087101583x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.313517019889634x):
#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;

}
// Slower C++ solution:
#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"; }

// Faster C++ solution for the same problem (measured speedup: 5.318075076761045x):
#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;

}