8 line code (formula based)
Intuition\nEither it will directly go from start to end.\nor it will 1st go from start to x then to y( in 1 connect) and then to end.\n\n** max(x,y) and min(x, 
# Intuition\nEither it will directly go from start to end.\nor it will 1st go from start to x then to y( in 1 connect) and then to end.\n\n** max(x,y) and min(x, y) is taken as sometimes in question y can be less than x;\n\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```\nclass Solution {\npublic:\n    vector<int> countOfPairs(int n, int x, int y) {\n        vector <int> ans(n, 0);\n        for(int s=1;s<=n;s++){ \n            for(int e=s+1;e<=n;e++){\n                int dist=min(e-s, abs(s-min(x,y))+1+abs(max(x,y)-e));\n                ans[dist-1]=ans[dist-1]+2;\n            }\n        }\n        return ans;\n    }\n    \n};\n```
['C++']