{
  "name": "quixbugs-python-lis",
  "description": "Fix bug in: lis",
  "dataset": "quixbugs",
  "instruction": "There is a Python file called lis.py in the current directory. It contains a buggy implementation of the lis algorithm. Find and fix the bug. The fix should be minimal - typically a single line change. Do not rewrite the entire function.",
  "setup_files": {
    "lis.py": "\ndef lis(arr):\n    ends = {}\n    longest = 0\n\n    for i, val in enumerate(arr):\n\n        prefix_lengths = [j for j in range(1, longest + 1) if arr[ends[j]] < val]\n\n        length = max(prefix_lengths) if prefix_lengths else 0\n\n        if length == longest or val < arr[ends[length + 1]]:\n            ends[length + 1] = i\n            longest = length + 1\n\n    return longest\n\n\n\n\"\"\"\nLongest Increasing Subsequence\nlongest-increasing-subsequence\n\n\nInput:\n    arr: A sequence of ints\n\nPrecondition:\n    The ints in arr are unique\n\nOutput:\n    The length of the longest monotonically increasing subsequence of arr\n\nExample:\n    >>> lis([4, 1, 5, 3, 7, 6, 2])\n    3\n\"\"\"\n",
    "test_lis.py": "import sys\n\nfrom lis import lis\n\nFUNC_NAME = \"lis\"\ntest_cases = [[[[]], 0], [[[3]], 1], [[[10, 20, 11, 32, 22, 48, 43]], 4], [[[4, 2, 1]], 1], [[[5, 1, 3, 4, 7]], 4], [[[4, 1]], 1], [[[-1, 0, 2]], 3], [[[0, 2]], 2], [[[4, 1, 5, 3, 7, 6, 2]], 3], [[[10, 22, 9, 33, 21, 50, 41, 60, 80]], 6], [[[7, 10, 9, 2, 3, 8, 1]], 3], [[[9, 11, 2, 13, 7, 15]], 4]]\n\npassed = 0\nfailed = 0\nfor tc in test_cases:\n    inputs = tc[0]\n    expected = tc[1]\n    try:\n        result = lis(*inputs)\n        if result == expected:\n            passed += 1\n        else:\n            print(f\"FAIL: {FUNC_NAME}({inputs}) = {result}, expected {expected}\")\n            failed += 1\n    except Exception as e:\n        print(f\"ERROR: {FUNC_NAME}({inputs}) raised {e}\")\n        failed += 1\n\nprint(f\"{passed}/{passed+failed} tests passed\")\nif failed > 0:\n    sys.exit(1)\n"
  },
  "verify": "cd $BENCH_WORK_DIR && python3 test_lis.py",
  "timeout": 180000,
  "tags": [
    "quixbugs",
    "python",
    "bug-fix"
  ]
}