#ifdef SENJAN #define _GLIBCXX_DEBUG #else #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #endif #include #include #include using namespace std; using namespace atcoder; using ll=long long; using ull=unsigned long long; using ld=long double; using bint = boost::multiprecision::cpp_int; using graph=vector>; template using min_priority_queue=priority_queue,greater>; constexpr int INF32=INT_MAX/2; constexpr ll INF64=LLONG_MAX/2; constexpr ld PI=3.14159265358979323846; constexpr int dx[]={0,0,-1,1,-1,-1,1,1},dy[]={-1,1,0,0,-1,1,-1,1}; template inline bool chmax(T &a,T b){return a inline bool chmin(T &a,T b){return a>b?a=b,true:false;} inline void dispYN(bool a){cout<<(a?"YES":"NO")<sync_with_stdio(0);cout<1){ ll m=(l+r)/2; if(m*m<=x) l=m; else r=m; } return l; } void _main(){ int n; cin >> n; while(n--){ ll a, b; cin >> a >> b; ll x = a+b+ll_sqrt(4*a*b); ll l=0, r=1LL<<31; while(r-l>1){ ll m=(l+r)/2; if(m*m<=x) l=m; else r=m; } cout << r << endl; } }