BIT + Math
We don\'t need BIT actually, using a diff array is sufficient\n\n\n\ntypedef long long ll;\n\nconstexpr ll MAXN = 1e5 + 5;\n\nll N;\nll BIT[MAXN];\n\nvoid upd(l
We don\'t need BIT actually, using a diff array is sufficient\n\n\n```\ntypedef long long ll;\n\nconstexpr ll MAXN = 1e5 + 5;\n\nll N;\nll BIT[MAXN];\n\nvoid upd(ll x, ll v) {\n    for (; x <= N; x += (x & -x)) {\n        BIT[x] += v;\n    }\n}\n\nvoid upd(ll l, ll r, ll v) {\n    if (l > N) return;\n    upd(l, v);\n    upd(r + 1, -v);\n}\n\nll query(ll x) {\n    ll ans = 0;\n    for(;x ; x-= (x & -x)) {\n        ans += BIT[x];\n    }\n    return ans;\n}\n\nclass Solution {\npublic:\n    vector<long long> countOfPairs(int n, int x, int y) {\n        N = n;\n        vector<ll> ans(n + 1);\n        ans[0] = n;\n        for (ll i = 1; i <= n; i ++) {\n            BIT[i] = 0;\n            ans[i] = n - i;\n        }\n        \n        for (ll i = 1; i <= n; i ++) {\n            upd(i, i, ans[i]);\n        }\n        \n        if (x == y) {\n            ans.erase(ans.begin());\n            for (auto &t: ans) t *= 2;\n            return ans;\n        }\n        \n        if (x > y) {\n            swap(x, y);\n        }\n        \n        for (ll i = 1; i < x; i ++) {\n            ll q = ((x + y + 1) / 2) + 1;\n            \n            if (q > y) continue;\n            upd(q - i, y - i, -1);\n            upd(x - i + 1, x - i + 1 + y - q, 1);\n            \n            upd(y + 1 - i, n - i, -1);\n            upd(x - i + 1 + 1, x - i + 1 + n - y, 1);\n        }\n        \n        for (ll i = x; i <= y; i ++) {\n            ll q = (2 * i - x + 1 + y) / 2 + 1;\n            q = max(q, i + 1);\n            if (q > y) continue;\n            \n            upd(q - i, y - i, -1);\n            upd(i - x + 1, i - x + 1 + y - q, 1);\n            \n            if (i < (y + x + 2) / 2 - 1) {\n                upd(y + 1 - i, n - i, -1);\n                upd(i - x + 1 + 1, i - x + 1 + n - y, 1);\n            }\n        }\n        \n        for (ll i = 1; i <= n; i ++) {\n            ans[i] = query(i);\n        }\n        \n        ans.erase(ans.begin());\n        for (auto &t: ans) t *= 2;\n        return ans;\n    }\n};\n```
['C++']