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

using namespace std;

inline void boost(){ 

	ios_base::sync_with_stdio(0); 

	cin.tie(0); 

}



int f[90001];

int main(){

	boost();

	int h,w,d;

	cin>>h>>w>>d;

	map <int, pair <int, int> >adr;

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

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

			int x;

			cin>>x;

			adr[x].first = i;

			adr[x].second = j;

		}

	}

	for(int i=1; i<=h*w; i++){

			if( i <= d)

				f[i] = 0;

			else{

				f[i] = f[i-d] + abs(adr[i].first - adr[i-d].first) + abs(adr[i].second - adr[i-d].second);

			}

	}

	int q;

	cin>>q;

	int z,y;

	vector <int> ans;

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

		cin>>z>>y;

		ans.push_back(f[y] - f[z]);

	}

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

		cout<<ans[i]<<endl;

	}

}

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

#define abs(x) ((x>0)?x:(-(x)))

int H,W,D,A;

int Q,L,R;

int px[90001] ,py [90001];

int d[90001];

int  main()

{

    scanf ("%d %d %d",&H,&W,&D);

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

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

            scanf ("%d",&A);

            px[A]=i,py[A]=j;

        }

    }

    for(int i=D+1;i<=H*W;i++){ 

        d[i]=d[i-D]+abs(px[i]-px[i-D])+ abs(py[i]-py[i-D]);

    } 

    scanf ("%d",&Q);

    while(Q--){ 

        scanf ("%d%d",&L,&R);

        printf ("%d\n",d[R]-d[L]);

    } 

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

#include <cstdio>

#include <algorithm>

using namespace std;

int n, h, a[100005], b[100005], ma, sb, ans;

int main() {

	int i;

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

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

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

		ma = max(ma, a[i]);

	}

	sort(b, b+n);

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

		ans++;

		h -= max(b[i], ma);

		if(h<=0) break;

	}

	if(h>0) {

		ans += (h+ma-1)/ma;

	}

	cout<<ans;

	return 0;

}

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

#include <algorithm>

using namespace std;

int n, h, a, b[100005], ma, ans;

int main() {

	int i;

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

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

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

		ma = max(ma, a);

	}

	sort(b, b+n);

	for(i=n-1; i>=0 && h>0; i--) {

		ans++;

		h -= max(b[i], ma);

	}

	if(h>0) ans += (h+ma-1)/ma;

	printf("%d", ans);

	return 0;

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

using namespace std;

typedef long long ll;

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

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

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define Would

#define you

#define please



int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);



	int N, H;

	cin >> N >> H;

	int a[100000] = {};

	int b[100000] = {};

	rep(i, N) {

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

	}



	sort(a, a + N);

	sort(b, b + N);



	int saidai = a[N - 1];



	int kaisuu = 0;

	rep(i, N) {

		if (b[N - i - 1] > saidai) {

			kaisuu++;

			H -= b[N - i - 1];

			if (H <= 0) break;

		}

	}

	

	if (H > 0) {

		kaisuu += H / saidai;

		if (H % saidai) kaisuu++;

	}

	co(kaisuu);

	Would you please return 0;

}

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

using namespace std;

typedef long long ll;

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

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

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define Would

#define you

#define please



int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);



	int N, H;

	cin >> N >> H;

	int saidai = 0;

	int b[100000];

	rep(i, N) {

		int a;

		cin >> a >> b[i];

		saidai = max(saidai, a);

	}



	sort(b, b + N);



	int kaisuu = 0;

	rep(i, N) {

		if (b[N - i - 1] > saidai) {

			kaisuu++;

			H -= b[N - i - 1];

			if (H <= 0) break;

		}

	}



	if (H > 0) {

		kaisuu += (H + saidai - 1) / saidai;

	}

	co(kaisuu);



	Would you please return 0;

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

using namespace std;

typedef long long ll;

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

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

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define Would

#define you

#define please



int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);



	int N, H;

	cin >> N >> H;

	int a[100000] = {};

	int b[100000] = {};

	rep(i, N) {

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

	}



	sort(a, a + N);

	sort(b, b + N);



	int saidai = a[N - 1];



	int kaisuu = 0;

	rep(i, N) {

		if (b[N - i - 1] > saidai) {

			kaisuu++;

			H -= b[N - i - 1];

			if (H <= 0) break;

		}

	}

	

	if (H > 0) {

		kaisuu += H / saidai;

		if (H % saidai) kaisuu++;

	}

	co(kaisuu);

	Would you please return 0;

}

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

#include<cstdio>

#include<algorithm>

using namespace std;

typedef long long ll;

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

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

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define Would

#define you

#define please



const int cm = 1 << 17;

char cn[cm], * ci = cn + cm, ct;

inline char getcha() {

	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }

	return *ci++;

}

inline int getint() {

	int A = 0;

	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';

	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';

	return A;

}



void pakuri_sort(int N, int A[]) {

	const int b = 8;

	int tmp[100001];

	rep(k, 4) {

		int kazu[1 << b] = {}, kazu2[1 << b] = {};

		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;

		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];

		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];

		k++;

		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;

		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];

		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];

	}

}



int main() {

	//cin.tie(0);

	//ios::sync_with_stdio(false);



	int N = getint(), H = getint();

	int saidai = 0;

	int b[100000];

	rep(i, N) {

		saidai = max(saidai, getint());

		b[i] = getint();

	}



	pakuri_sort(N, b);



	int kaisuu = 0;

	rep(i, N) {

		if (b[N - i - 1] > saidai) {

			kaisuu++;

			H -= b[N - i - 1];

			if (H <= 0) break;

		}

	}



	if (H > 0) {

		kaisuu += (H + saidai - 1) / saidai;

	}

	printf("%d", kaisuu);



	Would you please return 0;

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

using namespace std;

typedef long long ll;

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

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

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define Would

#define you

#define please



int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);



	int N, H;

	cin >> N >> H;

	int saidai = 0;

	int b[100000];

	rep(i, N) {

		int a;

		cin >> a >> b[i];

		saidai = max(saidai, a);

	}



	sort(b, b + N);



	int kaisuu = 0;

	rep(i, N) {

		if (b[N - i - 1] > saidai) {

			kaisuu++;

			H -= b[N - i - 1];

			if (H <= 0) break;

		}

	}



	if (H > 0) {

		kaisuu += (H + saidai - 1) / saidai;

	}

	co(kaisuu);



	Would you please return 0;

}

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

#include<cstdio>

#include<algorithm>

using namespace std;

typedef long long ll;

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

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

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define Would

#define you

#define please



const int cm = 1 << 17;

char cn[cm], * ci = cn + cm, ct;

inline char getcha() {

	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }

	return *ci++;

}

inline int getint() {

	int A = 0;

	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';

	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';

	return A;

}



void pakuri_sort(int N, int A[]) {

	const int b = 8;

	int tmp[100001];

	rep(k, 4) {

		int kazu[1 << b] = {}, kazu2[1 << b] = {};

		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;

		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];

		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];

		k++;

		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;

		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];

		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];

	}

}



int main() {

	//cin.tie(0);

	//ios::sync_with_stdio(false);



	int N = getint(), H = getint();

	int saidai = 0;

	int b[100000];

	rep(i, N) {

		saidai = max(saidai, getint());

		b[i] = getint();

	}



	pakuri_sort(N, b);



	int kaisuu = 0;

	rep(i, N) {

		if (b[N - i - 1] > saidai) {

			kaisuu++;

			H -= b[N - i - 1];

			if (H <= 0) break;

		}

	}



	if (H > 0) {

		kaisuu += (H + saidai - 1) / saidai;

	}

	printf("%d", kaisuu);



	Would you please return 0;

}
// Slower C++ solution:
// 基本テンプレート

 

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <string>

#include <cstring>

#include <deque>

#include <list>

#include <queue>

#include <stack>

#include <vector>

#include <utility>

#include <algorithm>

#include <map>

#include <set>

#include <complex>

#include <cmath>

#include <limits>

#include <cfloat>

#include <climits>

#include <ctime>

#include <cassert>

#include <numeric>

#include <fstream>

#include <functional>

using namespace std;

 

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

#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)

#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)

#define debug(...) fprintf(stderr, __VA_ARGS__)

#define int long long int

 

template<typename T> void chmax(T &a, T b) {a = max(a, b);}

template<typename T> void chmin(T &a, T b) {a = min(a, b);}

template<typename T> void chadd(T &a, T b) {a = a + b;}

 

typedef pair<int, int> pii;

typedef long long ll;

 

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

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

const ll INF = 1001001001001001LL;

const ll MOD = 1000000007LL;



int N, H;

int A[100010], B[100010];



int solve() {

    int rest = H, cnt = 0;

    int dam = A[0];

    rep(i,0,N) {

        if(dam > B[i]) break;

        rest -= B[i];

        cnt++;

        if(rest <= 0) return cnt;

    }



    cnt += (rest + dam - 1) / dam;

    return cnt;

}

 

signed main() {

    cin >> N >> H;

    rep(i,0,N) {

        cin >> A[i] >> B[i];

    }

    sort(A, A+N, greater<int>());

    sort(B, B+N, greater<int>());



    cout << solve() << endl;

    return 0;

}

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

#include <algorithm>

using namespace std;

using Int = long long int;





const Int INF = 1LL << 30;

const int S = 100000;

Int N, H;

Int A[S+10], B[S+10];



int main() {

    scanf("%lld%lld", &N, &H);

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

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

    }

    sort(A, A+N);

    sort(B, B+N);

    reverse(A, A+N);

    reverse(B, B+N);



    Int ub = INF, lb = -1;

    while(ub - lb > 1) {

        Int mid = (ub + lb) / 2;



        Int HP = H, rest = mid;

        for(int i=0; i<N && HP>0 && rest>0 && B[i] >= A[0]; i++, rest--) {

            HP -= B[i];

        }



        bool ok = (HP <= 0);

        if(!ok) {

            Int ope = (HP + A[0] - 1) / A[0];

            ok |= (ope <= rest);

        }



        (ok ? ub : lb) = mid;

    }



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

    return 0;

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

using namespace std;



int main(){

  int n, h;

  int a[100001] = {};

  int b[100001] = {};

  cin >> n >> h;

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

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

  int sum = 0;;

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

    if(h <= 0 || b[i] < a[n-1]) break;

    h -= b[i]; sum++;

  }

  if(h > 0){

    sum += h / a[n-1];

    sum += (h % a[n-1] > 0) ? 1 : 0;

  }

  cout << sum << endl;

  return 0;

}


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

#define ll long long

#define p pair<int, int>

using namespace std;



int main() {

    int n;

    ll h;

    cin >> n >> h;

    vector<p> v;

    int ma = -1;

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

        int a, b;

        cin >> a >> b;

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

        ma = max(ma, a);

    }

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

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

    int ans = 0;

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

        if (ma <= v[i].first) {

            h -= v[i].first;

            ans++;

        }

        if (ma > v[i].first || h <= 0) break;

    }

    if (h > 0) {

        ans += h / ma;

        if (h % ma != 0) ans++;

    }

    cout << ans << endl;

    return 0;

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

#include <cstdlib>

#include <iomanip>

#include <cmath>

#include <string>

#include <cstring>

#include <algorithm>

#include <vector>

#include <sstream>

#include <set>

#include <queue>

#include <stack>

#include <cctype>

#include <map>

#include <climits>

#include <bitset>

using namespace std;

#define MATH_PI 3.14159265358979323846

struct Knife{

	int iHurt;

	int iType=0;

}arrKnives[1000000];



bool cmp(Knife nifKnife1, Knife nifKnife2){

	return (nifKnife1.iHurt>nifKnife2.iHurt);

}



int main(){

	ios::sync_with_stdio(false);

	int n, iHP;

	register int i,c = 0;

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

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

		scanf("%d", &arrKnives[c].iHurt);

		++c;

		arrKnives[c].iType = 1;

		scanf("%d", &arrKnives[c].iHurt);

		++c;

	}

	sort(arrKnives, arrKnives + c, cmp);

	int iSum = 0;

	for (i = 0; i<c; ++i){

		if (arrKnives[i].iType == 1){

			++iSum;

			iHP -= arrKnives[i].iHurt;

			if (iHP <= 0){

				printf("%d", iSum);

				break;

			}

		}

		else if (arrKnives[i].iType != 1){

			if (iHP%arrKnives[i].iHurt == 0)

				iSum += iHP / arrKnives[i].iHurt;

			else 

				iSum += iHP / arrKnives[i].iHurt + 1;

			printf("%d", iSum);

			break;

		}

	}

endapp:

	//system("pause > nul");

	return 0;

}

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



using namespace std;



struct p{

    int l;

    int r;

}a[1000000];



bool cmp(p xx,p yy){

    return xx.l>yy.l;

}



int main(){

    int n,h;

    int c=0;

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

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

    {

        scanf("%d",&a[c++].l);

        a[c].r=1;

        scanf("%d",&a[c++].l);

    }

    sort(a,a+c,cmp);

    int sum=0;

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

    {

        if(a[i].r==1)

        {

            sum++;

            h-=a[i].l;

            if(h<=0)

            {

                printf("%d",sum);

                return 0;

            }

        }

        else if(a[i].r!=1)

        {

            if(h%a[i].l==0) sum+=h/a[i].l;

            else sum+=h/a[i].l+1;

            printf("%d",sum);

            return 0;



        }

    }

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

#include <cstdlib>

#include <iomanip>

#include <cmath>

#include <string>

#include <cstring>

#include <algorithm>

#include <vector>

#include <sstream>

#include <set>

#include <queue>

#include <stack>

#include <cctype>

#include <map>

#include <climits>

#include <bitset>

using namespace std;

#define MATH_PI 3.14159265358979323846

struct Knife{

	int iHurt;

	int iType=0;

}arrKnives[1000000];



bool cmp(Knife nifKnife1, Knife nifKnife2){

	return (nifKnife1.iHurt>nifKnife2.iHurt);

}



int main(){

	ios::sync_with_stdio(false);

	int n, iHP;

	register int i,c = 0;

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

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

		scanf("%d", &arrKnives[c].iHurt);

		++c;

		arrKnives[c].iType = 1;

		scanf("%d", &arrKnives[c].iHurt);

		++c;

	}

	sort(arrKnives, arrKnives + c, cmp);

	int iSum = 0;

	for (i = 0; i<c; ++i){

		if (arrKnives[i].iType == 1){

			++iSum;

			iHP -= arrKnives[i].iHurt;

			if (iHP <= 0){

				printf("%d", iSum);

				break;

			}

		}

		else if (arrKnives[i].iType != 1){

			if (iHP%arrKnives[i].iHurt == 0)

				iSum += iHP / arrKnives[i].iHurt;

			else 

				iSum += iHP / arrKnives[i].iHurt + 1;

			printf("%d", iSum);

			break;

		}

	}

endapp:

	//system("pause > nul");

	return 0;

}

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

using namespace std;

struct p

{

    int l;

    int r;

}a[1000000];

bool cmp(p xx,p yy)

{

    return xx.l>yy.l;

}



int main()

{

    int n,h,wsq=0;;

    int c=0;

    cin>>n>>h;

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

    {

        cin>>a[c++].l;

        a[c].r=1;

        cin>>a[c++].l;

    }

    sort(a,a+c,cmp);

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

    {

        if(a[i].r==1)

        {

            wsq++;

            h-=a[i].l;

            if(h<=0)

            {

                cout<<wsq<<endl;

                return 0;

            }

        }

        else if(a[i].r!=1)

        {

            if(h%a[i].l==0) 

			wsq+=h/a[i].l;

            else 

			wsq+=h/a[i].l+1;

            cout<<wsq<<endl;

            return 0;

        }

    }

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

#include <cstdlib>

#include <iomanip>

#include <cmath>

#include <string>

#include <cstring>

#include <algorithm>

#include <vector>

#include <sstream>

#include <set>

#include <queue>

#include <stack>

#include <cctype>

#include <map>

#include <climits>

#include <bitset>

using namespace std;

#define MATH_PI 3.14159265358979323846

struct Knife{

	int iHurt;

	int iType=0;

}arrKnives[1000000];



bool cmp(Knife nifKnife1, Knife nifKnife2){

	return (nifKnife1.iHurt>nifKnife2.iHurt);

}



int main(){

	ios::sync_with_stdio(false);

	int n, iHP;

	register int i,c = 0;

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

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

		scanf("%d", &arrKnives[c].iHurt);

		++c;

		arrKnives[c].iType = 1;

		scanf("%d", &arrKnives[c].iHurt);

		++c;

	}

	sort(arrKnives, arrKnives + c, cmp);

	int iSum = 0;

	for (i = 0; i<c; ++i){

		if (arrKnives[i].iType == 1){

			++iSum;

			iHP -= arrKnives[i].iHurt;

			if (iHP <= 0){

				printf("%d", iSum);

				break;

			}

		}

		else if (arrKnives[i].iType != 1){

			if (iHP%arrKnives[i].iHurt == 0)

				iSum += iHP / arrKnives[i].iHurt;

			else 

				iSum += iHP / arrKnives[i].iHurt + 1;

			printf("%d", iSum);

			break;

		}

	}

endapp:

	//system("pause > nul");

	return 0;

}

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

#include<cstdio>

#include<algorithm>

using namespace std;

inline int read(){

    int f=1,x=0;char c=getchar();

    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}

    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}

    return f*x;

} 

int POW(int a,int b,int c){

    int ans=1;

    while(b){

        if(b&1)ans=(ans*a)%c;

        a=(a*a)%c;

        b>>=1; 

    }

    return ans%c;

}

struct node{

    int x,y;

}; 

node s[1001000];

int cmp(node x,node y){

    return x.x>y.x;

}

int main(){

    std::ios::sync_with_stdio(false);

    int n=read(),m=read();

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

        s[i].x=read();

        s[i+1].y=1;

        s[i+1].x=read();

    }

    int ans=0;

    sort(s+1,s+2*n+1,cmp);

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

        if(s[i].y==1){

            m=m-s[i].x;

            ans++;

        }

        else{

            if(m%s[i].x==0){

                cout<<ans+m/s[i].x;

            }

            else cout<<ans+1+m/s[i].x;

            return 0;

        }

        if(m<=0){

            cout<<ans;

            return 0;

        }

    }

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

#include <cstdlib>

#include <iomanip>

#include <cmath>

#include <string>

#include <cstring>

#include <algorithm>

#include <vector>

#include <sstream>

#include <set>

#include <queue>

#include <stack>

#include <cctype>

#include <map>

#include <climits>

#include <bitset>

using namespace std;

#define MATH_PI 3.14159265358979323846

struct Knife{

	int iHurt;

	int iType=0;

}arrKnives[1000000];



bool cmp(Knife nifKnife1, Knife nifKnife2){

	return (nifKnife1.iHurt>nifKnife2.iHurt);

}



int main(){

	ios::sync_with_stdio(false);

	int n, iHP;

	register int i,c = 0;

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

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

		scanf("%d", &arrKnives[c].iHurt);

		++c;

		arrKnives[c].iType = 1;

		scanf("%d", &arrKnives[c].iHurt);

		++c;

	}

	sort(arrKnives, arrKnives + c, cmp);

	int iSum = 0;

	for (i = 0; i<c; ++i){

		if (arrKnives[i].iType == 1){

			++iSum;

			iHP -= arrKnives[i].iHurt;

			if (iHP <= 0){

				printf("%d", iSum);

				break;

			}

		}

		else if (arrKnives[i].iType != 1){

			if (iHP%arrKnives[i].iHurt == 0)

				iSum += iHP / arrKnives[i].iHurt;

			else 

				iSum += iHP / arrKnives[i].iHurt + 1;

			printf("%d", iSum);

			break;

		}

	}

endapp:

	//system("pause > nul");

	return 0;

}

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

 #include<cstdio>

 #include<cmath>

 #include<algorithm>

 //#include<cstring>

 using namespace std;

 struct knife

 {

     int ai;

     bool f;

 }m[2000018];

 inline int read()

 {

   int p=0,f=1;char c=getchar();

   while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}

   while(c>='0'&&c<='9'){p=p*10+c-'0';c=getchar();}

   return f*p;}

 int N,H,ans;

 bool cmp(knife x,knife y)

 {

     return x.ai>y.ai;//返回伤害最大的刀 

 }

 int main()

 {

     N=read(),H=read();

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

         m[i].ai=read(),

      m[i+N].ai=read(),

         m[i+N].f=true;

     //我们把每把刀看作是可以无限扔的和只能扔一次的两把刀，存进去 

     sort(m+1,m+1+N*2,cmp);//排序，便于取 

     int ans=0;           //ans最终答案

     for(int i=1;i<=2*N;i++)//枚举2*N把刀 

        {

          if(m[i].f)//接下来贪心，如果刀可以飞出去就废掉，同时加上伤害 

            {ans++;

             H-=m[i].ai;}

          else

             {

              int u=H%m[i].ai;

              //如果碰到第一把无限次飞而且伤害最高的就无限砍 

              ans+=H/m[i].ai;

              //一直砍到没血，记录ans+ 

              if(u)ans++;

            H=-1;

             }

           if(H<=0)

             {printf("%d",ans);

              return 0;}

             //如果怪物没血了就输出 

        }

 }