Just a runnable solution
\n\nimpl Solution {\n    pub fn count_of_pairs(n: i32, x: i32, y: i32) -> Vec<i64> {\n        let (mut x, mut y) = (x, y);\n        if y < x {\n            std:
\n```\nimpl Solution {\n    pub fn count_of_pairs(n: i32, x: i32, y: i32) -> Vec<i64> {\n        let (mut x, mut y) = (x, y);\n        if y < x {\n            std::mem::swap(&mut x, &mut y);\n        }\n        let mut ans = vec![0_i64; n as usize];\n        let cycle = y - x + 1;\n        let half_cycle = (cycle - 1) >> 1;\n        let tail1 = x - 1;\n        let tail2 = n - y;\n        let tail_to_tail = tail1 + tail2 + 1 + (x != y) as i32;\n        for i in 0..half_cycle {\n            ans[i as usize] = cycle as i64 * 2;\n        }\n        if cycle % 2 == 0 {\n            ans[half_cycle as usize] = cycle as i64;\n        }\n        for i in 1..tail_to_tail {\n            ans[(i - 1) as usize] += (tail_to_tail - i) as i64 * 2;\n        }\n        if x != y {\n            ans[0] -= 2;\n            for &tail in &[tail1, tail2] {\n                for i in 1..=tail {\n                    ans[i as usize] -= 2;\n                }\n            }\n        }\n        for &tail in &[tail1, tail2] {\n            for i in 1..tail + half_cycle {\n                ans[i as usize] += 4 * tail.min(half_cycle).min(i).min(tail + half_cycle - i) as i64;\n            }\n            if cycle % 2 == 0 {\n                for i in 1..=tail {\n                    ans[(i + half_cycle) as usize] += 2;\n                }\n            }\n        }\n        ans\n    }\n}\n```
['Rust']