#include <iostream>

using namespace std;

int main() {
    int t;
    cin >> t;
    for (int i = 0;i < t;i++) {
        int r,l,s;
        cin >> r >> l >> s;
        if (s - l < (r)-s) {
            cout << (s-l) * 2 + 1 << "\n";
        }
        else{
            cout << (s-(r)) * 2 << "\n";
        }
    }
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: