Language: C++

//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	int q;
	cin>>q;
	while(q--){
		ll a,b,ans=0,val,val1=0,val2,val3=0;
		cin>>a>>b;
		if(a>b){
			swap(a,b);
		}
		if(a==1&&b==1){
			cout<<0<<endl;
			continue;
		}
		val=a*b-1;
		//val1=1;
		int i;
		f(i,1,min(a,1000006)){
			if(i-1>0&&val/i>b&&val/i!=val/(i-1)){
				val1++;
			}
		}
		//val3=1;
		//cout<<val1<<endl;
		ans+=a-1;
		f(i,1,min(b,1000005)){
			if(i-1>0&&val/i>a&&val/i!=val/(i-1)){
				val3++;
			}
		}
		ans+=min(val3,(b-1-(a-1-val1)));
		cout<<ans+1<<endl;
	}	
} 
	

Compiler output:
a.cc: In function 'int main()':
a.cc:63:26: error: no matching function for call to 'min(long long int&, int)'
   63 |                 f(i,1,min(a,1000006)){
      |                       ~~~^~~~~~~~~~~
a.cc:22:28: note: in definition of macro 'f'
   22 | #define f(i,a,b) for(i=a;i<b;i++)
      |                            ^
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:63:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   63 |                 f(i,1,min(a,1000006)){
      |                       ~~~^~~~~~~~~~~
a.cc:22:28: note: in definition of macro 'f'
   22 | #define f(i,a,b) for(i=a;i<b;i++)
      |                            ^
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:63:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   63 |                 f(i,1,min(a,1000006)){
      |                       ~~~^~~~~~~~~~~
a.cc:22:28: note: in definition of macro 'f'
   22 | #define f(i,a,b) for(i=a;i<b;i++)
      |                            ^
a.cc:71:26: error: no matching function for call to 'min(long long int&, int)'
   71 |                 f(i,1,min(b,1000005)){
      |                       ~~~^~~~~~~~~~~
a.cc:22:28: note: in definition of macro 'f'
   22 | #define f(i,a,b) for(i=a;i<b;i++)
      |                            ^
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:71:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   71 |                 f(i,1,min(b,1000005)){
      |                       ~~~^~~~~~~~~~~
a.cc:22:28: note: in definition of macro 'f'
   22 | #define f(i,a,b) for(i=a;i<b;i++)
      |                            ^
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:71:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   71 |                 f(i,1,min(b,1000005)){
      |                       ~~~^~~~~~~~~~~
a.cc:22:28: note: in definition of macro 'f'
   22 | #define f(i,a,b) for(i=a;i<b;i++)
      |                            ^