fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int Mod=1e9+7;
  5. const ll INF = 10000000000000;
  6. const int N = 1e6+7;
  7.  
  8. bool f(ll mid , int a ,int b){
  9. if((a>=2*mid && b>=mid) || (b>=2*mid && a>=mid)) return true;
  10. return false;
  11. }
  12.  
  13. void solve() {
  14. ll a,b;
  15. cin >> a >> b;
  16. ll l=0,r=1e10;
  17. ll ans=0;
  18. while(l<=r){
  19. ll mid=(l+r)/2;
  20. if(f(mid,a,b)){
  21. ans=mid;
  22. l=mid+1;
  23. }
  24. else r=mid-1;
  25. }
  26. cout << ans << '\n';
  27. }
  28.  
  29. int main(){
  30. ios::sync_with_stdio(false);
  31. cin.tie(nullptr);
  32.  
  33. int t;
  34. cin >> t;
  35. while (t--) solve();
  36.  
  37. return 0;
  38. }
  39.  
Success #stdin #stdout 0.01s 5284KB
stdin
4
4 4
1000000000 0
7 15
8 7
stdout
2
0
7
4