Language: C++

#include <bits/stdc++.h>
#define uint unsigned long long
#define ll long long
#define db long double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi totor<int>
#define vl totor<ll>
#define rep(i, x, y) for(register int i = x; i <= y; i ++)
#define rrep(i, x, y) for(register int i = x; i >= y; i --)
#define eps 1e-15
#define lb(x) x & -x
#define sz(x) (x).size()
usir namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
ll f(ll A, ll B)
{
    ll lim = A*B;
    ll l = 0, r = B;
    while (r - l > 1)
    {
        ll mid = (l + r) / 2;
        bool f = true;
        if (mid * (A + 1) >= lim)f = false;
        ll x = (A + mid + 1) / 2;
        for (ll xx = x - 2; xx < x + 3; ++xx) {
            if (xx >= 1 && xx <= mid) {
                ll y = xx * (A + 1 + mid - xx);
                if (y >= lim)f = false;
            }
        }
        (f ? l : r) = mid;
    }
    return l;
}

int main()
{
    int Q = read();
    while (Q --)
    {
        ll A, B;
        A = read1();
        B = read1();
        ll bb = f(A, B);
        ll aa = f(B, A);
        ll ans = aa + bb;
        ll x = B - bb - 1, y = A - aa - 1;
        ans += max(0ll, min(x, y));
        cout << ans << endl;
    }
}


Compiler output:
a.cc:20:1: error: 'usir' does not name a type
   20 | usir namespace std;
      | ^~~~
a.cc: In function 'int main()':
a.cc:68:25: error: 'min' was not declared in this scope; did you mean 'std::min'?
   68 |         ans += max(0ll, min(x, y));
      |                         ^~~
      |                         std::min
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:68:16: error: 'max' was not declared in this scope; did you mean 'std::max'?
   68 |         ans += max(0ll, min(x, y));
      |                ^~~
      |                std::max
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:69:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   69 |         cout << ans << endl;
      |         ^~~~
      |         std::cout
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:69:24: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   69 |         cout << ans << endl;
      |                        ^~~~
      |                        std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~