output_description: For each query, print the maximum possible number of participants whose scores
  are smaller than Takahashi's.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      Q
      A_1 B_1
      :
      A_Q B_Q
attempt: #include <cstdio>
  #include <iostream>
  #include <algorithm>
  #include <vector>
  #include <map>
  #include <functional>
  #include <cmath>
  
  using namespace std;
  typedef long long int ll;
  
  #define repi(i,a,b) for(ll i=a;i<b;i++)
  #define rep(i,a) repi(i,0,a)
  #define rrep(i,a) for(ll i=a-1;i>=0;i--)
  
  ll solve(ll a, ll b){
    ll sqrtab = sqrt(a * b - 1);
    if(sqrtab * (sqrtab - 1) < a * b)
      return sqrtab * 2 - 1;
    else
      return sqrtab * 2 - 2;
  }
  
  int main(){
    ll Q;
    cin >> Q;
    rep(i, Q){
      ll a, b;
      cin >> a >> b;
      cout << solve(a, b) << endl;
    }
    return 0;
  }
  
problem_description: Statement
  
  10^{10^{10}} participants, including Takahashi, competed in two programming
  contests. In each contest, all participants had distinct ranks from first
  through 10^{10^{10}}-th.
  
  The _score_ of a participant is the product of his/her ranks in the two
  contests.
  
  Process the following Q queries:
  
    * In the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.
samples: [{"input": "8\n    1 4\n    10 5\n    3 3\n    4 11\n    8 9\n    22 40\n    8 36\n    314159265 358979323", "output": "1\n    12\n    4\n    11\n    14\n    57\n    31\n    671644785\n    \n\nLet us denote a participant who was ranked x-th in the first contest and y-th\nin the second contest as (x,y).\n\nIn the first query, (2,1) is a possible candidate of a participant whose score\nis smaller than Takahashi's. There are never two or more participants whose\nscores are smaller than Takahashi's, so we should print 1."}]