AVS
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nusing ll = long long;\nclass Solution {\npublic:\n    vector<long long> countOfPairs(int n, int x, int y) {\n        x--, y--;\n        if (x > y)\n            swap(x, y);\n        int z = y - x;\n        vector<ll> s(n);\n        auto add = [&](int l, int r) {\n            s[l - 1]++;\n            s[r]--;\n            // cout << l << " " << r << "\\n";\n        };\n        if (x == y) {\n            for (int i = 0; i < n; i++) {\n                add(1, i);\n                add(1, n - i - 1);\n            }\n        } else {\n            for (int i = 0; i < n; i++) {\n                // cout << i + 1 << ":-----\\n";\n                if (i <= x) {\n                    add(1, i);\n                    add(1, x - i);\n                    add(x - i + 1, x - i + z / 2);\n                    add(x - i + 1, x - i + (z + 1) / 2);\n                    add(x - i + 2, x - i + 1 + n - y - 1);\n                } else if (i <= y) {\n                    add(1, z / 2);\n                    add(1, (z + 1) / 2);\n                    int l = min(i - x, y - i + 1);\n                    int r = min(y - i, i - x + 1);\n                    add(l + 1, l + x);\n                    add(r + 1, r + n - y - 1);\n                } else {\n                    add(1, n - i - 1);\n                    add(1, i - y);\n                    add(i - y + 1, i - y + z / 2);\n                    add(i - y + 1, i - y + (z + 1) / 2);\n                    add(i - y + 2, i - y + 1 + x);\n                }\n            }\n        }\n        for (int i = 1; i < n; i++)\n            s[i] += s[i - 1];\n        return s;\n    }\n};\n```
['C++']