Rust incomprehensible answer
Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(n)\n\n# Code\n\nimpl Solution {\n    pub fn count_of_pairs(n: i32, x: i32, y: i32) -> Vec<i64> {\n 
# Complexity\n- Time complexity: $$O(n)$$\n\n- Space complexity: $$O(n)$$\n\n# Code\n```\nimpl Solution {\n    pub fn count_of_pairs(n: i32, x: i32, y: i32) -> Vec<i64> {\n        let loop_len = (x - y).abs() as usize + 1;\n        if loop_len <= 1 {\n            // trivial answer\n            return (0..n as i64 * 2 - 1).rev().step_by(2).collect();\n        }\n\n        let mut ans = vec![0; n as usize];\n        // count pairs in the loop\n        for i in 0..(loop_len - 1) / 2 {\n            ans[i] = loop_len as i64;\n        }\n        if loop_len & 1 == 0 {\n            ans[loop_len / 2 - 1] = loop_len as i64 / 2;\n        }\n\n        // helper Vec for head (1..x.min(y))\n        let mut to_loop_count = vec![2; loop_len / 2];\n        if loop_len & 1 == 0 {\n            *to_loop_count.last_mut().unwrap() = 1;\n        }\n\n        // include the head (1..x.min(y)) to the graph and count pairs\n        let head_len = x.min(y) as usize - 1;\n        let mut prefix_sum: Vec<i64> = std::iter::repeat(1)\n                .take(head_len + 1)\n            .chain(to_loop_count.iter().copied())\n            .collect();\n        for i in 1..prefix_sum.len() {\n            prefix_sum[i] += prefix_sum[i - 1];\n        }\n\n        for i in 0..prefix_sum.len() - 1 {\n            let j = (prefix_sum.len() - 1).min(i + head_len);\n            ans[i] += prefix_sum[j] - prefix_sum[i];\n        }\n        \n        // update helper Vec for tail (x.max(y) + 1..=n)\n        for i in 1..1 + head_len {\n            if i == to_loop_count.len() {\n                to_loop_count.push(0);\n            }\n            to_loop_count[i] += 1;\n        }\n\n        // include the tail (x.max(y) + 1..=n) to the graph and count pairs\n        let tail_len = (n - x.max(y)) as usize;\n        prefix_sum = std::iter::repeat(1)\n                .take(tail_len + 1)\n            .chain(to_loop_count.iter().copied())\n            .collect();\n        for i in 1..prefix_sum.len() {\n            prefix_sum[i] += prefix_sum[i - 1];\n        }\n\n        let mut tail_count = vec![0; prefix_sum.len() - 1];\n        for i in 0..prefix_sum.len() - 1 {\n            let j = (prefix_sum.len() - 1).min(i + tail_len);\n            ans[i] += prefix_sum[j] - prefix_sum[i];\n        }\n\n        // multiply by 2\n        for i in 0..ans.len() {\n            ans[i] *= 2;\n        }\n        ans\n    }\n}\n```
['Prefix Sum', 'Rust']