Source Code
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
 
const int N = 2e5 + 5;
 
void solve() {
    int n, k;
    cin >> n >> k;

    bool add = (n & 1) && (n / 2 + 1) < k; 
    cout << (k - 1) / 2 + add << '\n';
}
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}
Copy
Ramadan Candies OsamaX01
GNU G++17
5 ms
376 KB
Wrong Answer