#include using namespace std; #define ALL(x) x.begin(),x.end() #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b>n>>k; vector> v(n); rep(i,n){ cin>>v[i].first>>v[i].second; } auto check=[&](ll m){ ll cnt=0; rep(i,n){ cnt+=max(0ll,min(m,v[i].second)-v[i].first+1); } return cnt>=k; }; ll lw=0,hi=10ll*INF,res; while(lw<=hi){ ll mid=(lw+hi)/2; if(check(mid)){ res=mid; hi=mid-1; }else{ lw=mid+1; } } cout<