https://ac.nowcoder.com/acm/contest/37782/A
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5+9;
int a[N],b[N];
int n,m;
bool check(int x){
int sum=0;
for(int i=0;i<n;i++){
sum+=(x/b[i]+1)*a[i];
if(sum>=m) return 1;
}
return 0;
}
signed main(){
cin>>n>>m;
for(int i=0;i<n;i++) cin>>a[i]>>b[i];
int l=0,r=1e18;
while(l<r){
int mid=l+r>>1;
if(check(mid)) r=mid;
else l=mid+1;
}
cout<<r;
return 0;
}