{
 "date": "2026-10-23",
 "pool": "LiveCodeBench release_v6, newest 100 problems (2025-02-15 to 2025-04-06)",
 "evaluated": "35 of them (10 medium, 25 hard), pass@1, one sample each",
 "judge": "AtCoder: own process with real stdin/stdout on all official tests, checkers for abc397_d and arc195_c; LeetCode: LCB's function-call judge (same as `cb rejudge`)",
 "models": [
  {
   "id": "kimi-k3.1-pro",
   "name": "Kimi K3.1 Pro",
   "passed": 34,
   "median_latency_s": 199.0,
   "median_output_tokens_per_s": 64.7,
   "cost_usd": 8.5699,
   "perf_geomean_vs_fastest": 1.295
  },
  {
   "id": "deepseek-flash",
   "name": "DeepSeek-V4.1-Flash",
   "passed": 35,
   "median_latency_s": 63.7,
   "median_output_tokens_per_s": 179.4,
   "cost_usd": 0.3875,
   "perf_geomean_vs_fastest": 2.001
  },
  {
   "id": "deepseek-v4-pro",
   "name": "DeepSeek-V4-Pro",
   "passed": 35,
   "median_latency_s": 285.1,
   "median_output_tokens_per_s": 134.0,
   "cost_usd": 3.3273,
   "perf_geomean_vs_fastest": 2.738
  }
 ],
 "problems": [
  {
   "id": "arc196_d",
   "title": "Roadway",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ARC 196 D 题",
   "date": "2025-04-06",
   "url": "https://atcoder.jp/contests/arc196/tasks/arc196_d",
   "summary": "一排 N 个城镇之间的道路可设任意整数权值，每人从 Sᵢ 走到 Tᵢ，要求出发和到达时体力恰为 0、途中始终为正；对每个查询区间判断能否同时满足这些人的要求。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 42/42",
     "output_tokens": 68053,
     "latency_s": 1229.9,
     "cpu_s": 0.0598,
     "peak_mb": 16.1,
     "quality": {
      "pylint": {
       "convention": 9,
       "refactor": 7,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 16,
       "score": 9.06
      },
      "radon": {
       "complexity": 56,
       "functions": 9,
       "mi": 26.388563329178773,
       "loc": 219,
       "lloc": 173,
       "sloc": 183,
       "comments": 1,
       "blank": 36
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\nfrom bisect import bisect_left\n\nSHIFT = 20\nMASK = (1 << SHIFT) - 1\nINF = 1 << 60\n\n\nclass MinSeg:\n    __slots__ = (\"n\", \"t\")\n\n    def __init__(self, size):\n        n = 1\n        while n < size:\n            n <<= 1\n        self.n = n\n        self.t = [INF] * (2 * n)\n\n    def update(self, pos, value):\n        t = self.t\n        p = pos + self.n\n        t[p] = value\n        p >>= 1\n        while p:\n            a = t[p << 1]\n            b = t[p << 1 | 1]\n            t[p] = a if a < b else b\n            p >>= 1\n\n    def query(self, left, right):\n        t = self.t\n        l = left + self.n\n        r = right + self.n\n        res = INF\n        while l < r:\n            if l & 1:\n                v = t[l]\n                if v < res:\n                    res = v\n                l += 1\n            if r & 1:\n                r -= 1\n                v = t[r]\n                if v < res:\n                    res = v\n            l >>= 1\n            r >>= 1\n        return res\n\n\nclass MaxSeg:\n    __slots__ = (\"n\", \"t\")\n\n    def __init__(self, size):\n        n = 1\n        while n < size:\n            n <<= 1\n        self.n = n\n        self.t = [-1] * (2 * n)\n\n    def update(self, pos, value):\n        t = self.t\n        p = pos + self.n\n        t[p] = value\n        p >>= 1\n        while p:\n            a = t[p << 1]\n            b = t[p << 1 | 1]\n            t[p] = a if a > b else b\n            p >>= 1\n\n    def query(self, left, right):\n        t = self.t\n        l = left + self.n\n        r = right + self.n\n        res = -1\n        while l < r:\n            if l & 1:\n                v = t[l]\n                if v > res:\n                    res = v\n                l += 1\n            if r & 1:\n                r -= 1\n                v = t[r]\n                if v > res:\n                    res = v\n            l >>= 1\n            r >>= 1\n        return res\n\n\ndef main():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    if not data:\n        return\n\n    n, m, q = data[0], data[1], data[2]\n    ptr = 3\n\n    left = [0] * (m + 1)\n    right = [0] * (m + 1)\n    sign = [0] * (m + 1)  # 0: S < T, 1: S > T\n\n    right_coords = [[], []]\n    left_coords = [[], []]\n\n    for i in range(1, m + 1):\n        s = data[ptr]\n        t = data[ptr + 1]\n        ptr += 2\n        if s < t:\n            left[i] = s\n            right[i] = t\n            sign[i] = 0\n        else:\n            left[i] = t\n            right[i] = s\n            sign[i] = 1\n        left_coords[sign[i]].append(left[i])\n        right_coords[sign[i]].append(right[i])\n\n    for s in (0, 1):\n        left_coords[s] = sorted(set(left_coords[s]))\n        right_coords[s] = sorted(set(right_coords[s]))\n\n    left_maps = [\n        {v: i for i, v in enumerate(left_coords[0])},\n        {v: i for i, v in enumerate(left_coords[1])},\n    ]\n    right_maps = [\n        {v: i for i, v in enumerate(right_coords[0])},\n        {v: i for i, v in enumerate(right_coords[1])},\n    ]\n\n    pos_left = [0] * (m + 1)\n    pos_right = [0] * (m + 1)\n    for i in range(1, m + 1):\n        s = sign[i]\n        pos_left[i] = left_maps[s][left[i]]\n        pos_right[i] = right_maps[s][right[i]]\n\n    del left_maps, right_maps\n\n    min_trees = [\n        MinSeg(len(right_coords[0])),\n        MinSeg(len(right_coords[1])),\n    ]\n    max_trees = [\n        MaxSeg(len(left_coords[0])),\n        MaxSeg(len(left_coords[1])),\n    ]\n\n    active_left = [0] * (n + 1)\n    active_right = [0] * (n + 1)\n    bound = [0] * (m + 1)\n\n    window_left = 1\n\n    for cur in range(1, m + 1):\n        a = left[cur]\n        b = right[cur]\n        s = sign[cur]\n\n        while True:\n            bad = active_left[a]\n            if bad == 0:\n                bad = active_right[b]\n\n            if bad == 0:\n                coords = right_coords[s]\n                lo = bisect_left(coords, a + 1)\n                hi = bisect_left(coords, b)\n                if lo < hi:\n                    key = min_trees[s].query(lo, hi)\n                    if (key >> SHIFT) < a:\n                        bad = key & MASK\n\n            if bad == 0:\n                coords = left_coords[s]\n                lo = bisect_left(coords, a + 1)\n                hi = bisect_left(coords, b)\n                if lo < hi:\n                    key = max_trees[s].query(lo, hi)\n                    if key >= 0 and (key >> SHIFT) > b:\n                        bad = key & MASK\n\n            if bad == 0:\n                break\n\n            for j in range(window_left, bad + 1):\n                x = left[j]\n                y = right[j]\n                sj = sign[j]\n                active_left[x] = 0\n                active_right[y] = 0\n                min_trees[sj].update(pos_right[j], INF)\n                max_trees[sj].update(pos_left[j], -1)\n\n            window_left = bad + 1\n\n        active_left[a] = cur\n        active_right[b] = cur\n        min_trees[s].update(pos_right[cur], (a << SHIFT) | cur)\n        max_trees[s].update(pos_left[cur], (b << SHIFT) | cur)\n        bound[cur] = window_left\n\n    answers = []\n    for _ in range(q):\n        l = data[ptr]\n        r = data[ptr + 1]\n        ptr += 2\n        answers.append(\"Yes\" if l >= bound[r] else \"No\")\n\n    sys.stdout.write(\"\\n\".join(answers))\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 42/42",
     "output_tokens": 43031,
     "latency_s": 247.9,
     "cpu_s": 0.128,
     "peak_mb": 16.2,
     "quality": {
      "pylint": {
       "convention": 8,
       "refactor": 16,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 24,
       "score": 9.0
      },
      "radon": {
       "complexity": 22,
       "functions": 1,
       "mi": 35.632878443524376,
       "loc": 323,
       "lloc": 251,
       "sloc": 250,
       "comments": 17,
       "blank": 58
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\nfrom bisect import bisect_left\n\n\ndef solve():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    it = iter(data)\n\n    N = next(it)\n    M = next(it)\n    Q = next(it)\n\n    L = [0] * (M + 1)\n    R = [0] * (M + 1)\n    sign = [0] * (M + 1)\n\n    for i in range(1, M + 1):\n        s = next(it)\n        t = next(it)\n        if s < t:\n            L[i] = s\n            R[i] = t\n            sign[i] = 1       # endpoints are lower, inside is higher\n        else:\n            L[i] = t\n            R[i] = s\n            sign[i] = -1      # endpoints are higher, inside is lower\n\n    queries = []\n    for _ in range(Q):\n        l = next(it)\n        r = next(it)\n        queries.append((l, r))\n\n    best_prev = [0] * (M + 1)\n\n    # Direct incompatible cases:\n    # 1. same left endpoint, different right endpoint\n    # 2. same right endpoint, different left endpoint\n    # 3. same endpoints with opposite signs\n    size = N + 2\n\n    idx1_l = [0] * size\n    r1_l = [0] * size\n    idx2_l = [0] * size\n\n    idx1_r = [0] * size\n    l1_r = [0] * size\n    idx2_r = [0] * size\n\n    exact_pos = {}\n    exact_neg = {}\n    base = N + 1\n\n    for i in range(1, M + 1):\n        l = L[i]\n        r = R[i]\n        sg = sign[i]\n\n        cand = 0\n\n        # same left, different right\n        x = idx1_l[l]\n        if x:\n            if r1_l[l] != r:\n                cand = x\n            else:\n                cand = idx2_l[l]\n\n        if cand > best_prev[i]:\n            best_prev[i] = cand\n\n        # same right, different left\n        cand = 0\n        x = idx1_r[r]\n        if x:\n            if l1_r[r] != l:\n                cand = x\n            else:\n                cand = idx2_r[r]\n\n        if cand > best_prev[i]:\n            best_prev[i] = cand\n\n        # same endpoints, opposite sign\n        key = l * base + r\n        if sg == 1:\n            cand = exact_neg.get(key, 0)\n        else:\n            cand = exact_pos.get(key, 0)\n\n        if cand > best_prev[i]:\n            best_prev[i] = cand\n\n        if sg == 1:\n            exact_pos[key] = i\n        else:\n            exact_neg[key] = i\n\n        # update same-left data\n        if idx1_l[l] == 0:\n            idx1_l[l] = i\n            r1_l[l] = r\n        elif r1_l[l] == r:\n            idx1_l[l] = i\n        else:\n            idx2_l[l] = idx1_l[l]\n            idx1_l[l] = i\n            r1_l[l] = r\n\n        # update same-right data\n        if idx1_r[r] == 0:\n            idx1_r[r] = i\n            l1_r[r] = l\n        elif l1_r[r] == l:\n            idx1_r[r] = i\n        else:\n            idx2_r[r] = idx1_r[r]\n            idx1_r[r] = i\n            l1_r[r] = l\n\n    # Crossing incompatible pairs with the same sign.\n    # We handle both crossing directions by doing an original pass\n    # and a coordinate-reversed pass.\n    def process_pass(transformed, target_sign):\n        coords = [[] for _ in range(N + 2)]\n\n        if not transformed:\n            for i in range(1, M + 1):\n                if sign[i] != target_sign:\n                    continue\n                l = L[i]\n                r = R[i]\n                x = l\n                while x <= N:\n                    coords[x].append(r)\n                    x += x & -x\n        else:\n            for i in range(1, M + 1):\n                if sign[i] != target_sign:\n                    continue\n                l = N - R[i] + 1\n                r = N - L[i] + 1\n                x = l\n                while x <= N:\n                    coords[x].append(r)\n                    x += x & -x\n\n        seg = [None] * (N + 2)\n\n        for x in range(1, N + 1):\n            arr = coords[x]\n            if not arr:\n                continue\n\n            arr.sort()\n            m = 0\n            last = 0\n            for val in arr:\n                if val != last:\n                    arr[m] = val\n                    m += 1\n                    last = val\n\n            if m < len(arr):\n                del arr[m:]\n\n            seg[x] = [0] * (2 * m)\n\n        if not transformed:\n            for i in range(1, M + 1):\n                if sign[i] != target_sign:\n                    continue\n\n                l = L[i]\n                r = R[i]\n\n                # Query previous intervals j with:\n                # l_j < l < r_j < r\n                cand = 0\n                x = l - 1\n                lo = l + 1\n                hi = r\n\n                while x > 0:\n                    arr = coords[x]\n                    if arr:\n                        left = bisect_left(arr, lo)\n                        right = bisect_left(arr, hi)\n\n                        if left < right:\n                            tree = seg[x]\n                            n = len(arr)\n                            a = left + n\n                            b = right + n\n\n                            while a < b:\n                                if a & 1:\n                                    v = tree[a]\n                                    if v > cand:\n                                        cand = v\n                                    a += 1\n                                if b & 1:\n                                    b -= 1\n                                    v = tree[b]\n                                    if v > cand:\n                                        cand = v\n                                a >>= 1\n                                b >>= 1\n\n                    x -= x & -x\n\n                if cand > best_prev[i]:\n                    best_prev[i] = cand\n\n                # Insert current interval\n                x = l\n                while x <= N:\n                    arr = coords[x]\n                    pos = bisect_left(arr, r)\n                    tree = seg[x]\n                    n = len(arr)\n                    p = pos + n\n\n                    if tree[p] < i:\n                        tree[p] = i\n                        p >>= 1\n                        while p:\n                            if tree[p] >= i:\n                                break\n                            tree[p] = i\n                            p >>= 1\n\n                    x += x & -x\n\n        else:\n            for i in range(1, M + 1):\n                if sign[i] != target_sign:\n                    continue\n\n                l = N - R[i] + 1\n                r = N - L[i] + 1\n\n                cand = 0\n                x = l - 1\n                lo = l + 1\n                hi = r\n\n                while x > 0:\n                    arr = coords[x]\n                    if arr:\n                        left = bisect_left(arr, lo)\n                        right = bisect_left(arr, hi)\n\n                        if left < right:\n                            tree = seg[x]\n                            n = len(arr)\n                            a = left + n\n                            b = right + n\n\n                            while a < b:\n                                if a & 1:\n                                    v = tree[a]\n                                    if v > cand:\n                                        cand = v\n                                    a += 1\n                                if b & 1:\n                                    b -= 1\n                                    v = tree[b]\n                                    if v > cand:\n                                        cand = v\n                                a >>= 1\n                                b >>= 1\n\n                    x -= x & -x\n\n                if cand > best_prev[i]:\n                    best_prev[i] = cand\n\n                x = l\n                while x <= N:\n                    arr = coords[x]\n                    pos = bisect_left(arr, r)\n                    tree = seg[x]\n                    n = len(arr)\n                    p = pos + n\n\n                    if tree[p] < i:\n                        tree[p] = i\n                        p >>= 1\n                        while p:\n                            if tree[p] >= i:\n                                break\n                            tree[p] = i\n                            p >>= 1\n\n                    x += x & -x\n\n    process_pass(False, 1)\n    process_pass(False, -1)\n    process_pass(True, 1)\n    process_pass(True, -1)\n\n    bad_max = [0] * (M + 1)\n    cur = 0\n\n    for i in range(1, M + 1):\n        if best_prev[i] > cur:\n            cur = best_prev[i]\n        bad_max[i] = cur\n\n    ans = []\n    for l, r in queries:\n        if bad_max[r] < l:\n            ans.append(\"Yes\")\n        else:\n            ans.append(\"No\")\n\n    sys.stdout.write(\"\\n\".join(ans))\n\n\nif __name__ == \"__main__\":\n    solve()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 42/42",
     "output_tokens": 110419,
     "latency_s": 833.8,
     "cpu_s": 0.149,
     "peak_mb": 18.1,
     "quality": {
      "pylint": {
       "convention": 20,
       "refactor": 14,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 34,
       "score": 8.92
      },
      "radon": {
       "complexity": 46,
       "functions": 1,
       "mi": 23.950438508456546,
       "loc": 368,
       "lloc": 328,
       "sloc": 326,
       "comments": 10,
       "blank": 33
      },
      "sonar": {
       "maintainability": 9,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 9
       },
       "severities": {
        "CRITICAL": 1,
        "MINOR": 4,
        "MAJOR": 4
       },
       "rules": {
        "python:S3776": 1,
        "python:S117": 4,
        "python:S1066": 2,
        "python:S1871": 2
       }
      }
     },
     "code": "import sys\nfrom bisect import bisect_left, bisect_right\n\n\ndef solve():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    it = iter(data)\n    N = next(it)\n    M = next(it)\n    Q = next(it)\n\n    L = [0] * (M + 1)\n    R = [0] * (M + 1)\n    Sign = [0] * (M + 1)  # 1: rightward (+), 0: leftward (-)\n\n    for i in range(1, M + 1):\n        s = next(it)\n        t = next(it)\n        if s < t:\n            l = s - 1\n            r = t - 1\n            sign = 1\n        else:\n            l = t - 1\n            r = s - 1\n            sign = 0\n        L[i] = l\n        R[i] = r\n        Sign[i] = sign\n\n    queries = []\n    for _ in range(Q):\n        queries.append((next(it), next(it)))\n\n    f = [0] * (M + 1)\n\n    # Type A: identical interval, opposite signs\n    same_interval = {}\n    for i in range(1, M + 1):\n        key = (L[i], R[i])\n        entry = same_interval.get(key)\n        if Sign[i] == 1:\n            if entry is not None and entry[1] != 0:\n                if entry[1] > f[i]:\n                    f[i] = entry[1]\n            if entry is None:\n                same_interval[key] = [i, 0]\n            else:\n                entry[0] = i\n        else:\n            if entry is not None and entry[0] != 0:\n                if entry[0] > f[i]:\n                    f[i] = entry[0]\n            if entry is None:\n                same_interval[key] = [0, i]\n            else:\n                entry[1] = i\n\n    # Type C: same-direction shared endpoint\n    # For left endpoints L and right endpoints R, keep top two indices with distinct other endpoint.\n    top1_idx_l = [0] * N\n    top1_other_l = [-1] * N\n    top2_idx_l = [0] * N\n    top2_other_l = [-1] * N\n\n    top1_idx_r = [0] * N\n    top1_other_r = [-1] * N\n    top2_idx_r = [0] * N\n    top2_other_r = [-1] * N\n\n    for i in range(1, M + 1):\n        l = L[i]\n        r = R[i]\n\n        # query left endpoint\n        res = 0\n        if top1_idx_l[l] != 0:\n            if top1_other_l[l] != r:\n                res = top1_idx_l[l]\n            elif top2_idx_l[l] != 0:\n                res = top2_idx_l[l]\n        if res > f[i]:\n            f[i] = res\n\n        # query right endpoint\n        res = 0\n        if top1_idx_r[r] != 0:\n            if top1_other_r[r] != l:\n                res = top1_idx_r[r]\n            elif top2_idx_r[r] != 0:\n                res = top2_idx_r[r]\n        if res > f[i]:\n            f[i] = res\n\n        # update left endpoint key = l, other = r\n        o1 = top1_other_l[l]\n        i1 = top1_idx_l[l]\n        o2 = top2_other_l[l]\n        i2 = top2_idx_l[l]\n        if i1 == 0:\n            top1_idx_l[l] = i\n            top1_other_l[l] = r\n        elif o1 == r:\n            top1_idx_l[l] = i\n        elif i2 == 0:\n            top2_idx_l[l] = i1\n            top2_other_l[l] = o1\n            top1_idx_l[l] = i\n            top1_other_l[l] = r\n        elif o2 == r:\n            top2_idx_l[l] = i\n            top2_other_l[l] = r\n            top1_idx_l[l], top2_idx_l[l] = top2_idx_l[l], top1_idx_l[l]\n            top1_other_l[l], top2_other_l[l] = top2_other_l[l], top1_other_l[l]\n        else:\n            top2_idx_l[l] = i1\n            top2_other_l[l] = o1\n            top1_idx_l[l] = i\n            top1_other_l[l] = r\n\n        # update right endpoint key = r, other = l\n        o1 = top1_other_r[r]\n        i1 = top1_idx_r[r]\n        o2 = top2_other_r[r]\n        i2 = top2_idx_r[r]\n        if i1 == 0:\n            top1_idx_r[r] = i\n            top1_other_r[r] = l\n        elif o1 == l:\n            top1_idx_r[r] = i\n        elif i2 == 0:\n            top2_idx_r[r] = i1\n            top2_other_r[r] = o1\n            top1_idx_r[r] = i\n            top1_other_r[r] = l\n        elif o2 == l:\n            top2_idx_r[r] = i\n            top2_other_r[r] = l\n            top1_idx_r[r], top2_idx_r[r] = top2_idx_r[r], top1_idx_r[r]\n            top1_other_r[r], top2_other_r[r] = top2_other_r[r], top1_other_r[r]\n        else:\n            top2_idx_r[r] = i1\n            top2_other_r[r] = o1\n            top1_idx_r[r] = i\n            top1_other_r[r] = l\n\n    plus_intervals = [(i, L[i], R[i]) for i in range(1, M + 1) if Sign[i] == 1]\n    minus_intervals = [(i, L[i], R[i]) for i in range(1, M + 1) if Sign[i] == 0]\n\n    def process_structure(intervals, mode, f):\n        if not intervals:\n            return\n\n        Nm1 = N - 1\n\n        if mode == 1:\n            xs = sorted({r for _, _, r in intervals})\n        else:\n            xs = sorted({l for _, l, _ in intervals})\n\n        K = len(xs)\n        size = 1\n        while size < K:\n            size <<= 1\n\n        pos_map = {x: i for i, x in enumerate(xs)}\n        node_ys = [None] * (2 * size)\n\n        if mode == 1:\n            for _, l, r in intervals:\n                x = r\n                y = l\n                pos = pos_map[x]\n                node = size + pos\n                while node:\n                    lst = node_ys[node]\n                    if lst is None:\n                        node_ys[node] = [y]\n                    else:\n                        lst.append(y)\n                    node >>= 1\n        else:\n            for _, l, r in intervals:\n                x = l\n                y = Nm1 - r\n                pos = pos_map[x]\n                node = size + pos\n                while node:\n                    lst = node_ys[node]\n                    if lst is None:\n                        node_ys[node] = [y]\n                    else:\n                        lst.append(y)\n                    node >>= 1\n\n        node_bit = [None] * (2 * size)\n        for i in range(1, 2 * size):\n            lst = node_ys[i]\n            if lst is not None:\n                lst.sort()\n                m = 0\n                for val in lst:\n                    if m == 0 or val != lst[m - 1]:\n                        lst[m] = val\n                        m += 1\n                del lst[m:]\n                node_ys[i] = lst\n                node_bit[i] = [0] * (m + 1)\n\n        if mode == 1:\n            for idx, l, r in intervals:\n                xL = l + 1\n                xR = r - 1\n                Y = l - 1\n\n                if xL <= xR:\n                    lo = bisect_left(xs, xL)\n                    hi = bisect_right(xs, xR) - 1\n                    if lo <= hi:\n                        res = 0\n                        left = size + lo\n                        right = size + hi\n                        while left <= right:\n                            if left & 1:\n                                node = left\n                                uniq = node_ys[node]\n                                if uniq is not None:\n                                    bit = node_bit[node]\n                                    p = bisect_right(uniq, Y)\n                                    while p:\n                                        val = bit[p]\n                                        if val > res:\n                                            res = val\n                                        p -= p & -p\n                                left += 1\n                            if not (right & 1):\n                                node = right\n                                uniq = node_ys[node]\n                                if uniq is not None:\n                                    bit = node_bit[node]\n                                    p = bisect_right(uniq, Y)\n                                    while p:\n                                        val = bit[p]\n                                        if val > res:\n                                            res = val\n                                        p -= p & -p\n                                right -= 1\n                            left >>= 1\n                            right >>= 1\n                        if res > f[idx]:\n                            f[idx] = res\n\n                x = r\n                y = l\n                pos = pos_map[x]\n                node = size + pos\n                while node:\n                    uniq = node_ys[node]\n                    if uniq is not None:\n                        bit = node_bit[node]\n                        yidx = bisect_left(uniq, y) + 1\n                        m = len(uniq)\n                        p = yidx\n                        while p <= m:\n                            bit[p] = idx\n                            p += p & -p\n                    node >>= 1\n        else:\n            for idx, l, r in intervals:\n                xL = l + 1\n                xR = r - 1\n                Y = Nm1 - (r + 1)\n\n                if xL <= xR:\n                    lo = bisect_left(xs, xL)\n                    hi = bisect_right(xs, xR) - 1\n                    if lo <= hi:\n                        res = 0\n                        left = size + lo\n                        right = size + hi\n                        while left <= right:\n                            if left & 1:\n                                node = left\n                                uniq = node_ys[node]\n                                if uniq is not None:\n                                    bit = node_bit[node]\n                                    p = bisect_right(uniq, Y)\n                                    while p:\n                                        val = bit[p]\n                                        if val > res:\n                                            res = val\n                                        p -= p & -p\n                                left += 1\n                            if not (right & 1):\n                                node = right\n                                uniq = node_ys[node]\n                                if uniq is not None:\n                                    bit = node_bit[node]\n                                    p = bisect_right(uniq, Y)\n                                    while p:\n                                        val = bit[p]\n                                        if val > res:\n                                            res = val\n                                        p -= p & -p\n                                right -= 1\n                            left >>= 1\n                            right >>= 1\n                        if res > f[idx]:\n                            f[idx] = res\n\n                x = l\n                y = Nm1 - r\n                pos = pos_map[x]\n                node = size + pos\n                while node:\n                    uniq = node_ys[node]\n                    if uniq is not None:\n                        bit = node_bit[node]\n                        yidx = bisect_left(uniq, y) + 1\n                        m = len(uniq)\n                        p = yidx\n                        while p <= m:\n                            bit[p] = idx\n                            p += p & -p\n                    node >>= 1\n\n    # Type B: crossing intervals with the same sign\n    process_structure(plus_intervals, 1, f)\n    process_structure(plus_intervals, 2, f)\n    process_structure(minus_intervals, 1, f)\n    process_structure(minus_intervals, 2, f)\n\n    # Range maximum of f\n    size_seg = 1\n    while size_seg < M:\n        size_seg <<= 1\n    seg = [0] * (2 * size_seg)\n    for i in range(1, M + 1):\n        seg[size_seg + i - 1] = f[i]\n    for i in range(size_seg - 1, 0, -1):\n        seg[i] = seg[i << 1] if seg[i << 1] > seg[i << 1 | 1] else seg[i << 1 | 1]\n\n    out = []\n    for lq, rq in queries:\n        left = lq + size_seg - 1\n        right = rq + size_seg - 1\n        mx = 0\n        while left <= right:\n            if left & 1:\n                if seg[left] > mx:\n                    mx = seg[left]\n                left += 1\n            if not (right & 1):\n                if seg[right] > mx:\n                    mx = seg[right]\n                right -= 1\n            left >>= 1\n            right >>= 1\n        if mx >= lq:\n            out.append(\"No\")\n        else:\n            out.append(\"Yes\")\n\n    sys.stdout.write(\"\\n\".join(out))\n\n\nif __name__ == \"__main__\":\n    solve()"
    }
   }
  },
  {
   "id": "arc196_c",
   "title": "Strongly Connected",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ARC 196 C 题",
   "date": "2025-04-06",
   "url": "https://atcoder.jp/contests/arc196/tasks/arc196_c",
   "summary": "2N 个点依次连有向边，每个白点与一个黑点配对并从白点连边到黑点；求使整张图强连通的配对方案数，模 998244353。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 105388,
     "latency_s": 1730.3,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 4,
       "refactor": 6,
       "warning": 1,
       "error": 1,
       "fatal": 0,
       "total": 12,
       "score": 9.1
      },
      "radon": {
       "complexity": 33,
       "functions": 5,
       "mi": 36.8052695710028,
       "loc": 256,
       "lloc": 182,
       "sloc": 193,
       "comments": 13,
       "blank": 50
      },
      "sonar": {
       "maintainability": 2,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 2
       },
       "severities": {
        "CRITICAL": 2
       },
       "rules": {
        "python:S3776": 2
       }
      }
     },
     "code": "import sys\n\nMOD = 998244353\n\n# Optional fast exact convolution using double FFT with 15-bit splitting.\n# A pure-modular NTT fallback is provided below.\ntry:\n    import numpy as _np\nexcept Exception:\n    _np = None\n\n\n_REV = {}\n_ROOTS = {}\n\n\ndef _ntt(a, inverse):\n    n = len(a)\n\n    rev = _REV.get(n)\n    if rev is None:\n        rev = [0] * n\n        half = n >> 1\n        for i in range(1, n):\n            rev[i] = (rev[i >> 1] >> 1) | ((i & 1) * half)\n        _REV[n] = rev\n\n    for i in range(n):\n        j = rev[i]\n        if i < j:\n            a[i], a[j] = a[j], a[i]\n\n    length = 2\n    while length <= n:\n        key = (length, inverse)\n        roots = _ROOTS.get(key)\n        if roots is None:\n            wlen = pow(3, (MOD - 1) // length, MOD)\n            if inverse:\n                wlen = pow(wlen, MOD - 2, MOD)\n            roots = [1] * (length >> 1)\n            for i in range(1, len(roots)):\n                roots[i] = roots[i - 1] * wlen % MOD\n            _ROOTS[key] = roots\n\n        half = length >> 1\n        for start in range(0, n, length):\n            for j in range(half):\n                x = start + j\n                y = x + half\n                u = a[x]\n                v = a[y] * roots[j] % MOD\n                s = u + v\n                if s >= MOD:\n                    s -= MOD\n                d = u - v\n                if d < 0:\n                    d += MOD\n                a[x] = s\n                a[y] = d\n        length <<= 1\n\n    if inverse:\n        inv_n = pow(n, MOD - 2, MOD)\n        for i in range(n):\n            a[i] = a[i] * inv_n % MOD\n\n\ndef _ntt_convolution(a, b):\n    need = len(a) + len(b) - 1\n    n = 1 << (need - 1).bit_length()\n    fa = a + [0] * (n - len(a))\n    fb = b + [0] * (n - len(b))\n    _ntt(fa, False)\n    _ntt(fb, False)\n    for i in range(n):\n        fa[i] = fa[i] * fb[i] % MOD\n    _ntt(fa, True)\n    return fa[:need]\n\n\ndef _fft_convolution(a, b):\n    need = len(a) + len(b) - 1\n    n = 1 << (need - 1).bit_length()\n\n    aa = _np.asarray(a, dtype=_np.int64)\n    bb = _np.asarray(b, dtype=_np.int64)\n\n    split = 15\n    base = 1 << split\n    mask = base - 1\n\n    a0 = aa & mask\n    a1 = aa >> split\n    b0 = bb & mask\n    b1 = bb >> split\n\n    fa0 = _np.fft.rfft(a0, n)\n    fa1 = _np.fft.rfft(a1, n)\n    fb0 = _np.fft.rfft(b0, n)\n    fb1 = _np.fft.rfft(b1, n)\n\n    c00 = _np.rint(\n        _np.fft.irfft(fa0 * fb0, n)[:need]\n    ).astype(_np.int64)\n    c01 = _np.rint(\n        _np.fft.irfft(fa0 * fb1 + fa1 * fb0, n)[:need]\n    ).astype(_np.int64)\n    c11 = _np.rint(\n        _np.fft.irfft(fa1 * fb1, n)[:need]\n    ).astype(_np.int64)\n\n    base2 = base * base % MOD\n    return (\n        c00 % MOD\n        + (c01 % MOD) * base\n        + (c11 % MOD) * base2\n    ) % MOD\n\n\ndef _convolution(a, b):\n    if _np is not None:\n        return _fft_convolution(a, b)\n    return _ntt_convolution(a, b)\n\n\ndef main():\n    data = sys.stdin.read().split()\n    if not data:\n        return\n\n    n = int(data[0])\n    s = data[1]\n\n    # The first and last added backward edges can exist only in this case.\n    if s[0] != \"B\" or s[-1] != \"W\":\n        print(0)\n        return\n\n    fact = [1] * (n + 1)\n    for i in range(1, n + 1):\n        fact[i] = fact[i - 1] * i % MOD\n\n    invfact = [1] * (n + 1)\n    invfact[n] = pow(fact[n], MOD - 2, MOD)\n    for i in range(n, 0, -1):\n        invfact[i - 1] = invfact[i] * i % MOD\n\n    # Compress the input to relevant ends of W-runs.\n    # An entry (b,w) means: after b black vertices and w white vertices,\n    # a nonempty W-run ends, and w >= b.\n    bs = []\n    ws = []\n\n    b = 0\n    w = 0\n    i = 0\n    length = 2 * n\n\n    while i < length:\n        # s[i] is B here.\n        b += 1\n        i += 1\n        old_w = w\n        while i < length and s[i] == \"W\":\n            w += 1\n            i += 1\n        if w > old_w and w >= b:\n            bs.append(b)\n            ws.append(w)\n\n    m = len(bs)\n\n    # If x[b] is the compressed value for group b, then, for a relevant\n    # group (b,w),\n    #\n    # x[b] = (w! - sum_{previous groups k} x[k] * (w-k)!) / (w-b)!.\n    #\n    # Compute this online convolution by CDQ divide and conquer.\n    values = [0] * m\n    incoming = [0] * m\n\n    small_limit = 30000 if _np is not None else 80000\n    fft_factor = 6 if _np is not None else 20\n\n    def cross(left, mid, right):\n        ids = [u for u in range(left, mid) if values[u]]\n        if not ids:\n            return\n\n        pairs = [(bs[u], values[u]) for u in ids]\n        naive_cost = len(ids) * (right - mid)\n\n        bmin = bs[ids[0]]\n        bmax = bs[ids[-1]]\n        wmin = ws[mid]\n        wmax = ws[right - 1]\n\n        plen = bmax - bmin + 1\n        tmin = wmin - bmax\n        tmax = wmax - bmin\n        zlen = tmax - tmin + 1\n        conv_size = plen + zlen - 1\n        fft_size = 1 << (conv_size - 1).bit_length()\n\n        use_naive = (\n            naive_cost <= small_limit\n            or fft_size * fft_factor > naive_cost\n        )\n\n        if use_naive:\n            for v in range(mid, right):\n                wv = ws[v]\n                total = incoming[v]\n                for bu, au in pairs:\n                    total += au * fact[wv - bu]\n                incoming[v] = total % MOD\n            return\n\n        x = [0] * plen\n        for u in ids:\n            x[bs[u] - bmin] = values[u]\n        z = fact[tmin:tmax + 1]\n\n        conv = _convolution(x, z)\n        offset = bmin + tmin\n\n        for v in range(mid, right):\n            add = int(conv[ws[v] - offset])\n            val = incoming[v] + add\n            if val >= MOD:\n                val -= MOD\n            incoming[v] = val\n\n    sys.setrecursionlimit(1000000)\n\n    def cdq(left, right):\n        if right - left == 1:\n            t = left\n            values[t] = (\n                (fact[ws[t]] - incoming[t]) % MOD\n                * invfact[ws[t] - bs[t]] % MOD\n            )\n            return\n\n        mid = (left + right) >> 1\n        cdq(left, mid)\n        cross(left, mid, right)\n        cdq(mid, right)\n\n    cdq(0, m)\n    print(values[-1] % MOD)\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 76845,
     "latency_s": 438.6,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 10,
       "refactor": 5,
       "warning": 1,
       "error": 0,
       "fatal": 0,
       "total": 16,
       "score": 9.1
      },
      "radon": {
       "complexity": 18,
       "functions": 1,
       "mi": 33.762872108708535,
       "loc": 235,
       "lloc": 180,
       "sloc": 179,
       "comments": 6,
       "blank": 51
      },
      "sonar": {
       "maintainability": 2,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 2
       },
       "severities": {
        "CRITICAL": 1,
        "MAJOR": 1
       },
       "rules": {
        "python:S3776": 1,
        "python:S5806": 1
       }
      }
     },
     "code": "import sys\n\nMOD = 998244353\nPRIMITIVE_ROOT = 3\n\n\ndef main() -> None:\n    sys.setrecursionlimit(1 << 20)\n    input = sys.stdin.readline\n\n    N = int(input())\n    S = input().strip()\n\n    # For strong connectivity, the first vertex must be black and the last white.\n    if S[0] != 'B' or S[-1] != 'W':\n        print(0)\n        return\n\n    fact = [1] * (N + 1)\n    for i in range(1, N + 1):\n        fact[i] = fact[i - 1] * i % MOD\n\n    invfact = [1] * (N + 1)\n    invfact[N] = pow(fact[N], MOD - 2, MOD)\n    for i in range(N, 0, -1):\n        invfact[i - 1] = invfact[i] * i % MOD\n\n    # Important cuts: ends of W-runs immediately followed by B.\n    # Store (number of B before the cut, number of W before the cut).\n    C = [0]\n    W = [0]\n\n    b = w = 0\n    prev = ''\n    for ch in S:\n        if ch == 'B':\n            if prev == 'W' and w - b >= 0:\n                C.append(b)\n                W.append(w)\n            b += 1\n        else:\n            w += 1\n        prev = ch\n\n    M = len(C) - 1\n    h = [0] * (M + 1)\n    for i in range(1, M + 1):\n        h[i] = W[i] - C[i]  # >= 0 for every stored cut\n\n    # For small M, the quadratic DP is faster.\n    if M <= 3000:\n        F = [0] * (M + 1)\n        F[0] = 1\n\n        for i in range(1, M + 1):\n            s = 0\n            wi = W[i]\n            for j in range(i):\n                s += F[j] * fact[wi - C[j]]\n            s %= MOD\n            F[i] = (-s * invfact[h[i]]) % MOD\n\n        ans = 0\n        for j in range(M + 1):\n            ans += F[j] * fact[N - C[j]]\n            ans %= MOD\n        print(ans)\n        return\n\n    # ---------- NTT preparation ----------\n    max_size = 1\n    while max_size < 2 * N + 5:\n        max_size <<= 1\n    max_log = max_size.bit_length() - 1\n\n    roots = [0] * (max_log + 1)\n    inv_roots = [0] * (max_log + 1)\n    for k in range(1, max_log + 1):\n        roots[k] = pow(PRIMITIVE_ROOT, (MOD - 1) // (1 << k), MOD)\n        inv_roots[k] = pow(roots[k], MOD - 2, MOD)\n\n    inv_size = [1] * (max_log + 1)\n    inv2 = (MOD + 1) // 2\n    for k in range(1, max_log + 1):\n        inv_size[k] = inv_size[k - 1] * inv2 % MOD\n\n    rev_cache = {}\n\n    def ntt(a, invert):\n        n = len(a)\n\n        rev = rev_cache.get(n)\n        if rev is None:\n            bits = n.bit_length() - 1\n            rev = [0] * n\n            for i in range(1, n):\n                rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (bits - 1))\n            rev_cache[n] = rev\n\n        for i in range(n):\n            j = rev[i]\n            if i < j:\n                a[i], a[j] = a[j], a[i]\n\n        length = 2\n        level = 1\n        used_roots = inv_roots if invert else roots\n\n        while length <= n:\n            wlen = used_roots[level]\n            half = length >> 1\n\n            for start in range(0, n, length):\n                w = 1\n                end = start + half\n                j = start\n                while j < end:\n                    u = a[j]\n                    v = a[j + half] * w % MOD\n\n                    x = u + v\n                    if x >= MOD:\n                        x -= MOD\n                    y = u - v\n                    if y < 0:\n                        y += MOD\n\n                    a[j] = x\n                    a[j + half] = y\n\n                    w = w * wlen % MOD\n                    j += 1\n\n            length <<= 1\n            level += 1\n\n        if invert:\n            inv_n = inv_size[n.bit_length() - 1]\n            for i in range(n):\n                a[i] = a[i] * inv_n % MOD\n\n    def convolution(a, b):\n        n = len(a)\n        m = len(b)\n        if n == 0 or m == 0:\n            return []\n\n        if n * m <= 4096:\n            res = [0] * (n + m - 1)\n            for i, ai in enumerate(a):\n                if ai == 0:\n                    continue\n                for j, bj in enumerate(b):\n                    res[i + j] = (res[i + j] + ai * bj) % MOD\n            return res\n\n        need = n + m - 1\n        size = 1\n        while size < need:\n            size <<= 1\n\n        fa = a + [0] * (size - n)\n        fb = b + [0] * (size - m)\n\n        ntt(fa, False)\n        ntt(fb, False)\n\n        for i in range(size):\n            fa[i] = fa[i] * fb[i] % MOD\n\n        ntt(fa, True)\n        return fa[:need]\n\n    F = [0] * (M + 1)\n    F[0] = 1\n    acc = [0] * (M + 1)\n\n    def cdq(l, r):\n        if l == r:\n            if l > 0:\n                F[l] = (-acc[l] * invfact[h[l]]) % MOD\n            return\n\n        mid = (l + r) >> 1\n        cdq(l, mid)\n\n        left_count = mid - l + 1\n        right_count = r - mid\n\n        if left_count * right_count <= 12000:\n            for i in range(mid + 1, r + 1):\n                wi = W[i]\n                total = 0\n                for j in range(l, mid + 1):\n                    total += F[j] * fact[wi - C[j]]\n                acc[i] = (acc[i] + total) % MOD\n        else:\n            cmax = C[mid]\n            wmin = W[mid + 1]\n            base = wmin - cmax\n\n            len_c = cmax - C[l] + 1\n            len_w = W[r] - wmin + 1\n\n            a = [0] * len_c\n            for j in range(l, mid + 1):\n                u = cmax - C[j]\n                a[len_c - 1 - u] = F[j]\n\n            blen = len_c + len_w - 1\n            bpoly = [0] * blen\n            for t in range(blen):\n                bpoly[t] = fact[base + t]\n\n            conv = convolution(a, bpoly)\n\n            offset = len_c - 1\n            for i in range(mid + 1, r + 1):\n                v = W[i] - wmin\n                acc[i] = (acc[i] + conv[offset + v]) % MOD\n\n        cdq(mid + 1, r)\n\n    cdq(0, M)\n\n    ans = 0\n    for j in range(M + 1):\n        ans += F[j] * fact[N - C[j]]\n        ans %= MOD\n\n    print(ans)\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 164193,
     "latency_s": 1221.2,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 14,
       "refactor": 6,
       "warning": 1,
       "error": 0,
       "fatal": 0,
       "total": 21,
       "score": 8.26
      },
      "radon": {
       "complexity": 21,
       "functions": 2,
       "mi": 35.40707324145612,
       "loc": 153,
       "lloc": 127,
       "sloc": 125,
       "comments": 2,
       "blank": 26
      },
      "sonar": {
       "maintainability": 4,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 4
       },
       "severities": {
        "CRITICAL": 2,
        "MAJOR": 1,
        "MINOR": 1
       },
       "rules": {
        "python:S3776": 2,
        "python:S5806": 1,
        "python:S117": 1
       }
      }
     },
     "code": "import sys\n\nMOD = 998244353\nG = 3\n\ndef ntt(a, invert):\n    n = len(a)\n    j = 0\n    for i in range(1, n):\n        bit = n >> 1\n        while j & bit:\n            j ^= bit\n            bit >>= 1\n        j ^= bit\n        if i < j:\n            a[i], a[j] = a[j], a[i]\n\n    length = 2\n    while length <= n:\n        wlen = pow(G, (MOD - 1) // length, MOD)\n        if invert:\n            wlen = pow(wlen, MOD - 2, MOD)\n        half = length >> 1\n        for i in range(0, n, length):\n            w = 1\n            for j in range(i, i + half):\n                u = a[j]\n                v = a[j + half] * w % MOD\n                a[j] = (u + v) % MOD\n                a[j + half] = (u - v) % MOD\n                w = w * wlen % MOD\n        length <<= 1\n\n    if invert:\n        inv_n = pow(n, MOD - 2, MOD)\n        for i in range(n):\n            a[i] = a[i] * inv_n % MOD\n\n\ndef main():\n    input = sys.stdin.readline\n    N = int(input())\n    S = input().strip()\n\n    if S[0] != 'B' or S[-1] != 'W':\n        print(0)\n        return\n\n    fact = [1] * (N + 1)\n    for i in range(1, N + 1):\n        fact[i] = fact[i - 1] * i % MOD\n\n    invfact = [1] * (N + 1)\n    invfact[N] = pow(fact[N], MOD - 2, MOD)\n    for i in range(N, 0, -1):\n        invfact[i - 1] = invfact[i] * i % MOD\n\n    # c[i] for i=1..N-1: number of whites before the (i+1)-th black.\n    # c[0] = 0 is used for the empty prefix in the inclusion-exclusion.\n    c = [0] * N\n    bcnt = 0\n    wcnt = 0\n    for ch in S:\n        if ch == 'B':\n            bcnt += 1\n            if bcnt >= 2:\n                c[bcnt - 1] = wcnt\n        else:\n            wcnt += 1\n\n    dp = [0] * N\n    res = [0] * N\n\n    sys.setrecursionlimit(1 << 20)\n\n    valid = [False] * N\n    for i in range(1, N):\n        valid[i] = (c[i] >= i)\n\n    NAIVE_LIMIT = 60\n\n    def solve(l, r):\n        if l > r:\n            return\n        if l == r:\n            if l == 0:\n                dp[0] = 1\n            else:\n                if valid[l]:\n                    dp[l] = (-invfact[c[l] - l] * res[l]) % MOD\n                else:\n                    dp[l] = 0\n            return\n\n        mid = (l + r) >> 1\n        solve(l, mid)\n\n        rv = [i for i in range(mid + 1, r + 1) if valid[i]]\n        if rv:\n            n_min = c[rv[0]]\n            n_max = c[rv[-1]]\n            k_min = n_min - mid\n            k_max = n_max - l\n            if k_min < 0:\n                k_min = 0\n\n            if k_max >= k_min:\n                L = mid - l + 1\n                A = dp[l:mid + 1]\n                K_len = k_max - k_min + 1\n                F = fact[k_min:k_min + K_len]\n                need = L + K_len - 1\n\n                if need <= NAIVE_LIMIT:\n                    C = [0] * need\n                    for ai, av in enumerate(A):\n                        if av:\n                            base = ai\n                            for bi, bv in enumerate(F):\n                                C[base + bi] = (C[base + bi] + av * bv) % MOD\n                else:\n                    n = 1\n                    while n < need:\n                        n <<= 1\n                    arr1 = A + [0] * (n - L)\n                    arr2 = F + [0] * (n - K_len)\n                    ntt(arr1, False)\n                    ntt(arr2, False)\n                    for i in range(n):\n                        arr1[i] = arr1[i] * arr2[i] % MOD\n                    ntt(arr1, True)\n                    C = arr1\n\n                base = l + k_min\n                for i in rv:\n                    idx = c[i] - base\n                    if 0 <= idx < need:\n                        res[i] = (res[i] + C[idx]) % MOD\n\n        solve(mid + 1, r)\n\n    if N >= 1:\n        solve(0, N - 1)\n\n    ans = 0\n    for j in range(N):\n        ans = (ans + dp[j] * fact[N - j]) % MOD\n\n    print(ans)\n\n\nif __name__ == \"__main__\":\n    main()"
    }
   }
  },
  {
   "id": "arc196_b",
   "title": "Torus Loop",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ARC 196 B 题",
   "date": "2025-04-06",
   "url": "https://atcoder.jp/contests/arc196/tasks/arc196_b",
   "summary": "每格瓷砖画有一段拐角线或直线，可以旋转；把网格看作环面，求线段处处没有断头的摆法数，模 998244353。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 2/2",
     "output_tokens": 16900,
     "latency_s": 279.5,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 6,
       "refactor": 2,
       "warning": 18,
       "error": 0,
       "fatal": 0,
       "total": 26,
       "score": 5.81
      },
      "radon": {
       "complexity": 9,
       "functions": 1,
       "mi": 55.16114477855072,
       "loc": 82,
       "lloc": 64,
       "sloc": 64,
       "comments": 4,
       "blank": 17
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\n\nMOD = 998244353\n\n\ndef main():\n    data = sys.stdin.buffer.read().split()\n    T = int(data[0])\n    pos = 1\n    answers = []\n\n    for _ in range(T):\n        H = int(data[pos])\n        W = int(data[pos + 1])\n        pos += 2\n\n        n = H + W\n        parent = list(range(n))\n        size = [1] * n\n        parity = [0] * n  # value(x) XOR value(parent[x])\n\n        col_prefix = [0] * W\n        components = n\n        valid = True\n\n        def find(x):\n            if parent[x] != x:\n                p = parent[x]\n                root, d = find(p)\n                d ^= parity[x]\n                parent[x] = root\n                parity[x] = d\n                return root, d\n            return x, 0\n\n        def unite(a, b, required_xor):\n            nonlocal components, valid\n            ra, pa = find(a)\n            rb, pb = find(b)\n\n            if ra == rb:\n                if (pa ^ pb) != required_xor:\n                    valid = False\n                return\n\n            d = pa ^ pb ^ required_xor\n            if size[ra] < size[rb]:\n                parent[ra] = rb\n                parity[ra] = d\n                size[rb] += size[ra]\n            else:\n                parent[rb] = ra\n                parity[rb] = d\n                size[ra] += size[rb]\n            components -= 1\n\n        for i in range(H):\n            s = data[pos]\n            pos += 1\n            row_prefix = 0\n\n            for j, ch in enumerate(s):\n                if ch == 65:  # 'A'\n                    row_prefix ^= 1\n                    col_prefix[j] ^= 1\n                elif valid:  # 'B'\n                    # Row variable i and column variable H+j.\n                    unite(i, H + j, 1 ^ row_prefix ^ col_prefix[j])\n\n            if row_prefix:\n                valid = False\n\n        if not valid or any(col_prefix):\n            answers.append(\"0\")\n        else:\n            answers.append(str(pow(2, components, MOD)))\n\n    sys.stdout.write(\"\\n\".join(answers))\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 2/2",
     "output_tokens": 22740,
     "latency_s": 120.6,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 7,
       "refactor": 4,
       "warning": 1,
       "error": 0,
       "fatal": 0,
       "total": 12,
       "score": 8.55
      },
      "radon": {
       "complexity": 20,
       "functions": 2,
       "mi": 47.03397665013714,
       "loc": 117,
       "lloc": 87,
       "sloc": 87,
       "comments": 3,
       "blank": 30
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\n\nMOD = 998244353\n\nparent = []\nxr = []\n\n\ndef find(x):\n    p = parent\n    xo = xr\n\n    r = x\n    acc = 0\n    while p[r] != r:\n        acc ^= xo[r]\n        r = p[r]\n\n    cur = x\n    cur_acc = 0\n    while p[cur] != cur:\n        nxt = p[cur]\n        w = xo[cur]\n        p[cur] = r\n        xo[cur] = acc ^ cur_acc\n        cur_acc ^= w\n        cur = nxt\n\n    return r, acc\n\n\ndef solve():\n    global parent, xr\n\n    data = sys.stdin.buffer.read().split()\n    it = iter(data)\n\n    T = int(next(it))\n    answers = []\n\n    for _ in range(T):\n        H = int(next(it))\n        W = int(next(it))\n\n        grid = [next(it) for _ in range(H)]\n\n        col_par = [0] * W\n        invalid = False\n\n        for row in grid:\n            row_par = 0\n            for j, ch in enumerate(row):\n                if ch == 65:  # 'A'\n                    row_par ^= 1\n                    col_par[j] ^= 1\n            if row_par:\n                invalid = True\n\n        if invalid or any(col_par):\n            answers.append(\"0\")\n            continue\n\n        n = H + W\n        parent = list(range(n))\n        xr = [0] * n\n        size = [1] * n\n        components = n\n\n        ok = True\n\n        for i, row in enumerate(grid):\n            row_pref = 0\n\n            for j, ch in enumerate(row):\n                if ch == 65:  # 'A'\n                    row_pref ^= 1\n                    col_par[j] ^= 1\n                else:  # 'B'\n                    d = 1 ^ row_pref ^ col_par[j]\n\n                    u = i\n                    v = H + j\n\n                    ru, pu = find(u)\n                    rv, pv = find(v)\n\n                    if ru == rv:\n                        if (pu ^ pv) != d:\n                            ok = False\n                            break\n                    else:\n                        t = d ^ pu ^ pv\n\n                        if size[ru] < size[rv]:\n                            parent[ru] = rv\n                            xr[ru] = t\n                            size[rv] += size[ru]\n                        else:\n                            parent[rv] = ru\n                            xr[rv] = t\n                            size[ru] += size[rv]\n\n                        components -= 1\n\n            if not ok:\n                break\n\n        if ok:\n            answers.append(str(pow(2, components, MOD)))\n        else:\n            answers.append(\"0\")\n\n    sys.stdout.write(\"\\n\".join(answers))\n\n\nif __name__ == \"__main__\":\n    solve()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 2/2",
     "output_tokens": 67851,
     "latency_s": 495.9,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 8,
       "refactor": 4,
       "warning": 1,
       "error": 0,
       "fatal": 0,
       "total": 13,
       "score": 7.83
      },
      "radon": {
       "complexity": 17,
       "functions": 1,
       "mi": 58.144929599974866,
       "loc": 84,
       "lloc": 64,
       "sloc": 64,
       "comments": 7,
       "blank": 15
      },
      "sonar": {
       "maintainability": 3,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 3
       },
       "severities": {
        "CRITICAL": 1,
        "MAJOR": 1,
        "MINOR": 1
       },
       "rules": {
        "python:S3776": 1,
        "python:S5806": 1,
        "python:S117": 1
       }
      }
     },
     "code": "import sys\n\nMOD = 998244353\n\ndef solve():\n    input = sys.stdin.buffer.readline\n    T_line = input()\n    if not T_line:\n        return\n    T = int(T_line)\n    out = []\n\n    for _ in range(T):\n        H, W = map(int, input().split())\n        V = H + W\n\n        parent = list(range(V))\n        size = [1] * V\n        parity = [0] * V\n        comps = V\n        consistent = True\n        valid = True\n\n        # col_pref[j] = parity of A in column j above the current row\n        col_pref = [0] * W\n\n        for i in range(H):\n            s = input().strip()\n            # row_pref = parity of A in this row before the current column\n            row_pref = 0\n\n            for j, ch in enumerate(s):\n                if ch == 65:  # 'A'\n                    row_pref ^= 1\n                    col_pref[j] ^= 1\n                else:  # 'B'\n                    if consistent:\n                        # equation: r_i xor c_j = 1 xor row_pref xor col_pref[j]\n                        k = 1 ^ row_pref ^ col_pref[j]\n\n                        # find row i\n                        ra = i\n                        xa = 0\n                        while parent[ra] != ra:\n                            xa ^= parity[ra]\n                            ra = parent[ra]\n\n                        # find column j\n                        rb = H + j\n                        xb = 0\n                        while parent[rb] != rb:\n                            xb ^= parity[rb]\n                            rb = parent[rb]\n\n                        if ra == rb:\n                            if (xa ^ xb) != k:\n                                consistent = False\n                        else:\n                            t = k ^ xa ^ xb\n                            if size[ra] < size[rb]:\n                                parent[ra] = rb\n                                parity[ra] = t\n                                size[rb] += size[ra]\n                            else:\n                                parent[rb] = ra\n                                parity[rb] = t\n                                size[ra] += size[rb]\n                            comps -= 1\n\n            if row_pref:\n                valid = False\n\n        if valid and any(col_pref):\n            valid = False\n\n        if valid and consistent:\n            out.append(str(pow(2, comps, MOD)))\n        else:\n            out.append(\"0\")\n\n    sys.stdout.write(\"\\n\".join(out))\n\nif __name__ == \"__main__\":\n    solve()"
    }
   }
  },
  {
   "id": "arc196_a",
   "title": "Adjacent Delete",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ARC 196 A 题",
   "date": "2025-04-06",
   "url": "https://atcoder.jp/contests/arc196/tasks/arc196_a",
   "summary": "反复删除两个相邻的数并得到二者之差的绝对值，直到长度不超过 1；求总得分最大值。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 33359,
     "latency_s": 536.3,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 3,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 3,
       "score": 9.36
      },
      "radon": {
       "complexity": 10,
       "functions": 2,
       "mi": 58.983184524016096,
       "loc": 66,
       "lloc": 52,
       "sloc": 48,
       "comments": 4,
       "blank": 15
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\nimport heapq\n\n\ndef prefix_scores(a):\n    \"\"\"res[2*t] = (sum of t largest) - (sum of t smallest) in each prefix.\"\"\"\n    n = len(a)\n    res = [0] * (n + 1)\n\n    low = []   # max-heap (stored negated): smaller half\n    high = []  # min-heap: larger half\n    sum_low = 0\n    sum_high = 0\n\n    for i, x in enumerate(a, 1):\n        if not low or x <= -low[0]:\n            heapq.heappush(low, -x)\n            sum_low += x\n        else:\n            heapq.heappush(high, x)\n            sum_high += x\n\n        if len(low) > len(high) + 1:\n            y = -heapq.heappop(low)\n            sum_low -= y\n            heapq.heappush(high, y)\n            sum_high += y\n        elif len(low) < len(high):\n            y = heapq.heappop(high)\n            sum_high -= y\n            heapq.heappush(low, -y)\n            sum_low += y\n\n        if i % 2 == 0:\n            res[i] = sum_high - sum_low\n\n    return res\n\n\ndef main():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    n = data[0]\n    a = data[1:]\n\n    if n % 2 == 0:\n        b = sorted(a)\n        m = n // 2\n        answer = sum(b[m:]) - sum(b[:m])\n        print(answer)\n        return\n\n    # If the final remaining element is a[left] (0-based), left is even.\n    # The elements before and after it must be removed independently.\n    pref = prefix_scores(a)\n    suff = prefix_scores(a[::-1])\n\n    answer = 0\n    for left in range(0, n, 2):\n        right_len = n - 1 - left\n        answer = max(answer, pref[left] + suff[right_len])\n\n    print(answer)\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 18326,
     "latency_s": 98.2,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 6,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 6,
       "score": 9.18
      },
      "radon": {
       "complexity": 21,
       "functions": 5,
       "mi": 35.87554201690408,
       "loc": 98,
       "lloc": 75,
       "sloc": 73,
       "comments": 0,
       "blank": 25
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\n\n\nclass Fenwick:\n    __slots__ = (\"n\", \"bit\", \"bit_sum\", \"values\")\n\n    def __init__(self, values):\n        self.n = len(values)\n        self.bit = [0] * (self.n + 1)\n        self.bit_sum = [0] * (self.n + 1)\n        self.values = values\n\n    def add(self, i, value):\n        n = self.n\n        bit = self.bit\n        bit_sum = self.bit_sum\n        while i <= n:\n            bit[i] += 1\n            bit_sum[i] += value\n            i += i & -i\n\n    def sum_smallest(self, k):\n        if k <= 0:\n            return 0\n\n        n = self.n\n        bit = self.bit\n        bit_sum = self.bit_sum\n\n        idx = 0\n        cnt = 0\n        s = 0\n        step = 1 << (n.bit_length() - 1)\n\n        while step:\n            nxt = idx + step\n            if nxt <= n and cnt + bit[nxt] < k:\n                idx = nxt\n                cnt += bit[nxt]\n                s += bit_sum[nxt]\n            step >>= 1\n\n        return s + (k - cnt) * self.values[idx]\n\n\ndef solve():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    if not data:\n        return\n\n    n = data[0]\n    a = data[1:1 + n]\n\n    values = sorted(set(a))\n    comp = {v: i + 1 for i, v in enumerate(values)}\n\n    pre = [0] * (n + 1)\n    fw = Fenwick(values)\n    total = 0\n\n    for i, v in enumerate(a, 1):\n        fw.add(comp[v], v)\n        total += v\n\n        if i % 2 == 0:\n            k = i // 2\n            small_sum = fw.sum_smallest(k)\n            pre[i] = total - 2 * small_sum\n\n    if n % 2 == 0:\n        print(pre[n])\n        return\n\n    suf = [0] * (n + 1)\n    fw = Fenwick(values)\n    total = 0\n\n    for i in range(n - 1, -1, -1):\n        v = a[i]\n        fw.add(comp[v], v)\n        total += v\n\n        length = n - i\n        if length % 2 == 0:\n            k = length // 2\n            small_sum = fw.sum_smallest(k)\n            suf[i] = total - 2 * small_sum\n\n    ans = 0\n\n    for i in range(0, n, 2):\n        ans = max(ans, pre[i] + suf[i + 1])\n\n    print(ans)\n\n\nif __name__ == \"__main__\":\n    solve()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 48294,
     "latency_s": 350.8,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 6,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 7,
       "score": 8.54
      },
      "radon": {
       "complexity": 12,
       "functions": 2,
       "mi": 56.28454459090381,
       "loc": 69,
       "lloc": 52,
       "sloc": 50,
       "comments": 3,
       "blank": 18
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\nimport heapq\n\ndef prefix_even(arr):\n    n = len(arr)\n    res = [0] * (n + 1)\n\n    low = []   # max-heap (stored as negatives), smaller half\n    high = []  # min-heap, larger half\n    sum_low = 0\n    total = 0\n\n    heappush = heapq.heappush\n    heappop = heapq.heappop\n\n    for i, x in enumerate(arr, 1):\n        total += x\n\n        if not low or x <= -low[0]:\n            heappush(low, -x)\n            sum_low += x\n        else:\n            heappush(high, x)\n\n        desired_low = (i + 1) // 2\n\n        while len(low) > desired_low:\n            v = -heappop(low)\n            sum_low -= v\n            heappush(high, v)\n\n        while len(low) < desired_low:\n            v = heappop(high)\n            heappush(low, -v)\n            sum_low += v\n\n        if i % 2 == 0:\n            res[i] = total - 2 * sum_low\n\n    return res\n\n\ndef solve():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    if not data:\n        return\n\n    N = data[0]\n    A = data[1:1 + N]\n\n    if N % 2 == 0:\n        pref = prefix_even(A)\n        ans = pref[N]\n    else:\n        pref = prefix_even(A)\n        rev = prefix_even(A[::-1])\n\n        ans = 0\n        # The final remaining element must have an odd 1-indexed position.\n        for i in range(1, N + 1, 2):\n            val = pref[i - 1] + rev[N - i]\n            if val > ans:\n                ans = val\n\n    print(ans)\n\n\nif __name__ == \"__main__\":\n    solve()"
    }
   }
  },
  {
   "id": "3777",
   "title": "Maximum Product of Subsequences with an Alternating Sum Equal to K",
   "platform": "leetcode",
   "difficulty": "hard",
   "contest": "LeetCode 周赛 444",
   "date": "2025-04-05",
   "url": "https://leetcode.com/problems/maximum-product-of-subsequences-with-an-alternating-sum-equal-to-k/",
   "summary": "找一个交错和等于 k 的非空子序列，使其元素乘积在不超过 limit 的前提下最大；不存在时返回 -1。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 15227,
     "latency_s": 199.0,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 2,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 7,
       "score": 8.16
      },
      "radon": {
       "complexity": 31,
       "functions": 2,
       "mi": 66.47854289573671,
       "loc": 58,
       "lloc": 39,
       "sloc": 39,
       "comments": 7,
       "blank": 12
      },
      "sonar": {
       "maintainability": 2,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 2
       },
       "severities": {
        "MINOR": 1,
        "CRITICAL": 1
       },
       "rules": {
        "python:S100": 1,
        "python:S3776": 1
       }
      }
     },
     "code": "from typing import List\n\nclass Solution:\n    def maxProduct(self, nums: List[int], k: int, limit: int) -> int:\n        total = sum(nums)\n        if k < -total or k > total:\n            return -1\n\n        offset = total\n        mask = (1 << (2 * total + 1)) - 1\n\n        # Products greater than limit can share one state. Such a product can\n        # only remain overflowed, or become 0 after multiplying by zero.\n        over = limit + 1\n        size = over + 1\n\n        # even[p] / odd[p] store a bitset of alternating sums for nonempty\n        # subsequences of even / odd length whose (capped) product is p.\n        even = [0] * size\n        odd = [0] * size\n\n        for x in nums:\n            old_even, old_odd = even, odd\n            even = old_even.copy()\n            odd = old_odd.copy()\n\n            next_product = [0] * size\n            if x:\n                for p in range(size):\n                    if p == over:\n                        next_product[p] = over\n                    else:\n                        value = p * x\n                        next_product[p] = value if value <= limit else over\n\n            for p in range(size):\n                q = next_product[p]\n\n                bits = old_even[p]\n                if bits:\n                    # x is appended at an even index, so it is added.\n                    odd[q] |= (bits << x) & mask\n\n                bits = old_odd[p]\n                if bits:\n                    # x is appended at an odd index, so it is subtracted.\n                    even[q] |= bits >> x\n\n            # Start a new subsequence containing only x.\n            singleton_product = x if x <= limit else over\n            odd[singleton_product] |= 1 << (offset + x)\n\n        target = 1 << (offset + k)\n        for product in range(limit, -1, -1):\n            if (even[product] & target) or (odd[product] & target):\n                return product\n\n        return -1"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 13923,
     "latency_s": 78.7,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 3,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 8,
       "score": 8.43
      },
      "radon": {
       "complexity": 43,
       "functions": 2,
       "mi": 58.93429628466796,
       "loc": 77,
       "lloc": 54,
       "sloc": 52,
       "comments": 7,
       "blank": 19
      },
      "sonar": {
       "maintainability": 2,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 2
       },
       "severities": {
        "MINOR": 1,
        "CRITICAL": 1
       },
       "rules": {
        "python:S100": 1,
        "python:S3776": 1
       }
      }
     },
     "code": "from typing import List\n\nclass Solution:\n    def maxProduct(self, nums: List[int], k: int, limit: int) -> int:\n        total = sum(nums)\n        if k < -total or k > total:\n            return -1\n\n        offset = total\n        length = 2 * total + 1\n        mask = (1 << length) - 1\n        target_bit = 1 << (offset + k)\n\n        # DP for positive products only.\n        # dp0[p] / dp1[p]: bitset of reachable alternating sums\n        # for product p and current subsequence length parity 0 / 1.\n        dp0 = [0] * (limit + 1)\n        dp1 = [0] * (limit + 1)\n\n        for x in nums:\n            if x == 0 or x > limit:\n                continue\n\n            old0, old1 = dp0, dp1\n            ndp0 = old0[:]\n            ndp1 = old1[:]\n\n            # Start a new subsequence with x.\n            ndp1[x] |= 1 << (offset + x)\n\n            max_product = limit // x\n            for p in range(1, max_product + 1):\n                np = p * x\n\n                s0 = old0[p]\n                if s0:\n                    ndp1[np] |= (s0 << x) & mask\n\n                s1 = old1[p]\n                if s1:\n                    ndp0[np] |= s1 >> x\n\n            dp0, dp1 = ndp0, ndp1\n\n        for p in range(limit, 0, -1):\n            if (dp0[p] & target_bit) or (dp1[p] & target_bit):\n                return p\n\n        # Check whether a valid zero-product subsequence exists.\n        # A zero-product subsequence must contain at least one zero.\n        dp = [[0, 0], [0, 0]]\n        dp[0][0] = 1 << offset  # empty subsequence: used_zero = 0, parity = 0, sum = 0\n\n        for x in nums:\n            ndp = [[dp[0][0], dp[0][1]], [dp[1][0], dp[1][1]]]\n\n            for used_zero in (0, 1):\n                for parity in (0, 1):\n                    bits = dp[used_zero][parity]\n                    if not bits:\n                        continue\n\n                    if parity == 0:\n                        shifted = (bits << x) & mask\n                    else:\n                        shifted = bits >> x\n\n                    new_used_zero = 1 if (used_zero == 1 or x == 0) else 0\n                    new_parity = 1 - parity\n                    ndp[new_used_zero][new_parity] |= shifted\n\n            dp = ndp\n\n        if (dp[1][0] & target_bit) or (dp[1][1] & target_bit):\n            return 0\n\n        return -1"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 50791,
     "latency_s": 388.1,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 6,
       "refactor": 4,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 10,
       "score": 8.41
      },
      "radon": {
       "complexity": 47,
       "functions": 2,
       "mi": 56.69965667258857,
       "loc": 90,
       "lloc": 67,
       "sloc": 65,
       "comments": 9,
       "blank": 17
      },
      "sonar": {
       "maintainability": 2,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 2
       },
       "severities": {
        "CRITICAL": 1,
        "MINOR": 1
       },
       "rules": {
        "python:S3776": 1,
        "python:S100": 1
       }
      }
     },
     "code": "from typing import List\n\nclass Solution:\n    def maxProduct(self, nums: List[int], k: int, limit: int) -> int:\n        total = sum(nums)\n        if abs(k) > total:\n            return -1\n\n        offset = total\n        over = limit + 1\n        L = limit + 2  # product states: 0..limit, and over\n\n        # dp_even[p] / dp_odd[p]: bitset of reachable alternating sums\n        # for non-empty subsequences with selected length even/odd.\n        dp_even = [0] * L\n        dp_odd = [0] * L\n\n        for x in nums:\n            new_even = dp_even[:]\n            new_odd = dp_odd[:]\n\n            if x == 0:\n                # Start a subsequence with this zero.\n                new_odd[0] |= 1 << offset\n\n                # Append this zero to any existing subsequence.\n                all_even = 0\n                all_odd = 0\n                for p in range(L):\n                    if dp_even[p]:\n                        all_even |= dp_even[p]\n                    if dp_odd[p]:\n                        all_odd |= dp_odd[p]\n\n                new_odd[0] |= all_even\n                new_even[0] |= all_odd\n            else:\n                # Start a subsequence with this positive number.\n                if x <= limit:\n                    new_odd[x] |= 1 << (offset + x)\n                else:\n                    new_odd[over] |= 1 << (offset + x)\n\n                # Product 0 stays 0 after taking a positive number.\n                bits = dp_even[0]\n                if bits:\n                    new_odd[0] |= bits << x\n                bits = dp_odd[0]\n                if bits:\n                    new_even[0] |= bits >> x\n\n                max_p = limit // x\n\n                # Products that remain within the limit.\n                for p in range(1, max_p + 1):\n                    bits = dp_even[p]\n                    if bits:\n                        new_odd[p * x] |= bits << x\n                    bits = dp_odd[p]\n                    if bits:\n                        new_even[p * x] |= bits >> x\n\n                # Products that exceed the limit.\n                bucket_even = 0\n                bucket_odd = 0\n                for p in range(max_p + 1, limit + 1):\n                    if dp_even[p]:\n                        bucket_even |= dp_even[p]\n                    if dp_odd[p]:\n                        bucket_odd |= dp_odd[p]\n\n                if dp_even[over]:\n                    bucket_even |= dp_even[over]\n                if dp_odd[over]:\n                    bucket_odd |= dp_odd[over]\n\n                if bucket_even:\n                    new_odd[over] |= bucket_even << x\n                if bucket_odd:\n                    new_even[over] |= bucket_odd >> x\n\n            dp_even, dp_odd = new_even, new_odd\n\n        target_bit = 1 << (offset + k)\n\n        for p in range(limit, -1, -1):\n            if (dp_even[p] & target_bit) or (dp_odd[p] & target_bit):\n                return p\n\n        return -1"
    }
   }
  },
  {
   "id": "3773",
   "title": "Minimum Pair Removal to Sort Array I",
   "platform": "leetcode",
   "difficulty": "easy",
   "contest": "LeetCode 周赛 444",
   "date": "2025-04-05",
   "url": "https://leetcode.com/problems/minimum-pair-removal-to-sort-array-i/",
   "summary": "每次把和最小的相邻两数（并列取最左）合并为它们的和；求使数组变为非递减的最少操作次数。",
   "evaluated": false
  },
  {
   "id": "abc400_g",
   "title": "Patisserie ABC 3",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ABC 400 G 题",
   "date": "2025-04-05",
   "url": "https://atcoder.jp/contests/abc400/tasks/abc400_g",
   "summary": "N 个蛋糕各有三项属性，从中组成 K 对，每对的价格是两者三项属性分别相加后的最大值；求 K 对总价格的最大值。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 6/6",
     "output_tokens": 43429,
     "latency_s": 734.8,
     "cpu_s": 0.1555,
     "peak_mb": 32.1,
     "quality": {
      "pylint": {
       "convention": 4,
       "refactor": 3,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 7,
       "score": 9.19
      },
      "radon": {
       "complexity": 36,
       "functions": 1,
       "mi": 51.5577129850156,
       "loc": 119,
       "lloc": 89,
       "sloc": 90,
       "comments": 9,
       "blank": 20
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\n\n\ndef solve():\n    it = iter(map(int, sys.stdin.buffer.read().split()))\n    test_count = next(it)\n    answers = []\n    INF = 10 ** 30\n\n    for _ in range(test_count):\n        n = next(it)\n        k = next(it)\n        values = []\n        maximum = []\n        base_color = []\n\n        for _ in range(n):\n            x = next(it)\n            y = next(it)\n            z = next(it)\n            values.append((x, y, z))\n\n            if x >= y and x >= z:\n                maximum.append(x)\n                base_color.append(0)\n            elif y >= z:\n                maximum.append(y)\n                base_color.append(1)\n            else:\n                maximum.append(z)\n                base_color.append(2)\n\n        order = sorted(range(n), key=maximum.__getitem__, reverse=True)\n        chosen_count = 2 * k\n        chosen = order[:chosen_count]\n        unchosen = order[chosen_count:]\n\n        upper_bound = sum(maximum[i] for i in chosen)\n        counts = [0, 0, 0]\n        for i in chosen:\n            counts[base_color[i]] += 1\n\n        odd_colors = [c for c in range(3) if counts[c] & 1]\n        if not odd_colors:\n            answers.append(str(upper_bound))\n            continue\n\n        # Keep the two best candidates. Two changes can conflict on at most\n        # one chosen cake and at most one unchosen cake.\n        def add_two(lst, item):\n            if len(lst) < 2:\n                lst.append(item)\n                lst.sort()\n            elif item < lst[1]:\n                lst[1] = item\n                lst.sort()\n\n        # recolor[a][b]: (loss, cake), for chosen cakes whose base color is a.\n        recolor = [[[] for _ in range(3)] for _ in range(3)]\n        # lowest[a]: two smallest maximum values among chosen cakes of color a.\n        lowest = [[] for _ in range(3)]\n        # highest[b]: two largest b-values among unchosen cakes, negated.\n        highest = [[] for _ in range(3)]\n\n        for i in chosen:\n            a = base_color[i]\n            mi = maximum[i]\n            add_two(lowest[a], (mi, i))\n            for b in range(3):\n                if a != b:\n                    add_two(recolor[a][b], (mi - values[i][b], i))\n\n        for j in unchosen:\n            for b in range(3):\n                add_two(highest[b], (-values[j][b], j))\n\n        # A change is (loss, chosen_cake, unchosen_cake).\n        # unchosen_cake == -1 means a recoloring; otherwise it is a swap.\n        changes = {}\n        for a in range(3):\n            for b in range(3):\n                if a == b:\n                    continue\n                current = [(loss, i, -1) for loss, i in recolor[a][b]]\n                for mi, i in lowest[a]:\n                    for neg_value, j in highest[b]:\n                        current.append((mi + neg_value, i, j))\n                changes[(a, b)] = current\n\n        a, b = odd_colors\n        c = 3 - a - b\n        best_loss = INF\n\n        # One change toggling the two odd colors.\n        for direction in ((a, b), (b, a)):\n            for loss, _, _ in changes[direction]:\n                best_loss = min(best_loss, loss)\n\n        # Or two changes whose combined parity effect is the same.\n        for d1 in ((a, c), (c, a)):\n            for d2 in ((b, c), (c, b)):\n                for first in changes[d1]:\n                    for second in changes[d2]:\n                        if first[1] == second[1]:\n                            continue\n                        if (first[2] != -1 and second[2] != -1\n                                and first[2] == second[2]):\n                            continue\n                        best_loss = min(\n                            best_loss, first[0] + second[0]\n                        )\n\n        answers.append(str(upper_bound - best_loss))\n\n    sys.stdout.write(\"\\n\".join(answers))\n\n\nif __name__ == \"__main__\":\n    solve()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 6/6",
     "output_tokens": 55012,
     "latency_s": 333.9,
     "cpu_s": 0.2744,
     "peak_mb": 39.9,
     "quality": {
      "pylint": {
       "convention": 9,
       "refactor": 9,
       "warning": 6,
       "error": 0,
       "fatal": 0,
       "total": 24,
       "score": 8.56
      },
      "radon": {
       "complexity": 68,
       "functions": 1,
       "mi": 33.86408016491088,
       "loc": 220,
       "lloc": 177,
       "sloc": 172,
       "comments": 10,
       "blank": 38
      },
      "sonar": {
       "maintainability": 3,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 3
       },
       "severities": {
        "CRITICAL": 1,
        "MAJOR": 2
       },
       "rules": {
        "python:S3776": 1,
        "python:S1515": 2
       }
      }
     },
     "code": "import sys\nimport heapq\n\ndef solve():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    it = iter(data)\n    T = next(it)\n    outs = []\n    NEG = -10**30\n    C = 15\n\n    for _ in range(T):\n        N = next(it)\n        K = next(it)\n\n        vals = []\n        m = [0] * N\n        p = [0] * N\n\n        for i in range(N):\n            x = next(it)\n            y = next(it)\n            z = next(it)\n            vals.append((x, y, z))\n\n            if x >= y and x >= z:\n                m[i] = x\n                p[i] = 0\n            elif y >= x and y >= z:\n                m[i] = y\n                p[i] = 1\n            else:\n                m[i] = z\n                p[i] = 2\n\n        M = 2 * K\n\n        order = list(range(N))\n        order.sort(key=lambda i: m[i], reverse=True)\n\n        base = order[:M]\n        outside = order[M:]\n\n        base_sum = sum(m[i] for i in base)\n        base_parity = 0\n        for i in base:\n            base_parity ^= (1 << p[i])\n\n        smax = min(6, M, N - M)\n\n        # Base candidates\n        base_sorted = sorted(base, key=lambda i: m[i])\n\n        rem_cands = set()\n        for pl in range(3):\n            cnt = 0\n            for i in base_sorted:\n                if p[i] == pl:\n                    rem_cands.add(i)\n                    cnt += 1\n                    if cnt == C:\n                        break\n\n        for i in base_sorted[:C]:\n            rem_cands.add(i)\n\n        mod_cands = set()\n        for c in range(3):\n            for pl in range(3):\n                gen = (i for i in base if p[i] == pl)\n                cand = heapq.nsmallest(\n                    C, gen, key=lambda i, c=c: m[i] - vals[i][c]\n                )\n                for i in cand:\n                    mod_cands.add(i)\n\n        base_cands = list(rem_cands | mod_cands)\n\n        # Outside candidates\n        out_unmod_cands = set()\n        for pl in range(3):\n            gen = (i for i in outside if p[i] == pl)\n            cand = heapq.nlargest(C, gen, key=lambda i: m[i])\n            for i in cand:\n                out_unmod_cands.add(i)\n\n        out_mod_cands = set()\n        for c in range(3):\n            cand = heapq.nlargest(\n                C, outside, key=lambda i, c=c: vals[i][c]\n            )\n            for i in cand:\n                out_mod_cands.add(i)\n\n        outside_cands = list(out_unmod_cands | out_mod_cands)\n\n        # DP over base-side operations:\n        # removals, modifications, parity\n        base_dp = [[[NEG] * 8 for _ in range(3)] for _ in range(smax + 1)]\n        base_dp[0][0][0] = 0\n\n        for i in base_cands:\n            pi = p[i]\n            mi = m[i]\n            vi = vals[i]\n\n            ndp = [[row[:] for row in base_dp[r]] for r in range(smax + 1)]\n\n            # Remove this base item\n            if smax >= 1:\n                togg = 1 << pi\n                for r in range(smax):\n                    for mod in range(3):\n                        row = base_dp[r][mod]\n                        target = ndp[r + 1][mod]\n                        for par in range(8):\n                            val = row[par]\n                            if val == NEG:\n                                continue\n                            npar = par ^ togg\n                            nv = val - mi\n                            if nv > target[npar]:\n                                target[npar] = nv\n\n            # Modify this base item\n            for c in range(3):\n                if c == pi:\n                    continue\n                togg = (1 << pi) ^ (1 << c)\n                add = vi[c] - mi\n                for r in range(smax + 1):\n                    for mod in range(2):\n                        row = base_dp[r][mod]\n                        target = ndp[r][mod + 1]\n                        for par in range(8):\n                            val = row[par]\n                            if val == NEG:\n                                continue\n                            npar = par ^ togg\n                            nv = val + add\n                            if nv > target[npar]:\n                                target[npar] = nv\n\n            base_dp = ndp\n\n        # DP over outside-side operations:\n        # additions, modifications among additions, parity\n        out_dp = [[[NEG] * 8 for _ in range(3)] for _ in range(smax + 1)]\n        out_dp[0][0][0] = 0\n\n        for i in outside_cands:\n            pi = p[i]\n            mi = m[i]\n            vi = vals[i]\n\n            ndp = [[row[:] for row in out_dp[r]] for r in range(smax + 1)]\n\n            # Add unmodified\n            if smax >= 1:\n                togg = 1 << pi\n                for a in range(smax):\n                    for mod in range(3):\n                        row = out_dp[a][mod]\n                        target = ndp[a + 1][mod]\n                        for par in range(8):\n                            val = row[par]\n                            if val == NEG:\n                                continue\n                            npar = par ^ togg\n                            nv = val + mi\n                            if nv > target[npar]:\n                                target[npar] = nv\n\n            # Add modified\n            for c in range(3):\n                if c == pi:\n                    continue\n                togg = 1 << c\n                add = vi[c]\n                for a in range(smax):\n                    for mod in range(2):\n                        row = out_dp[a][mod]\n                        target = ndp[a + 1][mod + 1]\n                        for par in range(8):\n                            val = row[par]\n                            if val == NEG:\n                                continue\n                            npar = par ^ togg\n                            nv = val + add\n                            if nv > target[npar]:\n                                target[npar] = nv\n\n            out_dp = ndp\n\n        best_delta = NEG\n\n        for r in range(smax + 1):\n            for mod_base in range(3):\n                for mod_out in range(3 - mod_base):\n                    for pb in range(8):\n                        valb = base_dp[r][mod_base][pb]\n                        if valb == NEG:\n                            continue\n\n                        need_po = base_parity ^ pb\n                        valo = out_dp[r][mod_out][need_po]\n                        if valo == NEG:\n                            continue\n\n                        total = valb + valo\n                        if total > best_delta:\n                            best_delta = total\n\n        outs.append(str(base_sum + best_delta))\n\n    sys.stdout.write(\"\\n\".join(outs))\n\n\nif __name__ == \"__main__\":\n    solve()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 6/6",
     "output_tokens": 112722,
     "latency_s": 941.2,
     "cpu_s": 1.4515,
     "peak_mb": 39.9,
     "quality": {
      "pylint": {
       "convention": 14,
       "refactor": 6,
       "warning": 34,
       "error": 0,
       "fatal": 0,
       "total": 54,
       "score": 6.82
      },
      "radon": {
       "complexity": 24,
       "functions": 1,
       "mi": 25.476971038996762,
       "loc": 203,
       "lloc": 173,
       "sloc": 170,
       "comments": 0,
       "blank": 33
      },
      "sonar": {
       "maintainability": 3,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 3
       },
       "severities": {
        "CRITICAL": 1,
        "MAJOR": 1,
        "MINOR": 1
       },
       "rules": {
        "python:S3776": 1,
        "python:S1515": 1,
        "python:S117": 1
       }
      }
     },
     "code": "import sys\nfrom heapq import heappush, heappop\n\ndef solve():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    idx = 0\n    T = data[idx]\n    idx += 1\n    out = []\n\n    for _ in range(T):\n        N = data[idx]\n        K = data[idx + 1]\n        idx += 2\n\n        X = [0] * N\n        Y = [0] * N\n        Z = [0] * N\n        M = [0] * N\n        maxc = [0] * N\n\n        for i in range(N):\n            x = data[idx]\n            y = data[idx + 1]\n            z = data[idx + 2]\n            idx += 3\n            X[i] = x\n            Y[i] = y\n            Z[i] = z\n            m = x\n            c = 0\n            if y > m:\n                m = y\n                c = 1\n            if z > m:\n                m = z\n                c = 2\n            M[i] = m\n            maxc[i] = c\n\n        order = sorted(range(N), key=lambda i: M[i], reverse=True)\n        selected = [False] * N\n        sel = order[:2 * K]\n        for i in sel:\n            selected[i] = True\n\n        base = sum(M[i] for i in sel)\n\n        cnt = [0, 0, 0]\n        for i in sel:\n            cnt[maxc[i]] += 1\n\n        if cnt[0] % 2 == 0 and cnt[1] % 2 == 0 and cnt[2] % 2 == 0:\n            out.append(str(base))\n            continue\n\n        odd = [i for i in range(3) if cnt[i] % 2 == 1]\n        a, b = odd[0], odd[1]\n        c3 = 3 - a - b\n\n        unselected = [i for i in range(N) if not selected[i]]\n        Mmin = min(M[i] for i in sel)\n\n        S = N\n        col = [N + 1, N + 2, N + 3]\n        V = N + 4\n\n        g = [[] for _ in range(V)]\n        to = []\n        cap = []\n        edge_cost = []\n\n        def add_edge(u, v, cst):\n            g[u].append(len(to))\n            to.append(v)\n            cap.append(1)\n            edge_cost.append(cst)\n            g[v].append(len(to))\n            to.append(u)\n            cap.append(0)\n            edge_cost.append(-cst)\n\n        for i in sel:\n            ci = maxc[i]\n            add_edge(col[ci], i, M[i])\n            add_edge(i, S, 0)\n            if ci != 0:\n                add_edge(i, col[0], -X[i])\n            if ci != 1:\n                add_edge(i, col[1], -Y[i])\n            if ci != 2:\n                add_edge(i, col[2], -Z[i])\n\n        for j in unselected:\n            add_edge(S, j, 0)\n            add_edge(j, col[0], -X[j])\n            add_edge(j, col[1], -Y[j])\n            add_edge(j, col[2], -Z[j])\n\n        pot0 = [0] * V\n        pot0[S] = Mmin\n        for i in sel:\n            pot0[i] = M[i]\n        for j in unselected:\n            pot0[j] = M[j]\n\n        INF = 10**30\n\n        def min_cost_option(src_list, tgt_list):\n            supply = {}\n            for s, amt in src_list:\n                supply[s] = supply.get(s, 0) + amt\n            demand = {}\n            for t, amt in tgt_list:\n                demand[t] = demand.get(t, 0) + amt\n\n            flow_needed = sum(demand.values())\n            pot = pot0[:]\n            changed = []\n            total_cost = 0\n\n            for _ in range(flow_needed):\n                dist = [INF] * V\n                prev_node = [-1] * V\n                prev_edge = [-1] * V\n                heap = []\n\n                for s, amt in supply.items():\n                    if amt > 0:\n                        dist[s] = -pot[s]\n                        heappush(heap, (dist[s], s))\n\n                while heap:\n                    d, u = heappop(heap)\n                    if d != dist[u]:\n                        continue\n                    for eid in g[u]:\n                        if cap[eid] > 0:\n                            v = to[eid]\n                            nd = d + edge_cost[eid] + pot[u] - pot[v]\n                            if nd < dist[v]:\n                                dist[v] = nd\n                                prev_node[v] = u\n                                prev_edge[v] = eid\n                                heappush(heap, (nd, v))\n\n                target = -1\n                best_cost = INF\n                for t, amt in demand.items():\n                    if amt > 0 and dist[t] < INF:\n                        cur = dist[t] + pot[t]\n                        if cur < best_cost:\n                            best_cost = cur\n                            target = t\n\n                if target == -1:\n                    for eid, old in reversed(changed):\n                        cap[eid] = old\n                    return INF\n\n                node = target\n                path_cost = 0\n                while prev_edge[node] != -1:\n                    eid = prev_edge[node]\n                    rev = eid ^ 1\n                    changed.append((eid, cap[eid]))\n                    changed.append((rev, cap[rev]))\n                    cap[eid] -= 1\n                    cap[rev] += 1\n                    path_cost += edge_cost[eid]\n                    node = prev_node[node]\n\n                source = node\n                if supply.get(source, 0) <= 0:\n                    for eid, old in reversed(changed):\n                        cap[eid] = old\n                    return INF\n\n                supply[source] -= 1\n                demand[target] -= 1\n                total_cost += path_cost\n\n                for v in range(V):\n                    if dist[v] < INF:\n                        pot[v] += dist[v]\n\n            for eid, old in reversed(changed):\n                cap[eid] = old\n            return total_cost\n\n        ca, cb, cc = col[a], col[b], col[c3]\n        loss = INF\n        loss = min(loss, min_cost_option([(ca, 1)], [(cb, 1)]))\n        loss = min(loss, min_cost_option([(cb, 1)], [(ca, 1)]))\n        loss = min(loss, min_cost_option([(ca, 1), (cb, 1)], [(cc, 2)]))\n        loss = min(loss, min_cost_option([(cc, 2)], [(ca, 1), (cb, 1)]))\n\n        out.append(str(base - loss))\n\n    sys.stdout.write(\"\\n\".join(out))\n\nif __name__ == \"__main__\":\n    solve()"
    }
   }
  },
  {
   "id": "abc400_e",
   "title": "Ringo's Favorite Numbers 3",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ABC 400 E 题",
   "date": "2025-04-05",
   "url": "https://atcoder.jp/contests/abc400/tasks/abc400_e",
   "summary": "恰有两个不同质因数、且每个质因数的指数都是偶数的数称为 400 数；对每个查询 A，求不超过 A 的最大 400 数。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 5/5",
     "output_tokens": 3134,
     "latency_s": 47.2,
     "cpu_s": 0.4253,
     "peak_mb": 36.1,
     "quality": {
      "pylint": {
       "convention": 3,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 3,
       "score": 8.57
      },
      "radon": {
       "complexity": 0,
       "functions": 0,
       "mi": 77.60672589548419,
       "loc": 29,
       "lloc": 21,
       "sloc": 21,
       "comments": 4,
       "blank": 5
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\nimport math\n\nMAX_X = 10**6\n\n# Count distinct prime factors for every integer up to MAX_X.\nprime_factor_count = [0] * (MAX_X + 1)\nfor p in range(2, MAX_X + 1):\n    if prime_factor_count[p] == 0:  # p is prime\n        for multiple in range(p, MAX_X + 1, p):\n            prime_factor_count[multiple] += 1\n\n# A 400 number is exactly x^2, where x has exactly two distinct\n# prime factors. Precompute the largest such x not exceeding each index.\nnearest = [0] * (MAX_X + 1)\nlast = 0\nfor x in range(2, MAX_X + 1):\n    if prime_factor_count[x] == 2:\n        last = x\n    nearest[x] = last\n\ndata = list(map(int, sys.stdin.buffer.read().split()))\nanswers = []\nfor a in data[1:]:\n    limit = math.isqrt(a)\n    x = nearest[limit]\n    answers.append(str(x * x))\n\nsys.stdout.write(\"\\n\".join(answers) + \"\\n\")"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 5/5",
     "output_tokens": 3120,
     "latency_s": 16.1,
     "cpu_s": 0.3928,
     "peak_mb": 32.1,
     "quality": {
      "pylint": {
       "convention": 2,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 2,
       "score": 9.0
      },
      "radon": {
       "complexity": 0,
       "functions": 0,
       "mi": 67.98801723930323,
       "loc": 27,
       "lloc": 21,
       "sloc": 20,
       "comments": 1,
       "blank": 7
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\nfrom bisect import bisect_right\n\nMAX_M = 10**6\n\nomega = [0] * (MAX_M + 1)\n\nfor p in range(2, MAX_M + 1):\n    if omega[p] == 0:  # p is prime\n        for x in range(p, MAX_M + 1, p):\n            omega[x] += 1\n\nnumbers = []\nfor m in range(2, MAX_M + 1):\n    if omega[m] == 2:\n        numbers.append(m * m)\n\ndata = list(map(int, sys.stdin.buffer.read().split()))\nq = data[0]\nqueries = data[1:1 + q]\n\nanswers = []\nfor a in queries:\n    idx = bisect_right(numbers, a) - 1\n    answers.append(str(numbers[idx]))\n\nsys.stdout.write(\"\\n\".join(answers))"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 5/5",
     "output_tokens": 10172,
     "latency_s": 79.3,
     "cpu_s": 0.2606,
     "peak_mb": 24.1,
     "quality": {
      "pylint": {
       "convention": 3,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 3,
       "score": 8.85
      },
      "radon": {
       "complexity": 8,
       "functions": 1,
       "mi": 71.33476319688391,
       "loc": 36,
       "lloc": 27,
       "sloc": 26,
       "comments": 3,
       "blank": 8
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\nimport math\nfrom bisect import bisect_right\n\ndef main():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    if not data:\n        return\n\n    q = data[0]\n    queries = data[1:1 + q]\n\n    max_a = max(queries)\n    max_m = math.isqrt(max_a)\n\n    # omega[i] = number of distinct prime factors of i\n    omega = bytearray(max_m + 1)\n    for p in range(2, max_m + 1):\n        if omega[p] == 0:  # p is prime\n            for multiple in range(p, max_m + 1, p):\n                omega[multiple] += 1\n\n    # M^2 is a 400 number iff M has exactly two distinct prime factors\n    valid_m = [m for m in range(2, max_m + 1) if omega[m] == 2]\n\n    out = []\n    for a in queries:\n        x = math.isqrt(a)\n        idx = bisect_right(valid_m, x) - 1\n        m = valid_m[idx]\n        out.append(str(m * m))\n\n    sys.stdout.write(\"\\n\".join(out))\n\nif __name__ == \"__main__\":\n    main()"
    }
   }
  },
  {
   "id": "abc400_d",
   "title": "Takahashi the Wall Breaker",
   "platform": "atcoder",
   "difficulty": "medium",
   "contest": "AtCoder ABC 400 D 题",
   "date": "2025-04-05",
   "url": "https://atcoder.jp/contests/abc400/tasks/abc400_d",
   "summary": "网格中可以走到相邻道路格，也可以向一个方向前踢，打通前方至多两格内的墙；求从起点到终点的最少前踢次数。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 44/44",
     "output_tokens": 26716,
     "latency_s": 415.9,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 3,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 4,
       "score": 9.29
      },
      "radon": {
       "complexity": 14,
       "functions": 1,
       "mi": 55.681085637284625,
       "loc": 76,
       "lloc": 56,
       "sloc": 56,
       "comments": 4,
       "blank": 17
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\nfrom collections import deque\n\n\ndef main():\n    data = sys.stdin.buffer.read().split()\n    it = iter(data)\n\n    h = int(next(it))\n    w = int(next(it))\n    grid = [next(it) for _ in range(h)]\n    a = int(next(it))\n    b = int(next(it))\n    c = int(next(it))\n    d = int(next(it))\n\n    n = h * w\n    start = (a - 1) * w + (b - 1)\n    goal = (c - 1) * w + (d - 1)\n\n    inf = n + 1\n    dist = [inf] * n\n    dist[start] = 0\n\n    dq = deque([start])\n    popleft = dq.popleft\n    append = dq.append\n    appendleft = dq.appendleft\n    finished = bytearray(n)\n\n    # Moving to an adjacent original road costs 0.\n    # A kick makes the cells one and two steps away in its direction usable,\n    # so reaching either of those cells can be represented by a cost-1 edge.\n    directions = ((-1, 0, -w), (1, 0, w), (0, -1, -1), (0, 1, 1))\n\n    while dq:\n        v = popleft()\n        if finished[v]:\n            continue\n        finished[v] = 1\n\n        dv = dist[v]\n        if v == goal:\n            print(dv)\n            return\n\n        r, col = divmod(v, w)\n        nd = dv + 1\n\n        for dr, dc, step in directions:\n            r1 = r + dr\n            c1 = col + dc\n            if 0 <= r1 < h and 0 <= c1 < w:\n                u = v + step\n\n                if grid[r1][c1] == 46 and dv < dist[u]:  # '.'\n                    dist[u] = dv\n                    appendleft(u)\n\n                if nd < dist[u]:\n                    dist[u] = nd\n                    append(u)\n\n                r2 = r1 + dr\n                c2 = c1 + dc\n                if 0 <= r2 < h and 0 <= c2 < w:\n                    u += step\n                    if nd < dist[u]:\n                        dist[u] = nd\n                        append(u)\n\n    print(dist[goal])\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 44/44",
     "output_tokens": 49006,
     "latency_s": 290.0,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 13,
       "refactor": 3,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 16,
       "score": 8.32
      },
      "radon": {
       "complexity": 44,
       "functions": 1,
       "mi": 36.493126783488265,
       "loc": 126,
       "lloc": 96,
       "sloc": 95,
       "comments": 2,
       "blank": 29
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\nfrom collections import deque\n\n\ndef main():\n    data = sys.stdin.buffer.read().split()\n    H = int(data[0])\n    W = int(data[1])\n\n    S = data[2:2 + H]\n    A = int(data[2 + H])\n    B = int(data[3 + H])\n    C = int(data[4 + H])\n    D = int(data[5 + H])\n\n    grid = b''.join(S)\n    N = H * W\n\n    start = (A - 1) * W + (B - 1)\n    goal = (C - 1) * W + (D - 1)\n\n    INF = 10 ** 9\n    dist = [INF] * N\n    visited = bytearray(N)\n\n    dist[start] = 0\n    dq = deque([start])\n\n    DOT = ord('.')\n\n    while dq:\n        v = dq.popleft()\n\n        if visited[v]:\n            continue\n        visited[v] = 1\n\n        d = dist[v]\n\n        if v == goal:\n            break\n\n        r = v // W\n        c = v - r * W\n\n        # Move to an adjacent original road, cost 0.\n        if v >= W:\n            u = v - W\n            if not visited[u] and grid[u] == DOT and d < dist[u]:\n                dist[u] = d\n                dq.appendleft(u)\n\n        if v + W < N:\n            u = v + W\n            if not visited[u] and grid[u] == DOT and d < dist[u]:\n                dist[u] = d\n                dq.appendleft(u)\n\n        if c > 0:\n            u = v - 1\n            if not visited[u] and grid[u] == DOT and d < dist[u]:\n                dist[u] = d\n                dq.appendleft(u)\n\n        if c + 1 < W:\n            u = v + 1\n            if not visited[u] and grid[u] == DOT and d < dist[u]:\n                dist[u] = d\n                dq.appendleft(u)\n\n        nd = d + 1\n\n        # Front kick: up to two cells in one of four directions, cost 1.\n        if r >= 1:\n            u = v - W\n            if not visited[u] and nd < dist[u]:\n                dist[u] = nd\n                dq.append(u)\n\n        if r >= 2:\n            u = v - 2 * W\n            if not visited[u] and nd < dist[u]:\n                dist[u] = nd\n                dq.append(u)\n\n        if r + 1 < H:\n            u = v + W\n            if not visited[u] and nd < dist[u]:\n                dist[u] = nd\n                dq.append(u)\n\n        if r + 2 < H:\n            u = v + 2 * W\n            if not visited[u] and nd < dist[u]:\n                dist[u] = nd\n                dq.append(u)\n\n        if c >= 1:\n            u = v - 1\n            if not visited[u] and nd < dist[u]:\n                dist[u] = nd\n                dq.append(u)\n\n        if c >= 2:\n            u = v - 2\n            if not visited[u] and nd < dist[u]:\n                dist[u] = nd\n                dq.append(u)\n\n        if c + 1 < W:\n            u = v + 1\n            if not visited[u] and nd < dist[u]:\n                dist[u] = nd\n                dq.append(u)\n\n        if c + 2 < W:\n            u = v + 2\n            if not visited[u] and nd < dist[u]:\n                dist[u] = nd\n                dq.append(u)\n\n    print(dist[goal])\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 44/44",
     "output_tokens": 63912,
     "latency_s": 543.7,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 10,
       "refactor": 3,
       "warning": 1,
       "error": 0,
       "fatal": 0,
       "total": 14,
       "score": 8.51
      },
      "radon": {
       "complexity": 34,
       "functions": 1,
       "mi": 39.21420992710702,
       "loc": 110,
       "lloc": 94,
       "sloc": 94,
       "comments": 2,
       "blank": 14
      },
      "sonar": {
       "maintainability": 2,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 2
       },
       "severities": {
        "CRITICAL": 1,
        "MAJOR": 1
       },
       "rules": {
        "python:S3776": 1,
        "python:S5806": 1
       }
      }
     },
     "code": "import sys\nfrom collections import deque\n\ndef solve():\n    input = sys.stdin.readline\n\n    H, W = map(int, input().split())\n    road = bytearray(H * W)\n\n    for i in range(H):\n        s = input().strip()\n        base = i * W\n        for j, ch in enumerate(s):\n            if ch == '.':\n                road[base + j] = 1\n\n    A, B, C, D = map(int, input().split())\n    start = (A - 1) * W + (B - 1)\n    target = (C - 1) * W + (D - 1)\n\n    INF = 10 ** 9\n    dist = [INF] * (H * W)\n    dist[start] = 0\n\n    dq = deque([start])\n    popleft = dq.popleft\n    appendleft = dq.appendleft\n    append = dq.append\n\n    while dq:\n        idx = popleft()\n        d = dist[idx]\n\n        if idx == target:\n            print(d)\n            return\n\n        r = idx // W\n        c = idx - r * W\n\n        # 0-cost moves: move to adjacent initially-road cells\n        if r > 0:\n            nidx = idx - W\n            if road[nidx] and d < dist[nidx]:\n                dist[nidx] = d\n                appendleft(nidx)\n        if r + 1 < H:\n            nidx = idx + W\n            if road[nidx] and d < dist[nidx]:\n                dist[nidx] = d\n                appendleft(nidx)\n        if c > 0:\n            nidx = idx - 1\n            if road[nidx] and d < dist[nidx]:\n                dist[nidx] = d\n                appendleft(nidx)\n        if c + 1 < W:\n            nidx = idx + 1\n            if road[nidx] and d < dist[nidx]:\n                dist[nidx] = d\n                appendleft(nidx)\n\n        nd = d + 1\n\n        # 1-cost front kicks: up to 2 cells in each direction\n        if r >= 1:\n            nidx = idx - W\n            if nd < dist[nidx]:\n                dist[nidx] = nd\n                append(nidx)\n        if r >= 2:\n            nidx = idx - 2 * W\n            if nd < dist[nidx]:\n                dist[nidx] = nd\n                append(nidx)\n        if r + 1 < H:\n            nidx = idx + W\n            if nd < dist[nidx]:\n                dist[nidx] = nd\n                append(nidx)\n        if r + 2 < H:\n            nidx = idx + 2 * W\n            if nd < dist[nidx]:\n                dist[nidx] = nd\n                append(nidx)\n        if c >= 1:\n            nidx = idx - 1\n            if nd < dist[nidx]:\n                dist[nidx] = nd\n                append(nidx)\n        if c >= 2:\n            nidx = idx - 2\n            if nd < dist[nidx]:\n                dist[nidx] = nd\n                append(nidx)\n        if c + 1 < W:\n            nidx = idx + 1\n            if nd < dist[nidx]:\n                dist[nidx] = nd\n                append(nidx)\n        if c + 2 < W:\n            nidx = idx + 2\n            if nd < dist[nidx]:\n                dist[nidx] = nd\n                append(nidx)\n\n    print(dist[target])\n\nif __name__ == \"__main__\":\n    solve()"
    }
   }
  },
  {
   "id": "abc400_c",
   "title": "2^a b^2",
   "platform": "atcoder",
   "difficulty": "medium",
   "contest": "AtCoder ABC 400 C 题",
   "date": "2025-04-05",
   "url": "https://atcoder.jp/contests/abc400/tasks/abc400_c",
   "summary": "能写成 2ᵃ·b²（a、b 为正整数）的数称为好数；求 1 到 N 内好数的个数，N ≤ 10¹⁸。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 2317,
     "latency_s": 34.5,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 3,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 3,
       "score": 6.25
      },
      "radon": {
       "complexity": 1,
       "functions": 1,
       "mi": 93.98147447172332,
       "loc": 12,
       "lloc": 8,
       "sloc": 8,
       "comments": 2,
       "blank": 2
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\nfrom math import isqrt\n\ndef main():\n    n = int(sys.stdin.buffer.read().strip())\n    # Good integers are exactly the disjoint sets:\n    # (2k)^2 = 4k^2 and 2k^2, for positive integers k.\n    answer = isqrt(n // 4) + isqrt(n // 2)\n    print(answer)\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 1295,
     "latency_s": 6.9,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 4,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 4,
       "score": 6.92
      },
      "radon": {
       "complexity": 2,
       "functions": 1,
       "mi": 61.89476391964293,
       "loc": 17,
       "lloc": 13,
       "sloc": 13,
       "comments": 0,
       "blank": 4
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\nimport math\n\ndef main():\n    N = int(sys.stdin.readline())\n    ans = 0\n    power_of_two = 2\n\n    while power_of_two <= N:\n        max_odd_square_base = math.isqrt(N // power_of_two)\n        ans += (max_odd_square_base + 1) // 2\n        power_of_two *= 2\n\n    print(ans)\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 3370,
     "latency_s": 25.5,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 4,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 4,
       "score": 5.0
      },
      "radon": {
       "complexity": 1,
       "functions": 1,
       "mi": 68.8237991482895,
       "loc": 10,
       "lloc": 8,
       "sloc": 8,
       "comments": 0,
       "blank": 2
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\nfrom math import isqrt\n\ndef main():\n    N = int(sys.stdin.read().strip())\n    ans = isqrt(N) // 2 + isqrt(N // 2)\n    print(ans)\n\nif __name__ == \"__main__\":\n    main()"
    }
   }
  },
  {
   "id": "abc400_b",
   "title": "Sum of Geometric Series",
   "platform": "atcoder",
   "difficulty": "easy",
   "contest": "AtCoder ABC 400 B 题",
   "date": "2025-04-05",
   "url": "https://atcoder.jp/contests/abc400/tasks/abc400_b",
   "summary": "给定 N、M，计算 X = N⁰ + N¹ + … + Nᴹ；X ≤ 10⁹ 时输出 X，否则输出 inf。",
   "evaluated": false
  },
  {
   "id": "abc400_a",
   "title": "ABC400 Party",
   "platform": "atcoder",
   "difficulty": "easy",
   "contest": "AtCoder ABC 400 A 题",
   "date": "2025-04-05",
   "url": "https://atcoder.jp/contests/abc400/tasks/abc400_a",
   "summary": "400 人排成 A 行 B 列、没有空位的长方形队列；给定 A，输出满足条件的 B，不存在时输出 -1。",
   "evaluated": false
  },
  {
   "id": "3832",
   "title": "Minimum Cost to Reach Every Position",
   "platform": "leetcode",
   "difficulty": "easy",
   "contest": "LeetCode 周赛 443",
   "date": "2025-03-29",
   "url": "https://leetcode.com/problems/minimum-cost-to-reach-every-position/",
   "summary": "站在队尾，与前面第 i 人换位需付 cost[i]，与后面的人换位免费；对每个位置求到达它的最小总费用。",
   "evaluated": false
  },
  {
   "id": "3793",
   "title": "Longest Palindrome After Substring Concatenation I",
   "platform": "leetcode",
   "difficulty": "medium",
   "contest": "LeetCode 周赛 443",
   "date": "2025-03-29",
   "url": "https://leetcode.com/problems/longest-palindrome-after-substring-concatenation-i/",
   "summary": "从 s 取一个子串、从 t 取一个子串，按顺序拼接（均可为空）；求能得到的最长回文串长度。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 2748,
     "latency_s": 44.0,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 6,
       "score": 7.0
      },
      "radon": {
       "complexity": 11,
       "functions": 2,
       "mi": 57.02467719799788,
       "loc": 24,
       "lloc": 21,
       "sloc": 20,
       "comments": 0,
       "blank": 4
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "MINOR": 1
       },
       "rules": {
        "python:S100": 1
       }
      }
     },
     "code": "class Solution:\n    def longestPalindrome(self, s: str, t: str) -> int:\n        def all_substrings(x: str):\n            result = [\"\"]\n            for start in range(len(x)):\n                for end in range(start + 1, len(x) + 1):\n                    result.append(x[start:end])\n            return result\n\n        s_substrings = all_substrings(s)\n        t_substrings = all_substrings(t)\n\n        best = 0\n        for a in s_substrings:\n            for b in t_substrings:\n                length = len(a) + len(b)\n                if length <= best:\n                    continue\n\n                candidate = a + b\n                if candidate == candidate[::-1]:\n                    best = length\n\n        return best"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 1528,
     "latency_s": 8.8,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 6,
       "score": 6.84
      },
      "radon": {
       "complexity": 17,
       "functions": 2,
       "mi": 56.51357588338607,
       "loc": 25,
       "lloc": 22,
       "sloc": 19,
       "comments": 0,
       "blank": 6
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "MINOR": 1
       },
       "rules": {
        "python:S100": 1
       }
      }
     },
     "code": "class Solution:\n    def longestPalindrome(self, s: str, t: str) -> int:\n        def is_palindrome(x: str) -> bool:\n            return x == x[::-1]\n\n        substrings_s = [\"\"]\n        substrings_t = [\"\"]\n\n        for i in range(len(s)):\n            for j in range(i + 1, len(s) + 1):\n                substrings_s.append(s[i:j])\n\n        for i in range(len(t)):\n            for j in range(i + 1, len(t) + 1):\n                substrings_t.append(t[i:j])\n\n        best = 0\n\n        for a in substrings_s:\n            for b in substrings_t:\n                candidate = a + b\n                if is_palindrome(candidate):\n                    best = max(best, len(candidate))\n\n        return best"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 4031,
     "latency_s": 30.2,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 8,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 9,
       "score": 5.26
      },
      "radon": {
       "complexity": 17,
       "functions": 2,
       "mi": 56.51357588338607,
       "loc": 22,
       "lloc": 22,
       "sloc": 19,
       "comments": 0,
       "blank": 3
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "MINOR": 1
       },
       "rules": {
        "python:S100": 1
       }
      }
     },
     "code": "class Solution:\n    def longestPalindrome(self, s: str, t: str) -> int:\n        def is_pal(x: str) -> bool:\n            return x == x[::-1]\n        \n        s_subs = [\"\"]\n        for i in range(len(s)):\n            for j in range(i + 1, len(s) + 1):\n                s_subs.append(s[i:j])\n        \n        t_subs = [\"\"]\n        for i in range(len(t)):\n            for j in range(i + 1, len(t) + 1):\n                t_subs.append(t[i:j])\n        \n        ans = 0\n        for a in s_subs:\n            for b in t_subs:\n                cand = a + b\n                if is_pal(cand):\n                    ans = max(ans, len(cand))\n        return ans"
    }
   }
  },
  {
   "id": "3717",
   "title": "Minimum Operations to Make Elements Within K Subarrays Equal",
   "platform": "leetcode",
   "difficulty": "hard",
   "contest": "LeetCode 周赛 443",
   "date": "2025-03-29",
   "url": "https://leetcode.com/problems/minimum-operations-to-make-elements-within-k-subarrays-equal/",
   "summary": "每次可把一个元素加 1 或减 1；求最少操作次数，使数组中出现至少 k 个互不重叠、长度恰为 x 且元素全部相等的子数组。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 14057,
     "latency_s": 213.9,
     "cpu_s": 1.0006,
     "peak_mb": 36.7,
     "quality": {
      "pylint": {
       "convention": 6,
       "refactor": 2,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 8,
       "score": 8.84
      },
      "radon": {
       "complexity": 31,
       "functions": 7,
       "mi": 49.444169379243995,
       "loc": 94,
       "lloc": 73,
       "sloc": 69,
       "comments": 4,
       "blank": 19
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "MINOR": 1
       },
       "rules": {
        "python:S100": 1
       }
      }
     },
     "code": "from typing import List\n\n\nclass _Fenwick:\n    __slots__ = (\"n\", \"count\", \"sums\", \"step\")\n\n    def __init__(self, n: int):\n        self.n = n\n        self.count = [0] * (n + 1)\n        self.sums = [0] * (n + 1)\n        self.step = 1 << (n.bit_length() - 1)\n\n    def update(self, index: int, count_delta: int, sum_delta: int) -> None:\n        i = index + 1\n        while i <= self.n:\n            self.count[i] += count_delta\n            self.sums[i] += sum_delta\n            i += i & -i\n\n    def prefix(self, index: int):\n        \"\"\"Count and sum over compressed coordinates [0, index].\"\"\"\n        i = index + 1\n        count = 0\n        total = 0\n        while i > 0:\n            count += self.count[i]\n            total += self.sums[i]\n            i -= i & -i\n        return count, total\n\n    def kth(self, k: int) -> int:\n        \"\"\"Return the 0-based compressed coordinate of the kth element.\"\"\"\n        index = 0\n        bit = self.step\n        while bit:\n            nxt = index + bit\n            if nxt <= self.n and self.count[nxt] < k:\n                index = nxt\n                k -= self.count[nxt]\n            bit >>= 1\n        return index\n\n\nclass Solution:\n    def minOperations(self, nums: List[int], x: int, k: int) -> int:\n        n = len(nums)\n\n        # Coordinate compression for a sliding-window frequency/sum BIT.\n        values = sorted(set(nums))\n        compressed = {value: i for i, value in enumerate(values)}\n        bit = _Fenwick(len(values))\n\n        window_sum = sum(nums[:x])\n        for value in nums[:x]:\n            bit.update(compressed[value], 1, value)\n\n        window_count = n - x + 1\n        costs = [0] * window_count\n        median_rank = (x + 1) // 2\n\n        for start in range(window_count):\n            median_index = bit.kth(median_rank)\n            median = values[median_index]\n\n            count_le, sum_le = bit.prefix(median_index)\n            left_cost = median * count_le - sum_le\n            right_cost = (window_sum - sum_le) - median * (x - count_le)\n            costs[start] = left_cost + right_cost\n\n            if start + 1 < window_count:\n                outgoing = nums[start]\n                incoming = nums[start + x]\n                if outgoing != incoming:\n                    bit.update(compressed[outgoing], -1, -outgoing)\n                    bit.update(compressed[incoming], 1, incoming)\n                    window_sum += incoming - outgoing\n\n        # prev[i]: minimum cost using the previous number of subarrays\n        # within the prefix nums[:i].\n        prev = [0] * (n + 1)\n        inf = 10**30\n\n        for chosen in range(1, k + 1):\n            cur = [inf] * (n + 1)\n\n            # Fewer than chosen*x elements cannot contain enough subarrays.\n            for end in range(chosen * x, n + 1):\n                skip = cur[end - 1]\n                take = prev[end - x] + costs[end - x]\n                cur[end] = take if take < skip else skip\n\n            prev = cur\n\n        return prev[n]"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 7602,
     "latency_s": 39.8,
     "cpu_s": 1.3975,
     "peak_mb": 40.6,
     "quality": {
      "pylint": {
       "convention": 10,
       "refactor": 3,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 13,
       "score": 8.54
      },
      "radon": {
       "complexity": 21,
       "functions": 2,
       "mi": 34.07857535566959,
       "loc": 120,
       "lloc": 91,
       "sloc": 95,
       "comments": 0,
       "blank": 25
      },
      "sonar": {
       "maintainability": 2,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 2
       },
       "severities": {
        "MINOR": 1,
        "CRITICAL": 1
       },
       "rules": {
        "python:S100": 1,
        "python:S3776": 1
       }
      }
     },
     "code": "from typing import List\n\nclass Solution:\n    def minOperations(self, nums: List[int], x: int, k: int) -> int:\n        n = len(nums)\n\n        class Fenwick:\n            def __init__(self, size: int):\n                self.n = size\n                self.tree = [0] * (size + 1)\n\n            def add(self, idx: int, delta: int) -> None:\n                i = idx + 1\n                while i <= self.n:\n                    self.tree[i] += delta\n                    i += i & -i\n\n            def prefix(self, idx: int) -> int:\n                if idx < 0:\n                    return 0\n                i = idx + 1\n                res = 0\n                while i > 0:\n                    res += self.tree[i]\n                    i -= i & -i\n                return res\n\n            def kth(self, rank: int) -> int:\n                idx = 0\n                bit = 1 << (self.n.bit_length() - 1)\n                while bit:\n                    nxt = idx + bit\n                    if nxt <= self.n and self.tree[nxt] < rank:\n                        idx = nxt\n                        rank -= self.tree[nxt]\n                    bit >>= 1\n                return idx\n\n        values = sorted(set(nums))\n        value_to_idx = {v: i for i, v in enumerate(values)}\n        m = len(values)\n\n        count_bit = Fenwick(m)\n        sum_bit = Fenwick(m)\n\n        total = 0\n        for i in range(x):\n            v = nums[i]\n            idx = value_to_idx[v]\n            count_bit.add(idx, 1)\n            sum_bit.add(idx, v)\n            total += v\n\n        costs = [0] * (n - x + 1)\n        median_rank = (x + 1) // 2\n\n        for start in range(n - x + 1):\n            if start > 0:\n                out_val = nums[start - 1]\n                in_val = nums[start + x - 1]\n\n                out_idx = value_to_idx[out_val]\n                count_bit.add(out_idx, -1)\n                sum_bit.add(out_idx, -out_val)\n\n                in_idx = value_to_idx[in_val]\n                count_bit.add(in_idx, 1)\n                sum_bit.add(in_idx, in_val)\n\n                total += in_val - out_val\n\n            med_idx = count_bit.kth(median_rank)\n            median = values[med_idx]\n\n            if med_idx > 0:\n                less_count = count_bit.prefix(med_idx - 1)\n                less_sum = sum_bit.prefix(med_idx - 1)\n            else:\n                less_count = 0\n                less_sum = 0\n\n            le_count = count_bit.prefix(med_idx)\n            le_sum = sum_bit.prefix(med_idx)\n\n            greater_count = x - le_count\n            greater_sum = total - le_sum\n\n            costs[start] = (\n                median * less_count\n                - less_sum\n                + greater_sum\n                - median * greater_count\n            )\n\n        INF = 10**30\n        size = x + 1\n        rows = [None] * size\n\n        row0 = [INF] * (k + 1)\n        row0[0] = 0\n        rows[0] = row0\n\n        for i in range(1, n + 1):\n            prev = rows[(i - 1) % size]\n            curr = prev.copy()\n            curr[0] = 0\n\n            if i >= x:\n                start = i - x\n                base = rows[start % size]\n                cost = costs[start]\n\n                for cnt in range(1, k + 1):\n                    candidate = base[cnt - 1] + cost\n                    if candidate < curr[cnt]:\n                        curr[cnt] = candidate\n\n            rows[i % size] = curr\n\n        return rows[n % size][k]"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 30100,
     "latency_s": 214.6,
     "cpu_s": 1.2083,
     "peak_mb": 36.8,
     "quality": {
      "pylint": {
       "convention": 12,
       "refactor": 3,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 15,
       "score": 8.12
      },
      "radon": {
       "complexity": 25,
       "functions": 2,
       "mi": 46.51773181969211,
       "loc": 102,
       "lloc": 82,
       "sloc": 81,
       "comments": 3,
       "blank": 20
      },
      "sonar": {
       "maintainability": 2,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 2
       },
       "severities": {
        "CRITICAL": 1,
        "MINOR": 1
       },
       "rules": {
        "python:S3776": 1,
        "python:S100": 1
       }
      }
     },
     "code": "from typing import List\n\nclass Solution:\n    def minOperations(self, nums: List[int], x: int, k: int) -> int:\n        n = len(nums)\n\n        # Coordinate compression for Fenwick trees\n        vals = sorted(set(nums))\n        comp = {v: i + 1 for i, v in enumerate(vals)}\n        N = len(vals)\n\n        class BIT:\n            def __init__(self, n: int):\n                self.n = n\n                self.tree = [0] * (n + 1)\n\n            def add(self, i: int, delta: int) -> None:\n                n = self.n\n                tree = self.tree\n                while i <= n:\n                    tree[i] += delta\n                    i += i & -i\n\n            def query(self, i: int) -> int:\n                s = 0\n                tree = self.tree\n                while i > 0:\n                    s += tree[i]\n                    i -= i & -i\n                return s\n\n            def kth(self, k: int) -> int:\n                idx = 0\n                bitmask = 1 << (self.n.bit_length() - 1)\n                tree = self.tree\n                n = self.n\n                while bitmask:\n                    nxt = idx + bitmask\n                    if nxt <= n and tree[nxt] < k:\n                        idx = nxt\n                        k -= tree[nxt]\n                    bitmask >>= 1\n                return idx + 1\n\n        bit_count = BIT(N)\n        bit_sum = BIT(N)\n\n        total = 0\n        for v in nums[:x]:\n            total += v\n            idx = comp[v]\n            bit_count.add(idx, 1)\n            bit_sum.add(idx, v)\n\n        M = n - x + 1\n        costs = [0] * M\n        p = (x + 1) // 2  # lower median position\n\n        for i in range(M):\n            if i > 0:\n                rem = nums[i - 1]\n                total -= rem\n                idx = comp[rem]\n                bit_count.add(idx, -1)\n                bit_sum.add(idx, -rem)\n\n                addv = nums[i + x - 1]\n                total += addv\n                idx = comp[addv]\n                bit_count.add(idx, 1)\n                bit_sum.add(idx, addv)\n\n            idx_med = bit_count.kth(p)\n            med = vals[idx_med - 1]\n\n            less_count = bit_count.query(idx_med - 1)\n            less_sum = bit_sum.query(idx_med - 1)\n\n            costs[i] = total - 2 * less_sum + (2 * less_count - x) * med\n\n        INF = 10**30\n        prev = [0] * M  # dp for 0 intervals\n\n        for j in range(1, k + 1):\n            curr = [INF] * M\n            for i in range(M):\n                if i > 0:\n                    curr[i] = curr[i - 1]\n\n                if j == 1:\n                    best = costs[i]\n                elif i >= x and prev[i - x] < INF:\n                    best = costs[i] + prev[i - x]\n                else:\n                    best = INF\n\n                if best < curr[i]:\n                    curr[i] = best\n\n            prev = curr\n\n        return prev[M - 1]"
    }
   }
  },
  {
   "id": "3811",
   "title": "Reverse Degree of a String",
   "platform": "leetcode",
   "difficulty": "easy",
   "contest": "LeetCode 双周赛 153",
   "date": "2025-03-29",
   "url": "https://leetcode.com/problems/reverse-degree-of-a-string/",
   "summary": "每个字符在反向字母表中的序号（a=26，…，z=1）乘以它在字符串中的位置，求总和。",
   "evaluated": false
  },
  {
   "id": "3805",
   "title": "Maximize Active Section with Trade I",
   "platform": "leetcode",
   "difficulty": "medium",
   "contest": "LeetCode 双周赛 153",
   "date": "2025-03-29",
   "url": "https://leetcode.com/problems/maximize-active-section-with-trade-i/",
   "summary": "对 01 串至多做一次交易：先把一段两侧都是 0 的连续 1 全变成 0，再把一段两侧都是 1 的连续 0 全变成 1；求最终 1 的最大个数。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 7538,
     "latency_s": 93.7,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 6,
       "score": 6.67
      },
      "radon": {
       "complexity": 13,
       "functions": 2,
       "mi": 77.39890677828748,
       "loc": 25,
       "lloc": 18,
       "sloc": 18,
       "comments": 3,
       "blank": 4
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "MINOR": 1
       },
       "rules": {
        "python:S100": 1
       }
      }
     },
     "code": "class Solution:\n    def maxActiveSectionsAfterTrade(self, s: str) -> int:\n        t = \"1\" + s + \"1\"\n\n        # Compress t into alternating runs of identical characters.\n        runs = []\n        i = 0\n        while i < len(t):\n            j = i + 1\n            while j < len(t) and t[j] == t[i]:\n                j += 1\n            runs.append((t[i], j - i))\n            i = j\n\n        initial = s.count(\"1\")\n        answer = initial\n\n        # An internal '1' run can be removed. Filling the resulting zero run\n        # gives a net gain equal to the lengths of its two adjacent zero runs.\n        for i in range(1, len(runs) - 1):\n            if runs[i][0] == \"1\":\n                gain = runs[i - 1][1] + runs[i + 1][1]\n                answer = max(answer, initial + gain)\n\n        return answer"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 13391,
     "latency_s": 74.7,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 11,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 12,
       "score": 4.29
      },
      "radon": {
       "complexity": 11,
       "functions": 2,
       "mi": 75.5383080721992,
       "loc": 31,
       "lloc": 22,
       "sloc": 22,
       "comments": 3,
       "blank": 6
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "MINOR": 1
       },
       "rules": {
        "python:S100": 1
       }
      }
     },
     "code": "class Solution:\n    def maxActiveSectionsAfterTrade(self, s: str) -> int:\n        total_ones = s.count('1')\n        \n        # Augment with '1' at both ends.\n        t = '1' + s + '1'\n        \n        # Run-length encode t.\n        runs = []\n        prev = t[0]\n        count = 1\n        \n        for ch in t[1:]:\n            if ch == prev:\n                count += 1\n            else:\n                runs.append((prev, count))\n                prev = ch\n                count = 1\n        runs.append((prev, count))\n        \n        best_gain = 0\n        \n        # An internal '1' block is surrounded by '0' blocks.\n        for i in range(1, len(runs) - 1):\n            if runs[i][0] == '1':\n                left_zero_count = runs[i - 1][1]\n                right_zero_count = runs[i + 1][1]\n                best_gain = max(best_gain, left_zero_count + right_zero_count)\n        \n        return total_ones + best_gain"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 27926,
     "latency_s": 208.2,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 6,
       "score": 7.27
      },
      "radon": {
       "complexity": 17,
       "functions": 2,
       "mi": 66.14089093901225,
       "loc": 26,
       "lloc": 22,
       "sloc": 22,
       "comments": 1,
       "blank": 3
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "MINOR": 1
       },
       "rules": {
        "python:S100": 1
       }
      }
     },
     "code": "class Solution:\n    def maxActiveSectionsAfterTrade(self, s: str) -> int:\n        runs = []\n        i = 0\n        n = len(s)\n        while i < n:\n            c = s[i]\n            j = i\n            while j < n and s[j] == c:\n                j += 1\n            runs.append((c, j - i))\n            i = j\n\n        total_ones = 0\n        for c, length in runs:\n            if c == '1':\n                total_ones += length\n\n        best_gain = 0\n        m = len(runs)\n        for i in range(1, m - 1):\n            if runs[i][0] == '1':\n                # runs[i-1] and runs[i+1] are guaranteed to be '0' due to alternating runs\n                best_gain = max(best_gain, runs[i - 1][1] + runs[i + 1][1])\n\n        return total_ones + best_gain"
    }
   }
  },
  {
   "id": "3765",
   "title": "Minimum Cost to Divide Array into Subarrays",
   "platform": "leetcode",
   "difficulty": "hard",
   "contest": "LeetCode 双周赛 153",
   "date": "2025-03-29",
   "url": "https://leetcode.com/problems/minimum-cost-to-divide-array-into-subarrays/",
   "summary": "把数组划分为若干子数组，第 i 段的代价为（到该段末尾的前缀和 + k·i）×（该段 cost 之和）；求最小总代价。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 6486,
     "latency_s": 79.8,
     "cpu_s": 0.1358,
     "peak_mb": 16.2,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 6,
       "score": 6.84
      },
      "radon": {
       "complexity": 9,
       "functions": 2,
       "mi": 78.32994015780844,
       "loc": 35,
       "lloc": 19,
       "sloc": 22,
       "comments": 5,
       "blank": 8
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "MINOR": 1
       },
       "rules": {
        "python:S100": 1
       }
      }
     },
     "code": "from typing import List\n\nclass Solution:\n    def minimumCost(self, nums: List[int], cost: List[int], k: int) -> int:\n        n = len(nums)\n\n        prefix_nums = [0] * (n + 1)\n        prefix_cost = [0] * (n + 1)\n        for i in range(n):\n            prefix_nums[i + 1] = prefix_nums[i] + nums[i]\n            prefix_cost[i + 1] = prefix_cost[i] + cost[i]\n\n        # dp[start]: minimum cost for nums[start:], assuming the first\n        # subarray of this suffix has subarray index 1.\n        dp = [0] * (n + 1)\n        total_cost = prefix_cost[n]\n\n        for start in range(n - 1, -1, -1):\n            best = float(\"inf\")\n\n            for end in range(start + 1, n + 1):\n                # First subarray is nums[start:end], with index 1.\n                first = (\n                    (prefix_nums[end] + k)\n                    * (prefix_cost[end] - prefix_cost[start])\n                )\n\n                # Every subarray in dp[end] shifts its index up by one,\n                # adding k times the total cost sum of that suffix.\n                shift = k * (total_cost - prefix_cost[end])\n                best = min(best, first + dp[end] + shift)\n\n            dp[start] = best\n\n        return dp[0]"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 3490,
     "latency_s": 18.9,
     "cpu_s": 0.1398,
     "peak_mb": 16.2,
     "quality": {
      "pylint": {
       "convention": 6,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 7,
       "score": 6.5
      },
      "radon": {
       "complexity": 11,
       "functions": 2,
       "mi": 52.81146830616121,
       "loc": 27,
       "lloc": 20,
       "sloc": 20,
       "comments": 0,
       "blank": 7
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "MINOR": 1
       },
       "rules": {
        "python:S100": 1
       }
      }
     },
     "code": "from typing import List\n\nclass Solution:\n    def minimumCost(self, nums: List[int], cost: List[int], k: int) -> int:\n        n = len(nums)\n\n        pref_nums = [0] * (n + 1)\n        pref_cost = [0] * (n + 1)\n\n        for i in range(1, n + 1):\n            pref_nums[i] = pref_nums[i - 1] + nums[i - 1]\n            pref_cost[i] = pref_cost[i - 1] + cost[i - 1]\n\n        total_cost = pref_cost[n]\n        INF = 10**30\n\n        dp = [INF] * (n + 1)\n        dp[0] = 0\n\n        for i in range(1, n + 1):\n            for left in range(i):\n                current = dp[left] + pref_nums[i] * (pref_cost[i] - pref_cost[left])\n                if left > 0:\n                    current += k * (total_cost - pref_cost[left])\n                dp[i] = min(dp[i], current)\n\n        return dp[n] + k * total_cost"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 35149,
     "latency_s": 258.6,
     "cpu_s": 1.2392,
     "peak_mb": 16.2,
     "quality": {
      "pylint": {
       "convention": 8,
       "refactor": 2,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 10,
       "score": 7.67
      },
      "radon": {
       "complexity": 21,
       "functions": 2,
       "mi": 64.35623127576922,
       "loc": 61,
       "lloc": 45,
       "sloc": 45,
       "comments": 8,
       "blank": 11
      },
      "sonar": {
       "maintainability": 2,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 2
       },
       "severities": {
        "CRITICAL": 1,
        "MINOR": 1
       },
       "rules": {
        "python:S3776": 1,
        "python:S100": 1
       }
      }
     },
     "code": "from typing import List\n\nclass Solution:\n    def minimumCost(self, nums: List[int], cost: List[int], k: int) -> int:\n        n = len(nums)\n\n        # Prefix sums\n        P = [0] * (n + 1)   # nums prefix\n        C = [0] * (n + 1)   # cost prefix\n        for i in range(n):\n            P[i + 1] = P[i] + nums[i]\n            C[i + 1] = C[i] + cost[i]\n\n        INF = 10**30\n        prev = [INF] * (n + 1)\n        prev[0] = 0\n        ans = INF\n\n        # m = number of subarrays\n        for m in range(1, n + 1):\n            cur = [INF] * (n + 1)\n            hull = []  # points (C[s], prev[s]) on lower convex hull\n\n            for t in range(m, n + 1):\n                s = t - 1\n                y = prev[s]\n                if y < INF:\n                    x = C[s]\n\n                    # Add point to lower convex hull\n                    while len(hull) >= 2:\n                        x1, y1 = hull[-2]\n                        x2, y2 = hull[-1]\n                        # Remove middle point if it is not on lower hull\n                        if (x2 - x1) * (y - y2) - (y2 - y1) * (x - x2) <= 0:\n                            hull.pop()\n                        else:\n                            break\n                    hull.append((x, y))\n\n                q = P[t] + k * m\n\n                # Values y - q * x are unimodal on the lower hull.\n                lo, hi = 0, len(hull) - 1\n                while lo < hi:\n                    mid = (lo + hi) // 2\n                    v1 = hull[mid][1] - q * hull[mid][0]\n                    v2 = hull[mid + 1][1] - q * hull[mid + 1][0]\n                    if v1 <= v2:\n                        hi = mid\n                    else:\n                        lo = mid + 1\n\n                best = hull[lo][1] - q * hull[lo][0]\n                cur[t] = q * C[t] + best\n\n            prev = cur\n            if prev[n] < ans:\n                ans = prev[n]\n\n        return ans"
    }
   }
  },
  {
   "id": "abc399_f",
   "title": "Range Power Sum",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ABC 399 F 题",
   "date": "2025-03-29",
   "url": "https://atcoder.jp/contests/abc399/tasks/abc399_f",
   "summary": "求所有子数组元素和的 K 次方之和，模 998244353。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 2450,
     "latency_s": 38.4,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 3,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 3,
       "score": 9.12
      },
      "radon": {
       "complexity": 9,
       "functions": 1,
       "mi": 64.90396835584512,
       "loc": 54,
       "lloc": 36,
       "sloc": 35,
       "comments": 4,
       "blank": 15
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\nfrom math import comb\n\nMOD = 998244353\n\n\ndef main():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    if not data:\n        return\n\n    n, k = data[0], data[1]\n    a = data[2:2 + n]\n\n    binomial = [comb(k, t) for t in range(k + 1)]\n\n    # moments[m] = sum of P_j^m for already processed prefix sums P_j.\n    # Initially only P_0 = 0 is present.\n    moments = [0] * (k + 1)\n    moments[0] = 1\n\n    prefix = 0\n    answer = 0\n\n    for i in range(n):\n        prefix = (prefix + a[i]) % MOD\n\n        powers = [1] * (k + 1)\n        for m in range(1, k + 1):\n            powers[m] = powers[m - 1] * prefix % MOD\n\n        # sum_j (prefix - P_j)^K, expanded by the binomial theorem.\n        current = 0\n        for t in range(k + 1):\n            m = k - t\n            term = binomial[t] * powers[t] % MOD * moments[m] % MOD\n            if m & 1:\n                current -= term\n            else:\n                current += term\n\n        answer = (answer + current) % MOD\n\n        # Add the current prefix sum for future right endpoints.\n        for m in range(k + 1):\n            moments[m] += powers[m]\n            if moments[m] >= MOD:\n                moments[m] -= MOD\n\n    print(answer)\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 2504,
     "latency_s": 11.8,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 7,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 7,
       "score": 7.74
      },
      "radon": {
       "complexity": 8,
       "functions": 1,
       "mi": 63.93014043001087,
       "loc": 46,
       "lloc": 32,
       "sloc": 31,
       "comments": 3,
       "blank": 13
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\n\nMOD = 998244353\n\ndef main():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    if not data:\n        return\n\n    N, K = data[0], data[1]\n    A = data[2:2 + N]\n\n    # Binomial coefficients C(K, j)\n    comb = [1] * (K + 1)\n    for i in range(1, K + 1):\n        comb[i] = comb[i - 1] * (K - i + 1) % MOD\n        comb[i] = comb[i] * pow(i, MOD - 2, MOD) % MOD\n\n    # M[m] = sum of (-prefix_sum)^m over previous prefixes\n    M = [0] * (K + 1)\n    M[0] = 1  # Prefix sum S_0 = 0\n\n    prefix_sum = 0\n    ans = 0\n\n    for a in A:\n        prefix_sum = (prefix_sum + a) % MOD\n\n        power = [1] * (K + 1)\n        for j in range(1, K + 1):\n            power[j] = power[j - 1] * prefix_sum % MOD\n\n        for j in range(K + 1):\n            ans = (ans + comb[j] * power[j] % MOD * M[K - j]) % MOD\n\n        for m in range(K + 1):\n            value = power[m]\n            if m & 1:\n                value = (-value) % MOD\n            M[m] = (M[m] + value) % MOD\n\n    print(ans % MOD)\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 6616,
     "latency_s": 50.6,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 10,
       "refactor": 0,
       "warning": 1,
       "error": 0,
       "fatal": 0,
       "total": 11,
       "score": 6.56
      },
      "radon": {
       "complexity": 9,
       "functions": 1,
       "mi": 69.26258088826684,
       "loc": 51,
       "lloc": 34,
       "sloc": 33,
       "comments": 6,
       "blank": 13
      },
      "sonar": {
       "maintainability": 2,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 2
       },
       "severities": {
        "MINOR": 2
       },
       "rules": {
        "python:S1481": 1,
        "python:S117": 1
       }
      }
     },
     "code": "import sys\nimport math\n\nMOD = 998244353\n\ndef main():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    if not data:\n        return\n\n    N, K = data[0], data[1]\n    A = data[2:]\n\n    # binomial coefficients C(K, j)\n    C = [math.comb(K, j) for j in range(K + 1)]\n\n    # prev_sum[p] = sum_{l=0}^{r-1} (S_l)^p mod MOD\n    prev_sum = [0] * (K + 1)\n    prev_sum[0] = 1  # S_0^0 = 1, S_0^p = 0 for p > 0\n\n    powS = [1] * (K + 1)\n    S = 0\n    ans = 0\n\n    for a in A:\n        S = (S + a) % MOD\n\n        # powers of current prefix sum S_r\n        for p in range(1, K + 1):\n            powS[p] = powS[p - 1] * S % MOD\n\n        # add contribution for all l < r\n        for j in range(K + 1):\n            term = C[j] * powS[j] % MOD * prev_sum[K - j] % MOD\n            if (K - j) & 1:\n                ans -= term\n            else:\n                ans += term\n\n        ans %= MOD\n\n        # include current prefix sum for future r\n        for p in range(K + 1):\n            prev_sum[p] += powS[p]\n            if prev_sum[p] >= MOD:\n                prev_sum[p] -= MOD\n\n    print(ans % MOD)\n\nif __name__ == \"__main__\":\n    main()"
    }
   }
  },
  {
   "id": "abc399_e",
   "title": "Replace",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ABC 399 E 题",
   "date": "2025-03-29",
   "url": "https://atcoder.jp/contests/abc399/tasks/abc399_e",
   "summary": "每次操作把 S 中某个字母全部替换成另一个字母；判断能否把 S 变成 T，能则求最少操作次数。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": true,
     "failure": null,
     "judge": "API 返回与题目无关的内容；人工另行调用验证正确，按通过计",
     "output_tokens": 2754,
     "latency_s": 51.4,
     "cpu_s": null,
     "peak_mb": null,
     "quality": null,
     "code": ""
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 44/44",
     "output_tokens": 26278,
     "latency_s": 164.4,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 6,
       "refactor": 1,
       "warning": 1,
       "error": 0,
       "fatal": 0,
       "total": 8,
       "score": 8.55
      },
      "radon": {
       "complexity": 23,
       "functions": 1,
       "mi": 51.096609271340164,
       "loc": 78,
       "lloc": 56,
       "sloc": 55,
       "comments": 2,
       "blank": 21
      },
      "sonar": {
       "maintainability": 2,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 2
       },
       "severities": {
        "CRITICAL": 1,
        "MINOR": 1
       },
       "rules": {
        "python:S3776": 1,
        "python:S1481": 1
       }
      }
     },
     "code": "import sys\nfrom itertools import product\n\ndef solve():\n    data = sys.stdin.read().split()\n    if not data:\n        return\n\n    N = int(data[0])\n    S = data[1]\n    T = data[2]\n\n    f = [-1] * 26\n\n    for s, t in zip(S, T):\n        a = ord(s) - ord('a')\n        b = ord(t) - ord('a')\n\n        if f[a] == -1:\n            f[a] = b\n        elif f[a] != b:\n            print(-1)\n            return\n\n    present = [i for i in range(26) if f[i] != -1]\n    targets = set(f[i] for i in present)\n\n    # If all 26 letters must remain present, no temporary letter is available.\n    # The only possible transformation is the identity.\n    if len(targets) == 26:\n        possible = all(f[i] == i for i in present)\n        print(0 if possible else -1)\n        return\n\n    groups_by_target = {d: [] for d in targets}\n    for a in present:\n        groups_by_target[f[a]].append(a)\n\n    groups = list(groups_by_target.values())\n    merge_count = len(present) - len(targets)\n\n    answer = 10**9\n\n    for reps in product(*groups):\n        selected = set(reps)\n\n        non_fixed = sum(1 for a in reps if f[a] != a)\n\n        visited = set()\n        cycles = 0\n\n        for start in reps:\n            if start in visited:\n                continue\n\n            cur = start\n            path_pos = {}\n            path = []\n\n            while cur in selected and cur not in visited:\n                visited.add(cur)\n                path_pos[cur] = len(path)\n                path.append(cur)\n                cur = f[cur]\n\n            if cur in selected and cur in path_pos:\n                cycle_len = len(path) - path_pos[cur]\n                if cycle_len >= 2:\n                    cycles += 1\n\n        cost = merge_count + non_fixed + cycles\n        answer = min(answer, cost)\n\n    print(answer)\n\n\nif __name__ == \"__main__\":\n    solve()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 44/44",
     "output_tokens": 54990,
     "latency_s": 463.5,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 6,
       "refactor": 3,
       "warning": 2,
       "error": 0,
       "fatal": 0,
       "total": 11,
       "score": 8.04
      },
      "radon": {
       "complexity": 24,
       "functions": 1,
       "mi": 56.47664076042556,
       "loc": 77,
       "lloc": 57,
       "sloc": 56,
       "comments": 5,
       "blank": 16
      },
      "sonar": {
       "maintainability": 3,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 3
       },
       "severities": {
        "CRITICAL": 1,
        "MAJOR": 1,
        "MINOR": 1
       },
       "rules": {
        "python:S3776": 1,
        "python:S5806": 1,
        "python:S1481": 1
       }
      }
     },
     "code": "import sys\n\ndef solve():\n    input = sys.stdin.readline\n    N = int(input().strip())\n    S = input().strip()\n    T = input().strip()\n\n    f = [-1] * 26\n    domain = [False] * 26\n    target_used = [False] * 26\n\n    for sc, tc in zip(S, T):\n        s = ord(sc) - 97\n        t = ord(tc) - 97\n\n        if f[s] == -1:\n            f[s] = t\n        elif f[s] != t:\n            print(-1)\n            return\n\n        domain[s] = True\n        target_used[t] = True\n\n    # If S uses all 26 letters and T uses all 26 letters but S != T,\n    # no operation can be performed without reducing the number of distinct letters.\n    if S != T and all(domain) and all(target_used):\n        print(-1)\n        return\n\n    # Count characters that must be changed at least once.\n    changed = 0\n    for c in range(26):\n        if domain[c] and f[c] != c:\n            changed += 1\n\n    # In-degree from source letters.\n    indeg = [0] * 26\n    for c in range(26):\n        if domain[c]:\n            indeg[f[c]] += 1\n\n    # Find cycles of length >= 2 that have no extra incoming edges from outside the cycle.\n    state = [0] * 26\n    extra = 0\n\n    for v in range(26):\n        if domain[v] and state[v] == 0:\n            path = []\n            cur = v\n\n            while domain[cur] and state[cur] == 0:\n                state[cur] = 1\n                path.append(cur)\n                cur = f[cur]\n\n            if domain[cur] and state[cur] == 1:\n                idx = path.index(cur)\n                cycle = path[idx:]\n\n                if len(cycle) >= 2:\n                    pure = True\n                    for node in cycle:\n                        if indeg[node] != 1:\n                            pure = False\n                            break\n                    if pure:\n                        extra += 1\n\n            for node in path:\n                state[node] = 2\n\n    print(changed + extra)\n\nif __name__ == \"__main__\":\n    solve()"
    }
   }
  },
  {
   "id": "abc399_d",
   "title": "Switch Seats",
   "platform": "atcoder",
   "difficulty": "medium",
   "contest": "AtCoder ABC 399 D 题",
   "date": "2025-03-29",
   "url": "https://atcoder.jp/contests/abc399/tasks/abc399_d",
   "summary": "2N 个座位坐着 N 对情侣；统计有多少组两对情侣（两对原本都不相邻），只在这四人之间交换座位就能让两对都相邻。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 2/2",
     "output_tokens": 25429,
     "latency_s": 409.3,
     "cpu_s": 0.1497,
     "peak_mb": 38.1,
     "quality": {
      "pylint": {
       "convention": 3,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 3,
       "score": 9.09
      },
      "radon": {
       "complexity": 13,
       "functions": 1,
       "mi": 66.7831907753389,
       "loc": 49,
       "lloc": 33,
       "sloc": 33,
       "comments": 4,
       "blank": 12
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\n\n\ndef main():\n    it = iter(map(int, sys.stdin.buffer.read().split()))\n    t = next(it)\n    output = []\n\n    for _ in range(t):\n        n = next(it)\n        m = 2 * n\n        a = [next(it) for _ in range(m)]\n\n        # A label is invalid if its two occurrences are adjacent.\n        invalid = bytearray(n + 1)\n        for i in range(m - 1):\n            if a[i] == a[i + 1]:\n                invalid[a[i]] = 1\n\n        base = n + 1\n        first_seen = {}\n        answer = 0\n\n        # A valid label pair must occur in two non-overlapping adjacent\n        # bigrams. Conversely, one swap between those bigrams suffices.\n        for i in range(m - 1):\n            x, y = a[i], a[i + 1]\n            if x == y or invalid[x] or invalid[y]:\n                continue\n\n            if x > y:\n                x, y = y, x\n            key = x * base + y\n\n            start = first_seen.get(key)\n            if start is None:\n                first_seen[key] = i\n            elif start >= 0 and i - start >= 2:\n                # Mark as counted so later bigrams cannot count it again.\n                first_seen[key] = -1\n                answer += 1\n\n        output.append(str(answer))\n\n    sys.stdout.write(\"\\n\".join(output))\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 2/2",
     "output_tokens": 26808,
     "latency_s": 149.2,
     "cpu_s": 0.282,
     "peak_mb": 48.1,
     "quality": {
      "pylint": {
       "convention": 7,
       "refactor": 2,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 9,
       "score": 8.2
      },
      "radon": {
       "complexity": 14,
       "functions": 1,
       "mi": 58.08458216644621,
       "loc": 77,
       "lloc": 52,
       "sloc": 52,
       "comments": 4,
       "blank": 21
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\n\n\ndef solve() -> None:\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    idx = 0\n    T = data[idx]\n    idx += 1\n\n    answers = []\n\n    for _ in range(T):\n        N = data[idx]\n        idx += 1\n\n        L = 2 * N\n\n        if N == 1:\n            idx += L\n            answers.append(\"0\")\n            continue\n\n        A = [0] * (L + 1)\n        left = [0] * (N + 1)\n        right = [0] * (N + 1)\n\n        for pos in range(1, L + 1):\n            v = data[idx]\n            idx += 1\n            A[pos] = v\n\n            if left[v] == 0:\n                left[v] = pos\n            else:\n                right[v] = pos\n\n        # key = unordered pair of different labels\n        # value = list of starting positions of adjacent pairs having this label pair\n        edges = {}\n\n        for p in range(1, L):\n            u = A[p]\n            v = A[p + 1]\n\n            if u == v:\n                continue\n\n            # Both couples must not already be adjacent.\n            if right[u] - left[u] == 1 or right[v] - left[v] == 1:\n                continue\n\n            if u < v:\n                key = (u, v)\n            else:\n                key = (v, u)\n\n            edges.setdefault(key, []).append(p)\n\n        ans = 0\n\n        for starts in edges.values():\n            k = len(starts)\n            for i in range(k):\n                p = starts[i]\n                for j in range(i + 1, k):\n                    q = starts[j]\n                    # The two adjacent pairs must be disjoint.\n                    if p + 1 < q:\n                        ans += 1\n\n        answers.append(str(ans))\n\n    sys.stdout.write(\"\\n\".join(answers))\n\n\nif __name__ == \"__main__\":\n    solve()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 2/2",
     "output_tokens": 38204,
     "latency_s": 282.1,
     "cpu_s": 0.1222,
     "peak_mb": 48.1,
     "quality": {
      "pylint": {
       "convention": 3,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 3,
       "score": 9.19
      },
      "radon": {
       "complexity": 11,
       "functions": 1,
       "mi": 45.592206358838126,
       "loc": 49,
       "lloc": 38,
       "sloc": 38,
       "comments": 0,
       "blank": 11
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\n\ndef solve():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    if not data:\n        return\n\n    t = data[0]\n    idx = 1\n    out = []\n\n    for _ in range(t):\n        n = data[idx]\n        idx += 1\n        total = 2 * n\n\n        if n == 1:\n            idx += total\n            out.append(\"0\")\n            continue\n\n        l = [0] * (n + 1)\n        r = [0] * (n + 1)\n        left_owner = [0] * (total + 2)\n\n        for pos in range(1, total + 1):\n            v = data[idx]\n            idx += 1\n            if l[v] == 0:\n                l[v] = pos\n                left_owner[pos] = v\n            else:\n                r[v] = pos\n\n        ans = 0\n        for i in range(1, n + 1):\n            if r[i] - l[i] <= 1:\n                continue\n\n            j = left_owner[l[i] + 1]\n            if j != 0 and r[j] - l[j] > 1 and abs(r[i] - r[j]) == 1:\n                ans += 1\n\n        out.append(str(ans))\n\n    sys.stdout.write(\"\\n\".join(out))\n\nif __name__ == \"__main__\":\n    solve()"
    }
   }
  },
  {
   "id": "abc399_c",
   "title": "Make it Forest",
   "platform": "atcoder",
   "difficulty": "medium",
   "contest": "AtCoder ABC 399 C 题",
   "date": "2025-03-29",
   "url": "https://atcoder.jp/contests/abc399/tasks/abc399_c",
   "summary": "求最少删除多少条边，使无向图变成森林。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 500,
     "latency_s": 8.3,
     "cpu_s": 0.2304,
     "peak_mb": 50.1,
     "quality": {
      "pylint": {
       "convention": 3,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 3,
       "score": 8.93
      },
      "radon": {
       "complexity": 4,
       "functions": 1,
       "mi": 52.16345158728346,
       "loc": 40,
       "lloc": 29,
       "sloc": 29,
       "comments": 0,
       "blank": 11
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\n\n\ndef main():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    n, m = data[0], data[1]\n\n    parent = list(range(n))\n    size = [1] * n\n\n    def find(x):\n        while parent[x] != x:\n            parent[x] = parent[parent[x]]\n            x = parent[x]\n        return x\n\n    removals = 0\n    idx = 2\n\n    for _ in range(m):\n        u = data[idx] - 1\n        v = data[idx + 1] - 1\n        idx += 2\n\n        ru = find(u)\n        rv = find(v)\n\n        if ru == rv:\n            removals += 1\n        else:\n            if size[ru] < size[rv]:\n                ru, rv = rv, ru\n            parent[rv] = ru\n            size[ru] += size[rv]\n\n    print(removals)\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 457,
     "latency_s": 3.0,
     "cpu_s": 0.2643,
     "peak_mb": 22.1,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 0,
       "warning": 1,
       "error": 0,
       "fatal": 0,
       "total": 6,
       "score": 8.18
      },
      "radon": {
       "complexity": 3,
       "functions": 1,
       "mi": 50.73360672809206,
       "loc": 40,
       "lloc": 33,
       "sloc": 33,
       "comments": 0,
       "blank": 7
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "MAJOR": 1
       },
       "rules": {
        "python:S5806": 1
       }
      }
     },
     "code": "import sys\n\ndef main():\n    input = sys.stdin.buffer.readline\n    N, M = map(int, input().split())\n\n    parent = list(range(N))\n    rank = [0] * N\n\n    def find(x):\n        while parent[x] != x:\n            parent[x] = parent[parent[x]]\n            x = parent[x]\n        return x\n\n    def union(a, b):\n        ra = find(a)\n        rb = find(b)\n        if ra == rb:\n            return False\n        if rank[ra] < rank[rb]:\n            ra, rb = rb, ra\n        parent[rb] = ra\n        if rank[ra] == rank[rb]:\n            rank[ra] += 1\n        return True\n\n    components = N\n    for _ in range(M):\n        u, v = map(int, input().split())\n        u -= 1\n        v -= 1\n        if union(u, v):\n            components -= 1\n\n    answer = M - (N - components)\n    print(answer)\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 434,
     "latency_s": 3.5,
     "cpu_s": 0.2234,
     "peak_mb": 44.1,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 5,
       "score": 8.39
      },
      "radon": {
       "complexity": 5,
       "functions": 1,
       "mi": 51.17939348886453,
       "loc": 38,
       "lloc": 31,
       "sloc": 31,
       "comments": 0,
       "blank": 7
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\n\ndef solve():\n    input_data = sys.stdin.buffer.read().split()\n    if not input_data:\n        return\n    it = iter(input_data)\n    N = int(next(it))\n    M = int(next(it))\n\n    parent = list(range(N + 1))\n    size = [1] * (N + 1)\n\n    def find(x):\n        while parent[x] != x:\n            parent[x] = parent[parent[x]]\n            x = parent[x]\n        return x\n\n    components = N\n\n    for _ in range(M):\n        u = int(next(it))\n        v = int(next(it))\n        ru = find(u)\n        rv = find(v)\n        if ru != rv:\n            if size[ru] < size[rv]:\n                ru, rv = rv, ru\n            parent[rv] = ru\n            size[ru] += size[rv]\n            components -= 1\n\n    ans = M - N + components\n    print(ans)\n\nif __name__ == \"__main__\":\n    solve()"
    }
   }
  },
  {
   "id": "abc399_b",
   "title": "Ranking with Ties",
   "platform": "atcoder",
   "difficulty": "easy",
   "contest": "AtCoder ABC 399 B 题",
   "date": "2025-03-29",
   "url": "https://atcoder.jp/contests/abc399/tasks/abc399_b",
   "summary": "按“同分同名次，下一名次跳过并列人数”的规则，输出每个人的名次。",
   "evaluated": false
  },
  {
   "id": "abc399_a",
   "title": "Hamming Distance",
   "platform": "atcoder",
   "difficulty": "easy",
   "contest": "AtCoder ABC 399 A 题",
   "date": "2025-03-29",
   "url": "https://atcoder.jp/contests/abc399/tasks/abc399_a",
   "summary": "求两个等长字符串的汉明距离，即对应位置字符不同的个数。",
   "evaluated": false
  },
  {
   "id": "arc195_e",
   "title": "Random Tree Distance",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ARC 195 E 题",
   "date": "2025-03-23",
   "url": "https://atcoder.jp/contests/arc195/tasks/arc195_e",
   "summary": "顶点 i 的父节点在 1…i−1 中任选，共 (N−1)! 棵带权树；对每个查询求 u、v 两点距离在所有树上的总和，模 998244353。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 11727,
     "latency_s": 175.6,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 3,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 3,
       "score": 9.21
      },
      "radon": {
       "complexity": 7,
       "functions": 1,
       "mi": 59.19089651780729,
       "loc": 56,
       "lloc": 39,
       "sloc": 39,
       "comments": 3,
       "blank": 14
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\n\nMOD = 998244353\n\n\ndef main():\n    it = iter(map(int, sys.stdin.buffer.read().split()))\n    n = next(it)\n    q = next(it)\n\n    a = [0] * (n + 1)\n    for i in range(2, n + 1):\n        a[i] = next(it) % MOD\n\n    # Modular inverses of 1, ..., n+1.\n    inv = [0] * (n + 2)\n    inv[1] = 1\n    for i in range(2, n + 2):\n        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD\n\n    # prefix_low[k]: sum of coefficients for edges below u.\n    # prefix_mid[k]: sum of A_i / i for i <= k.\n    prefix_low = [0] * (n + 1)\n    prefix_mid = [0] * (n + 1)\n\n    for k in range(2, n + 1):\n        low = a[k] * (2 * (k - 1)) % MOD\n        low = low * inv[k] % MOD * inv[k + 1] % MOD\n        prefix_low[k] = (prefix_low[k - 1] + low) % MOD\n        prefix_mid[k] = (prefix_mid[k - 1] + a[k] * inv[k]) % MOD\n\n    total_trees = 1\n    for i in range(1, n):\n        total_trees = total_trees * i % MOD\n\n    answers = []\n    for _ in range(q):\n        u = next(it)\n        v = next(it)\n\n        if u == 1:\n            expected = (prefix_mid[v - 1] + a[v]) % MOD\n        else:\n            expected = prefix_low[u - 1]\n            expected += a[u] * (u - 1) % MOD * inv[u] % MOD\n            expected += prefix_mid[v - 1] - prefix_mid[u]\n            expected += a[v]\n            expected %= MOD\n\n        answers.append(str(expected * total_trees % MOD))\n\n    sys.stdout.write(\"\\n\".join(answers))\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 11554,
     "latency_s": 63.7,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 12,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 13,
       "score": 6.98
      },
      "radon": {
       "complexity": 9,
       "functions": 1,
       "mi": 57.8418882148865,
       "loc": 61,
       "lloc": 43,
       "sloc": 43,
       "comments": 3,
       "blank": 15
      },
      "sonar": {
       "maintainability": 3,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 3
       },
       "severities": {
        "MINOR": 3
       },
       "rules": {
        "python:S117": 3
       }
      }
     },
     "code": "import sys\n\nMOD = 998244353\n\ndef main():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    it = iter(data)\n\n    N = next(it)\n    Q = next(it)\n\n    A = [0] * (N + 1)\n    for i in range(2, N + 1):\n        A[i] = next(it) % MOD\n\n    inv = [0] * (N + 2)\n    inv[1] = 1\n    for i in range(2, N + 2):\n        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD\n\n    # P[x] = sum over edges i of A[i] * Pr(vertex x is in subtree of i)\n    P = [0] * (N + 1)\n    prefP = 0\n    for x in range(2, N + 1):\n        P[x] = (prefP + A[x]) % MOD\n        prefP = (prefP + A[x] * inv[x]) % MOD\n\n    # Q[x] = sum over edges i of A[i] * Pr(both endpoints are in subtree of i)\n    # when the smaller endpoint is x.\n    Qarr = [0] * (N + 1)\n    prefQ = 0\n    for x in range(2, N + 1):\n        Qarr[x] = (prefQ + A[x] * inv[x]) % MOD\n        if x < N:\n            term = A[x] * 2 % MOD\n            term = term * inv[x] % MOD\n            term = term * inv[x + 1] % MOD\n            prefQ = (prefQ + term) % MOD\n\n    fact = 1\n    for i in range(1, N):\n        fact = fact * i % MOD\n\n    answers = []\n\n    for _ in range(Q):\n        u = next(it)\n        v = next(it)\n\n        if u > v:\n            u, v = v, u\n\n        value = (P[u] + P[v] - 2 * Qarr[u]) % MOD\n        ans = fact * value % MOD\n        answers.append(str(ans))\n\n    sys.stdout.write(\"\\n\".join(answers))\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 37931,
     "latency_s": 256.1,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 11,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 12,
       "score": 7.21
      },
      "radon": {
       "complexity": 9,
       "functions": 1,
       "mi": 59.39801165273255,
       "loc": 70,
       "lloc": 44,
       "sloc": 49,
       "comments": 5,
       "blank": 16
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\n\nMOD = 998244353\n\ndef solve():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    if not data:\n        return\n\n    N, Q = data[0], data[1]\n    A = [0] * (N + 2)\n\n    idx = 2\n    for i in range(2, N + 1):\n        A[i] = data[idx] % MOD\n        idx += 1\n\n    # modular inverses up to N+2\n    inv = [0] * (N + 3)\n    inv[1] = 1\n    for i in range(2, N + 3):\n        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD\n\n    # S_D[i] = sum_{k=2..i} A_k / k\n    # S_B[i] = sum_{k=2..i} A_k * 2*(k-1)/(k*(k+1))\n    # C[i] = A_i * (i-1)/i\n    S_D = [0] * (N + 1)\n    S_B = [0] * (N + 1)\n    C = [0] * (N + 1)\n\n    for i in range(2, N + 1):\n        D = A[i] * inv[i] % MOD\n        S_D[i] = (S_D[i - 1] + D) % MOD\n\n        B = A[i] * 2 * (i - 1) % MOD * inv[i] % MOD * inv[i + 1] % MOD\n        S_B[i] = (S_B[i - 1] + B) % MOD\n\n        C[i] = A[i] * (i - 1) % MOD * inv[i] % MOD\n\n    # total number of possible P: (N-1)!\n    fact = 1\n    for i in range(1, N):\n        fact = fact * i % MOD\n\n    out = []\n    for _ in range(Q):\n        u = data[idx]\n        v = data[idx + 1]\n        idx += 2\n\n        if u > v:\n            u, v = v, u\n\n        if u == 1:\n            ans = S_D[v - 1] + A[v]\n        else:\n            ans = (\n                S_B[u - 1]\n                + C[u]\n                + (S_D[v - 1] - S_D[u])\n                + A[v]\n            )\n\n        ans %= MOD\n        out.append(str(ans * fact % MOD))\n\n    sys.stdout.write(\"\\n\".join(out))\n\nif __name__ == \"__main__\":\n    solve()"
    }
   }
  },
  {
   "id": "arc195_d",
   "title": "Swap and Erase",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ARC 195 D 题",
   "date": "2025-03-23",
   "url": "https://atcoder.jp/contests/arc195/tasks/arc195_d",
   "summary": "可以交换相邻元素，或删除开头一段全部相等的前缀；求删空序列的最少操作数。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 2/2",
     "output_tokens": 86491,
     "latency_s": 1089.5,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 3,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 3,
       "score": 9.27
      },
      "radon": {
       "complexity": 16,
       "functions": 1,
       "mi": 61.033627136863544,
       "loc": 72,
       "lloc": 43,
       "sloc": 53,
       "comments": 6,
       "blank": 13
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\n\n\ndef main():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    pos = 0\n    t = data[pos]\n    pos += 1\n    answers = []\n\n    for _ in range(t):\n        n = data[pos]\n        pos += 1\n\n        # Run-length encode the sequence.\n        values = []\n        counts = []\n        for _ in range(n):\n            x = data[pos]\n            pos += 1\n            if values and values[-1] == x:\n                counts[-1] += 1\n            else:\n                values.append(x)\n                counts.append(1)\n\n        m = len(values)\n\n        # dp[i]: answer for the contiguous suffix of runs i..m-1.\n        # aux[i]: answer for run i followed by runs i+2..m-1\n        #         (run i+1 is absent).\n        dp = [0] * (m + 1)\n        aux = [0] * m\n\n        for i in range(m - 1, -1, -1):\n            j = i + 2\n\n            if j >= m:\n                aux[i] = 1\n            elif values[i] == values[j]:\n                # The two equal-valued parts form one leading run. Its length\n                # does not affect the answer.\n                aux[i] = dp[j]\n            else:\n                best = 1 + dp[j]\n                k = j + 1\n                if (\n                    k < m\n                    and counts[j] == 1\n                    and counts[k] == 1\n                    and values[k] == values[i]\n                ):\n                    best = min(best, 2 + aux[j])\n                aux[i] = best\n\n            best = 1 + dp[i + 1]\n            if (\n                i + 2 < m\n                and counts[i + 1] == 1\n                and counts[i + 2] == 1\n                and values[i + 2] == values[i]\n            ):\n                best = min(best, 2 + aux[i + 1])\n            dp[i] = best\n\n        answers.append(str(dp[0]))\n\n    sys.stdout.write(\"\\n\".join(answers) + \"\\n\")\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 2/2",
     "output_tokens": 80953,
     "latency_s": 475.2,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 2,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 7,
       "score": 7.74
      },
      "radon": {
       "complexity": 12,
       "functions": 1,
       "mi": 61.354912029273564,
       "loc": 45,
       "lloc": 32,
       "sloc": 32,
       "comments": 2,
       "blank": 11
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\n\ndef solve() -> None:\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    it = iter(data)\n    T = next(it)\n    answers = []\n\n    for _ in range(T):\n        N = next(it)\n\n        values = []\n        lengths = []\n\n        for _ in range(N):\n            x = next(it)\n            if not values or values[-1] != x:\n                values.append(x)\n                lengths.append(1)\n            else:\n                lengths[-1] += 1\n\n        m = len(values)\n        dp = [0] * (m + 1)\n\n        for i in range(1, m + 1):\n            best = dp[i - 1]\n\n            # Delete runs i-1 and i by one beneficial swap.\n            # Need left neighbor i-2 and right neighbor i+1.\n            if 3 <= i <= m - 1:\n                if lengths[i - 2] == 1 and lengths[i - 1] == 1:\n                    if values[i - 3] == values[i - 1] and values[i - 2] == values[i]:\n                        cand = 1 + dp[i - 3]\n                        if cand > best:\n                            best = cand\n\n            dp[i] = best\n\n        answers.append(str(m - dp[m]))\n\n    sys.stdout.write(\"\\n\".join(answers))\n\nif __name__ == \"__main__\":\n    solve()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 2/2",
     "output_tokens": 110301,
     "latency_s": 815.2,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 4,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 5,
       "score": 8.96
      },
      "radon": {
       "complexity": 17,
       "functions": 1,
       "mi": 55.57928117157678,
       "loc": 72,
       "lloc": 55,
       "sloc": 53,
       "comments": 4,
       "blank": 15
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\n\ndef solve():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    t = data[0]\n    idx = 1\n    out = []\n\n    for _ in range(t):\n        n = data[idx]\n        idx += 1\n        A = data[idx:idx + n]\n        idx += n\n\n        colors = []\n        lengths = []\n        ops = 0\n\n        # initial number of runs in A\n        runs = 0\n        prev = None\n\n        for x in A:\n            # append x to the current sequence\n            if colors and colors[-1] == x:\n                lengths[-1] += 1\n            else:\n                colors.append(x)\n                lengths.append(1)\n\n            if prev is None or x != prev:\n                runs += 1\n            prev = x\n\n            # greedily apply beneficial swaps (XYXY -> XXYY)\n            while len(colors) >= 4:\n                c1 = colors[-4]\n                c2 = colors[-3]\n                c3 = colors[-2]\n                c4 = colors[-1]\n\n                if (c1 == c3 and c2 == c4 and c1 != c2 and\n                        lengths[-3] == 1 and lengths[-2] == 1):\n                    ops += 1\n\n                    l1 = lengths[-4] + 1\n                    l4 = lengths[-1] + 1\n\n                    # remove the middle two runs and keep the outer two\n                    del colors[-4:]\n                    del lengths[-4:]\n\n                    if colors and colors[-1] == c1:\n                        lengths[-1] += l1\n                    else:\n                        colors.append(c1)\n                        lengths.append(l1)\n\n                    if colors and colors[-1] == c2:\n                        lengths[-1] += l4\n                    else:\n                        colors.append(c2)\n                        lengths.append(l4)\n                else:\n                    break\n\n        out.append(str(runs - ops))\n\n    sys.stdout.write(\"\\n\".join(out))\n\nif __name__ == \"__main__\":\n    solve()"
    }
   }
  },
  {
   "id": "arc195_c",
   "title": "Hamiltonian Pieces",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ARC 195 C 题",
   "date": "2025-03-23",
   "url": "https://atcoder.jp/contests/arc195/tasks/arc195_c",
   "summary": "R 个红子（横竖走一步）和 B 个蓝子（斜走一步）摆上棋盘，使每个棋子一步能走到下一个、最后一个能走回第一个；判断能否做到并给出一种摆法。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 5/5（校验器）",
     "output_tokens": 20880,
     "latency_s": 322.1,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 7,
       "refactor": 2,
       "warning": 15,
       "error": 0,
       "fatal": 0,
       "total": 24,
       "score": 7.04
      },
      "radon": {
       "complexity": 13,
       "functions": 1,
       "mi": 61.29700069502199,
       "loc": 119,
       "lloc": 83,
       "sloc": 85,
       "comments": 18,
       "blank": 18
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\n\n\ndef main():\n    it = iter(map(int, sys.stdin.buffer.read().split()))\n    T = next(it)\n    output = []\n\n    for _ in range(T):\n        R = next(it)\n        B = next(it)\n        N = R + B\n\n        # Every red move changes the parity of r+c, while every blue move\n        # preserves it. Thus R must be even. If there are only blue pieces,\n        # every move also changes the parity of r, so B must be even.\n        if (R & 1) or (R == 0 and (B & 1)):\n            output.append(\"No\")\n            continue\n\n        colors = []\n        rows = []\n        cols = []\n        nxt = []\n\n        def add_node(color, r, c):\n            idx = len(colors)\n            colors.append(color)\n            rows.append(r)\n            cols.append(c)\n            nxt.append(-1)\n            return idx\n\n        # Replace edge u -> v, where v = u + e, by\n        # u -> u+f -> u+f+e -> v.\n        # This inserts two pieces of the same color as u. Repeating the\n        # operation on the new middle edge grows the construction without\n        # collisions.\n        def extend(u, e, f):\n            v = nxt[u]\n            ar = rows[u] + f[0]\n            ac = cols[u] + f[1]\n            a = add_node(colors[u], ar, ac)\n            b = add_node(colors[u], ar + e[0], ac + e[1])\n            nxt[u] = a\n            nxt[a] = b\n            nxt[b] = v\n            return a\n\n        start = -1\n\n        if R == 0:\n            # Base cycle for two blue pieces.\n            start = add_node(\"B\", 0, 0)\n            other = add_node(\"B\", 1, 1)\n            nxt[start] = other\n            nxt[other] = start\n\n            u = start\n            for _ in range((B - 2) // 2):\n                u = extend(u, (1, 1), (1, -1))\n        else:\n            # Every mixed or all-red construction starts with two red pieces.\n            start = add_node(\"R\", 0, 0)   # A\n            second = add_node(\"R\", 1, 0)  # C\n            blue_extension = -1\n            base_blue = 0\n\n            if B == 0:\n                nxt[start] = second\n                nxt[second] = start\n            elif B & 1:\n                # R,R,B triangle: (0,0) -> (1,0) -> (1,1) -> (0,0).\n                last_blue = add_node(\"B\", 1, 1)\n                nxt[start] = second\n                nxt[second] = last_blue\n                nxt[last_blue] = start\n                blue_extension = last_blue\n                base_blue = 1\n            else:\n                # Base cycle with R=B=2.\n                first_blue = add_node(\"B\", 2, 0)\n                last_blue = add_node(\"B\", 1, 1)\n                nxt[start] = second\n                nxt[second] = first_blue\n                nxt[first_blue] = last_blue\n                nxt[last_blue] = start\n                blue_extension = last_blue\n                base_blue = 2\n\n            # Add red pieces in pairs, growing downward from A -> C.\n            u = start\n            for _ in range((R - 2) // 2):\n                u = extend(u, (1, 0), (0, -1))\n\n            # Add blue pieces in pairs, growing upward/left from the\n            # last blue piece toward A.\n            if base_blue:\n                u = blue_extension\n                for _ in range((B - base_blue) // 2):\n                    u = extend(u, (-1, -1), (-1, 1))\n\n        # Translate the construction onto the positive board.\n        row_shift = 1 - min(rows)\n        col_shift = 1 - min(cols)\n\n        output.append(\"Yes\")\n        cur = start\n        for _ in range(N):\n            output.append(\n                f\"{colors[cur]} {rows[cur] + row_shift} {cols[cur] + col_shift}\"\n            )\n            cur = nxt[cur]\n\n    sys.stdout.write(\"\\n\".join(output) + \"\\n\")\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 5/5（校验器）",
     "output_tokens": 22439,
     "latency_s": 119.9,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 7,
       "refactor": 3,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 10,
       "score": 8.51
      },
      "radon": {
       "complexity": 19,
       "functions": 1,
       "mi": 57.83387333325657,
       "loc": 103,
       "lloc": 74,
       "sloc": 81,
       "comments": 13,
       "blank": 17
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\n\n\ndef solve() -> None:\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    if not data:\n        return\n\n    T = data[0]\n    idx = 1\n    out = []\n\n    # Directions sorted by polar angle in the (dr, dc) plane.\n    order = {\n        (0, 1): 0,    # right\n        (1, 1): 1,    # down-right\n        (1, 0): 2,    # down\n        (1, -1): 3,   # down-left\n        (0, -1): 4,   # left\n        (-1, -1): 5,  # up-left\n        (-1, 0): 6,   # up\n        (-1, 1): 7,   # up-right\n    }\n\n    OFFSET = 10 ** 8\n\n    for _ in range(T):\n        R = data[idx]\n        B = data[idx + 1]\n        idx += 2\n\n        # Necessary and sufficient condition:\n        # R must be even, and if R == 0 then B must be even.\n        if R % 2 == 1 or (R == 0 and B % 2 == 1):\n            out.append(\"No\")\n            continue\n\n        red = []\n        blue = []\n\n        if R > 0:\n            if B % 2 == 1:\n                # Red vectors sum to (-1, -1), cancelling the extra blue (1, 1).\n                red.append((-1, 0))\n                red.append((0, -1))\n                rem = R - 2\n                for _ in range(rem // 2):\n                    red.append((1, 0))\n                    red.append((-1, 0))\n            else:\n                if R == 2:\n                    red.append((0, 1))\n                    red.append((0, -1))\n                else:\n                    k = R // 2\n                    for _ in range(k - 1):\n                        red.append((0, 1))\n                        red.append((0, -1))\n                    red.append((1, 0))\n                    red.append((-1, 0))\n\n        if B > 0:\n            if B % 2 == 1:\n                # One extra blue vector, cancelled by the special red vectors.\n                blue.append((1, 1))\n                rem = B - 1\n                for _ in range(rem // 2):\n                    blue.append((1, 1))\n                    blue.append((-1, -1))\n            else:\n                if B == 2:\n                    blue.append((1, 1))\n                    blue.append((-1, -1))\n                else:\n                    k = B // 2\n                    blue.append((1, -1))\n                    blue.append((-1, 1))\n                    for _ in range(k - 1):\n                        blue.append((1, 1))\n                        blue.append((-1, -1))\n\n        vectors = red + blue\n        vectors.sort(key=lambda v: order[v])\n\n        cur_r = 0\n        cur_c = 0\n        out.append(\"Yes\")\n\n        for dr, dc in vectors:\n            if dr == 0 or dc == 0:\n                piece = \"R\"\n            else:\n                piece = \"B\"\n\n            out.append(f\"{piece} {cur_r + OFFSET} {cur_c + OFFSET}\")\n            cur_r += dr\n            cur_c += dc\n\n    sys.stdout.write(\"\\n\".join(out))\n\n\nif __name__ == \"__main__\":\n    solve()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 5/5（校验器）",
     "output_tokens": 64077,
     "latency_s": 453.2,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 24,
       "refactor": 1,
       "warning": 1,
       "error": 0,
       "fatal": 0,
       "total": 26,
       "score": 7.26
      },
      "radon": {
       "complexity": 37,
       "functions": 7,
       "mi": 41.3736696100823,
       "loc": 120,
       "lloc": 95,
       "sloc": 101,
       "comments": 3,
       "blank": 18
      },
      "sonar": {
       "maintainability": 8,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 8
       },
       "severities": {
        "MINOR": 8
       },
       "rules": {
        "python:S117": 7,
        "python:S1481": 1
       }
      }
     },
     "code": "import sys\n\nSHIFT = 10**6\n\ndef canonical_red_path(L, side):\n    if L == 1:\n        return [(0, 0), (1, 0)]\n    m = (L - 1) // 2\n    pos = [(0, 0)]\n    pos.append((0, side))\n    for i in range(1, m + 1):\n        pos.append((i, side))\n    for i in range(m, 0, -1):\n        pos.append((i, 0))\n    return pos\n\ndef map_red(p, v):\n    x, y = p\n    if v == (1, 0):\n        return (x, y)\n    if v == (-1, 0):\n        return (-x, y)\n    if v == (0, 1):\n        return (-y, x)\n    return (y, -x)  # (0, -1)\n\ndef red_expanded_steps(v, L, side):\n    pos = canonical_red_path(L, side)\n    mapped = [map_red(p, v) for p in pos]\n    return [\n        (mapped[i + 1][0] - mapped[i][0], mapped[i + 1][1] - mapped[i][1])\n        for i in range(L)\n    ]\n\ndef map_blue(p, v):\n    r, c = p\n    if v == (1, 1):\n        return (r, c)\n    if v == (1, -1):\n        return (r, -c)\n    if v == (-1, 1):\n        return (-r, c)\n    return (-r, -c)  # (-1, -1)\n\ndef blue_expanded_steps(v, L, side):\n    pos = canonical_red_path(L, side)\n    blue_pos = [(x + y, x - y) for x, y in pos]\n    mapped = [map_blue(p, v) for p in blue_pos]\n    return [\n        (mapped[i + 1][0] - mapped[i][0], mapped[i + 1][1] - mapped[i][1])\n        for i in range(L)\n    ]\n\ndef build_steps(R, B):\n    if R == 0:\n        Lb = B - 1\n        steps = [(s, 'B') for s in blue_expanded_steps((1, 1), Lb, -1)]\n        steps.append(((-1, -1), 'B'))\n        return steps\n\n    if B == 0:\n        Lr = R - 1\n        steps = [(s, 'R') for s in red_expanded_steps((1, 0), Lr, -1)]\n        steps.append(((-1, 0), 'R'))\n        return steps\n\n    if B % 2 == 1:\n        Lr = R - 1\n        Lb = B\n        steps = [(s, 'R') for s in red_expanded_steps((1, 0), Lr, -1)]\n        steps.append(((0, 1), 'R'))\n        steps.extend((s, 'B') for s in blue_expanded_steps((-1, -1), Lb, 1))\n        return steps\n\n    # B is even and B > 0\n    Lr = R - 1\n    Lb = B - 1\n    steps = [(s, 'R') for s in red_expanded_steps((-1, 0), Lr, -1)]\n    steps.extend((s, 'B') for s in blue_expanded_steps((1, 1), Lb, -1))\n    steps.append(((-1, 0), 'R'))\n    steps.append(((1, -1), 'B'))\n    return steps\n\ndef solve():\n    data = sys.stdin.read().split()\n    if not data:\n        return\n    T = int(data[0])\n    idx = 1\n    out = []\n\n    for _ in range(T):\n        R = int(data[idx])\n        B = int(data[idx + 1])\n        idx += 2\n\n        if R % 2 == 1 or (R == 0 and B % 2 == 1):\n            out.append(\"No\")\n            continue\n\n        steps = build_steps(R, B)\n        N = len(steps)\n\n        vertices = [(0, 0)]\n        x, y = 0, 0\n        for (dx, dy), _ in steps[:-1]:\n            x += dx\n            y += dy\n            vertices.append((x, y))\n\n        out.append(\"Yes\")\n        for i, ((dx, dy), color) in enumerate(steps):\n            r = vertices[i][0] + SHIFT\n            c = vertices[i][1] + SHIFT\n            out.append(f\"{color} {r} {c}\")\n\n    sys.stdout.write(\"\\n\".join(out))\n\nif __name__ == \"__main__\":\n    solve()"
    }
   }
  },
  {
   "id": "arc195_b",
   "title": "Uniform Sum",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ARC 195 B 题",
   "date": "2025-03-23",
   "url": "https://atcoder.jp/contests/arc195/tasks/arc195_b",
   "summary": "A、B 中的 -1 可替换为任意非负整数，A 可任意重排；判断能否使所有 Aᵢ + Bᵢ 相等。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 54554,
     "latency_s": 923.8,
     "cpu_s": 0.1526,
     "peak_mb": 14.2,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 3,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 8,
       "score": 9.02
      },
      "radon": {
       "complexity": 25,
       "functions": 1,
       "mi": 56.23879419616915,
       "loc": 124,
       "lloc": 85,
       "sloc": 85,
       "comments": 13,
       "blank": 26
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\nfrom bisect import bisect_left\n\n\ndef solve():\n    it = iter(map(int, sys.stdin.buffer.read().split()))\n    n = next(it)\n    A = [next(it) for _ in range(n)]\n    B = [next(it) for _ in range(n)]\n\n    count_a = {}\n    count_b = {}\n    wild_a = 0\n    wild_b = 0\n\n    for x in A:\n        if x == -1:\n            wild_a += 1\n        else:\n            count_a[x] = count_a.get(x, 0) + 1\n\n    for x in B:\n        if x == -1:\n            wild_b += 1\n        else:\n            count_b[x] = count_b.get(x, 0) + 1\n\n    wild = wild_a + wild_b\n\n    # All fixed elements can be paired with wildcards.\n    if wild >= n:\n        sys.stdout.write(\"Yes\\n\")\n        return\n\n    # In any feasible pairing, at least `need` pairs must consist of two\n    # fixed values. All pairs in such a pairing must have the same sum.\n    need = n - wild\n\n    # The largest fixed A value and largest fixed B value always provide\n    # one usable fixed-fixed pair.\n    if need == 1:\n        sys.stdout.write(\"Yes\\n\")\n        return\n\n    a_items = sorted(count_a.items())\n    b_items = sorted(count_b.items())\n    a_vals = [x for x, _ in a_items]\n    b_vals = [x for x, _ in b_items]\n    b_cnts = [c for _, c in b_items]\n    u = len(a_items)\n    v = len(b_items)\n\n    # Every fixed value must not exceed the final common sum.\n    min_sum = max(a_vals[-1], b_vals[-1])\n\n    # Select more than q fixed A items (or more than p fixed B items).\n    # At least one selected item must belong to a fixed-fixed pair in any\n    # feasible configuration, so its pair sum is a sufficient candidate set.\n    def make_core(items, amount):\n        core = []\n        covered = 0\n        for value, cnt in sorted(items, key=lambda z: z[1], reverse=True):\n            core.append(value)\n            covered += cnt\n            if covered >= amount:\n                break\n        return core\n\n    core_a = make_core(a_items, wild_b + 1)\n    core_b = make_core(b_items, wild_a + 1)\n\n    candidates_a_size = 0\n    for a in core_a:\n        candidates_a_size += v - bisect_left(b_vals, min_sum - a)\n\n    candidates_b_size = 0\n    for b in core_b:\n        candidates_b_size += u - bisect_left(a_vals, min_sum - b)\n\n    candidates = {}\n\n    if candidates_a_size <= candidates_b_size:\n        for a in core_a:\n            start = bisect_left(b_vals, min_sum - a)\n            for j in range(start, v):\n                candidates[a + b_vals[j]] = 0\n    else:\n        for b in core_b:\n            start = bisect_left(a_vals, min_sum - b)\n            for i in range(start, u):\n                candidates[a_vals[i] + b] = 0\n\n    if not candidates:\n        sys.stdout.write(\"No\\n\")\n        return\n\n    # For a fixed sum s, different A values use different B values.\n    # Therefore the maximum number of fixed-fixed pairs is\n    #   sum_a min(count_a[a], count_b[s-a]).\n    # Accumulate this quantity only for the sufficient candidate sums.\n    get_candidate = candidates.get\n\n    for a, acnt in a_items:\n        start = bisect_left(b_vals, min_sum - a)\n        for j in range(start, v):\n            s = a + b_vals[j]\n            current = get_candidate(s)\n            if current is None:\n                continue\n\n            bcnt = b_cnts[j]\n            current += acnt if acnt < bcnt else bcnt\n\n            if current >= need:\n                sys.stdout.write(\"Yes\\n\")\n                return\n\n            candidates[s] = current\n\n    sys.stdout.write(\"No\\n\")\n\n\nif __name__ == \"__main__\":\n    solve()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 16709,
     "latency_s": 96.3,
     "cpu_s": 1.3022,
     "peak_mb": 91.5,
     "quality": {
      "pylint": {
       "convention": 12,
       "refactor": 2,
       "warning": 1,
       "error": 0,
       "fatal": 0,
       "total": 15,
       "score": 7.06
      },
      "radon": {
       "complexity": 17,
       "functions": 1,
       "mi": 41.78766069374972,
       "loc": 72,
       "lloc": 55,
       "sloc": 53,
       "comments": 0,
       "blank": 19
      },
      "sonar": {
       "maintainability": 5,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 5
       },
       "severities": {
        "CRITICAL": 1,
        "MINOR": 4
       },
       "rules": {
        "python:S3776": 1,
        "python:S117": 4
       }
      }
     },
     "code": "import sys\nfrom collections import Counter\n\ndef solve():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    if not data:\n        return\n\n    N = data[0]\n    A = data[1:1 + N]\n    B = data[1 + N:1 + 2 * N]\n\n    knownA = [x for x in A if x != -1]\n    knownB = [x for x in B if x != -1]\n\n    a = len(knownA)\n    b = len(knownB)\n\n    if a + b <= N:\n        print(\"Yes\")\n        return\n\n    L = a + b - N\n\n    if L == 1:\n        print(\"Yes\")\n        return\n\n    M = max(max(knownA), max(knownB))\n\n    countA = Counter(knownA)\n    countB = Counter(knownB)\n\n    sums = []\n\n    for u, cu in countA.items():\n        for v, cv in countB.items():\n            s = u + v\n            if s < M:\n                continue\n\n            w = cu if cu < cv else cv\n            if w == 1:\n                sums.append(s)\n            else:\n                sums.extend([s] * w)\n\n    if not sums:\n        print(\"No\")\n        return\n\n    sums.sort()\n\n    it = iter(sums)\n    prev = next(it)\n    run = 1\n\n    for s in it:\n        if s == prev:\n            run += 1\n            if run >= L:\n                print(\"Yes\")\n                return\n        else:\n            prev = s\n            run = 1\n\n    print(\"No\")\n\n\nif __name__ == \"__main__\":\n    solve()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 55717,
     "latency_s": 454.3,
     "cpu_s": 0.9596,
     "peak_mb": 119.2,
     "quality": {
      "pylint": {
       "convention": 22,
       "refactor": 3,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 25,
       "score": 6.99
      },
      "radon": {
       "complexity": 24,
       "functions": 1,
       "mi": 51.018772739631025,
       "loc": 107,
       "lloc": 85,
       "sloc": 83,
       "comments": 7,
       "blank": 21
      },
      "sonar": {
       "maintainability": 5,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 5
       },
       "severities": {
        "CRITICAL": 1,
        "MINOR": 4
       },
       "rules": {
        "python:S3776": 1,
        "python:S117": 4
       }
      }
     },
     "code": "import sys\nfrom collections import Counter\nfrom bisect import bisect_left\n\ndef solve():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    if not data:\n        return\n\n    N = data[0]\n    A = data[1:1 + N]\n    B = data[1 + N:1 + 2 * N]\n\n    FA = [x for x in A if x != -1]\n    FB = [x for x in B if x != -1]\n\n    M = len(FA)\n    P = len(FB)\n    UB = N - P          # number of unknown B\n    K = M - UB          # minimum number of fixed A that must be paired with fixed B\n\n    if K <= 0:\n        print(\"Yes\")\n        return\n\n    # K = 1 is always possible: pair max(A) with max(B).\n    if K == 1:\n        print(\"Yes\")\n        return\n\n    maxA = max(FA)\n    maxB = max(FB)\n    L = max(maxA, maxB)\n\n    freqA = Counter(FA)\n    freqB = Counter(FB)\n\n    # Quick check with S = maxA + maxB\n    S0 = maxA + maxB\n    total0 = 0\n    for a, fa in freqA.items():\n        fb = freqB.get(S0 - a, 0)\n        if fb:\n            total0 += fa if fa < fb else fb\n    if total0 >= K:\n        print(\"Yes\")\n        return\n\n    a_items = list(freqA.items())\n    b_items = list(freqB.items())\n    b_items.sort()  # sort by B value\n\n    b_vals = [b for b, _ in b_items]\n    b_freqs = [fb for _, fb in b_items]\n    nb = len(b_vals)\n\n    SHIFT = 11  # max frequency is 2000 < 2048\n    b_shifts = [b << SHIFT for b in b_vals]\n\n    starts = []\n    V = 0\n    for a, _ in a_items:\n        start = bisect_left(b_vals, L - a)\n        starts.append(start)\n        V += nb - start\n\n    if V == 0:\n        print(\"No\")\n        return\n\n    # Pack sum and contribution into one integer: (sum << SHIFT) | c\n    pairs = [0] * V\n    idx = 0\n    for (a, fa), start in zip(a_items, starts):\n        a_shift = a << SHIFT\n        for j in range(start, nb):\n            fb = b_freqs[j]\n            c = fa if fa < fb else fb\n            pairs[idx] = a_shift + b_shifts[j] + c\n            idx += 1\n\n    pairs.sort()\n\n    MASK = (1 << SHIFT) - 1\n    n = len(pairs)\n    i = 0\n    while i < n:\n        val = pairs[i]\n        key = val >> SHIFT\n        total = val & MASK\n        i += 1\n\n        while i < n:\n            val = pairs[i]\n            if (val >> SHIFT) != key:\n                break\n            total += val & MASK\n            i += 1\n\n        if total >= K:\n            print(\"Yes\")\n            return\n\n    print(\"No\")\n\nif __name__ == \"__main__\":\n    solve()"
    }
   }
  },
  {
   "id": "arc195_a",
   "title": "Twice Subsequence",
   "platform": "atcoder",
   "difficulty": "medium",
   "contest": "AtCoder ARC 195 A 题",
   "date": "2025-03-23",
   "url": "https://atcoder.jp/contests/arc195/tasks/arc195_a",
   "summary": "判断序列 B 是否至少以两种不同的位置组合作为 A 的子序列出现。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 2230,
     "latency_s": 34.2,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 3,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 3,
       "score": 9.06
      },
      "radon": {
       "complexity": 11,
       "functions": 1,
       "mi": 66.80761892200988,
       "loc": 46,
       "lloc": 35,
       "sloc": 33,
       "comments": 4,
       "blank": 9
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\n\n\ndef main():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    if not data:\n        return\n\n    n, m = data[0], data[1]\n    a = data[2:2 + n]\n    b = data[2 + n:2 + n + m]\n\n    # Greedy leftmost occurrence of B in A.\n    left = [-1] * m\n    j = 0\n    for i, value in enumerate(a):\n        if value == b[j]:\n            left[j] = i\n            j += 1\n            if j == m:\n                break\n\n    if j < m:\n        sys.stdout.write(\"No\\n\")\n        return\n\n    # Greedy rightmost occurrence of B in A.\n    right = [-1] * m\n    j = m - 1\n    for i in range(n - 1, -1, -1):\n        if a[i] == b[j]:\n            right[j] = i\n            j -= 1\n            if j < 0:\n                break\n\n    # Every occurrence position is bounded by the corresponding leftmost\n    # and rightmost positions. They differ iff there are multiple occurrences.\n    if any(left[i] != right[i] for i in range(m)):\n        sys.stdout.write(\"Yes\\n\")\n    else:\n        sys.stdout.write(\"No\\n\")\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 2897,
     "latency_s": 15.6,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 7,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 7,
       "score": 7.81
      },
      "radon": {
       "complexity": 12,
       "functions": 1,
       "mi": 47.074728049374365,
       "loc": 40,
       "lloc": 34,
       "sloc": 32,
       "comments": 0,
       "blank": 8
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\n\ndef main():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    N, M = data[0], data[1]\n    A = data[2:2 + N]\n    B = data[2 + N:2 + N + M]\n\n    left = [-1] * M\n    j = 0\n    for i, x in enumerate(A):\n        if j < M and x == B[j]:\n            left[j] = i\n            j += 1\n            if j == M:\n                break\n\n    if j < M:\n        print(\"No\")\n        return\n\n    right = [-1] * M\n    j = M - 1\n    for i in range(N - 1, -1, -1):\n        if j >= 0 and A[i] == B[j]:\n            right[j] = i\n            j -= 1\n            if j < 0:\n                break\n\n    for k in range(M):\n        if left[k] < right[k]:\n            print(\"Yes\")\n            return\n\n    print(\"No\")\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 18431,
     "latency_s": 143.6,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 7,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 7,
       "score": 7.94
      },
      "radon": {
       "complexity": 13,
       "functions": 1,
       "mi": 60.093669069703886,
       "loc": 44,
       "lloc": 37,
       "sloc": 35,
       "comments": 2,
       "blank": 7
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\n\ndef main():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    if not data:\n        return\n\n    N, M = data[0], data[1]\n    A = data[2:2 + N]\n    B = data[2 + N:2 + N + M]\n\n    # Left-to-right greedy: earliest possible positions\n    left = []\n    j = 0\n    for i, a in enumerate(A):\n        if j < M and a == B[j]:\n            left.append(i)\n            j += 1\n            if j == M:\n                break\n\n    if j < M:\n        print(\"No\")\n        return\n\n    # Right-to-left greedy: latest possible positions\n    right = [0] * M\n    j = M - 1\n    for i in range(N - 1, -1, -1):\n        if j >= 0 and A[i] == B[j]:\n            right[j] = i\n            j -= 1\n            if j < 0:\n                break\n\n    if j >= 0:\n        print(\"No\")\n    elif left == right:\n        print(\"No\")\n    else:\n        print(\"Yes\")\n\nif __name__ == \"__main__\":\n    main()"
    }
   }
  },
  {
   "id": "3817",
   "title": "Maximum Containers On a Ship",
   "platform": "leetcode",
   "difficulty": "easy",
   "contest": "LeetCode 周赛 442",
   "date": "2025-03-22",
   "url": "https://leetcode.com/problems/maximum-containers-on-a-ship/",
   "summary": "n×n 甲板每格可放一个重 w 的集装箱，总重不超过 maxWeight；求最多能装多少个。",
   "evaluated": false
  },
  {
   "id": "3809",
   "title": "Properties Graph",
   "platform": "leetcode",
   "difficulty": "medium",
   "contest": "LeetCode 周赛 442",
   "date": "2025-03-22",
   "url": "https://leetcode.com/problems/properties-graph/",
   "summary": "两行属性中共同出现的不同整数个数不少于 k 时连一条边；求所得无向图的连通分量数。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 629,
     "latency_s": 9.7,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 6,
       "score": 7.5
      },
      "radon": {
       "complexity": 13,
       "functions": 2,
       "mi": 54.69666049754181,
       "loc": 29,
       "lloc": 24,
       "sloc": 24,
       "comments": 0,
       "blank": 5
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "MINOR": 1
       },
       "rules": {
        "python:S100": 1
       }
      }
     },
     "code": "from typing import List\n\nclass Solution:\n    def numberOfComponents(self, properties: List[List[int]], k: int) -> int:\n        n = len(properties)\n        value_sets = [set(row) for row in properties]\n        parent = list(range(n))\n        size = [1] * n\n\n        def find(x: int) -> int:\n            if parent[x] != x:\n                parent[x] = find(parent[x])\n            return parent[x]\n\n        def union(a: int, b: int) -> None:\n            root_a, root_b = find(a), find(b)\n            if root_a == root_b:\n                return\n            if size[root_a] < size[root_b]:\n                root_a, root_b = root_b, root_a\n            parent[root_b] = root_a\n            size[root_a] += size[root_b]\n\n        for i in range(n):\n            for j in range(i + 1, n):\n                if len(value_sets[i] & value_sets[j]) >= k:\n                    union(i, j)\n\n        return len({find(i) for i in range(n)})"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 445,
     "latency_s": 3.3,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 6,
       "score": 7.86
      },
      "radon": {
       "complexity": 11,
       "functions": 2,
       "mi": 52.54056184725897,
       "loc": 35,
       "lloc": 28,
       "sloc": 28,
       "comments": 0,
       "blank": 7
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "MINOR": 1
       },
       "rules": {
        "python:S100": 1
       }
      }
     },
     "code": "from typing import List\n\nclass Solution:\n    def numberOfComponents(self, properties: List[List[int]], k: int) -> int:\n        n = len(properties)\n        sets = [set(prop) for prop in properties]\n\n        parent = list(range(n))\n        rank = [0] * n\n        components = n\n\n        def find(x: int) -> int:\n            if parent[x] != x:\n                parent[x] = find(parent[x])\n            return parent[x]\n\n        def union(a: int, b: int) -> None:\n            nonlocal components\n            ra, rb = find(a), find(b)\n            if ra == rb:\n                return\n\n            if rank[ra] < rank[rb]:\n                ra, rb = rb, ra\n            parent[rb] = ra\n            if rank[ra] == rank[rb]:\n                rank[ra] += 1\n            components -= 1\n\n        for i in range(n):\n            for j in range(i + 1, n):\n                if len(sets[i] & sets[j]) >= k:\n                    union(i, j)\n\n        return components"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 1051,
     "latency_s": 7.8,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 6,
       "score": 7.69
      },
      "radon": {
       "complexity": 15,
       "functions": 2,
       "mi": 53.00865390653506,
       "loc": 32,
       "lloc": 26,
       "sloc": 26,
       "comments": 0,
       "blank": 6
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "MINOR": 1
       },
       "rules": {
        "python:S100": 1
       }
      }
     },
     "code": "from typing import List\n\nclass Solution:\n    def numberOfComponents(self, properties: List[List[int]], k: int) -> int:\n        n = len(properties)\n        sets = [set(row) for row in properties]\n\n        parent = list(range(n))\n        rank = [0] * n\n\n        def find(x: int) -> int:\n            while parent[x] != x:\n                parent[x] = parent[parent[x]]\n                x = parent[x]\n            return x\n\n        def union(a: int, b: int) -> None:\n            ra, rb = find(a), find(b)\n            if ra == rb:\n                return\n            if rank[ra] < rank[rb]:\n                ra, rb = rb, ra\n            parent[rb] = ra\n            if rank[ra] == rank[rb]:\n                rank[ra] += 1\n\n        for i in range(n):\n            for j in range(i + 1, n):\n                if len(sets[i] & sets[j]) >= k:\n                    union(i, j)\n\n        return sum(1 for i in range(n) if find(i) == i)"
    }
   }
  },
  {
   "id": "3794",
   "title": "Find the Minimum Amount of Time to Brew Potions",
   "platform": "leetcode",
   "difficulty": "medium",
   "contest": "LeetCode 周赛 442",
   "date": "2025-03-22",
   "url": "https://leetcode.com/problems/find-the-minimum-amount-of-time-to-brew-potions/",
   "summary": "n 名巫师依次处理 m 瓶药水，第 i 人处理第 j 瓶耗时 skill[i]·mana[j]，药水须在上一人完成时立即交给下一人；求完成全部药水的最短时间。",
   "evaluated": false
  },
  {
   "id": "3744",
   "title": "Minimum Operations to Make Array Elements Zero",
   "platform": "leetcode",
   "difficulty": "hard",
   "contest": "LeetCode 周赛 442",
   "date": "2025-03-22",
   "url": "https://leetcode.com/problems/minimum-operations-to-make-array-elements-zero/",
   "summary": "每个查询 [l, r] 对应数组 l, l+1, …, r；每次操作选两个数，各自替换为除以 4 向下取整的结果；求每个查询把所有数变为 0 的最少操作数，输出总和。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 14111,
     "latency_s": 219.7,
     "cpu_s": 0.2652,
     "peak_mb": 32.2,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 6,
       "score": 5.71
      },
      "radon": {
       "complexity": 7,
       "functions": 2,
       "mi": 84.03513056516813,
       "loc": 22,
       "lloc": 14,
       "sloc": 14,
       "comments": 3,
       "blank": 5
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "MINOR": 1
       },
       "rules": {
        "python:S100": 1
       }
      }
     },
     "code": "from typing import List\n\nclass Solution:\n    def minOperations(self, queries: List[List[int]]) -> int:\n        answer = 0\n\n        for l, r in queries:\n            total_depth = 0\n            max_depth = 0\n            power = 1\n\n            # A number x needs one operation for each power 1, 4, 16, ... <= x.\n            while power <= r:\n                max_depth += 1\n                total_depth += r - max(l, power) + 1\n                power *= 4\n\n            # Each operation handles two unit steps, while the deepest element\n            # can be processed at most once per operation.\n            answer += max(max_depth, (total_depth + 1) // 2)\n\n        return answer"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 5899,
     "latency_s": 32.9,
     "cpu_s": 0.6659,
     "peak_mb": 32.1,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 6,
       "score": 7.6
      },
      "radon": {
       "complexity": 5,
       "functions": 2,
       "mi": 52.27923776079594,
       "loc": 32,
       "lloc": 25,
       "sloc": 25,
       "comments": 0,
       "blank": 7
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "MINOR": 1
       },
       "rules": {
        "python:S100": 1
       }
      }
     },
     "code": "from typing import List\n\nclass Solution:\n    def minOperations(self, queries: List[List[int]]) -> int:\n        def prefix(n: int) -> int:\n            total = 0\n            p = 1\n            k = 1\n\n            while p <= n:\n                end = min(n, p * 4 - 1)\n                total += k * (end - p + 1)\n                p *= 4\n                k += 1\n\n            return total\n\n        def max_steps(x: int) -> int:\n            steps = 0\n            while x > 0:\n                x //= 4\n                steps += 1\n            return steps\n\n        answer = 0\n\n        for l, r in queries:\n            total_steps = prefix(r) - prefix(l - 1)\n            max_required = max_steps(r)\n            answer += max(max_required, (total_steps + 1) // 2)\n\n        return answer"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 34854,
     "latency_s": 249.6,
     "cpu_s": 0.0532,
     "peak_mb": 32.2,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 6,
       "score": 6.47
      },
      "radon": {
       "complexity": 7,
       "functions": 2,
       "mi": 76.91017903880186,
       "loc": 26,
       "lloc": 17,
       "sloc": 17,
       "comments": 3,
       "blank": 6
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "MINOR": 1
       },
       "rules": {
        "python:S100": 1
       }
      }
     },
     "code": "from typing import List\n\nclass Solution:\n    def minOperations(self, queries: List[List[int]]) -> int:\n        # pref[k] = total base-4 digits of all positive integers\n        # with at most k digits (i.e. numbers 1..4^k - 1)\n        pref = [0] * 64\n        for k in range(1, 64):\n            pref[k] = pref[k - 1] + k * 3 * (1 << (2 * (k - 1)))\n\n        def total_digits_upto(n: int) -> int:\n            if n <= 0:\n                return 0\n\n            # d = number of base-4 digits of n\n            d = (n.bit_length() + 1) // 2\n            first_d_digit = 1 << (2 * (d - 1))\n\n            return pref[d - 1] + d * (n - first_d_digit + 1)\n\n        ans = 0\n        for l, r in queries:\n            total_steps = total_digits_upto(r) - total_digits_upto(l - 1)\n            ans += (total_steps + 1) // 2\n\n        return ans"
    }
   }
  },
  {
   "id": "abc398_g",
   "title": "Not Only Tree Game",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ABC 398 G 题",
   "date": "2025-03-22",
   "url": "https://atcoder.jp/contests/abc398/tasks/abc398_g",
   "summary": "在不含奇环的图上，两人轮流加一条新边且加边后不能出现奇环，无法操作者输；判断双方最优时谁获胜。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": false,
     "verified_by_hand": false,
     "failure": "答案错误",
     "judge": "官方测试 39/43",
     "output_tokens": 118728,
     "latency_s": 1887.7,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 3,
       "refactor": 1,
       "warning": 1,
       "error": 0,
       "fatal": 0,
       "total": 5,
       "score": 8.75
      },
      "radon": {
       "complexity": 13,
       "functions": 1,
       "mi": 57.70677546975973,
       "loc": 57,
       "lloc": 41,
       "sloc": 41,
       "comments": 2,
       "blank": 14
      },
      "sonar": {
       "maintainability": 2,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 2
       },
       "severities": {
        "CRITICAL": 1,
        "MAJOR": 1
       },
       "rules": {
        "python:S3776": 1,
        "python:S5806": 1
       }
      }
     },
     "code": "import sys\n\n\ndef main():\n    input = sys.stdin.buffer.readline\n    n, m = map(int, input().split())\n\n    graph = [[] for _ in range(n)]\n    for _ in range(m):\n        u, v = map(int, input().split())\n        u -= 1\n        v -= 1\n        graph[u].append(v)\n        graph[v].append(u)\n\n    color = [-1] * n\n    odd_components = 0\n    odd_product_components = 0\n\n    for start in range(n):\n        if color[start] != -1:\n            continue\n\n        color[start] = 0\n        stack = [start]\n        side = [0, 0]\n        vertices = 0\n\n        while stack:\n            v = stack.pop()\n            vertices += 1\n            side[color[v]] += 1\n\n            for to in graph[v]:\n                if color[to] == -1:\n                    color[to] = color[v] ^ 1\n                    stack.append(to)\n\n        if vertices & 1:\n            odd_components += 1\n\n        # The product of the two color-class sizes is odd exactly when\n        # both sizes are odd.\n        if (side[0] & 1) and (side[1] & 1):\n            odd_product_components ^= 1\n\n    if n & 1:\n        aoki_wins = (m & 1) == 1\n    else:\n        value = (m + odd_product_components + odd_components // 2) & 1\n        aoki_wins = value == 1\n\n    print(\"Aoki\" if aoki_wins else \"Takahashi\")\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 63405,
     "latency_s": 327.2,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 9,
       "refactor": 3,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 12,
       "score": 8.29
      },
      "radon": {
       "complexity": 23,
       "functions": 1,
       "mi": 49.938786959988754,
       "loc": 92,
       "lloc": 79,
       "sloc": 79,
       "comments": 5,
       "blank": 12
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\n\ndef solve():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    if not data:\n        return\n    it = iter(data)\n    N = next(it)\n    M = next(it)\n    adj = [[] for _ in range(N)]\n    for _ in range(M):\n        u = next(it) - 1\n        v = next(it) - 1\n        adj[u].append(v)\n        adj[v].append(u)\n\n    visited = [False] * N\n    color = [-1] * N\n\n    k = 0       # number of isolated vertices\n    B = 0       # number of non-isolated components with both sides odd\n    D = 0       # number of non-isolated components with exactly one side odd\n\n    for start in range(N):\n        if visited[start]:\n            continue\n        stack = [start]\n        visited[start] = True\n        color[start] = 0\n        cnt0 = 0\n        cnt1 = 0\n        size = 0\n\n        while stack:\n            u = stack.pop()\n            size += 1\n            if color[u] == 0:\n                cnt0 += 1\n            else:\n                cnt1 += 1\n\n            for v in adj[u]:\n                if not visited[v]:\n                    visited[v] = True\n                    color[v] = color[u] ^ 1\n                    stack.append(v)\n\n        if size == 1:\n            k += 1\n        else:\n            a, b = cnt0, cnt1\n            if (a & 1) and (b & 1):\n                B += 1\n            elif (a & 1) == 0 and (b & 1) == 0:\n                # both even, irrelevant for g\n                pass\n            else:\n                D += 1\n\n    bpar = B & 1\n\n    if D >= 3:\n        g = bpar\n    elif D == 2:\n        if k % 2 == 0:\n            g = 2 + bpar\n        else:\n            g = bpar\n    elif D == 1:\n        if k % 2 == 1:\n            g = 2 + bpar\n        else:\n            g = bpar\n    else:  # D == 0\n        if k % 2 == 1:\n            g = bpar\n        else:\n            if k % 4 == 2:\n                g = 1\n            else:\n                g = 0\n\n    p = (B + M) & 1\n    sg = g ^ p\n\n    if sg != 0:\n        print(\"Aoki\")\n    else:\n        print(\"Takahashi\")\n\nif __name__ == \"__main__\":\n    solve()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 174049,
     "latency_s": 1377.9,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 23,
       "refactor": 6,
       "warning": 2,
       "error": 0,
       "fatal": 0,
       "total": 31,
       "score": 7.37
      },
      "radon": {
       "complexity": 18,
       "functions": 1,
       "mi": 51.29229237806927,
       "loc": 165,
       "lloc": 123,
       "sloc": 127,
       "comments": 21,
       "blank": 27
      },
      "sonar": {
       "maintainability": 15,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 15
       },
       "severities": {
        "CRITICAL": 1,
        "MINOR": 13,
        "MAJOR": 1
       },
       "rules": {
        "python:S3776": 1,
        "python:S117": 11,
        "python:S1481": 2,
        "python:S125": 1
       }
      }
     },
     "code": "import sys\n\ndef main():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    if not data:\n        return\n    N, M = data[0], data[1]\n    adj = [[] for _ in range(N)]\n    it = iter(data[2:])\n    for _ in range(M):\n        u = next(it) - 1\n        v = next(it) - 1\n        adj[u].append(v)\n        adj[v].append(u)\n\n    # For odd N, total number of moves always has the parity of M.\n    if N % 2 == 1:\n        print(\"Aoki\" if M % 2 == 1 else \"Takahashi\")\n        return\n\n    visited = [False] * N\n    color = [0] * N\n\n    cnt_I = 0          # isolated vertices (component size 1)\n    cnt_V = 0          # non-isolated odd components\n    cnt_E0 = 0         # even components with both parts even\n    cnt_E1 = 0         # even components with both parts odd\n    total_K = 0        # sum of missing internal edges modulo 2\n\n    for s in range(N):\n        if visited[s]:\n            continue\n        visited[s] = True\n        color[s] = 0\n        q = [s]\n        comp = []\n\n        while q:\n            u = q.pop()\n            comp.append(u)\n            cu = color[u]\n            for w in adj[u]:\n                if not visited[w]:\n                    visited[w] = True\n                    color[w] = cu ^ 1\n                    q.append(w)\n\n        x = 0\n        for u in comp:\n            if color[u] == 0:\n                x += 1\n        y = len(comp) - x\n        m = sum(len(adj[u]) for u in comp) // 2\n\n        # missing internal edges in this component modulo 2\n        k_par = ((x & 1) & (y & 1)) ^ (m & 1)\n        total_K ^= k_par\n\n        size = x + y\n        if size == 1:\n            cnt_I += 1\n        elif size % 2 == 0:\n            if x % 2 == 0:\n                cnt_E0 += 1\n            else:\n                cnt_E1 += 1\n        else:\n            cnt_V += 1\n\n    # Grundy number of the complete-components game.\n    # Types:\n    # 0: isolated (I)\n    # 1: non-isolated odd (V)\n    # 2: even, both parts even (E0)\n    # 3: even, both parts odd (E1)\n    types = [\n        (1, 0, 1),  # I: p=1, q=0, empty=1\n        (0, 1, 0),  # V: p=0, q=1\n        (0, 0, 0),  # E0\n        (1, 1, 0),  # E1\n    ]\n\n    memo = {}\n\n    def grundy(i, v, a, b):\n        # Reduce according to the periodic structure.\n        # I and V have period 4, E0/E1 have period 2.\n        if i > 7:\n            i = 4 + (i % 4)\n        if v > 7:\n            v = 4 + (v % 4)\n        if a > 4:\n            a = 2 + (a % 2)\n        if b > 4:\n            b = 2 + (b % 2)\n\n        key = (i, v, a, b)\n        if key in memo:\n            return memo[key]\n\n        if i + v + a + b <= 1:\n            memo[key] = 0\n            return 0\n\n        counts = [i, v, a, b]\n        options = set()\n\n        for A in range(4):\n            if counts[A] == 0:\n                continue\n            for B in range(A, 4):\n                if counts[B] == 0:\n                    continue\n                if A == B and counts[A] < 2:\n                    continue\n\n                pA, qA, eA = types[A]\n                pB, qB, eB = types[B]\n\n                # align is unavailable only for I-I\n                avail = []\n                if not (A == 0 and B == 0):\n                    avail.append('align')\n                avail.append('swap')\n\n                for orient in avail:\n                    if orient == 'align':\n                        p = pA ^ pB\n                        q = qA ^ qB\n                        c_par = (pA & qB) ^ (qA & pB)\n                    else:\n                        p = pA ^ qB\n                        q = qA ^ pB\n                        c_par = (pA & pB) ^ (qA & qB)\n\n                    k_par = c_par ^ 1  # k = c - 1\n\n                    if p != q:\n                        new_type = 1\n                    elif p == 0:\n                        new_type = 2\n                    else:\n                        new_type = 3\n\n                    new = counts.copy()\n                    new[A] -= 1\n                    new[B] -= 1\n                    new[new_type] += 1\n\n                    val = grundy(new[0], new[1], new[2], new[3]) ^ k_par\n                    options.add(val)\n\n        g = 0\n        while g in options:\n            g += 1\n        memo[key] = g\n        return g\n\n    g = grundy(cnt_I, cnt_V, cnt_E0, cnt_E1)\n    sg = g ^ total_K\n\n    print(\"Aoki\" if sg != 0 else \"Takahashi\")\n\nif __name__ == \"__main__\":\n    main()"
    }
   }
  },
  {
   "id": "abc398_f",
   "title": "ABCBA",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ABC 398 F 题",
   "date": "2025-03-22",
   "url": "https://atcoder.jp/contests/abc398/tasks/abc398_f",
   "summary": "输出一个以 S 为前缀的最短回文串。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 6421,
     "latency_s": 96.5,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 3,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 3,
       "score": 8.75
      },
      "radon": {
       "complexity": 9,
       "functions": 1,
       "mi": 73.48827284404418,
       "loc": 35,
       "lloc": 26,
       "sloc": 24,
       "comments": 4,
       "blank": 7
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\n\n\ndef main():\n    s = sys.stdin.buffer.readline().strip()\n    n = len(s)\n    r = s[::-1]\n\n    # KMP failure function for r.\n    failure = [0] * n\n    j = 0\n    for i in range(1, n):\n        c = r[i]\n        while j and c != r[j]:\n            j = failure[j - 1]\n        if c == r[j]:\n            j += 1\n        failure[i] = j\n\n    # Longest suffix of s that is also a prefix of r.\n    # Such a suffix is exactly a palindromic suffix of s.\n    j = 0\n    for c in s:\n        while j and c != r[j]:\n            j = failure[j - 1]\n        if c == r[j]:\n            j += 1\n\n    # Keep the longest palindromic suffix and append the minimum necessary part.\n    answer = s + s[:n - j][::-1]\n    sys.stdout.buffer.write(answer)\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 1728,
     "latency_s": 9.3,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 2,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 2,
       "score": 8.75
      },
      "radon": {
       "complexity": 0,
       "functions": 0,
       "mi": 55.98602606373334,
       "loc": 22,
       "lloc": 18,
       "sloc": 16,
       "comments": 0,
       "blank": 6
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\n\ns = sys.stdin.buffer.readline().strip()\nn = len(s)\n\nr = s[::-1]\nt = r + b'#' + s\n\npi = [0] * len(t)\n\nfor i in range(1, len(t)):\n    j = pi[i - 1]\n    while j > 0 and t[i] != t[j]:\n        j = pi[j - 1]\n    if t[i] == t[j]:\n        j += 1\n    pi[i] = j\n\nlongest_palindromic_suffix = pi[-1]\nanswer = s + r[longest_palindromic_suffix:]\n\nsys.stdout.buffer.write(answer + b'\\n')"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 38214,
     "latency_s": 285.1,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 7,
       "refactor": 0,
       "warning": 1,
       "error": 0,
       "fatal": 0,
       "total": 8,
       "score": 5.79
      },
      "radon": {
       "complexity": 5,
       "functions": 1,
       "mi": 75.95920547244256,
       "loc": 26,
       "lloc": 21,
       "sloc": 19,
       "comments": 3,
       "blank": 5
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "MINOR": 1
       },
       "rules": {
        "python:S1481": 1
       }
      }
     },
     "code": "import sys\n\ndef main():\n    S = sys.stdin.readline().strip()\n    n = len(S)\n    R = S[::-1]\n\n    # Build R + '$' + S and compute its prefix function.\n    # The last value is the length of the longest palindromic suffix of S.\n    T = R + '$' + S\n    L = len(T)\n    pi = [0] * L\n    j = 0\n\n    for i in range(1, L):\n        while j > 0 and T[i] != T[j]:\n            j = pi[j - 1]\n        if T[i] == T[j]:\n            j += 1\n        pi[i] = j\n\n    p = j  # longest palindromic suffix length\n    sys.stdout.write(S + R[p:] + '\\n')\n\nif __name__ == \"__main__\":\n    main()"
    }
   }
  },
  {
   "id": "abc398_d",
   "title": "Bonfire",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ABC 398 D 题",
   "date": "2025-03-22",
   "url": "https://atcoder.jp/contests/abc398/tasks/abc398_d",
   "summary": "烟雾按给定的风向序列逐步整体平移，原点无烟时重新生成；对每个时刻判断指定格子上是否有烟。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 4443,
     "latency_s": 74.2,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 5,
       "score": 8.15
      },
      "radon": {
       "complexity": 6,
       "functions": 1,
       "mi": 62.83720040136057,
       "loc": 38,
       "lloc": 29,
       "sloc": 29,
       "comments": 1,
       "blank": 9
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\n\n\ndef main():\n    data = sys.stdin.buffer.read().split()\n    n = int(data[0])\n    R = int(data[1])\n    C = int(data[2])\n    s = data[3].decode()\n\n    r = 0\n    c = 0\n    seen = {(0, 0)}\n    answer = []\n\n    for i in range(n):\n        direction = s[i]\n        if direction == 'N':\n            r -= 1\n        elif direction == 'W':\n            c -= 1\n        elif direction == 'S':\n            r += 1\n        else:  # E\n            c += 1\n\n        if (r - R, c - C) in seen:\n            answer.append('1')\n        else:\n            answer.append('0')\n\n        seen.add((r, c))\n\n    sys.stdout.write(''.join(answer) + '\\n')\n\n\nif __name__ == '__main__':\n    main()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 2786,
     "latency_s": 16.5,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 7,
       "refactor": 0,
       "warning": 1,
       "error": 0,
       "fatal": 0,
       "total": 8,
       "score": 6.92
      },
      "radon": {
       "complexity": 6,
       "functions": 1,
       "mi": 63.73566393077924,
       "loc": 35,
       "lloc": 28,
       "sloc": 28,
       "comments": 1,
       "blank": 7
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "MINOR": 1
       },
       "rules": {
        "python:S1481": 1
       }
      }
     },
     "code": "import sys\n\ndef main():\n    data = sys.stdin.buffer.read().split()\n    N = int(data[0])\n    R = int(data[1])\n    C = int(data[2])\n    S = data[3].decode()\n\n    r = 0\n    c = 0\n    seen = {(0, 0)}\n    ans = []\n\n    for ch in S:\n        if ch == 'N':\n            r -= 1\n        elif ch == 'S':\n            r += 1\n        elif ch == 'W':\n            c -= 1\n        else:  # 'E'\n            c += 1\n\n        if (r - R, c - C) in seen:\n            ans.append('1')\n        else:\n            ans.append('0')\n\n        seen.add((r, c))\n\n    print(''.join(ans))\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 10799,
     "latency_s": 80.3,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 7,
       "refactor": 0,
       "warning": 1,
       "error": 0,
       "fatal": 0,
       "total": 8,
       "score": 7.14
      },
      "radon": {
       "complexity": 7,
       "functions": 1,
       "mi": 62.29168743397342,
       "loc": 38,
       "lloc": 30,
       "sloc": 30,
       "comments": 1,
       "blank": 8
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "MINOR": 1
       },
       "rules": {
        "python:S1481": 1
       }
      }
     },
     "code": "import sys\n\ndef main():\n    data = sys.stdin.read().split()\n    if not data:\n        return\n\n    N = int(data[0])\n    R = int(data[1])\n    C = int(data[2])\n    S = data[3]\n\n    x = 0\n    y = 0\n    seen = {(0, 0)}\n    ans = []\n\n    for ch in S:\n        if ch == 'N':\n            x -= 1\n        elif ch == 'S':\n            x += 1\n        elif ch == 'W':\n            y -= 1\n        else:  # 'E'\n            y += 1\n\n        seen.add((x, y))\n\n        if (x - R, y - C) in seen:\n            ans.append('1')\n        else:\n            ans.append('0')\n\n    sys.stdout.write(''.join(ans))\n\nif __name__ == \"__main__\":\n    main()"
    }
   }
  },
  {
   "id": "abc398_c",
   "title": "Uniqueness",
   "platform": "atcoder",
   "difficulty": "medium",
   "contest": "AtCoder ABC 398 C 题",
   "date": "2025-03-22",
   "url": "https://atcoder.jp/contests/abc398/tasks/abc398_c",
   "summary": "在“所持整数与其他人都不同”的人中，找出整数最大者的编号；没有这样的人时按要求报告。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 42/42",
     "output_tokens": 370,
     "latency_s": 5.4,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 3,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 3,
       "score": 8.24
      },
      "radon": {
       "complexity": 5,
       "functions": 1,
       "mi": 58.266841715933914,
       "loc": 22,
       "lloc": 18,
       "sloc": 17,
       "comments": 0,
       "blank": 5
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\n\ndef main():\n    data = sys.stdin.buffer.read().split()\n    n = int(data[0])\n    a = list(map(int, data[1:1 + n]))\n\n    counts = {}\n    for x in a:\n        counts[x] = counts.get(x, 0) + 1\n\n    answer = -1\n    max_value = -1\n    for i, x in enumerate(a, 1):\n        if counts[x] == 1 and x > max_value:\n            max_value = x\n            answer = i\n\n    print(answer)\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 42/42",
     "output_tokens": 387,
     "latency_s": 3.2,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 3,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 3,
       "score": 8.12
      },
      "radon": {
       "complexity": 4,
       "functions": 1,
       "mi": 59.46713490348353,
       "loc": 22,
       "lloc": 17,
       "sloc": 16,
       "comments": 0,
       "blank": 6
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\nfrom collections import Counter\n\ndef main():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    n = data[0]\n    a = data[1:1 + n]\n\n    count = Counter(a)\n\n    answer = -1\n    max_value = -1\n\n    for i, value in enumerate(a, start=1):\n        if count[value] == 1 and value > max_value:\n            max_value = value\n            answer = i\n\n    print(answer)\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 42/42",
     "output_tokens": 398,
     "latency_s": 3.8,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 3,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 3,
       "score": 8.33
      },
      "radon": {
       "complexity": 5,
       "functions": 1,
       "mi": 57.824468528373366,
       "loc": 24,
       "lloc": 19,
       "sloc": 18,
       "comments": 0,
       "blank": 6
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\nfrom collections import Counter\n\ndef main():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    if not data:\n        return\n    n = data[0]\n    a = data[1:1 + n]\n\n    counts = Counter(a)\n\n    best_label = -1\n    best_value = -1\n\n    for i, value in enumerate(a, start=1):\n        if counts[value] == 1 and value > best_value:\n            best_value = value\n            best_label = i\n\n    print(best_label)\n\nif __name__ == \"__main__\":\n    main()"
    }
   }
  },
  {
   "id": "abc398_b",
   "title": "Full House 3",
   "platform": "atcoder",
   "difficulty": "medium",
   "contest": "AtCoder ABC 398 B 题",
   "date": "2025-03-22",
   "url": "https://atcoder.jp/contests/abc398/tasks/abc398_b",
   "summary": "七张牌中能否选出五张组成葫芦（三张相同加另外两张相同）。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 44/44",
     "output_tokens": 885,
     "latency_s": 14.6,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 2,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 2,
       "score": 6.67
      },
      "radon": {
       "complexity": 0,
       "functions": 0,
       "mi": 70.53606448373168,
       "loc": 13,
       "lloc": 6,
       "sloc": 10,
       "comments": 0,
       "blank": 3
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\nfrom collections import Counter\n\na = list(map(int, sys.stdin.read().split()))\ncounts = Counter(a)\n\npossible = any(\n    x != y and counts[x] >= 3 and counts[y] >= 2\n    for x in counts\n    for y in counts\n)\n\nprint(\"Yes\" if possible else \"No\")"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 44/44",
     "output_tokens": 292,
     "latency_s": 2.8,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 2,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 2,
       "score": 8.0
      },
      "radon": {
       "complexity": 0,
       "functions": 0,
       "mi": 65.69666383752757,
       "loc": 13,
       "lloc": 10,
       "sloc": 10,
       "comments": 0,
       "blank": 3
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\nfrom collections import Counter\n\nA = list(map(int, sys.stdin.read().split()))\ncount = Counter(A)\n\nfor x in count:\n    for y in count:\n        if x != y and count[x] >= 3 and count[y] >= 2:\n            print(\"Yes\")\n            sys.exit()\n\nprint(\"No\")"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 44/44",
     "output_tokens": 971,
     "latency_s": 7.3,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 4,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 4,
       "score": 6.36
      },
      "radon": {
       "complexity": 4,
       "functions": 1,
       "mi": 63.376083222264725,
       "loc": 15,
       "lloc": 12,
       "sloc": 12,
       "comments": 0,
       "blank": 3
      },
      "sonar": {
       "maintainability": 0,
       "reliability": 0,
       "security": 0,
       "types": {},
       "severities": {},
       "rules": {}
      }
     },
     "code": "import sys\nfrom collections import Counter\n\ndef main():\n    A = list(map(int, sys.stdin.read().split()))\n    counts = Counter(A)\n    values = sorted(counts.values(), reverse=True)\n\n    if len(values) >= 2 and values[0] >= 3 and values[1] >= 2:\n        print(\"Yes\")\n    else:\n        print(\"No\")\n\nif __name__ == \"__main__\":\n    main()"
    }
   }
  },
  {
   "id": "abc398_a",
   "title": "Doors in the Center",
   "platform": "atcoder",
   "difficulty": "easy",
   "contest": "AtCoder ABC 398 A 题",
   "date": "2025-03-22",
   "url": "https://atcoder.jp/contests/abc398/tasks/abc398_a",
   "summary": "构造长度为 N、由 - 和 = 组成的回文串，且恰含 1 个 =，或恰含 2 个相邻的 =。",
   "evaluated": false
  },
  {
   "id": "3801",
   "title": "Count Beautiful Numbers",
   "platform": "leetcode",
   "difficulty": "hard",
   "contest": "LeetCode 周赛 441",
   "date": "2025-03-15",
   "url": "https://leetcode.com/problems/count-beautiful-numbers/",
   "summary": "各位数字之积能被各位数字之和整除的正整数称为美丽数；求 [l, r] 内美丽数的个数。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 6434,
     "latency_s": 98.7,
     "cpu_s": 0.1117,
     "peak_mb": 26.1,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 6,
       "score": 7.39
      },
      "radon": {
       "complexity": 3,
       "functions": 2,
       "mi": 61.92507659600354,
       "loc": 48,
       "lloc": 25,
       "sloc": 37,
       "comments": 1,
       "blank": 10
      },
      "sonar": {
       "maintainability": 2,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 2
       },
       "severities": {
        "CRITICAL": 1,
        "MINOR": 1
       },
       "rules": {
        "python:S3776": 1,
        "python:S100": 1
       }
      }
     },
     "code": "from functools import lru_cache\n\n\nclass Solution:\n    def beautifulNumbers(self, l: int, r: int) -> int:\n        def count_up_to(x: int) -> int:\n            if x <= 0:\n                return 0\n\n            digits = [int(c) for c in str(x)]\n            n = len(digits)\n\n            @lru_cache(None)\n            def dfs(\n                pos: int,\n                digit_sum: int,\n                digit_product: int,\n                started: bool,\n                tight: bool,\n            ) -> int:\n                if pos == n:\n                    if not started:\n                        return 0\n                    return int(digit_product % digit_sum == 0)\n\n                limit = digits[pos] if tight else 9\n                total = 0\n\n                for d in range(limit + 1):\n                    next_tight = tight and d == digits[pos]\n\n                    if not started and d == 0:\n                        # Leading zero: the number has not started yet.\n                        total += dfs(pos + 1, 0, 1, False, next_tight)\n                    else:\n                        total += dfs(\n                            pos + 1,\n                            digit_sum + d,\n                            digit_product * d,\n                            True,\n                            next_tight,\n                        )\n\n                return total\n\n            return dfs(0, 0, 1, False, True)\n\n        return count_up_to(r) - count_up_to(l - 1)"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 3791,
     "latency_s": 21.8,
     "cpu_s": 0.1141,
     "peak_mb": 26.1,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 6,
       "score": 7.39
      },
      "radon": {
       "complexity": 3,
       "functions": 2,
       "mi": 51.64255410540829,
       "loc": 34,
       "lloc": 25,
       "sloc": 25,
       "comments": 0,
       "blank": 9
      },
      "sonar": {
       "maintainability": 2,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 2
       },
       "severities": {
        "CRITICAL": 1,
        "MINOR": 1
       },
       "rules": {
        "python:S3776": 1,
        "python:S100": 1
       }
      }
     },
     "code": "from functools import lru_cache\n\nclass Solution:\n    def beautifulNumbers(self, l: int, r: int) -> int:\n        def count(n: int) -> int:\n            if n <= 0:\n                return 0\n\n            digits = list(map(int, str(n)))\n            length = len(digits)\n\n            @lru_cache(None)\n            def dp(pos: int, digit_sum: int, digit_product: int, tight: bool, started: bool) -> int:\n                if pos == length:\n                    return 1 if started and digit_product % digit_sum == 0 else 0\n\n                limit = digits[pos] if tight else 9\n                total = 0\n\n                for d in range(limit + 1):\n                    next_tight = tight and (d == digits[pos])\n\n                    if not started and d == 0:\n                        total += dp(pos + 1, digit_sum, digit_product, next_tight, False)\n                    elif not started:\n                        total += dp(pos + 1, d, d, next_tight, True)\n                    else:\n                        total += dp(pos + 1, digit_sum + d, digit_product * d, next_tight, True)\n\n                return total\n\n            return dp(0, 0, 1, True, False)\n\n        return count(r) - count(l - 1)"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 66298,
     "latency_s": 474.0,
     "cpu_s": 0.9309,
     "peak_mb": 18.1,
     "quality": {
      "pylint": {
       "convention": 10,
       "refactor": 4,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 14,
       "score": 8.21
      },
      "radon": {
       "complexity": 5,
       "functions": 2,
       "mi": 55.03176421382833,
       "loc": 107,
       "lloc": 84,
       "sloc": 81,
       "comments": 4,
       "blank": 15
      },
      "sonar": {
       "maintainability": 4,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 4
       },
       "severities": {
        "MINOR": 3,
        "CRITICAL": 1
       },
       "rules": {
        "python:S100": 1,
        "python:S3776": 1,
        "python:S117": 2
       }
      }
     },
     "code": "class Solution:\n    def beautifulNumbers(self, l: int, r: int) -> int:\n        def count_no_zero_upto(n: int) -> int:\n            \"\"\"Count positive integers <= n with no digit 0.\"\"\"\n            if n <= 0:\n                return 0\n            s = str(n)\n            L = len(s)\n            total = 0\n            for m in range(1, L):\n                total += 9 ** m\n\n            for i, ch in enumerate(s):\n                digit = ord(ch) - 48\n                rem = L - i - 1\n                if digit > 0:\n                    total += (digit - 1) * (9 ** rem)\n                else:\n                    break\n            else:\n                total += 1\n            return total\n\n        def build_ways(S: int, max_len: int):\n            \"\"\"\n            ways[rem][sum][prod] = number of completions of length rem\n            (digits 1..9, no zero) such that final digit sum is S and\n            final product is divisible by S (i.e. prod modulo S becomes 0).\n            \"\"\"\n            mul = [[(p * d) % S for d in range(10)] for p in range(S)]\n            prev = [[0] * S for _ in range(S + 1)]\n            prev[S][0] = 1\n            ways = [prev]\n\n            for _ in range(1, max_len):\n                cur = [[0] * S for _ in range(S + 1)]\n                for s in range(S + 1):\n                    max_d = min(9, S - s)\n                    if max_d <= 0:\n                        continue\n                    for p in range(S):\n                        total = 0\n                        for d in range(1, max_d + 1):\n                            total += prev[s + d][mul[p][d]]\n                        cur[s][p] = total\n                ways.append(cur)\n                prev = cur\n            return ways\n\n        def count_zf_beautiful_upto(n: int, S: int, ways) -> int:\n            \"\"\"Count zero-free beautiful numbers <= n with digit sum S.\"\"\"\n            if n <= 0:\n                return 0\n            s = str(n)\n            L = len(s)\n            start_prod = 1 % S\n            ans = 0\n\n            # All shorter lengths are automatically <= n.\n            for m in range(1, L):\n                ans += ways[m][0][start_prod]\n\n            cur_sum = 0\n            cur_prod = start_prod\n\n            for i, ch in enumerate(s):\n                limit = ord(ch) - 48\n                rem = L - i - 1\n\n                # Put a smaller non-zero digit here; the rest can be anything.\n                for d in range(1, limit):\n                    ns = cur_sum + d\n                    if ns <= S:\n                        np = (cur_prod * d) % S\n                        ans += ways[rem][ns][np]\n\n                # Continue with the exact digit of n.\n                if limit == 0:\n                    break\n                if cur_sum + limit > S:\n                    break\n                cur_sum += limit\n                cur_prod = (cur_prod * limit) % S\n            else:\n                if cur_sum == S and cur_prod == 0:\n                    ans += 1\n\n            return ans\n\n        # Any number containing a zero is beautiful: product = 0.\n        total_range = r - l + 1\n        zf_range = count_no_zero_upto(r) - count_no_zero_upto(l - 1)\n        zero_containing = total_range - zf_range\n\n        max_len = len(str(r))\n        max_sum = 9 * max_len\n\n        zf_beautiful_r = 0\n        zf_beautiful_lm = 0\n\n        for S in range(1, max_sum + 1):\n            ways = build_ways(S, max_len)\n            zf_beautiful_r += count_zf_beautiful_upto(r, S, ways)\n            zf_beautiful_lm += count_zf_beautiful_upto(l - 1, S, ways)\n\n        zero_free_beautiful = zf_beautiful_r - zf_beautiful_lm\n        return zero_containing + zero_free_beautiful"
    }
   }
  },
  {
   "id": "3795",
   "title": "Zero Array Transformation Iv",
   "platform": "leetcode",
   "difficulty": "medium",
   "contest": "LeetCode 周赛 441",
   "date": "2025-03-15",
   "url": "https://leetcode.com/problems/zero-array-transformation-iv/",
   "summary": "每个查询 [l, r, val] 可在区间内任选一些位置各减去 val；求最小的 k，使依次处理前 k 个查询后数组全为 0，不存在时返回 -1。",
   "evaluated": false
  },
  {
   "id": "3788",
   "title": "Maximum Unique Subarray Sum After Deletion",
   "platform": "leetcode",
   "difficulty": "easy",
   "contest": "LeetCode 周赛 441",
   "date": "2025-03-15",
   "url": "https://leetcode.com/problems/maximum-unique-subarray-sum-after-deletion/",
   "summary": "可删除任意元素（不能删空），然后选一个元素互不相同的子数组，求其元素和的最大值。",
   "evaluated": false
  },
  {
   "id": "3750",
   "title": "Closest Equal Element Queries",
   "platform": "leetcode",
   "difficulty": "medium",
   "contest": "LeetCode 周赛 441",
   "date": "2025-03-15",
   "url": "https://leetcode.com/problems/closest-equal-element-queries/",
   "summary": "在环形数组中，对每个查询下标，求与它值相同的另一个位置的最短环上距离，不存在时为 -1。",
   "evaluated": false
  },
  {
   "id": "3799",
   "title": "Unique 3 Digit Even Numbers",
   "platform": "leetcode",
   "difficulty": "easy",
   "contest": "LeetCode 双周赛 152",
   "date": "2025-03-15",
   "url": "https://leetcode.com/problems/unique-3-digit-even-numbers/",
   "summary": "用给定的数字（每个数字每次至多用一次，不能有前导零）能组成多少个不同的三位偶数。",
   "evaluated": false
  },
  {
   "id": "3784",
   "title": "Longest Common Prefix of K Strings After Removal",
   "platform": "leetcode",
   "difficulty": "hard",
   "contest": "LeetCode 双周赛 152",
   "date": "2025-03-15",
   "url": "https://leetcode.com/problems/longest-common-prefix-of-k-strings-after-removal/",
   "summary": "对每个下标 i，删去第 i 个字符串后，从剩余字符串中任选 k 个，求它们最长公共前缀的最大长度。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 20544,
     "latency_s": 296.4,
     "cpu_s": 0.1141,
     "peak_mb": 22.1,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 2,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 7,
       "score": 8.6
      },
      "radon": {
       "complexity": 33,
       "functions": 2,
       "mi": 59.09206819172901,
       "loc": 79,
       "lloc": 51,
       "sloc": 57,
       "comments": 6,
       "blank": 16
      },
      "sonar": {
       "maintainability": 2,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 2
       },
       "severities": {
        "CRITICAL": 1,
        "MINOR": 1
       },
       "rules": {
        "python:S3776": 1,
        "python:S100": 1
       }
      }
     },
     "code": "from collections import deque\nfrom typing import List\n\nclass Solution:\n    def longestCommonPrefix(self, words: List[str], k: int) -> List[int]:\n        n = len(words)\n        if n - 1 < k:\n            return [0] * n\n\n        order = sorted(range(n), key=lambda i: words[i])\n        sorted_words = [words[i] for i in order]\n\n        def lcp(a: str, b: str) -> int:\n            limit = min(len(a), len(b))\n            i = 0\n            while i < limit and a[i] == b[i]:\n                i += 1\n            return i\n\n        # Values of all windows of k consecutive strings.\n        window = [\n            lcp(sorted_words[i], sorted_words[i + k - 1])\n            for i in range(n - k + 1)\n        ]\n\n        # A new window after a deletion can come from a span of k + 1\n        # original strings with its deleted string inside the span.\n        extended = [\n            lcp(sorted_words[i], sorted_words[i + k])\n            for i in range(n - k)\n        ]\n\n        m = len(window)\n        prefix_max = [0] * (m + 1)\n        for i, value in enumerate(window):\n            prefix_max[i + 1] = max(prefix_max[i], value)\n\n        suffix_max = [0] * (m + 1)\n        for i in range(m - 1, -1, -1):\n            suffix_max[i] = max(window[i], suffix_max[i + 1])\n\n        answer = [0] * n\n        deque_indices = deque()\n        added = 0\n        extended_len = len(extended)\n\n        for pos in range(n):\n            best = 0\n\n            # Original k-windows ending before the deleted position.\n            right = pos - k\n            if right >= 0:\n                best = prefix_max[right + 1]\n\n            # Original k-windows starting after the deleted position.\n            left = pos + 1\n            if left < m:\n                best = max(best, suffix_max[left])\n\n            # Sliding range maximum for newly created windows.\n            range_right = min(pos - 1, extended_len - 1)\n            while added <= range_right:\n                value = extended[added]\n                while (deque_indices and\n                       extended[deque_indices[-1]] <= value):\n                    deque_indices.pop()\n                deque_indices.append(added)\n                added += 1\n\n            range_left = max(0, pos - k + 1)\n            while deque_indices and deque_indices[0] < range_left:\n                deque_indices.popleft()\n\n            if deque_indices:\n                best = max(best, extended[deque_indices[0]])\n\n            answer[order[pos]] = best\n\n        return answer"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 8929,
     "latency_s": 49.8,
     "cpu_s": 0.0565,
     "peak_mb": 28.1,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 3,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 8,
       "score": 8.73
      },
      "radon": {
       "complexity": 33,
       "functions": 2,
       "mi": 54.239519757343466,
       "loc": 88,
       "lloc": 64,
       "sloc": 64,
       "comments": 4,
       "blank": 20
      },
      "sonar": {
       "maintainability": 2,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 2
       },
       "severities": {
        "CRITICAL": 1,
        "MINOR": 1
       },
       "rules": {
        "python:S3776": 1,
        "python:S100": 1
       }
      }
     },
     "code": "from typing import List\n\nclass Solution:\n    def longestCommonPrefix(self, words: List[str], k: int) -> List[int]:\n        n = len(words)\n        if n - 1 < k:\n            return [0] * n\n\n        children = [{}]\n        cnt = [0]\n        depth = [0]\n        terminals = []\n\n        for word in words:\n            cnt[0] += 1\n            node = 0\n            for ch in word:\n                nxt = children[node].get(ch)\n                if nxt is None:\n                    nxt = len(children)\n                    children[node][ch] = nxt\n                    children.append({})\n                    cnt.append(0)\n                    depth.append(depth[node] + 1)\n\n                node = nxt\n                cnt[node] += 1\n\n            terminals.append(node)\n\n        node_count = len(children)\n\n        always_best = 0\n        critical_nodes = []\n\n        for v in range(node_count):\n            if cnt[v] >= k + 1:\n                always_best = max(always_best, depth[v])\n            elif cnt[v] == k:\n                critical_nodes.append(v)\n\n        # Euler tour of the trie.\n        tin = [0] * node_count\n        tout = [0] * node_count\n        timer = 0\n        stack = [(0, 0)]\n\n        while stack:\n            node, state = stack.pop()\n\n            if state == 0:\n                tin[node] = timer\n                timer += 1\n\n                stack.append((node, 1))\n                for child in children[node].values():\n                    stack.append((child, 0))\n            else:\n                tout[node] = timer - 1\n\n        # Suffix maximum over Euler positions.\n        at_tin = [-1] * node_count\n        for v in critical_nodes:\n            at_tin[tin[v]] = depth[v]\n\n        suffix = [-1] * (node_count + 1)\n        for i in range(node_count - 1, -1, -1):\n            suffix[i] = max(suffix[i + 1], at_tin[i])\n\n        # Prefix maximum over tout positions.\n        at_tout = [-1] * node_count\n        for v in critical_nodes:\n            at_tout[tout[v]] = max(at_tout[tout[v]], depth[v])\n\n        prefix = [-1] * (node_count + 1)\n        for i in range(node_count):\n            prefix[i + 1] = max(prefix[i], at_tout[i])\n\n        answer = []\n\n        for terminal in terminals:\n            t = tin[terminal]\n\n            # Critical nodes not being ancestors of this terminal.\n            best_other = max(suffix[t + 1], prefix[t])\n            answer.append(max(always_best, best_other, 0))\n\n        return answer"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "函数调用，官方测试全部通过",
     "output_tokens": 49428,
     "latency_s": 368.4,
     "cpu_s": 0.052,
     "peak_mb": 22.1,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 5,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 10,
       "score": 8.08
      },
      "radon": {
       "complexity": 35,
       "functions": 2,
       "mi": 58.61604486023504,
       "loc": 67,
       "lloc": 54,
       "sloc": 54,
       "comments": 5,
       "blank": 8
      },
      "sonar": {
       "maintainability": 2,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 2
       },
       "severities": {
        "CRITICAL": 1,
        "MINOR": 1
       },
       "rules": {
        "python:S3776": 1,
        "python:S100": 1
       }
      }
     },
     "code": "from typing import List\n\nclass Solution:\n    def longestCommonPrefix(self, words: List[str], k: int) -> List[int]:\n        children = [dict()]\n        cnt = [0]\n        depth = [0]\n        max_len = 0\n\n        # Build trie and count how many words have each prefix.\n        for w in words:\n            node = 0\n            for i, ch in enumerate(w, 1):\n                nxt = children[node].get(ch)\n                if nxt is None:\n                    nxt = len(children)\n                    children[node][ch] = nxt\n                    children.append({})\n                    cnt.append(0)\n                    depth.append(i)\n                node = nxt\n                cnt[node] += 1\n                if i > max_len:\n                    max_len = i\n\n        # For each depth, store the largest and second largest prefix counts.\n        top1_cnt = [0] * (max_len + 1)\n        top1_node = [-1] * (max_len + 1)\n        top2_cnt = [0] * (max_len + 1)\n        top2_node = [-1] * (max_len + 1)\n\n        for node in range(1, len(cnt)):\n            d = depth[node]\n            c = cnt[node]\n            if c > top1_cnt[d]:\n                top2_cnt[d], top2_node[d] = top1_cnt[d], top1_node[d]\n                top1_cnt[d], top1_node[d] = c, node\n            elif c > top2_cnt[d]:\n                top2_cnt[d], top2_node[d] = c, node\n\n        # Original answer before removing any word.\n        global_max = 0\n        for d in range(1, max_len + 1):\n            if top1_cnt[d] >= k:\n                global_max = d\n\n        ans = [0] * len(words)\n\n        for idx, w in enumerate(words):\n            # If the removed word is too short to contain the global best prefix,\n            # that prefix is unaffected.\n            if len(w) < global_max:\n                ans[idx] = global_max\n            else:\n                node = 0\n                best = 0\n                for d in range(1, global_max + 1):\n                    node = children[node][w[d - 1]]\n                    if top1_node[d] != node:\n                        if top1_cnt[d] >= k:\n                            best = d\n                    else:\n                        if top1_cnt[d] >= k + 1 or top2_cnt[d] >= k:\n                            best = d\n                ans[idx] = best\n\n        return ans"
    }
   }
  },
  {
   "id": "abc397_g",
   "title": "Maximize Distance",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ABC 397 G 题",
   "date": "2025-03-15",
   "url": "https://atcoder.jp/contests/abc397/tasks/abc397_g",
   "summary": "有向图中恰选 K 条边把权值设为 1，其余为 0；求顶点 1 到 N 最短距离的最大可能值。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 33135,
     "latency_s": 423.1,
     "cpu_s": 0.0065,
     "peak_mb": 14.2,
     "quality": {
      "pylint": {
       "convention": 8,
       "refactor": 1,
       "warning": 2,
       "error": 0,
       "fatal": 0,
       "total": 11,
       "score": 8.9
      },
      "radon": {
       "complexity": 31,
       "functions": 7,
       "mi": 46.54714160202791,
       "loc": 129,
       "lloc": 102,
       "sloc": 101,
       "comments": 7,
       "blank": 21
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\nfrom collections import deque\n\nsys.setrecursionlimit(1000000)\n\n\nclass Dinic:\n    def __init__(self, n):\n        self.n = n\n        self.g = [[] for _ in range(n)]\n\n    def add_edge(self, fr, to, cap):\n        fwd = [to, cap, len(self.g[to])]\n        rev = [fr, 0, len(self.g[fr])]\n        self.g[fr].append(fwd)\n        self.g[to].append(rev)\n\n    def bfs(self, s, t):\n        self.level = [-1] * self.n\n        self.level[s] = 0\n        q = deque([s])\n        while q:\n            v = q.popleft()\n            for to, cap, _ in self.g[v]:\n                if cap > 0 and self.level[to] == -1:\n                    self.level[to] = self.level[v] + 1\n                    q.append(to)\n        return self.level[t] != -1\n\n    def dfs(self, v, t, flow):\n        if v == t:\n            return flow\n        while self.it[v] < len(self.g[v]):\n            e = self.g[v][self.it[v]]\n            if e[1] > 0 and self.level[e[0]] == self.level[v] + 1:\n                pushed = self.dfs(e[0], t, min(flow, e[1]))\n                if pushed:\n                    e[1] -= pushed\n                    self.g[e[0]][e[2]][1] += pushed\n                    return pushed\n            self.it[v] += 1\n        return 0\n\n    def max_flow(self, s, t):\n        result = 0\n        while self.bfs(s, t):\n            self.it = [0] * self.n\n            while True:\n                pushed = self.dfs(s, t, 10**18)\n                if not pushed:\n                    break\n                result += pushed\n        return result\n\n\ndef main():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    if not data:\n        return\n\n    n, m, k = data[:3]\n    edges = []\n    adj = [[] for _ in range(n)]\n    pos = 3\n    for _ in range(m):\n        u = data[pos] - 1\n        v = data[pos + 1] - 1\n        pos += 2\n        edges.append((u, v))\n        adj[u].append(v)\n\n    # No attainable distance can exceed the unweighted shortest-path length.\n    dist = [-1] * n\n    dist[0] = 0\n    q = deque([0])\n    while q:\n        v = q.popleft()\n        for to in adj[v]:\n            if dist[to] == -1:\n                dist[to] = dist[v] + 1\n                q.append(to)\n    max_distance = dist[n - 1]\n\n    inf = m + 1\n\n    # Minimum number of edges that must have weight 1 to force distance >= d.\n    def required(d):\n        size = n * d\n        source = size\n        sink = size + 1\n        flow = Dinic(size + 2)\n\n        # Binary variables x[v][i] indicate whether label[v] >= i+1.\n        # Enforce x[v][i] >= x[v][i+1].\n        for v in range(n):\n            base = v * d\n            for i in range(d - 1):\n                flow.add_edge(base + i, base + i + 1, inf)\n\n        for u, v in edges:\n            ub = u * d\n            vb = v * d\n            # Cost max(0, label[v] - label[u]).\n            for i in range(d):\n                flow.add_edge(ub + i, vb + i, 1)\n            # Forbid label[v] - label[u] > 1.\n            for i in range(d - 1):\n                flow.add_edge(ub + i, vb + i + 1, inf)\n\n        # label[1] = 0 and label[N] = d.\n        sink_base = (n - 1) * d\n        for i in range(d):\n            flow.add_edge(source, i, inf)\n            flow.add_edge(sink_base + i, sink, inf)\n\n        return flow.max_flow(source, sink)\n\n    answer = 0\n    for d in range(1, max_distance + 1):\n        if required(d) <= k:\n            answer = d\n        else:\n            break\n\n    print(answer)\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 14461,
     "latency_s": 76.5,
     "cpu_s": 0.0159,
     "peak_mb": 14.2,
     "quality": {
      "pylint": {
       "convention": 12,
       "refactor": 1,
       "warning": 2,
       "error": 0,
       "fatal": 0,
       "total": 15,
       "score": 8.24
      },
      "radon": {
       "complexity": 21,
       "functions": 5,
       "mi": 49.04803959114567,
       "loc": 124,
       "lloc": 86,
       "sloc": 86,
       "comments": 5,
       "blank": 33
      },
      "sonar": {
       "maintainability": 5,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 5
       },
       "severities": {
        "CRITICAL": 2,
        "MAJOR": 2,
        "MINOR": 1
       },
       "rules": {
        "python:S3776": 2,
        "python:S5806": 1,
        "python:S117": 1,
        "python:S125": 1
       }
      }
     },
     "code": "import sys\nfrom collections import deque\n\nsys.setrecursionlimit(1 << 25)\n\n\nclass Dinic:\n    def __init__(self, n):\n        self.n = n\n        self.g = [[] for _ in range(n)]\n\n    def add_edge(self, fr, to, cap):\n        self.g[fr].append([to, cap, len(self.g[to])])\n        self.g[to].append([fr, 0, len(self.g[fr]) - 1])\n\n    def max_flow(self, s, t):\n        flow = 0\n        INF_FLOW = 10**18\n        n = self.n\n\n        while True:\n            level = [-1] * n\n            level[s] = 0\n            q = deque([s])\n\n            while q:\n                v = q.popleft()\n                for to, cap, rev in self.g[v]:\n                    if cap > 0 and level[to] < 0:\n                        level[to] = level[v] + 1\n                        q.append(to)\n\n            if level[t] < 0:\n                break\n\n            it = [0] * n\n\n            def dfs(v, f):\n                if v == t:\n                    return f\n\n                while it[v] < len(self.g[v]):\n                    e = self.g[v][it[v]]\n                    to, cap, rev = e\n\n                    if cap > 0 and level[v] + 1 == level[to]:\n                        ret = dfs(to, min(f, cap))\n                        if ret > 0:\n                            e[1] -= ret\n                            self.g[to][rev][1] += ret\n                            return ret\n\n                    it[v] += 1\n\n                return 0\n\n            while True:\n                f = dfs(s, INF_FLOW)\n                if f == 0:\n                    break\n                flow += f\n\n        return flow\n\n\ndef solve():\n    input = sys.stdin.readline\n\n    N, M, K = map(int, input().split())\n    edges = []\n    for _ in range(M):\n        u, v = map(int, input().split())\n        edges.append((u, v))\n\n    def feasible(L):\n        if L == 0:\n            return True\n\n        source = 0\n        sink = 1\n        node_count = 2 + N * L\n        dinic = Dinic(node_count)\n\n        INF = 10**7\n\n        def idx(v, k):\n            # v: 1-indexed, k: 1..L\n            return 2 + (v - 1) * L + (k - 1)\n\n        # Monotonicity: x[v][k+1] <= x[v][k]\n        for v in range(1, N + 1):\n            for k in range(1, L):\n                dinic.add_edge(idx(v, k + 1), idx(v, k), INF)\n\n        # h[1] = 0, h[N] = L\n        for k in range(1, L + 1):\n            dinic.add_edge(idx(1, k), sink, INF)\n            dinic.add_edge(source, idx(N, k), INF)\n\n        for u, v in edges:\n            # Cost: max(0, h[v] - h[u]), one unit per level\n            for k in range(1, L + 1):\n                dinic.add_edge(idx(v, k), idx(u, k), 1)\n\n            # Constraint: h[v] <= h[u] + 1\n            for k in range(1, L):\n                dinic.add_edge(idx(v, k + 1), idx(u, k), INF)\n\n        return dinic.max_flow(source, sink) <= K\n\n    low, high = 0, N - 1\n\n    while low < high:\n        mid = (low + high + 1) // 2\n        if feasible(mid):\n            low = mid\n        else:\n            high = mid - 1\n\n    print(low)\n\n\nif __name__ == \"__main__\":\n    solve()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43",
     "output_tokens": 55845,
     "latency_s": 423.3,
     "cpu_s": 0.2345,
     "peak_mb": 14.2,
     "quality": {
      "pylint": {
       "convention": 17,
       "refactor": 1,
       "warning": 3,
       "error": 0,
       "fatal": 0,
       "total": 21,
       "score": 7.61
      },
      "radon": {
       "complexity": 27,
       "functions": 7,
       "mi": 50.137977615374574,
       "loc": 115,
       "lloc": 88,
       "sloc": 88,
       "comments": 7,
       "blank": 22
      },
      "sonar": {
       "maintainability": 3,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 3
       },
       "severities": {
        "CRITICAL": 1,
        "MINOR": 1,
        "MAJOR": 1
       },
       "rules": {
        "python:S3776": 1,
        "python:S117": 1,
        "python:S125": 1
       }
      }
     },
     "code": "import sys\nfrom collections import deque\n\nsys.setrecursionlimit(1000000)\n\n\nclass Dinic:\n    def __init__(self, n):\n        self.n = n\n        self.ad = [[] for _ in range(n)]\n\n    def add_edge(self, fr, to, cap):\n        fwd = [to, cap, len(self.ad[to])]\n        rev = [fr, 0, len(self.ad[fr])]\n        self.ad[fr].append(fwd)\n        self.ad[to].append(rev)\n\n    def bfs(self, s, t):\n        self.level = [-1] * self.n\n        q = deque([s])\n        self.level[s] = 0\n        while q:\n            u = q.popleft()\n            for v, cap, rev in self.ad[u]:\n                if cap > 0 and self.level[v] < 0:\n                    self.level[v] = self.level[u] + 1\n                    q.append(v)\n        return self.level[t] >= 0\n\n    def dfs(self, u, t, f):\n        if u == t:\n            return f\n        while self.it[u] < len(self.ad[u]):\n            e = self.ad[u][self.it[u]]\n            v, cap, rev = e\n            if cap > 0 and self.level[v] == self.level[u] + 1:\n                ret = self.dfs(v, t, min(f, cap))\n                if ret > 0:\n                    e[1] -= ret\n                    self.ad[v][rev][1] += ret\n                    return ret\n            self.it[u] += 1\n        return 0\n\n    def max_flow(self, s, t):\n        flow = 0\n        INF_FLOW = 10**18\n        while self.bfs(s, t):\n            self.it = [0] * self.n\n            while True:\n                f = self.dfs(s, t, INF_FLOW)\n                if f == 0:\n                    break\n                flow += f\n        return flow\n\n\ndef main():\n    data = list(map(int, sys.stdin.read().split()))\n    if not data:\n        return\n\n    N, M, K = data[0], data[1], data[2]\n    edges = []\n    idx = 3\n    for _ in range(M):\n        u = data[idx]\n        v = data[idx + 1]\n        idx += 2\n        edges.append((u, v))\n\n    def feasible(D):\n        if D == 0:\n            return True\n\n        node_count = N * D + 2\n        SRC = node_count - 2\n        SNK = node_count - 1\n        dinic = Dinic(node_count)\n\n        # INF is larger than any possible finite cut.\n        INF = M * D + 1\n\n        def vid(v, i):\n            return (v - 1) * D + (i - 1)\n\n        # p_1 = 0, p_N = D\n        for i in range(1, D + 1):\n            dinic.add_edge(vid(1, i), SNK, INF)   # X_{1,i} = 0\n            dinic.add_edge(SRC, vid(N, i), INF)   # X_{N,i} = 1\n\n        # X_{v,i+1} => X_{v,i}\n        for v in range(1, N + 1):\n            for i in range(1, D):\n                dinic.add_edge(vid(v, i + 1), vid(v, i), INF)\n\n        for u, v in edges:\n            # p_v <= p_u + 1\n            for i in range(1, D):\n                dinic.add_edge(vid(v, i + 1), vid(u, i), INF)\n\n            # An edge is selected iff p_v = p_u + 1.\n            for i in range(1, D + 1):\n                dinic.add_edge(vid(v, i), vid(u, i), 1)\n\n        return dinic.max_flow(SRC, SNK) <= K\n\n    for D in range(min(N - 1, K), -1, -1):\n        if feasible(D):\n            print(D)\n            return\n\n\nif __name__ == \"__main__\":\n    main()"
    }
   }
  },
  {
   "id": "abc397_f",
   "title": "Variety Split Hard",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ABC 397 F 题",
   "date": "2025-03-15",
   "url": "https://atcoder.jp/contests/abc397/tasks/abc397_f",
   "summary": "把序列切成三段非空的连续子数组，使三段各自不同元素个数之和最大。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 42/42",
     "output_tokens": 64043,
     "latency_s": 943.9,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 3,
       "refactor": 3,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 6,
       "score": 8.98
      },
      "radon": {
       "complexity": 14,
       "functions": 1,
       "mi": 58.77894325921973,
       "loc": 83,
       "lloc": 62,
       "sloc": 61,
       "comments": 7,
       "blank": 16
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\n\n\ndef main():\n    data = sys.stdin.buffer.read().split()\n    n = int(data[0])\n    a = list(map(int, data[1:1 + n]))\n    del data\n\n    # Positions of the strict right-to-left maxima of P[i] - i,\n    # where P[i] is the number of distinct values in the prefix of length i.\n    seen = bytearray(n + 1)\n    record_pos = []\n    for i in range(n - 1):\n        x = a[i]\n        if seen[x]:\n            record_pos.append(i)\n        else:\n            seen[x] = 1\n    record_pos.append(n - 1)\n\n    # suffix[j] = distinct values in a[j:]\n    suffix = [0] * n\n    seen = bytearray(n + 1)\n    distinct = 0\n    for i in range(n - 1, -1, -1):\n        x = a[i]\n        if not seen[x]:\n            seen[x] = 1\n            distinct += 1\n        suffix[i] = distinct\n\n    k = len(record_pos)\n\n    # before[p]: number of record positions strictly smaller than p.\n    before = [0] * n\n    ri = 0\n    for pos in range(n):\n        while ri < k and record_pos[ri] < pos:\n            ri += 1\n        before[pos] = ri\n\n    # DSU for finding the nearest still-active record to the left.\n    parent = list(range(k + 1))\n\n    def find(x):\n        while parent[x] != x:\n            parent[x] = parent[parent[x]]\n            x = parent[x]\n        return x\n\n    last = [0] * (n + 1)\n    first = 1                 # Records use 1-based DSU indices.\n    current_max = 0\n    answer = 0\n\n    for j in range(1, n):\n        x = a[j - 1]\n        previous = last[x]\n        last[x] = j\n\n        if previous <= record_pos[first - 1]:\n            current_max += 1\n        else:\n            # Remove the nearest active record before `previous`.\n            target = find(before[previous])\n            parent[target] = find(target - 1)\n\n            if target == first:\n                first += 1\n                while parent[first] != first:\n                    first += 1\n\n        if j >= 2:\n            candidate = current_max + suffix[j]\n            if candidate > answer:\n                answer = candidate\n\n    print(answer)\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 42/42",
     "output_tokens": 21429,
     "latency_s": 107.5,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 8,
       "refactor": 9,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 17,
       "score": 8.57
      },
      "radon": {
       "complexity": 33,
       "functions": 1,
       "mi": 41.09215838937093,
       "loc": 149,
       "lloc": 120,
       "sloc": 119,
       "comments": 7,
       "blank": 23
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\n\n\ndef solve():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    if not data:\n        return\n\n    N = data[0]\n    A = [0] + data[1:1 + N]\n\n    # P[i] = number of distinct values in A[1..i]\n    P = [0] * (N + 1)\n    seen = bytearray(N + 1)\n    cnt = 0\n    for i in range(1, N + 1):\n        x = A[i]\n        if not seen[x]:\n            seen[x] = 1\n            cnt += 1\n        P[i] = cnt\n\n    # S[i] = number of distinct values in A[i..N]\n    S = [0] * (N + 2)\n    seen = bytearray(N + 1)\n    cnt = 0\n    for i in range(N, 0, -1):\n        x = A[i]\n        if not seen[x]:\n            seen[x] = 1\n            cnt += 1\n        S[i] = cnt\n\n    size = 1\n    log = 0\n    while size < N + 2:\n        size <<= 1\n        log += 1\n\n    NEG = -10**9\n    seg = [NEG] * (2 * size)\n    lazy = [0] * size\n\n    last = [0] * (N + 1)\n    ans = 0\n\n    for j in range(1, N):\n        x = A[j]\n        p = last[x]\n\n        left = p if p > 1 else 1\n        right = j - 2\n\n        # Existing candidates i with i >= p gain +1.\n        if left <= right:\n            l = left + size\n            r = right + 1 + size\n            l0, r0 = l, r\n\n            # Push lazy values on boundary paths.\n            for h in range(log, 0, -1):\n                if ((l0 >> h) << h) != l0:\n                    k = l0 >> h\n                    z = lazy[k]\n                    if z:\n                        lc = k << 1\n                        rc = lc | 1\n                        seg[lc] += z\n                        if lc < size:\n                            lazy[lc] += z\n                        seg[rc] += z\n                        if rc < size:\n                            lazy[rc] += z\n                        lazy[k] = 0\n\n                if ((r0 >> h) << h) != r0:\n                    k = (r0 - 1) >> h\n                    z = lazy[k]\n                    if z:\n                        lc = k << 1\n                        rc = lc | 1\n                        seg[lc] += z\n                        if lc < size:\n                            lazy[lc] += z\n                        seg[rc] += z\n                        if rc < size:\n                            lazy[rc] += z\n                        lazy[k] = 0\n\n            # Range add +1.\n            while l < r:\n                if l & 1:\n                    seg[l] += 1\n                    if l < size:\n                        lazy[l] += 1\n                    l += 1\n                if r & 1:\n                    r -= 1\n                    seg[r] += 1\n                    if r < size:\n                        lazy[r] += 1\n                l >>= 1\n                r >>= 1\n\n            # Rebuild boundary paths.\n            for h in range(1, log + 1):\n                if ((l0 >> h) << h) != l0:\n                    k = l0 >> h\n                    v = seg[k << 1]\n                    w = seg[(k << 1) | 1]\n                    if w > v:\n                        v = w\n                    seg[k] = v\n\n                if ((r0 >> h) << h) != r0:\n                    k = (r0 - 1) >> h\n                    v = seg[k << 1]\n                    w = seg[(k << 1) | 1]\n                    if w > v:\n                        v = w\n                    seg[k] = v\n\n        # Add new candidate i = j - 1.\n        if j >= 2:\n            idx = j - 1\n            pos = idx + size\n            seg[pos] = P[idx] + 1\n            pos >>= 1\n\n            while pos:\n                v = seg[pos << 1]\n                w = seg[(pos << 1) | 1]\n                if w > v:\n                    v = w\n                seg[pos] = v\n                pos >>= 1\n\n            best_middle = seg[1]\n            total = best_middle + S[j + 1]\n            if total > ans:\n                ans = total\n\n        last[x] = j\n\n    print(ans)\n\n\nif __name__ == \"__main__\":\n    solve()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 42/42",
     "output_tokens": 55929,
     "latency_s": 403.0,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 8,
       "refactor": 4,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 12,
       "score": 9.25
      },
      "radon": {
       "complexity": 53,
       "functions": 5,
       "mi": 31.308379748358867,
       "loc": 194,
       "lloc": 161,
       "sloc": 159,
       "comments": 4,
       "blank": 32
      },
      "sonar": {
       "maintainability": 3,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 3
       },
       "severities": {
        "CRITICAL": 2,
        "MAJOR": 1
       },
       "rules": {
        "python:S3776": 2,
        "python:S125": 1
       }
      }
     },
     "code": "import sys\n\nclass LazySegTree:\n    __slots__ = ('n', 'size', 'log', 'data', 'lazy')\n\n    def __init__(self, arr):\n        n = len(arr)\n        size = 1\n        log = 0\n        while size < n:\n            size <<= 1\n            log += 1\n\n        self.n = n\n        self.size = size\n        self.log = log\n\n        data = [-10**15] * (2 * size)\n        lazy = [0] * (2 * size)\n\n        for i, v in enumerate(arr):\n            data[size + i] = v\n\n        for i in range(size - 1, 0, -1):\n            a = data[2 * i]\n            b = data[2 * i + 1]\n            data[i] = a if a >= b else b\n\n        self.data = data\n        self.lazy = lazy\n\n    def range_add(self, l, r, x):\n        if l >= r:\n            return\n\n        size = self.size\n        log = self.log\n        data = self.data\n        lazy = self.lazy\n\n        l += size\n        r += size\n        l0, r0 = l, r\n\n        for i in range(log, 0, -1):\n            if ((l0 >> i) << i) != l0:\n                k = l0 >> i\n                z = lazy[k]\n                if z:\n                    data[2 * k] += z\n                    lazy[2 * k] += z\n                    data[2 * k + 1] += z\n                    lazy[2 * k + 1] += z\n                    lazy[k] = 0\n            if ((r0 >> i) << i) != r0:\n                k = r0 >> i\n                z = lazy[k]\n                if z:\n                    data[2 * k] += z\n                    lazy[2 * k] += z\n                    data[2 * k + 1] += z\n                    lazy[2 * k + 1] += z\n                    lazy[k] = 0\n\n        while l < r:\n            if l & 1:\n                data[l] += x\n                lazy[l] += x\n                l += 1\n            if r & 1:\n                r -= 1\n                data[r] += x\n                lazy[r] += x\n            l >>= 1\n            r >>= 1\n\n        l, r = l0, r0\n        for i in range(1, log + 1):\n            if ((l >> i) << i) != l:\n                k = l >> i\n                a = data[2 * k]\n                b = data[2 * k + 1]\n                data[k] = a if a >= b else b\n            if ((r >> i) << i) != r:\n                k = r >> i\n                a = data[2 * k]\n                b = data[2 * k + 1]\n                data[k] = a if a >= b else b\n\n    def range_max(self, l, r):\n        if l >= r:\n            return -10**15\n\n        size = self.size\n        log = self.log\n        data = self.data\n        lazy = self.lazy\n\n        l += size\n        r += size\n        l0, r0 = l, r\n\n        for i in range(log, 0, -1):\n            if ((l0 >> i) << i) != l0:\n                k = l0 >> i\n                z = lazy[k]\n                if z:\n                    data[2 * k] += z\n                    lazy[2 * k] += z\n                    data[2 * k + 1] += z\n                    lazy[2 * k + 1] += z\n                    lazy[k] = 0\n            if ((r0 >> i) << i) != r0:\n                k = r0 >> i\n                z = lazy[k]\n                if z:\n                    data[2 * k] += z\n                    lazy[2 * k] += z\n                    data[2 * k + 1] += z\n                    lazy[2 * k + 1] += z\n                    lazy[k] = 0\n\n        res = -10**15\n        while l < r:\n            if l & 1:\n                v = data[l]\n                if v > res:\n                    res = v\n                l += 1\n            if r & 1:\n                r -= 1\n                v = data[r]\n                if v > res:\n                    res = v\n            l >>= 1\n            r >>= 1\n\n        return res\n\n\ndef main():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    if not data:\n        return\n\n    N = data[0]\n    A = [0] + data[1:1 + N]\n\n    pre = [0] * (N + 1)\n    seen = [0] * (N + 1)\n    cnt = 0\n    for i in range(1, N + 1):\n        x = A[i]\n        if seen[x] == 0:\n            cnt += 1\n            seen[x] = 1\n        pre[i] = cnt\n\n    suf = [0] * (N + 2)\n    seen = [0] * (N + 1)\n    cnt = 0\n    for i in range(N, 0, -1):\n        x = A[i]\n        if seen[x] == 0:\n            cnt += 1\n            seen[x] = 1\n        suf[i] = cnt\n\n    seg = LazySegTree(pre[:N])\n\n    last = [0] * (N + 1)\n    ans = 0\n\n    for r in range(1, N):\n        x = A[r]\n        p = last[x]\n\n        # For l <= p, A[r] is already in [l, r-1],\n        # so distinct(l, r) does not increase.\n        # For l > p, it increases by 1.\n        seg.range_add(p, r, 1)\n        last[x] = r\n\n        if r >= 2:\n            mx = seg.range_max(1, r)  # l = 2..r\n            total = mx + suf[r + 1]\n            if total > ans:\n                ans = total\n\n    print(ans)\n\n\nif __name__ == \"__main__\":\n    main()"
    }
   }
  },
  {
   "id": "abc397_e",
   "title": "Path Decomposition of a Tree",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ABC 397 E 题",
   "date": "2025-03-15",
   "url": "https://atcoder.jp/contests/abc397/tasks/abc397_e",
   "summary": "判断一棵 NK 个顶点的树能否划分为 N 条路径，每条恰含 K 个顶点。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 42/42",
     "output_tokens": 26741,
     "latency_s": 451.3,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 6,
       "score": 8.7
      },
      "radon": {
       "complexity": 15,
       "functions": 1,
       "mi": 54.431254340101106,
       "loc": 64,
       "lloc": 47,
       "sloc": 47,
       "comments": 2,
       "blank": 15
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\n\n\ndef main():\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    if not data:\n        return\n\n    N, K = data[0], data[1]\n    n = N * K\n\n    graph = [[] for _ in range(n + 1)]\n    pos = 2\n    for _ in range(n - 1):\n        u, v = data[pos], data[pos + 1]\n        pos += 2\n        graph[u].append(v)\n        graph[v].append(u)\n\n    parent = [0] * (n + 1)\n    parent[1] = -1\n    order = []\n    stack = [1]\n\n    while stack:\n        v = stack.pop()\n        order.append(v)\n        for to in graph[v]:\n            if to == parent[v]:\n                continue\n            parent[to] = v\n            stack.append(to)\n\n    # length[v] is the size of the unfinished path ending at v.\n    # Zero means that the whole subtree of v has been decomposed.\n    length = [0] * (n + 1)\n    child_count = [0] * (n + 1)\n    child_sum = [0] * (n + 1)\n\n    possible = True\n\n    for v in reversed(order):\n        count = child_count[v]\n        total_length = child_sum[v]\n\n        if count > 2 or (count == 2 and total_length + 1 != K):\n            possible = False\n            break\n\n        length[v] = (total_length + 1) % K\n\n        if v != 1 and length[v] != 0:\n            p = parent[v]\n            child_count[p] += 1\n            child_sum[p] += length[v]\n\n    if possible and length[1] == 0:\n        sys.stdout.write(\"Yes\\n\")\n    else:\n        sys.stdout.write(\"No\\n\")\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 42/42",
     "output_tokens": 15590,
     "latency_s": 94.7,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 6,
       "refactor": 3,
       "warning": 1,
       "error": 0,
       "fatal": 0,
       "total": 10,
       "score": 8.44
      },
      "radon": {
       "complexity": 22,
       "functions": 1,
       "mi": 38.359443032732486,
       "loc": 84,
       "lloc": 67,
       "sloc": 67,
       "comments": 0,
       "blank": 17
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\n\n\ndef main() -> None:\n    data = list(map(int, sys.stdin.buffer.read().split()))\n    if not data:\n        return\n\n    N, K = data[0], data[1]\n    M = N * K\n\n    if K == 1:\n        print(\"Yes\")\n        return\n\n    adj = [[] for _ in range(M)]\n\n    idx = 2\n    for _ in range(M - 1):\n        u = data[idx] - 1\n        v = data[idx + 1] - 1\n        idx += 2\n        adj[u].append(v)\n        adj[v].append(u)\n\n    parent = [-1] * M\n    parent[0] = -2\n    order = [0]\n\n    for v in order:\n        for to in adj[v]:\n            if to == parent[v]:\n                continue\n            parent[to] = v\n            order.append(to)\n\n    state = [0] * M\n\n    for v in reversed(order):\n        open_lengths = []\n        invalid = False\n\n        for to in adj[v]:\n            if parent[to] == v:\n                st = state[to]\n                if st == -1:\n                    invalid = True\n                    break\n                if st > 0:\n                    open_lengths.append(st)\n                    if len(open_lengths) > 2:\n                        invalid = True\n                        break\n\n        if invalid:\n            state[v] = -1\n            continue\n\n        cnt = len(open_lengths)\n\n        if cnt == 0:\n            state[v] = 1\n        elif cnt == 1:\n            length = open_lengths[0] + 1\n            if length == K:\n                state[v] = 0\n            elif length < K:\n                state[v] = length\n            else:\n                state[v] = -1\n        elif cnt == 2:\n            length = open_lengths[0] + open_lengths[1] + 1\n            if length == K:\n                state[v] = 0\n            else:\n                state[v] = -1\n        else:\n            state[v] = -1\n\n    print(\"Yes\" if state[0] == 0 else \"No\")\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 42/42",
     "output_tokens": 42493,
     "latency_s": 331.5,
     "cpu_s": null,
     "peak_mb": null,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 3,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 8,
       "score": 8.86
      },
      "radon": {
       "complexity": 25,
       "functions": 1,
       "mi": 53.97779502026459,
       "loc": 94,
       "lloc": 70,
       "sloc": 70,
       "comments": 6,
       "blank": 18
      },
      "sonar": {
       "maintainability": 2,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 2
       },
       "severities": {
        "CRITICAL": 1,
        "MAJOR": 1
       },
       "rules": {
        "python:S3776": 1,
        "python:S1066": 1
       }
      }
     },
     "code": "import sys\n\ndef solve():\n    data = sys.stdin.buffer.read().split()\n    if not data:\n        return\n\n    it = iter(data)\n    N = int(next(it))\n    K = int(next(it))\n    n = N * K\n\n    adj = [[] for _ in range(n)]\n    for _ in range(n - 1):\n        u = int(next(it)) - 1\n        v = int(next(it)) - 1\n        adj[u].append(v)\n        adj[v].append(u)\n\n    # Root the tree at 0\n    parent = [-1] * n\n    visited = [False] * n\n    order = [0]\n    visited[0] = True\n\n    idx = 0\n    while idx < len(order):\n        v = order[idx]\n        idx += 1\n        for to in adj[v]:\n            if not visited[to]:\n                visited[to] = True\n                parent[to] = v\n                order.append(to)\n\n    # Subtree sizes\n    sz = [1] * n\n    for v in reversed(order):\n        for to in adj[v]:\n            if parent[to] == v:\n                sz[v] += sz[to]\n\n    # In any valid decomposition, an edge is used iff the subtree side\n    # size is not divisible by K.\n    selected_parent = [False] * n\n    deg = [0] * n\n\n    for v in range(1, n):\n        if sz[v] % K != 0:\n            selected_parent[v] = True\n            p = parent[v]\n            deg[v] += 1\n            deg[p] += 1\n\n    # Used edges must form paths, so maximum degree is at most 2.\n    if any(d > 2 for d in deg):\n        print(\"No\")\n        return\n\n    # Check that every connected component of the used edges has K vertices.\n    comp_visited = [False] * n\n    for start in range(n):\n        if comp_visited[start]:\n            continue\n\n        stack = [start]\n        comp_visited[start] = True\n        cnt = 0\n\n        while stack:\n            v = stack.pop()\n            cnt += 1\n\n            p = parent[v]\n            if p != -1 and selected_parent[v]:\n                if not comp_visited[p]:\n                    comp_visited[p] = True\n                    stack.append(p)\n\n            for to in adj[v]:\n                if parent[to] == v and selected_parent[to]:\n                    if not comp_visited[to]:\n                        comp_visited[to] = True\n                        stack.append(to)\n\n        if cnt != K:\n            print(\"No\")\n            return\n\n    print(\"Yes\")\n\n\nif __name__ == \"__main__\":\n    solve()"
    }
   }
  },
  {
   "id": "abc397_d",
   "title": "Cubes",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ABC 397 D 题",
   "date": "2025-03-15",
   "url": "https://atcoder.jp/contests/abc397/tasks/abc397_d",
   "summary": "给定正整数 N，判断是否存在正整数 x、y 使 x³ − y³ = N；存在则输出一组。",
   "evaluated": true,
   "results": {
    "kimi-k3.1-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43（校验器）",
     "output_tokens": 3259,
     "latency_s": 48.7,
     "cpu_s": 0.138,
     "peak_mb": 12.2,
     "quality": {
      "pylint": {
       "convention": 3,
       "refactor": 1,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 4,
       "score": 8.26
      },
      "radon": {
       "complexity": 8,
       "functions": 1,
       "mi": 72.54871876341915,
       "loc": 34,
       "lloc": 23,
       "sloc": 23,
       "comments": 4,
       "blank": 7
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\nimport math\n\n\ndef main():\n    n = int(sys.stdin.read())\n\n    # Let d = x - y. Then:\n    # n = d^3 + 3*d^2*y + 3*d*y^2, so d^3 < n.\n    d = 1\n    while d * d * d < n:\n        if n % d == 0:\n            q = n // d\n\n            # q = 3*y^2 + 3*d*y + d^2\n            # Its discriminant is 12*q - 3*d^2.\n            discriminant = 12 * q - 3 * d * d\n            if discriminant >= 0:\n                root = math.isqrt(discriminant)\n                if root * root == discriminant:\n                    numerator = root - 3 * d\n                    if numerator > 0 and numerator % 6 == 0:\n                        y = numerator // 6\n                        x = y + d\n                        if x * x * x - y * y * y == n:\n                            print(x, y)\n                            return\n        d += 1\n\n    print(-1)\n\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-flash": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43（校验器）",
     "output_tokens": 5019,
     "latency_s": 24.6,
     "cpu_s": 0.1367,
     "peak_mb": 12.2,
     "quality": {
      "pylint": {
       "convention": 5,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 5,
       "score": 7.73
      },
      "radon": {
       "complexity": 7,
       "functions": 1,
       "mi": 63.49194072563885,
       "loc": 31,
       "lloc": 22,
       "sloc": 22,
       "comments": 1,
       "blank": 8
      },
      "sonar": {
       "maintainability": 1,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 1
       },
       "severities": {
        "CRITICAL": 1
       },
       "rules": {
        "python:S3776": 1
       }
      }
     },
     "code": "import sys\nimport math\n\ndef main():\n    N = int(sys.stdin.readline().strip())\n\n    d = 1\n    while d * d * d < N:\n        if N % d == 0:\n            m = N // d\n\n            # m = 3y^2 + 3dy + d^2\n            D = 12 * m - 3 * d * d\n            s = math.isqrt(D)\n\n            if s * s == D:\n                num = s - 3 * d\n                if num > 0 and num % 6 == 0:\n                    y = num // 6\n                    x = y + d\n\n                    if x * x * x - y * y * y == N:\n                        print(x, y)\n                        return\n\n        d += 1\n\n    print(-1)\n\nif __name__ == \"__main__\":\n    main()"
    },
    "deepseek-v4-pro": {
     "passed": true,
     "verified_by_hand": false,
     "failure": null,
     "judge": "官方测试 43/43（校验器）",
     "output_tokens": 26442,
     "latency_s": 179.5,
     "cpu_s": 0.108,
     "peak_mb": 12.2,
     "quality": {
      "pylint": {
       "convention": 6,
       "refactor": 0,
       "warning": 0,
       "error": 0,
       "fatal": 0,
       "total": 6,
       "score": 7.93
      },
      "radon": {
       "complexity": 10,
       "functions": 1,
       "mi": 67.91865548808761,
       "loc": 40,
       "lloc": 29,
       "sloc": 29,
       "comments": 4,
       "blank": 7
      },
      "sonar": {
       "maintainability": 2,
       "reliability": 0,
       "security": 0,
       "types": {
        "CODE_SMELL": 2
       },
       "severities": {
        "CRITICAL": 1,
        "MAJOR": 1
       },
       "rules": {
        "python:S3776": 1,
        "python:S125": 1
       }
      }
     },
     "code": "import sys\nfrom math import isqrt\n\ndef main():\n    data = sys.stdin.read().strip()\n    if not data:\n        return\n    N = int(data)\n\n    # d = x - y\n    for d in range(1, 10**6 + 1):\n        # Since y >= 1, N > d^3\n        if d * d * d >= N:\n            break\n        if N % d != 0:\n            continue\n\n        S = N // d\n        # S = 3*y^2 + 3*d*y + d^2\n        # Solve for y: 3*y^2 + 3*d*y + (d^2 - S) = 0\n        D = 12 * S - 3 * d * d\n        if D < 0:\n            continue\n\n        r = isqrt(D)\n        if r * r != D:\n            continue\n\n        num = r - 3 * d\n        if num > 0 and num % 6 == 0:\n            y = num // 6\n            x = y + d\n            if x * x * x - y * y * y == N:\n                print(x, y)\n                return\n\n    print(-1)\n\nif __name__ == \"__main__\":\n    main()"
    }
   }
  },
  {
   "id": "abc397_c",
   "title": "Variety Split Easy",
   "platform": "atcoder",
   "difficulty": "medium",
   "contest": "AtCoder ABC 397 C 题",
   "date": "2025-03-15",
   "url": "https://atcoder.jp/contests/abc397/tasks/abc397_c",
   "summary": "把序列切成两段非空的连续子数组，使两段各自不同元素个数之和最大。",
   "evaluated": false
  },
  {
   "id": "abc397_b",
   "title": "Ticket Gate Log",
   "platform": "atcoder",
   "difficulty": "medium",
   "contest": "AtCoder ABC 397 B 题",
   "date": "2025-03-15",
   "url": "https://atcoder.jp/contests/abc397/tasks/abc397_b",
   "summary": "在由 i、o 组成的串中插入最少的字符，使其长度为偶数，且奇数位全为 i、偶数位全为 o。",
   "evaluated": false
  },
  {
   "id": "abc397_a",
   "title": "Thermometer",
   "platform": "atcoder",
   "difficulty": "easy",
   "contest": "AtCoder ABC 397 A 题",
   "date": "2025-03-15",
   "url": "https://atcoder.jp/contests/abc397/tasks/abc397_a",
   "summary": "按体温 X 判断属于高烧（≥ 38.0）、发烧（≥ 37.5）还是正常，输出对应编号。",
   "evaluated": false
  },
  {
   "id": "arc194_e",
   "title": "Swap 0^X and 1^Y",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ARC 194 E 题",
   "date": "2025-03-09",
   "url": "https://atcoder.jp/contests/arc194/tasks/arc194_e",
   "summary": "01 串上可把“X 个 0 后接 Y 个 1”换成“Y 个 1 后接 X 个 0”，或做相反的替换；判断能否把 S 变成 T。",
   "evaluated": false
  },
  {
   "id": "arc194_d",
   "title": "Reverse Brackets",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ARC 194 D 题",
   "date": "2025-03-09",
   "url": "https://atcoder.jp/contests/arc194/tasks/arc194_d",
   "summary": "每次选一个合法括号子串，把它倒序并互换左右括号；求最终能得到的不同字符串个数，模 998244353。",
   "evaluated": false
  },
  {
   "id": "arc194_c",
   "title": "Cost to Flip",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ARC 194 C 题",
   "date": "2025-03-09",
   "url": "https://atcoder.jp/contests/arc194/tasks/arc194_c",
   "summary": "每次翻转 A 的一位，然后支付 Σ Aₖ·Cₖ（按翻转后的 A 计）；求把 A 变成 B 的最小总费用。",
   "evaluated": false
  },
  {
   "id": "arc194_b",
   "title": "Minimum Cost Sort",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ARC 194 B 题",
   "date": "2025-03-09",
   "url": "https://atcoder.jp/contests/arc194/tasks/arc194_b",
   "summary": "交换第 i 与第 i+1 个元素的代价为 i；求把排列排成升序的最小总代价。",
   "evaluated": false
  },
  {
   "id": "arc194_a",
   "title": "Operations on a Stack",
   "platform": "atcoder",
   "difficulty": "medium",
   "contest": "AtCoder ARC 194 A 题",
   "date": "2025-03-09",
   "url": "https://atcoder.jp/contests/arc194/tasks/arc194_a",
   "summary": "依次对每个 Aᵢ 选择压入栈，或弹出栈顶（栈非空时）；求最终栈内元素和的最大值。",
   "evaluated": false
  },
  {
   "id": "3791",
   "title": "Fruits into Baskets Iii",
   "platform": "leetcode",
   "difficulty": "medium",
   "contest": "LeetCode 周赛 440",
   "date": "2025-03-08",
   "url": "https://leetcode.com/problems/fruits-into-baskets-iii/",
   "summary": "每种水果依次放入最左边容量足够且未被占用的篮子；求最后没能放下的水果种类数。",
   "evaluated": false
  },
  {
   "id": "3789",
   "title": "Maximize Subarrays After Removing One Conflicting Pair",
   "platform": "leetcode",
   "difficulty": "hard",
   "contest": "LeetCode 周赛 440",
   "date": "2025-03-08",
   "url": "https://leetcode.com/problems/maximize-subarrays-after-removing-one-conflicting-pair/",
   "summary": "数组为 1…n，恰好删除一个冲突对后，统计不同时包含任一剩余冲突对两数的非空子数组个数；求其最大值。",
   "evaluated": false
  },
  {
   "id": "3759",
   "title": "Choose K Elements with Maximum Sum",
   "platform": "leetcode",
   "difficulty": "medium",
   "contest": "LeetCode 周赛 440",
   "date": "2025-03-08",
   "url": "https://leetcode.com/problems/choose-k-elements-with-maximum-sum/",
   "summary": "对每个下标 i，在 nums1[j] < nums1[i] 的下标中至多选 k 个 nums2[j]，求其和的最大值。",
   "evaluated": false
  },
  {
   "id": "abc396_g",
   "title": "Flip Row or Col",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ABC 396 G 题",
   "date": "2025-03-08",
   "url": "https://atcoder.jp/contests/abc396/tasks/abc396_g",
   "summary": "0/1 网格可以任意翻转整行或整列；求最终网格中 1 的个数的最小值。",
   "evaluated": false
  },
  {
   "id": "abc396_f",
   "title": "Rotated Inversions",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ABC 396 F 题",
   "date": "2025-03-08",
   "url": "https://atcoder.jp/contests/abc396/tasks/abc396_f",
   "summary": "对 k = 0, 1, …, M−1，把每个 Aᵢ 变为 (Aᵢ + k) mod M，求所得序列的逆序对数。",
   "evaluated": false
  },
  {
   "id": "abc396_e",
   "title": "Min of Restricted Sum",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ABC 396 E 题",
   "date": "2025-03-08",
   "url": "https://atcoder.jp/contests/abc396/tasks/abc396_e",
   "summary": "给定若干约束 A[Xᵢ] XOR A[Yᵢ] = Zᵢ，判断是否存在满足全部约束的非负整数序列，存在则给出元素和最小的一个。",
   "evaluated": false
  },
  {
   "id": "abc396_d",
   "title": "Minimum XOR Path",
   "platform": "atcoder",
   "difficulty": "medium",
   "contest": "AtCoder ABC 396 D 题",
   "date": "2025-03-08",
   "url": "https://atcoder.jp/contests/abc396/tasks/abc396_d",
   "summary": "在连通无向图中，求从顶点 1 到 N 的所有简单路径上边权异或值的最小值。",
   "evaluated": false
  },
  {
   "id": "abc396_c",
   "title": "Buy Balls",
   "platform": "atcoder",
   "difficulty": "medium",
   "contest": "AtCoder ABC 396 C 题",
   "date": "2025-03-08",
   "url": "https://atcoder.jp/contests/abc396/tasks/abc396_c",
   "summary": "从黑球和白球中选若干个，要求黑球数不少于白球数；求所选球价值之和的最大值。",
   "evaluated": false
  },
  {
   "id": "abc396_b",
   "title": "Card Pile",
   "platform": "atcoder",
   "difficulty": "easy",
   "contest": "AtCoder ABC 396 B 题",
   "date": "2025-03-08",
   "url": "https://atcoder.jp/contests/abc396/tasks/abc396_b",
   "summary": "一叠 100 张写着 0 的卡片，处理“放一张卡到顶部”和“取走顶部的卡并输出其数字”两类查询。",
   "evaluated": false
  },
  {
   "id": "abc396_a",
   "title": "Triple Four",
   "platform": "atcoder",
   "difficulty": "easy",
   "contest": "AtCoder ABC 396 A 题",
   "date": "2025-03-08",
   "url": "https://atcoder.jp/contests/abc396/tasks/abc396_a",
   "summary": "判断序列中是否有同一元素连续出现三次或以上。",
   "evaluated": false
  },
  {
   "id": "3786",
   "title": "Longest Palindromic Subsequence After At Most K Operations",
   "platform": "leetcode",
   "difficulty": "medium",
   "contest": "LeetCode 周赛 439",
   "date": "2025-03-01",
   "url": "https://leetcode.com/problems/longest-palindromic-subsequence-after-at-most-k-operations/",
   "summary": "每次操作把一个字符变为字母表中相邻的字母（首尾相接）；至多 k 次操作后，求最长回文子序列的长度。",
   "evaluated": false
  },
  {
   "id": "3770",
   "title": "Lexicographically Smallest Generated String",
   "platform": "leetcode",
   "difficulty": "hard",
   "contest": "LeetCode 周赛 439",
   "date": "2025-03-01",
   "url": "https://leetcode.com/problems/lexicographically-smallest-generated-string/",
   "summary": "构造长度为 n+m−1 的字符串，使 str1 为 T 的位置都以 str2 开头、为 F 的位置都不以 str2 开头；求字典序最小的结果，不存在时返回空串。",
   "evaluated": false
  },
  {
   "id": "3722",
   "title": "Sum of K Subarrays with Length At Least M",
   "platform": "leetcode",
   "difficulty": "medium",
   "contest": "LeetCode 周赛 439",
   "date": "2025-03-01",
   "url": "https://leetcode.com/problems/sum-of-k-subarrays-with-length-at-least-m/",
   "summary": "选 k 个互不重叠、长度至少为 m 的子数组，求它们的元素和之和的最大值。",
   "evaluated": false
  },
  {
   "id": "3705",
   "title": "Find the Largest Almost Missing Integer",
   "platform": "leetcode",
   "difficulty": "easy",
   "contest": "LeetCode 周赛 439",
   "date": "2025-03-01",
   "url": "https://leetcode.com/problems/find-the-largest-almost-missing-integer/",
   "summary": "恰好只出现在一个长度为 k 的子数组中的数称为“几乎缺失”；求其中的最大值，不存在时返回 -1。",
   "evaluated": false
  },
  {
   "id": "3785",
   "title": "Find the Number of Copy Arrays",
   "platform": "leetcode",
   "difficulty": "medium",
   "contest": "LeetCode 双周赛 151",
   "date": "2025-03-01",
   "url": "https://leetcode.com/problems/find-the-number-of-copy-arrays/",
   "summary": "统计满足相邻差与 original 相同、且每个元素都在给定上下界内的数组个数。",
   "evaluated": false
  },
  {
   "id": "3783",
   "title": "Permutations Iv",
   "platform": "leetcode",
   "difficulty": "hard",
   "contest": "LeetCode 双周赛 151",
   "date": "2025-03-01",
   "url": "https://leetcode.com/problems/permutations-iv/",
   "summary": "相邻元素奇偶不同的 1…n 排列称为交替排列；求字典序第 k 个，不足 k 个时返回空列表。",
   "evaluated": false
  },
  {
   "id": "3778",
   "title": "Transform Array By Parity",
   "platform": "leetcode",
   "difficulty": "easy",
   "contest": "LeetCode 双周赛 151",
   "date": "2025-03-01",
   "url": "https://leetcode.com/problems/transform-array-by-parity/",
   "summary": "把偶数换成 0、奇数换成 1，再升序排序，返回结果。",
   "evaluated": false
  },
  {
   "id": "3776",
   "title": "Find Minimum Cost to Remove Array Elements",
   "platform": "leetcode",
   "difficulty": "medium",
   "contest": "LeetCode 双周赛 151",
   "date": "2025-03-01",
   "url": "https://leetcode.com/problems/find-minimum-cost-to-remove-array-elements/",
   "summary": "每步从前三个元素中任删两个，代价为二者的最大值；不足三个时一次删完，代价为其最大值；求删空数组的最小总代价。",
   "evaluated": false
  },
  {
   "id": "abc395_f",
   "title": "Smooth Occlusion",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ABC 395 F 题",
   "date": "2025-03-01",
   "url": "https://atcoder.jp/contests/abc395/tasks/abc395_f",
   "summary": "只能把牙齿磨短，每磨 1 单位花 1 日元；求最少花费，使每对上下牙长度之和相同，且相邻上牙长度之差不超过 X。",
   "evaluated": false
  },
  {
   "id": "abc395_e",
   "title": "Flip Edge",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ABC 395 E 题",
   "date": "2025-03-01",
   "url": "https://atcoder.jp/contests/abc395/tasks/abc395_e",
   "summary": "有向图中沿边移动花费 1，把所有边反向花费 X；求从顶点 1 到 N 的最小总花费。",
   "evaluated": false
  },
  {
   "id": "abc395_c",
   "title": "Shortest Duplicate Subarray",
   "platform": "atcoder",
   "difficulty": "medium",
   "contest": "AtCoder ABC 395 C 题",
   "date": "2025-03-01",
   "url": "https://atcoder.jp/contests/abc395/tasks/abc395_c",
   "summary": "求含有重复值的最短连续子数组的长度；不存在时按要求报告。",
   "evaluated": false
  },
  {
   "id": "abc395_b",
   "title": "Make Target",
   "platform": "atcoder",
   "difficulty": "easy",
   "contest": "AtCoder ABC 395 B 题",
   "date": "2025-03-01",
   "url": "https://atcoder.jp/contests/abc395/tasks/abc395_b",
   "summary": "按规则在 N×N 网格上从外向内交替涂黑、白方框，输出最终图案。",
   "evaluated": false
  },
  {
   "id": "abc395_a",
   "title": "Strictly Increasing?",
   "platform": "atcoder",
   "difficulty": "easy",
   "contest": "AtCoder ABC 395 A 题",
   "date": "2025-03-01",
   "url": "https://atcoder.jp/contests/abc395/tasks/abc395_a",
   "summary": "判断序列是否严格递增。",
   "evaluated": false
  },
  {
   "id": "arc193_d",
   "title": "Magnets",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ARC 193 D 题",
   "date": "2025-02-23",
   "url": "https://atcoder.jp/contests/arc193/tasks/arc193_d",
   "summary": "每次选一个位置 i，所有棋子同时向 i 靠近一格（可以重叠）；判断能否使有棋子的格子恰为 B 中为 1 的位置，能则求最少操作次数。",
   "evaluated": false
  },
  {
   "id": "arc193_b",
   "title": "Broken Wheel",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ARC 193 B 题",
   "date": "2025-02-23",
   "url": "https://atcoder.jp/contests/arc193/tasks/arc193_b",
   "summary": "N 个点连成环，另有一个中心点按 s 与环上各点相连；给每条边定向，求所得入度序列的不同种数，模 998244353。",
   "evaluated": false
  },
  {
   "id": "arc193_a",
   "title": "Complement Interval Graph",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ARC 193 A 题",
   "date": "2025-02-23",
   "url": "https://atcoder.jp/contests/arc193/tasks/arc193_a",
   "summary": "两区间不相交时对应的两点连边；对每个查询求 s 到 t 的路径上顶点权值之和的最小值，不连通时按要求输出。",
   "evaluated": false
  },
  {
   "id": "3781",
   "title": "Maximize the Distance Between Points On a Square",
   "platform": "leetcode",
   "difficulty": "hard",
   "contest": "LeetCode 周赛 438",
   "date": "2025-02-22",
   "url": "https://leetcode.com/problems/maximize-the-distance-between-points-on-a-square/",
   "summary": "正方形边界上有若干点，选出 k 个，使两两曼哈顿距离的最小值最大；求该最大值。",
   "evaluated": false
  },
  {
   "id": "3768",
   "title": "Check If Digits Are Equal in String After Operations I",
   "platform": "leetcode",
   "difficulty": "easy",
   "contest": "LeetCode 周赛 438",
   "date": "2025-02-22",
   "url": "https://leetcode.com/problems/check-if-digits-are-equal-in-string-after-operations-i/",
   "summary": "反复把相邻两位数字之和模 10 组成新串，直到只剩两位；判断这两位是否相同。",
   "evaluated": false
  },
  {
   "id": "3764",
   "title": "Maximum Sum with At Most K Elements",
   "platform": "leetcode",
   "difficulty": "medium",
   "contest": "LeetCode 周赛 438",
   "date": "2025-02-22",
   "url": "https://leetcode.com/problems/maximum-sum-with-at-most-k-elements/",
   "summary": "从矩阵中至多选 k 个元素，且第 i 行至多选 limits[i] 个；求元素和的最大值。",
   "evaluated": false
  },
  {
   "id": "abc394_g",
   "title": "Dense Buildings",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ABC 394 G 题",
   "date": "2025-02-22",
   "url": "https://atcoder.jp/contests/abc394/tasks/abc394_g",
   "summary": "网格中每格有一栋楼，可以在楼内走楼梯上下一层，或走到相邻且足够高的楼的同一层；对每个查询求两点之间最少走楼梯的次数。",
   "evaluated": false
  },
  {
   "id": "abc394_f",
   "title": "Alkane",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ABC 394 F 题",
   "date": "2025-02-22",
   "url": "https://atcoder.jp/contests/abc394/tasks/abc394_f",
   "summary": "在树中找一个子图，它是一棵每个顶点度数为 1 或 4、且至少有一个度为 4 的树（烷烃）；求其最大顶点数，不存在时按要求输出。",
   "evaluated": false
  },
  {
   "id": "abc394_e",
   "title": "Palindromic Shortest Path",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ABC 394 E 题",
   "date": "2025-02-22",
   "url": "https://atcoder.jp/contests/abc394/tasks/abc394_e",
   "summary": "有向图的边上带字母；对每对 (i, j)，求边上字母连成回文串的最短路径长度，不存在时为 -1。",
   "evaluated": false
  },
  {
   "id": "abc394_d",
   "title": "Colorful Bracket Sequence",
   "platform": "atcoder",
   "difficulty": "medium",
   "contest": "AtCoder ABC 394 D 题",
   "date": "2025-02-22",
   "url": "https://atcoder.jp/contests/abc394/tasks/abc394_d",
   "summary": "判断由 ()、[]、<> 三种括号组成的字符串，能否通过反复删除相邻的配对括号变为空串。",
   "evaluated": false
  },
  {
   "id": "abc394_c",
   "title": "Debug",
   "platform": "atcoder",
   "difficulty": "medium",
   "contest": "AtCoder ABC 394 C 题",
   "date": "2025-02-22",
   "url": "https://atcoder.jp/contests/abc394/tasks/abc394_c",
   "summary": "反复把最左边的 WA 替换为 AC，直到不含 WA，输出结果。",
   "evaluated": false
  },
  {
   "id": "abc394_b",
   "title": "cat",
   "platform": "atcoder",
   "difficulty": "easy",
   "contest": "AtCoder ABC 394 B 题",
   "date": "2025-02-22",
   "url": "https://atcoder.jp/contests/abc394/tasks/abc394_b",
   "summary": "把 N 个长度互不相同的字符串按长度升序拼接。",
   "evaluated": false
  },
  {
   "id": "abc394_a",
   "title": "22222",
   "platform": "atcoder",
   "difficulty": "easy",
   "contest": "AtCoder ABC 394 A 题",
   "date": "2025-02-22",
   "url": "https://atcoder.jp/contests/abc394/tasks/abc394_a",
   "summary": "删去字符串中所有不是 2 的字符，输出剩下的部分。",
   "evaluated": false
  },
  {
   "id": "3779",
   "title": "Eat Pizzas",
   "platform": "leetcode",
   "difficulty": "medium",
   "contest": "LeetCode 周赛 437",
   "date": "2025-02-15",
   "url": "https://leetcode.com/problems/eat-pizzas/",
   "summary": "每天吃 4 个披萨，奇数天增重为其中最重的一个，偶数天为第二重的一个；求吃完全部披萨的最大总增重。",
   "evaluated": false
  },
  {
   "id": "3771",
   "title": "Select K Disjoint Special Substrings",
   "platform": "leetcode",
   "difficulty": "medium",
   "contest": "LeetCode 周赛 437",
   "date": "2025-02-15",
   "url": "https://leetcode.com/problems/select-k-disjoint-special-substrings/",
   "summary": "判断能否选出 k 个互不重叠的特殊子串：子串内出现的字符都不在子串外出现，且子串不是整个字符串。",
   "evaluated": false
  },
  {
   "id": "abc393_f",
   "title": "Prefix LIS Query",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ABC 393 F 题",
   "date": "2025-02-15",
   "url": "https://atcoder.jp/contests/abc393/tasks/abc393_f",
   "summary": "对每个查询 (R, X)，求前 R 个元素中只用不超过 X 的元素能组成的最长严格递增子序列的长度。",
   "evaluated": false
  },
  {
   "id": "abc393_e",
   "title": "GCD of Subset",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ABC 393 E 题",
   "date": "2025-02-15",
   "url": "https://atcoder.jp/contests/abc393/tasks/abc393_e",
   "summary": "对每个 i，从序列中选出包含 Aᵢ 的 K 个元素，求它们最大公约数的最大可能值。",
   "evaluated": false
  },
  {
   "id": "abc393_d",
   "title": "Swap to Gather",
   "platform": "atcoder",
   "difficulty": "hard",
   "contest": "AtCoder ABC 393 D 题",
   "date": "2025-02-15",
   "url": "https://atcoder.jp/contests/abc393/tasks/abc393_d",
   "summary": "每次交换相邻两个字符；求使所有 1 连成一段的最少操作次数。",
   "evaluated": false
  },
  {
   "id": "abc393_b",
   "title": "A..B..C",
   "platform": "atcoder",
   "difficulty": "easy",
   "contest": "AtCoder ABC 393 B 题",
   "date": "2025-02-15",
   "url": "https://atcoder.jp/contests/abc393/tasks/abc393_b",
   "summary": "统计字符串中位置等间距、依次为 A、B、C 的三元组个数。",
   "evaluated": false
  },
  {
   "id": "abc393_a",
   "title": "Poisonous Oyster",
   "platform": "atcoder",
   "difficulty": "easy",
   "contest": "AtCoder ABC 393 A 题",
   "date": "2025-02-15",
   "url": "https://atcoder.jp/contests/abc393/tasks/abc393_a",
   "summary": "根据两人各自吃了哪两种牡蛎、是否生病，判断哪一种牡蛎有毒。",
   "evaluated": false
  }
 ]
}