Python Super Hard
\nfrom operator import add\nfrom itertools import accumulate\nclass Solution:\n    def countOfPairs(self, n: int, x: int, y: int) -> List[int]:\n        \'\'\'\
```\nfrom operator import add\nfrom itertools import accumulate\nclass Solution:\n    def countOfPairs(self, n: int, x: int, y: int) -> List[int]:\n        \'\'\'\n        1 2 3 4 5 6 7\n              ^     ^\n\n\n        3, 4\n\n        [1, 2, 1, 0, 0, 0, 0]\n        [0, 1, 2, 1, 0, 0, 0]\n        [0, 0, 1, 2, 1, 0, 0]\n\n        [1, 3, 4, 3, 1]\n\n        want to get to x: x = 4\n\n        \n\n        1 2 3 4 5 6\n              ^   ^\n        [1, 2, 0, 0, 0, 0]\n        [0, 1, 2, 0, 0, 0]\n        [0, 0, 1, 2, 0, 0]\n\n        3, 3\n\n        [1, 3, 3, 1]\n        \n\n        \n\n        \'\'\'\n        if x > y:\n            x, y = y, x\n\n\n        def LtoRandRtoL(L, R):\n            res = [0] * (n * 2)\n            \n            for i in range(L):\n                res[i + 2] += 2\n                res[i + 2 + R] -= 2\n                \n            return list(accumulate(res))[:n]\n\n        def LtoC(L, cycle_size):\n            res = [0] * (n * 2)\n            for i in range(L):\n                res[i + 1] += 4\n                if cycle_size % 2 == 0:\n                    res[i + (cycle_size // 2)] -= 4\n                    res[i + (cycle_size // 2)] += 2\n                    res[i + 1 + (cycle_size // 2)] -= 2\n                \n                else:\n                    res[i + 1 + (cycle_size // 2)] -= 4\n\n                res[i] += 2\n                res[i + 1] -= 2\n\n            return list(accumulate(res))[:n]\n\n\n        def RtoC(R, cycle_size):\n            res = [0] * (n * 2)\n            for i in range(R):\n                res[i + 1] += 4\n                if cycle_size % 2 == 0:\n                    res[i + (cycle_size // 2)] -= 4\n                    res[i + (cycle_size // 2)] += 2\n                    res[i + 1 + (cycle_size // 2)] -= 2\n                \n                else:\n                    res[i + 1 + (cycle_size // 2)] -= 4\n\n                res[i] += 2\n                res[i + 1] -= 2\n\n            return list(accumulate(res))[:n]\n\n        def CtoC(cycle_size):\n            res = [0] * n\n\n            for i in range((cycle_size - 1) // 2):\n                res[i] += 2 * cycle_size\n            \n            if cycle_size % 2 == 0:\n                res[(cycle_size - 1) // 2] += cycle_size\n\n            return res\n\n\n        def LtoL(L):\n            res = [0] * n\n            for i in range(L):\n                res[i] += (L - 1 - i) * 2\n            return res \n\n        def RtoR(R):\n            res = [0] * n\n            for i in range(R):\n                res[i] += (R - 1 - i) * 2\n            return res \n\n\n        if x == y:\n            return LtoL(n)\n\n        L = x - 1\n        R = n - y\n        cycle_size = y - x + 1\n        arr = [0] * n\n\n        arr = map(add, arr, LtoRandRtoL(L, R))\n        arr = map(add, arr, LtoC(L, cycle_size))\n        arr = map(add, arr, RtoC(R, cycle_size))\n        arr = map(add, arr, CtoC(cycle_size))\n        arr = map(add, arr, LtoL(L))\n        arr = map(add, arr, RtoR(R))\n        \n \n\n        return arr\n\n        \n```
['Python3']