Comments

Thank you! Stupid mistake :(

It looks like there should be some movement if I am not wrong. I compared top-ranked person's solution:

int  n, pos, l, r;
cin >> n >> pos >> l >> r;
if (l == 1 && r == n) {
        cout << 0;
        return 0;
}
if (l == 1 ) {
        cout << 1+abs(pos-r);
        return 0;
}
if (r == n) {
        cout << 1 + abs(pos - l);
        return 0;
}
cout << min(2 + abs(pos - l) + abs(r - l), 2 + abs(pos - r) + abs(r - l));
return 0;

With my solution:

int n, pos, l, r;
cin >> n >> pos >> l >> r;

if (l == 1 && r == n) {
    cout << 0;
} else if (l == 1) {
    cout << 1 + abs(r - pos);
} else if (r == n) {
    cout << 1 + abs(l - pos);
} else if (l == r) {
    cout << 2;
} else {
    cout << 2 + min(abs(r - pos) + (r-l), abs(l - pos) + (r-l));
}
return 0;

And only difference in logic is for such type of use-cases like 7 3 3 3. However, I believe it is not clear situation.

Questions regarding Problem B. How should solution be interpreted for testcase: 7 3 3 3? Should Luba do any movement? From problem statement it is not clear what happens after closing windows for example from [3,7].

My solution has been hacked, but I found only that difference of my solution with others (likely successful).